mnemonic: rename seed_type() fn
Some functions have an argument named "seed_type" in which it was annoying to call the seed_type() fn. (especially for functions inside the same module)
This commit is contained in:
@@ -32,7 +32,7 @@ from PyQt5.QtWidgets import (QVBoxLayout, QCheckBox, QHBoxLayout, QLineEdit,
|
||||
QScrollArea, QWidget, QPushButton)
|
||||
|
||||
from electrum.i18n import _
|
||||
from electrum.mnemonic import Mnemonic, seed_type, is_any_2fa_seed_type
|
||||
from electrum.mnemonic import Mnemonic, calc_seed_type, is_any_2fa_seed_type
|
||||
from electrum import old_mnemonic
|
||||
from electrum import slip39
|
||||
|
||||
@@ -292,7 +292,7 @@ class SeedLayout(QVBoxLayout):
|
||||
b = self.slip39_seed is not None
|
||||
self.update_share_buttons()
|
||||
else:
|
||||
t = seed_type(s)
|
||||
t = calc_seed_type(s)
|
||||
label = _('Seed Type') + ': ' + t if t else ''
|
||||
if t and not b: # electrum seed, but does not conform to dialog rules
|
||||
# FIXME we should just accept any electrum seed and "redirect" the wizard automatically.
|
||||
|
||||
@@ -630,7 +630,7 @@ class WCHaveSeed(WalletWizardComponent, Logger):
|
||||
self.layout().addStretch(1)
|
||||
|
||||
def is_seed(self, x):
|
||||
t = mnemonic.seed_type(x)
|
||||
t = mnemonic.calc_seed_type(x)
|
||||
if self.wizard_data['wallet_type'] == 'standard':
|
||||
return mnemonic.is_seed(x) and not mnemonic.is_any_2fa_seed_type(t)
|
||||
elif self.wizard_data['wallet_type'] == '2fa':
|
||||
@@ -665,7 +665,7 @@ class WCHaveSeed(WalletWizardComponent, Logger):
|
||||
cosigner_data['seed'] = self.slayout.get_seed()
|
||||
cosigner_data['seed_variant'] = self.slayout.seed_type
|
||||
if self.slayout.seed_type == 'electrum':
|
||||
cosigner_data['seed_type'] = mnemonic.seed_type(self.slayout.get_seed())
|
||||
cosigner_data['seed_type'] = mnemonic.calc_seed_type(self.slayout.get_seed())
|
||||
else:
|
||||
cosigner_data['seed_type'] = self.slayout.seed_type
|
||||
cosigner_data['seed_extend'] = self.slayout.is_ext if self.can_passphrase else False
|
||||
|
||||
@@ -46,7 +46,7 @@ from .crypto import (pw_decode, pw_encode, sha256, sha256d, PW_HASH_VERSION_LATE
|
||||
CiphertextFormatError)
|
||||
from .util import (InvalidPassword, WalletFileException,
|
||||
BitcoinException, bfh, inv_dict, is_hex_str)
|
||||
from .mnemonic import Mnemonic, Wordlist, seed_type, is_seed
|
||||
from .mnemonic import Mnemonic, Wordlist, calc_seed_type, is_seed
|
||||
from .plugin import run_hook
|
||||
from .logging import Logger
|
||||
|
||||
@@ -380,7 +380,7 @@ class Deterministic_KeyStore(Software_KeyStore):
|
||||
if self.seed:
|
||||
raise Exception("a seed exists")
|
||||
self.seed = self.format_seed(seed)
|
||||
self._seed_type = seed_type(seed) or None
|
||||
self._seed_type = calc_seed_type(seed) or None
|
||||
|
||||
def get_seed(self, password):
|
||||
if not self.has_seed():
|
||||
@@ -1167,7 +1167,7 @@ def purpose48_derivation(account_id: int, xtype: str) -> str:
|
||||
|
||||
def from_seed(seed: str, *, passphrase: Optional[str], for_multisig: bool = False):
|
||||
passphrase = passphrase or ""
|
||||
t = seed_type(seed)
|
||||
t = calc_seed_type(seed)
|
||||
if t == 'old':
|
||||
if passphrase:
|
||||
raise Exception("'old'-type electrum seed cannot have passphrase")
|
||||
|
||||
@@ -258,7 +258,7 @@ def is_old_seed(seed: str) -> bool:
|
||||
return is_hex or (uses_electrum_words and (len(words) == 12 or len(words) == 24))
|
||||
|
||||
|
||||
def seed_type(x: str) -> str:
|
||||
def calc_seed_type(x: str) -> str:
|
||||
num_words = len(x.split())
|
||||
if is_old_seed(x):
|
||||
return 'old'
|
||||
@@ -277,7 +277,7 @@ def seed_type(x: str) -> str:
|
||||
|
||||
|
||||
def can_seed_have_passphrase(seed: str) -> bool:
|
||||
stype = seed_type(seed)
|
||||
stype = calc_seed_type(seed)
|
||||
if not stype:
|
||||
raise Exception(f'unexpected seed type: {stype!r}')
|
||||
if stype == 'old':
|
||||
@@ -294,7 +294,7 @@ def can_seed_have_passphrase(seed: str) -> bool:
|
||||
|
||||
|
||||
def is_seed(x: str) -> bool:
|
||||
return bool(seed_type(x))
|
||||
return bool(calc_seed_type(x))
|
||||
|
||||
|
||||
def is_any_2fa_seed_type(seed_type: str) -> bool:
|
||||
|
||||
@@ -36,7 +36,7 @@ from electrum import ecc, constants, keystore, version, bip32, bitcoin
|
||||
from electrum.bip32 import BIP32Node, xpub_type
|
||||
from electrum.crypto import sha256
|
||||
from electrum.transaction import PartialTxOutput, PartialTxInput, PartialTransaction, Transaction
|
||||
from electrum.mnemonic import Mnemonic, seed_type, is_any_2fa_seed_type
|
||||
from electrum.mnemonic import Mnemonic, calc_seed_type, is_any_2fa_seed_type
|
||||
from electrum.wallet import Multisig_Wallet, Deterministic_Wallet
|
||||
from electrum.i18n import _
|
||||
from electrum.plugin import BasePlugin, hook
|
||||
@@ -555,7 +555,7 @@ class TrustedCoinPlugin(BasePlugin):
|
||||
|
||||
@classmethod
|
||||
def xkeys_from_seed(self, seed, passphrase):
|
||||
t = seed_type(seed)
|
||||
t = calc_seed_type(seed)
|
||||
if not is_any_2fa_seed_type(t):
|
||||
raise Exception(f'unexpected seed type: {t!r}')
|
||||
words = seed.split()
|
||||
|
||||
@@ -489,7 +489,7 @@ class NewWalletWizard(AbstractWizard):
|
||||
can_passphrase = True
|
||||
|
||||
if seed_variant == 'electrum':
|
||||
seed_type = mnemonic.seed_type(seed)
|
||||
seed_type = mnemonic.calc_seed_type(seed)
|
||||
if seed_type != '':
|
||||
seed_valid = True
|
||||
can_passphrase = can_seed_have_passphrase(seed)
|
||||
|
||||
Reference in New Issue
Block a user