wizard: check xpub types before adding keystore
This commit is contained in:
@@ -307,17 +307,25 @@ class BaseWizard(object):
|
|||||||
self.on_keystore(k)
|
self.on_keystore(k)
|
||||||
|
|
||||||
def on_keystore(self, k):
|
def on_keystore(self, k):
|
||||||
|
from .bitcoin import xpub_type
|
||||||
|
t1 = xpub_type(k.xpub) #fixme: old wallets
|
||||||
if self.wallet_type == 'standard':
|
if self.wallet_type == 'standard':
|
||||||
|
if t1 not in ['standard', 'p2wpkh', 'p2wpkh-p2sh']:
|
||||||
|
self.show_error(_('Wrong key type') + ' %s'%t1)
|
||||||
|
self.run('choose_keystore')
|
||||||
|
return
|
||||||
self.keystores.append(k)
|
self.keystores.append(k)
|
||||||
self.run('create_wallet')
|
self.run('create_wallet')
|
||||||
elif self.wallet_type == 'multisig':
|
elif self.wallet_type == 'multisig':
|
||||||
|
if t1 not in ['standard', 'p2wsh', 'p2wsh-p2sh']:
|
||||||
|
self.show_error(_('Wrong key type') + ' %s'%t1)
|
||||||
|
self.run('choose_keystore')
|
||||||
|
return
|
||||||
if k.xpub in map(lambda x: x.xpub, self.keystores):
|
if k.xpub in map(lambda x: x.xpub, self.keystores):
|
||||||
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:
|
if len(self.keystores)>0:
|
||||||
t1 = xpub_type(k.xpub)
|
|
||||||
t2 = xpub_type(self.keystores[0].xpub)
|
t2 = xpub_type(self.keystores[0].xpub)
|
||||||
if t1 != t2:
|
if t1 != t2:
|
||||||
self.show_error(_('Cannot add this cosigner:') + '\n' + "Their key type is '%s', we are '%s'"%(t1, t2))
|
self.show_error(_('Cannot add this cosigner:') + '\n' + "Their key type is '%s', we are '%s'"%(t1, t2))
|
||||||
|
|||||||
Reference in New Issue
Block a user