Browse Source

follow-up prev commit: revert "strict checks" for old seeds

3.0.x
SomberNight 7 years ago
parent
commit
c05549c8cd
  1. 7
      lib/bitcoin.py
  2. 3
      lib/tests/test_bitcoin.py

7
lib/bitcoin.py

@ -264,10 +264,9 @@ def is_old_seed(seed):
seed = mnemonic.normalize_text(seed) seed = mnemonic.normalize_text(seed)
words = seed.split() words = seed.split()
try: try:
hex_seed = old_mnemonic.mn_decode(words) # checks here are deliberately left weak for legacy reasons, see #3149
words2 = old_mnemonic.mn_encode(hex_seed) old_mnemonic.mn_decode(words)
seed2 = ' '.join(words2) uses_electrum_words = True
uses_electrum_words = seed == seed2
except Exception: except Exception:
uses_electrum_words = False uses_electrum_words = False
try: try:

3
lib/tests/test_bitcoin.py

@ -355,7 +355,8 @@ class Test_seeds(unittest.TestCase):
('cell dumb heartbeat north boom tease ship baby bright kingdom rare badword', ''), ('cell dumb heartbeat north boom tease ship baby bright kingdom rare badword', ''),
('cElL DuMb hEaRtBeAt nOrTh bOoM TeAsE ShIp bAbY BrIgHt kInGdOm rArE SqUeEzE', 'old'), ('cElL DuMb hEaRtBeAt nOrTh bOoM TeAsE ShIp bAbY BrIgHt kInGdOm rArE SqUeEzE', 'old'),
(' cElL DuMb hEaRtBeAt nOrTh bOoM TeAsE ShIp bAbY BrIgHt kInGdOm rArE SqUeEzE ', 'old'), (' cElL DuMb hEaRtBeAt nOrTh bOoM TeAsE ShIp bAbY BrIgHt kInGdOm rArE SqUeEzE ', 'old'),
('hurry idiot prefer sunset mention mist jaw inhale impossible kingdom rare squeeze', ''), # almost 'old' but maps to 33 hex chars # below seed is actually 'invalid old' as it maps to 33 hex chars
('hurry idiot prefer sunset mention mist jaw inhale impossible kingdom rare squeeze', 'old'),
('cram swing cover prefer miss modify ritual silly deliver chunk behind inform able', 'standard'), ('cram swing cover prefer miss modify ritual silly deliver chunk behind inform able', 'standard'),
('cram swing cover prefer miss modify ritual silly deliver chunk behind inform', ''), ('cram swing cover prefer miss modify ritual silly deliver chunk behind inform', ''),
('ostrich security deer aunt climb inner alpha arm mutual marble solid task', 'standard'), ('ostrich security deer aunt climb inner alpha arm mutual marble solid task', 'standard'),

Loading…
Cancel
Save