mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
check xkey type when we add the keystore, so that we cover all cases
This commit is contained in:
parent
123c5e3165
commit
f0fe84d959
2 changed files with 12 additions and 8 deletions
|
@ -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)
|
self.add_xpub_dialog(title=title, message=message, run_next=self.on_restore_from_key, is_valid=v)
|
||||||
else:
|
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
|
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):
|
def on_restore_from_key(self, text):
|
||||||
k = keystore.from_keys(text)
|
k = keystore.from_keys(text)
|
||||||
|
@ -317,6 +310,14 @@ class BaseWizard(object):
|
||||||
self.show_error(_('Error: duplicate master public key'))
|
self.show_error(_('Error: duplicate master public key'))
|
||||||
self.run('choose_keystore')
|
self.run('choose_keystore')
|
||||||
return
|
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)
|
self.keystores.append(k)
|
||||||
if len(self.keystores) == 1:
|
if len(self.keystores) == 1:
|
||||||
xpub = k.get_master_public_key()
|
xpub = k.get_master_public_key()
|
||||||
|
|
|
@ -869,6 +869,9 @@ def deserialize_xpub(xkey):
|
||||||
def deserialize_xprv(xkey):
|
def deserialize_xprv(xkey):
|
||||||
return deserialize_xkey(xkey, True)
|
return deserialize_xkey(xkey, True)
|
||||||
|
|
||||||
|
def xpub_type(x):
|
||||||
|
return deserialize_xpub(x)[0]
|
||||||
|
|
||||||
|
|
||||||
def is_xpub(text):
|
def is_xpub(text):
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Add table
Reference in a new issue