1
0

wizard: fix regression: allow passphrase for some '2fa' seeds

fixes https://github.com/spesmilo/electrum/issues/9088
This commit is contained in:
SomberNight
2024-06-10 19:35:56 +00:00
parent 4f7dcc98bd
commit b95fbbb86f
3 changed files with 39 additions and 4 deletions

View File

@@ -276,6 +276,23 @@ def seed_type(x: str) -> str:
return ''
def can_seed_have_passphrase(seed: str) -> bool:
stype = seed_type(seed)
if not stype:
raise Exception(f'unexpected seed type: {stype!r}')
if stype == 'old':
return False
if stype == '2fa':
# post-version-2.7 2fa seeds can have passphrase, but older ones cannot
num_words = len(seed.split())
if num_words == 12:
return True
else:
return False
# all other types can have a seed extension/passphrase
return True
def is_seed(x: str) -> bool:
return bool(seed_type(x))

View File

@@ -13,7 +13,7 @@ from electrum.storage import WalletStorage, StorageEncryptionVersion
from electrum.wallet_db import WalletDB
from electrum.bip32 import normalize_bip32_derivation, xpub_type
from electrum import keystore, mnemonic, bitcoin
from electrum.mnemonic import is_any_2fa_seed_type
from electrum.mnemonic import is_any_2fa_seed_type, can_seed_have_passphrase
if TYPE_CHECKING:
from electrum.daemon import Daemon
@@ -492,8 +492,7 @@ class NewWalletWizard(AbstractWizard):
seed_type = mnemonic.seed_type(seed)
if seed_type != '':
seed_valid = True
if seed_type in ['old', '2fa']:
can_passphrase = False
can_passphrase = can_seed_have_passphrase(seed)
elif seed_variant == 'bip39':
is_checksum, is_wordlist = keystore.bip39_is_checksum_valid(seed)
validation_message = ('' if is_checksum else _('BIP39 checksum failed')) if is_wordlist else _('Unknown BIP39 wordlist')