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
This commit is contained in:
f321x
2026-03-23 09:54:28 +01:00
parent 89da2a3bee
commit 543b73be9b
+7 -2
View File
@@ -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():