Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
pooler committed Jan 3, 2021
2 parents 1a1fe93 + 07b0873 commit ab49ee8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 18 deletions.
6 changes: 3 additions & 3 deletions electrum_ltc/base_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,13 +509,13 @@ def restore_from_seed(self):
self.opt_ext = True
is_cosigning_seed = lambda x: mnemonic.seed_type(x) in ['standard', 'segwit']
test = mnemonic.is_seed if self.wallet_type == 'standard' else is_cosigning_seed
self.restore_seed_dialog(run_next=self.on_restore_seed, test=test)
f = lambda *args: self.run('on_restore_seed', *args)
self.restore_seed_dialog(run_next=f, test=test)

def on_restore_seed(self, seed, is_bip39, is_ext):
self.seed_type = 'bip39' if is_bip39 else mnemonic.seed_type(seed)
if self.seed_type == 'bip39':
def f(passphrase):
self.on_restore_bip39(seed, passphrase)
f = lambda passphrase: self.run('on_restore_bip39', seed, passphrase)
self.passphrase_dialog(run_next=f, is_restoring=True) if is_ext else f('')
elif self.seed_type in ['standard', 'segwit']:
f = lambda passphrase: self.run('create_keystore', seed, passphrase)
Expand Down
24 changes: 17 additions & 7 deletions electrum_ltc/gui/kivy/uix/dialogs/installwizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -874,16 +874,18 @@ def __init__(self, wizard, **kwargs):
self.ids.text_input_seed.text = ''
self.message = _('Please type your seed phrase using the virtual keyboard.')
self.title = _('Enter Seed')
self.ext = False
self.bip39 = False
self.opt_ext = kwargs['opt_ext']
self.opt_bip39 = kwargs['opt_bip39']
self.is_ext = False
self.is_bip39 = False

def options_dialog(self):
from .seed_options import SeedOptionsDialog
def callback(ext, bip39):
self.ext = ext
self.bip39 = bip39
self.is_ext = ext
self.is_bip39 = bip39
self.update_next_button()
d = SeedOptionsDialog(self.ext, self.bip39, callback)
d = SeedOptionsDialog(self.opt_ext, self.opt_bip39, self.is_ext, self.is_bip39, callback)
d.open()

def get_suggestions(self, prefix):
Expand All @@ -892,7 +894,13 @@ def get_suggestions(self, prefix):
yield w

def update_next_button(self):
self.ids.next.disabled = False if self.bip39 else not bool(self._test(self.get_text()))
from electrum_ltc.keystore import bip39_is_checksum_valid
text = self.get_text()
if self.is_bip39:
is_seed, is_wordlist = bip39_is_checksum_valid(text)
else:
is_seed = bool(self._test(text))
self.ids.next.disabled = not is_seed

def on_text(self, dt):
self.update_next_button()
Expand Down Expand Up @@ -980,7 +988,7 @@ def _remove_keyboard(self):
tis.focus = False

def get_params(self, b):
return (self.get_text(), self.bip39, self.ext)
return (self.get_text(), self.is_bip39, self.is_ext)


class ConfirmSeedDialog(RestoreSeedDialog):
Expand Down Expand Up @@ -1094,6 +1102,8 @@ def confirm_seed_dialog(self, **kwargs):
ConfirmSeedDialog(self, **kwargs).open()

def restore_seed_dialog(self, **kwargs):
kwargs['opt_bip39'] = self.opt_bip39
kwargs['opt_ext'] = self.opt_ext
RestoreSeedDialog(self, **kwargs).open()

def confirm_dialog(self, **kwargs):
Expand Down
25 changes: 17 additions & 8 deletions electrum_ltc/gui/kivy/uix/dialogs/seed_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
Builder.load_string('''
<SeedOptionsDialog@Popup>
id: popup
opt_bip39: False
opt_ext: False
is_bip39: False
is_ext: False
title: _('Seed Options')
size_hint: 0.8, 0.8
pos_hint: {'top':0.9}
Expand All @@ -22,16 +26,24 @@
size_hint: 1, 0.2
Label:
text: _('Extend Seed')
opacity: 1 if root.opt_ext else 0
CheckBox:
id:ext
disabled: not root.opt_ext
opacity: 1 if root.opt_ext else 0
active: root.is_ext
BoxLayout:
orientation: 'horizontal'
size_hint: 1, 0.2
Label:
text: _('BIP39')
id:bip39_label
opacity: 1 if root.opt_bip39 else 0
CheckBox:
id:bip39
disabled: not root.opt_bip39
opacity: 1 if root.opt_bip39 else 0
active: root.is_bip39
Widget:
size_hint: 1, 0.1
BoxLayout:
Expand All @@ -53,13 +65,10 @@


class SeedOptionsDialog(Factory.Popup):
def __init__(self, is_ext, is_bip39, callback):
def __init__(self, opt_ext, opt_bip39, is_ext, is_bip39, callback):
Factory.Popup.__init__(self)
self.ids.ext.active = is_ext
if is_bip39 is None:
self.ids.bip39.opacity = 0
self.ids.bip39_label.opacity = 0
self.ids.bip39.disabled = True
else:
self.ids.bip39.active = is_bip39
self.opt_ext = opt_ext
self.opt_bip39 = opt_bip39
self.is_ext = is_ext
self.is_bip39 = is_bip39
self.callback = callback

0 comments on commit ab49ee8

Please sign in to comment.