wizard: check xpub types before adding keystore

This commit is contained in:
ThomasV 2017-10-26 17:43:41 +02:00
parent a10e6b6436
commit 11bbe31ae3
1 changed files with 10 additions and 2 deletions

View File

@ -307,17 +307,25 @@ class BaseWizard(object):
self.on_keystore(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 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.run('create_wallet')
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):
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))