Catch wallet file related exceptions in Qt wizard.
This commit is contained in:
@@ -29,7 +29,8 @@ from unicodedata import normalize
|
||||
from . import bitcoin
|
||||
from .bitcoin import *
|
||||
from . import constants
|
||||
from .util import PrintError, InvalidPassword, hfu
|
||||
from .util import (PrintError, InvalidPassword, hfu, WalletFileException,
|
||||
BitcoinException)
|
||||
from .mnemonic import Mnemonic, load_wordlist
|
||||
from .plugins import run_hook
|
||||
|
||||
@@ -615,7 +616,8 @@ def xpubkey_to_address(x_pubkey):
|
||||
mpk, s = Old_KeyStore.parse_xpubkey(x_pubkey)
|
||||
pubkey = Old_KeyStore.get_pubkey_from_mpk(mpk, s[0], s[1])
|
||||
else:
|
||||
raise BaseException("Cannot parse pubkey")
|
||||
raise BitcoinException("Cannot parse pubkey. prefix: {}"
|
||||
.format(x_pubkey[0:2]))
|
||||
if pubkey:
|
||||
address = public_key_to_p2pkh(bfh(pubkey))
|
||||
return pubkey, address
|
||||
@@ -634,14 +636,15 @@ def hardware_keystore(d):
|
||||
if hw_type in hw_keystores:
|
||||
constructor = hw_keystores[hw_type]
|
||||
return constructor(d)
|
||||
raise BaseException('unknown hardware type', hw_type)
|
||||
raise WalletFileException('unknown hardware type: {}'.format(hw_type))
|
||||
|
||||
def load_keystore(storage, name):
|
||||
w = storage.get('wallet_type', 'standard')
|
||||
d = storage.get(name, {})
|
||||
t = d.get('type')
|
||||
if not t:
|
||||
raise BaseException('wallet format requires update')
|
||||
raise WalletFileException(
|
||||
'Wallet format requires update.\n'
|
||||
'Cannot find keystore for name {}'.format(name))
|
||||
if t == 'old':
|
||||
k = Old_KeyStore(d)
|
||||
elif t == 'imported':
|
||||
@@ -651,7 +654,8 @@ def load_keystore(storage, name):
|
||||
elif t == 'hardware':
|
||||
k = hardware_keystore(d)
|
||||
else:
|
||||
raise BaseException('unknown wallet type', t)
|
||||
raise WalletFileException(
|
||||
'Unknown type {} for keystore named {}'.format(t, name))
|
||||
return k
|
||||
|
||||
|
||||
@@ -709,7 +713,7 @@ def from_seed(seed, passphrase, is_p2sh):
|
||||
xtype = 'p2wsh' if is_p2sh else 'p2wpkh'
|
||||
keystore.add_xprv_from_seed(bip32_seed, xtype, der)
|
||||
else:
|
||||
raise BaseException(t)
|
||||
raise BitcoinException('Unexpected seed type {}'.format(t))
|
||||
return keystore
|
||||
|
||||
def from_private_key_list(text):
|
||||
@@ -743,5 +747,5 @@ def from_master_key(text):
|
||||
elif is_xpub(text):
|
||||
k = from_xpub(text)
|
||||
else:
|
||||
raise BaseException('Invalid key')
|
||||
raise BitcoinException('Invalid master key')
|
||||
return k
|
||||
|
||||
Reference in New Issue
Block a user