From 543b73be9bd96564ebf58101a4208ffeceff0403 Mon Sep 17 00:00:00 2001 From: f321x Date: Mon, 23 Mar 2026 09:54:28 +0100 Subject: [PATCH 1/2] wizard: catch NotLegacySinglesigScriptType Catch NetLegacySinglesigScriptType and convert it to a UserFacingException if the user tries to import a private key for which it is not possible to get a singlesig descriptor (e.g. p2wsh). Fixes #10536 --- electrum/wizard.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/electrum/wizard.py b/electrum/wizard.py index d441b02c4..6b2e7b65d 100644 --- a/electrum/wizard.py +++ b/electrum/wizard.py @@ -16,7 +16,7 @@ from electrum.storage import WalletStorage, StorageEncryptionVersion, StorageRea from electrum.util import UserFacingException from electrum.wallet_db import WalletDB from electrum.bip32 import normalize_bip32_derivation, xpub_type -from electrum import keystore, mnemonic, bitcoin +from electrum import descriptor, keystore, mnemonic, bitcoin from electrum.mnemonic import is_any_2fa_seed_type, can_seed_have_passphrase from electrum.util import multisig_type @@ -702,7 +702,12 @@ class NewWalletWizard(KeystoreWizard): for pk in keys: assert bitcoin.is_private_key(pk) txin_type, pubkey = k.import_privkey(pk, None) - addr = bitcoin.pubkey_to_address(txin_type, pubkey) + try: + addr = bitcoin.pubkey_to_address(txin_type, pubkey) + except descriptor.NotLegacySinglesigScriptType as e: + raise UserFacingException( + _("Importing individual private keys of type '{}' is not supported.").format(txin_type), + ) from e addresses[addr] = {'type': txin_type, 'pubkey': pubkey} elif 'address_list' in data: for addr in data['address_list'].split(): From 2c541d2663a2e5779ecd8aaf9f8886b98e241804 Mon Sep 17 00:00:00 2001 From: f321x Date: Mon, 23 Mar 2026 10:14:31 +0100 Subject: [PATCH 2/2] qt: ElectrumGui: repr(UserFacingException) -> str() Show UserFacingException in ElectrumGui.start_new_window as str() to the user, ther doesn't seem to be a good reason to show its repr? --- electrum/gui/qt/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/electrum/gui/qt/__init__.py b/electrum/gui/qt/__init__.py index c0835744a..9c151542c 100644 --- a/electrum/gui/qt/__init__.py +++ b/electrum/gui/qt/__init__.py @@ -413,11 +413,10 @@ class ElectrumGui(BaseElectrumGui, Logger): self.logger.exception('') if isinstance(e, UserFacingException) \ or isinstance(e, WalletFileException) and not e.should_report_crash: - err_text = str(e) if isinstance(e, WalletFileException) else repr(e) custom_message_box(icon=QMessageBox.Icon.Warning, parent=None, title=_('Error'), - text=_('Cannot load wallet') + '(2) :\n' + err_text) + text=_('Cannot load wallet') + '(2) :\n' + str(e)) else: send_exception_to_crash_reporter(e) if app_is_starting: