Browse Source
slip39: follow-ups
- fix kivy wizard restore-from-seed
- qt seed dialog: disable "next share" if current share is invalid
- fix tests: file paths should not depend on $PWD (working dir)
patch-4
SomberNight
4 years ago
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
4 changed files with
12 additions and
4 deletions
electrum/gui/kivy/uix/dialogs/installwizard.py
electrum/gui/qt/seed_dialog.py
electrum/slip39.py
electrum/tests/test_mnemonic.py
@ -989,7 +989,8 @@ class RestoreSeedDialog(WizardDialog):
tis . focus = False
def get_params ( self , b ) :
return ( self . get_text ( ) , self . is_bip39 , self . is_ext )
seed_type = ' bip39 ' if self . is_bip39 else ' electrum '
return ( self . get_text ( ) , seed_type , self . is_ext )
class ConfirmSeedDialog ( RestoreSeedDialog ) :
@ -302,7 +302,12 @@ class SeedLayout(QVBoxLayout):
self . prev_share_btn . show ( )
self . next_share_btn . show ( )
self . prev_share_btn . setEnabled ( self . slip39_mnemonic_index != 0 )
self . next_share_btn . setEnabled ( self . slip39_mnemonic_index < len ( self . slip39_mnemonics ) - 1 or ( bool ( self . seed_e . text ( ) . strip ( ) ) and not finished ) )
self . next_share_btn . setEnabled (
# already pressed "prev" and undoing that:
self . slip39_mnemonic_index < len ( self . slip39_mnemonics ) - 1
# finished entering latest share and starting new one:
or ( bool ( self . seed_e . text ( ) . strip ( ) ) and not self . slip39_current_mnemonic_invalid and not finished )
)
def on_prev_share ( self ) :
if not self . slip39_mnemonics [ self . slip39_mnemonic_index ] :
@ -28,8 +28,8 @@ import hmac
from collections import defaultdict
from hashlib import pbkdf2_hmac
from typing import Dict , Iterable , List , Optional , Set , Tuple
from electrum . i18n import _
from . i18n import _
from . mnemonic import Wordlist
Indices = Tuple [ int , . . . ]
@ -1,5 +1,6 @@
from typing import NamedTuple , Optional
import json
import os
from electrum import keystore
from electrum import mnemonic
@ -197,7 +198,8 @@ class Test_slip39(ElectrumTestCase):
""" Test SLIP39 test vectors. """
def test_slip39_vectors ( self ) :
with open ( " slip39-vectors.json " , " r " ) as f :
test_vector_file = os . path . join ( os . path . dirname ( __file__ ) , " slip39-vectors.json " )
with open ( test_vector_file , " r " ) as f :
vectors = json . load ( f )
for description , mnemonics , expected_secret in vectors :
if expected_secret :