Browse Source

check xkey type when we add the keystore, so that we cover all cases

seed_v14
ThomasV 7 years ago
parent
commit
f0fe84d959
  1. 17
      lib/base_wizard.py
  2. 3
      lib/bitcoin.py

17
lib/base_wizard.py

@ -160,15 +160,8 @@ class BaseWizard(object):
])
self.add_xpub_dialog(title=title, message=message, run_next=self.on_restore_from_key, is_valid=v)
else:
def check_xkey_type(x):
if keystore.is_xpub(x):
return bitcoin.deserialize_xpub(x)[0] == self.seed_type
elif keystore.is_xprv(x):
return bitcoin.deserialize_xprv(x)[0] == self.seed_type
else:
return False
i = len(self.keystores) + 1
self.add_cosigner_dialog(index=i, run_next=self.on_restore_from_key, is_valid=check_xkey_type)
self.add_cosigner_dialog(index=i, run_next=self.on_restore_from_key, is_valid=keystore.is_bip32_key)
def on_restore_from_key(self, text):
k = keystore.from_keys(text)
@ -317,6 +310,14 @@ class BaseWizard(object):
self.show_error(_('Error: duplicate master public key'))
self.run('choose_keystore')
return
from .bitcoin import xpub_type
if len(self.keystores)>0:
t1 = xpub_type(k.xpub)
t2 = xpub_type(self.keystores[0].xpub)
if t1 != t2:
self.show_error(_('Cannot add this cosigner:') + '\n' + "Their key type is '%s', we are '%s'"%(t1, t2))
self.run('choose_keystore')
return
self.keystores.append(k)
if len(self.keystores) == 1:
xpub = k.get_master_public_key()

3
lib/bitcoin.py

@ -869,6 +869,9 @@ def deserialize_xpub(xkey):
def deserialize_xprv(xkey):
return deserialize_xkey(xkey, True)
def xpub_type(x):
return deserialize_xpub(x)[0]
def is_xpub(text):
try:

Loading…
Cancel
Save