From 543b73be9bd96564ebf58101a4208ffeceff0403 Mon Sep 17 00:00:00 2001 From: f321x Date: Mon, 23 Mar 2026 09:54:28 +0100 Subject: [PATCH] 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():