do not raise BaseException
This commit is contained in:
parent
76e67daadd
commit
7b50790584
@ -15,7 +15,7 @@ for i, x in enumerate(sys.argv):
|
|||||||
VERSION = sys.argv[i+1]
|
VERSION = sys.argv[i+1]
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise BaseException('no version')
|
raise Exception('no version')
|
||||||
|
|
||||||
electrum = os.path.abspath(".") + "/"
|
electrum = os.path.abspath(".") + "/"
|
||||||
block_cipher = None
|
block_cipher = None
|
||||||
|
|||||||
@ -8,7 +8,7 @@ for i, x in enumerate(sys.argv):
|
|||||||
cmdline_name = sys.argv[i+1]
|
cmdline_name = sys.argv[i+1]
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise BaseException('no name')
|
raise Exception('no name')
|
||||||
|
|
||||||
PYTHON_VERSION = '3.5.4'
|
PYTHON_VERSION = '3.5.4'
|
||||||
PYHOME = 'c:/python' + PYTHON_VERSION
|
PYHOME = 'c:/python' + PYTHON_VERSION
|
||||||
|
|||||||
@ -23,7 +23,7 @@ for p in sys.stdin.read().split():
|
|||||||
try:
|
try:
|
||||||
data = requests.get("https://pypi.org/pypi/{}/{}/json".format(p, v)).json()["info"]
|
data = requests.get("https://pypi.org/pypi/{}/{}/json".format(p, v)).json()["info"]
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise BaseException("Package could not be found: {}=={}".format(p, v))
|
raise Exception("Package could not be found: {}=={}".format(p, v))
|
||||||
try:
|
try:
|
||||||
for r in data["requires_dist"]:
|
for r in data["requires_dist"]:
|
||||||
if ";" not in r:
|
if ";" not in r:
|
||||||
|
|||||||
@ -41,7 +41,7 @@ for k, n in files.items():
|
|||||||
string = re.sub("<div id=\"%s\">(.*?)</div>"%k, '', string, flags=re.DOTALL + re.MULTILINE)
|
string = re.sub("<div id=\"%s\">(.*?)</div>"%k, '', string, flags=re.DOTALL + re.MULTILINE)
|
||||||
continue
|
continue
|
||||||
if os.system("gpg --verify %s"%sigpath) != 0:
|
if os.system("gpg --verify %s"%sigpath) != 0:
|
||||||
raise BaseException(sigpath)
|
raise Exception(sigpath)
|
||||||
string = string.replace("##link_%s##"%k, link)
|
string = string.replace("##link_%s##"%k, link)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
2
electrum
2
electrum
@ -351,7 +351,7 @@ if __name__ == '__main__':
|
|||||||
sys.argv[i] = sys.stdin.read()
|
sys.argv[i] = sys.stdin.read()
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise BaseException('Cannot get argument from stdin')
|
raise Exception('Cannot get argument from stdin')
|
||||||
elif arg == '?':
|
elif arg == '?':
|
||||||
sys.argv[i] = input("Enter argument:")
|
sys.argv[i] = input("Enter argument:")
|
||||||
elif arg == ':':
|
elif arg == ':':
|
||||||
|
|||||||
@ -69,7 +69,7 @@ class BaseWizard(object):
|
|||||||
f = getattr(self, action)
|
f = getattr(self, action)
|
||||||
f(*args)
|
f(*args)
|
||||||
else:
|
else:
|
||||||
raise BaseException("unknown action", action)
|
raise Exception("unknown action", action)
|
||||||
|
|
||||||
def can_go_back(self):
|
def can_go_back(self):
|
||||||
return len(self.stack)>1
|
return len(self.stack)>1
|
||||||
@ -364,7 +364,7 @@ class BaseWizard(object):
|
|||||||
self.load_2fa()
|
self.load_2fa()
|
||||||
self.run('on_restore_seed', seed, is_ext)
|
self.run('on_restore_seed', seed, is_ext)
|
||||||
else:
|
else:
|
||||||
raise BaseException('Unknown seed type', self.seed_type)
|
raise Exception('Unknown seed type', self.seed_type)
|
||||||
|
|
||||||
def on_restore_bip39(self, seed, passphrase):
|
def on_restore_bip39(self, seed, passphrase):
|
||||||
f = lambda x: self.run('on_bip43', seed, passphrase, str(x))
|
f = lambda x: self.run('on_bip43', seed, passphrase, str(x))
|
||||||
|
|||||||
@ -156,14 +156,14 @@ class Blockchain(util.PrintError):
|
|||||||
def verify_header(self, header, prev_hash, target):
|
def verify_header(self, header, prev_hash, target):
|
||||||
_hash = hash_header(header)
|
_hash = hash_header(header)
|
||||||
if prev_hash != header.get('prev_block_hash'):
|
if prev_hash != header.get('prev_block_hash'):
|
||||||
raise BaseException("prev hash mismatch: %s vs %s" % (prev_hash, header.get('prev_block_hash')))
|
raise Exception("prev hash mismatch: %s vs %s" % (prev_hash, header.get('prev_block_hash')))
|
||||||
if constants.net.TESTNET:
|
if constants.net.TESTNET:
|
||||||
return
|
return
|
||||||
bits = self.target_to_bits(target)
|
bits = self.target_to_bits(target)
|
||||||
if bits != header.get('bits'):
|
if bits != header.get('bits'):
|
||||||
raise BaseException("bits mismatch: %s vs %s" % (bits, header.get('bits')))
|
raise Exception("bits mismatch: %s vs %s" % (bits, header.get('bits')))
|
||||||
if int('0x' + _hash, 16) > target:
|
if int('0x' + _hash, 16) > target:
|
||||||
raise BaseException("insufficient proof of work: %s vs target %s" % (int('0x' + _hash, 16), target))
|
raise Exception("insufficient proof of work: %s vs target %s" % (int('0x' + _hash, 16), target))
|
||||||
|
|
||||||
def verify_chunk(self, index, data):
|
def verify_chunk(self, index, data):
|
||||||
num = len(data) // 80
|
num = len(data) // 80
|
||||||
@ -306,10 +306,10 @@ class Blockchain(util.PrintError):
|
|||||||
def bits_to_target(self, bits):
|
def bits_to_target(self, bits):
|
||||||
bitsN = (bits >> 24) & 0xff
|
bitsN = (bits >> 24) & 0xff
|
||||||
if not (bitsN >= 0x03 and bitsN <= 0x1d):
|
if not (bitsN >= 0x03 and bitsN <= 0x1d):
|
||||||
raise BaseException("First part of bits should be in [0x03, 0x1d]")
|
raise Exception("First part of bits should be in [0x03, 0x1d]")
|
||||||
bitsBase = bits & 0xffffff
|
bitsBase = bits & 0xffffff
|
||||||
if not (bitsBase >= 0x8000 and bitsBase <= 0x7fffff):
|
if not (bitsBase >= 0x8000 and bitsBase <= 0x7fffff):
|
||||||
raise BaseException("Second part of bits should be in [0x8000, 0x7fffff]")
|
raise Exception("Second part of bits should be in [0x8000, 0x7fffff]")
|
||||||
return bitsBase << (8 * (bitsN-3))
|
return bitsBase << (8 * (bitsN-3))
|
||||||
|
|
||||||
def target_to_bits(self, target):
|
def target_to_bits(self, target):
|
||||||
|
|||||||
@ -81,7 +81,7 @@ def command(s):
|
|||||||
wallet = args[0].wallet
|
wallet = args[0].wallet
|
||||||
password = kwargs.get('password')
|
password = kwargs.get('password')
|
||||||
if c.requires_wallet and wallet is None:
|
if c.requires_wallet and wallet is None:
|
||||||
raise BaseException("wallet not loaded. Use 'electrum daemon load_wallet'")
|
raise Exception("wallet not loaded. Use 'electrum daemon load_wallet'")
|
||||||
if c.requires_password and password is None and wallet.has_password():
|
if c.requires_password and password is None and wallet.has_password():
|
||||||
return {'error': 'Password required' }
|
return {'error': 'Password required' }
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
@ -125,7 +125,7 @@ class Commands:
|
|||||||
@command('')
|
@command('')
|
||||||
def create(self, segwit=False):
|
def create(self, segwit=False):
|
||||||
"""Create a new wallet"""
|
"""Create a new wallet"""
|
||||||
raise BaseException('Not a JSON-RPC command')
|
raise Exception('Not a JSON-RPC command')
|
||||||
|
|
||||||
@command('wn')
|
@command('wn')
|
||||||
def restore(self, text):
|
def restore(self, text):
|
||||||
@ -133,7 +133,7 @@ class Commands:
|
|||||||
public key, a master private key, a list of bitcoin addresses
|
public key, a master private key, a list of bitcoin addresses
|
||||||
or bitcoin private keys. If you want to be prompted for your
|
or bitcoin private keys. If you want to be prompted for your
|
||||||
seed, type '?' or ':' (concealed) """
|
seed, type '?' or ':' (concealed) """
|
||||||
raise BaseException('Not a JSON-RPC command')
|
raise Exception('Not a JSON-RPC command')
|
||||||
|
|
||||||
@command('wp')
|
@command('wp')
|
||||||
def password(self, password=None, new_password=None):
|
def password(self, password=None, new_password=None):
|
||||||
@ -377,7 +377,7 @@ class Commands:
|
|||||||
return None
|
return None
|
||||||
out = self.wallet.contacts.resolve(x)
|
out = self.wallet.contacts.resolve(x)
|
||||||
if out.get('type') == 'openalias' and self.nocheck is False and out.get('validated') is False:
|
if out.get('type') == 'openalias' and self.nocheck is False and out.get('validated') is False:
|
||||||
raise BaseException('cannot verify alias', x)
|
raise Exception('cannot verify alias', x)
|
||||||
return out['address']
|
return out['address']
|
||||||
|
|
||||||
@command('n')
|
@command('n')
|
||||||
@ -522,7 +522,7 @@ class Commands:
|
|||||||
if raw:
|
if raw:
|
||||||
tx = Transaction(raw)
|
tx = Transaction(raw)
|
||||||
else:
|
else:
|
||||||
raise BaseException("Unknown transaction")
|
raise Exception("Unknown transaction")
|
||||||
return tx.as_dict()
|
return tx.as_dict()
|
||||||
|
|
||||||
@command('')
|
@command('')
|
||||||
@ -551,7 +551,7 @@ class Commands:
|
|||||||
"""Return a payment request"""
|
"""Return a payment request"""
|
||||||
r = self.wallet.get_payment_request(key, self.config)
|
r = self.wallet.get_payment_request(key, self.config)
|
||||||
if not r:
|
if not r:
|
||||||
raise BaseException("Request not found")
|
raise Exception("Request not found")
|
||||||
return self._format_request(r)
|
return self._format_request(r)
|
||||||
|
|
||||||
#@command('w')
|
#@command('w')
|
||||||
@ -618,7 +618,7 @@ class Commands:
|
|||||||
"Sign payment request with an OpenAlias"
|
"Sign payment request with an OpenAlias"
|
||||||
alias = self.config.get('alias')
|
alias = self.config.get('alias')
|
||||||
if not alias:
|
if not alias:
|
||||||
raise BaseException('No alias in your configuration')
|
raise Exception('No alias in your configuration')
|
||||||
alias_addr = self.wallet.contacts.resolve(alias)['address']
|
alias_addr = self.wallet.contacts.resolve(alias)['address']
|
||||||
self.wallet.sign_payment_request(address, alias, alias_addr, password)
|
self.wallet.sign_payment_request(address, alias, alias_addr, password)
|
||||||
|
|
||||||
|
|||||||
@ -199,7 +199,7 @@ def check_query(ns, sub, _type, keys):
|
|||||||
elif answer[1].rdtype == dns.rdatatype.RRSIG:
|
elif answer[1].rdtype == dns.rdatatype.RRSIG:
|
||||||
rrset, rrsig = answer
|
rrset, rrsig = answer
|
||||||
else:
|
else:
|
||||||
raise BaseException('No signature set in record')
|
raise Exception('No signature set in record')
|
||||||
if keys is None:
|
if keys is None:
|
||||||
keys = {dns.name.from_text(sub):rrset}
|
keys = {dns.name.from_text(sub):rrset}
|
||||||
dns.dnssec.validate(rrset, rrsig, keys)
|
dns.dnssec.validate(rrset, rrsig, keys)
|
||||||
@ -248,7 +248,7 @@ def get_and_validate(ns, url, _type):
|
|||||||
continue
|
continue
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise BaseException("DS does not match DNSKEY")
|
raise Exception("DS does not match DNSKEY")
|
||||||
# set key for next iteration
|
# set key for next iteration
|
||||||
keys = {name: rrset}
|
keys = {name: rrset}
|
||||||
# get TXT record (signed by zone)
|
# get TXT record (signed by zone)
|
||||||
|
|||||||
@ -923,7 +923,7 @@ class Network(util.DaemonThread):
|
|||||||
self.notify('updated')
|
self.notify('updated')
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise BaseException(interface.mode)
|
raise Exception(interface.mode)
|
||||||
# If not finished, get the next header
|
# If not finished, get the next header
|
||||||
if next_height:
|
if next_height:
|
||||||
if interface.mode == 'catch_up' and interface.tip > next_height + 50:
|
if interface.mode == 'catch_up' and interface.tip > next_height + 50:
|
||||||
@ -1055,7 +1055,7 @@ class Network(util.DaemonThread):
|
|||||||
self.switch_to_interface(i.server)
|
self.switch_to_interface(i.server)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise BaseException('blockchain not found', index)
|
raise Exception('blockchain not found', index)
|
||||||
|
|
||||||
if self.interface:
|
if self.interface:
|
||||||
server = self.interface.server
|
server = self.interface.server
|
||||||
@ -1074,7 +1074,7 @@ class Network(util.DaemonThread):
|
|||||||
except queue.Empty:
|
except queue.Empty:
|
||||||
raise util.TimeoutException(_('Server did not answer'))
|
raise util.TimeoutException(_('Server did not answer'))
|
||||||
if r.get('error'):
|
if r.get('error'):
|
||||||
raise BaseException(r.get('error'))
|
raise Exception(r.get('error'))
|
||||||
return r.get('result')
|
return r.get('result')
|
||||||
|
|
||||||
def broadcast(self, tx, timeout=30):
|
def broadcast(self, tx, timeout=30):
|
||||||
|
|||||||
@ -95,7 +95,7 @@ def get_payment_request(url):
|
|||||||
data = None
|
data = None
|
||||||
error = "payment URL not pointing to a valid file"
|
error = "payment URL not pointing to a valid file"
|
||||||
else:
|
else:
|
||||||
raise BaseException("unknown scheme", url)
|
raise Exception("unknown scheme", url)
|
||||||
pr = PaymentRequest(data, error)
|
pr = PaymentRequest(data, error)
|
||||||
return pr
|
return pr
|
||||||
|
|
||||||
@ -340,9 +340,9 @@ def verify_cert_chain(chain):
|
|||||||
x.check_date()
|
x.check_date()
|
||||||
else:
|
else:
|
||||||
if not x.check_ca():
|
if not x.check_ca():
|
||||||
raise BaseException("ERROR: Supplied CA Certificate Error")
|
raise Exception("ERROR: Supplied CA Certificate Error")
|
||||||
if not cert_num > 1:
|
if not cert_num > 1:
|
||||||
raise BaseException("ERROR: CA Certificate Chain Not Provided by Payment Processor")
|
raise Exception("ERROR: CA Certificate Chain Not Provided by Payment Processor")
|
||||||
# if the root CA is not supplied, add it to the chain
|
# if the root CA is not supplied, add it to the chain
|
||||||
ca = x509_chain[cert_num-1]
|
ca = x509_chain[cert_num-1]
|
||||||
if ca.getFingerprint() not in ca_list:
|
if ca.getFingerprint() not in ca_list:
|
||||||
@ -352,7 +352,7 @@ def verify_cert_chain(chain):
|
|||||||
root = ca_list[f]
|
root = ca_list[f]
|
||||||
x509_chain.append(root)
|
x509_chain.append(root)
|
||||||
else:
|
else:
|
||||||
raise BaseException("Supplied CA Not Found in Trusted CA Store.")
|
raise Exception("Supplied CA Not Found in Trusted CA Store.")
|
||||||
# verify the chain of signatures
|
# verify the chain of signatures
|
||||||
cert_num = len(x509_chain)
|
cert_num = len(x509_chain)
|
||||||
for i in range(1, cert_num):
|
for i in range(1, cert_num):
|
||||||
@ -373,10 +373,10 @@ def verify_cert_chain(chain):
|
|||||||
hashBytes = bytearray(hashlib.sha512(data).digest())
|
hashBytes = bytearray(hashlib.sha512(data).digest())
|
||||||
verify = pubkey.verify(sig, x509.PREFIX_RSA_SHA512 + hashBytes)
|
verify = pubkey.verify(sig, x509.PREFIX_RSA_SHA512 + hashBytes)
|
||||||
else:
|
else:
|
||||||
raise BaseException("Algorithm not supported")
|
raise Exception("Algorithm not supported")
|
||||||
util.print_error(self.error, algo.getComponentByName('algorithm'))
|
util.print_error(self.error, algo.getComponentByName('algorithm'))
|
||||||
if not verify:
|
if not verify:
|
||||||
raise BaseException("Certificate not Signed by Provided CA Certificate Chain")
|
raise Exception("Certificate not Signed by Provided CA Certificate Chain")
|
||||||
|
|
||||||
return x509_chain[0], ca
|
return x509_chain[0], ca
|
||||||
|
|
||||||
|
|||||||
@ -403,7 +403,7 @@ class DeviceMgr(ThreadJob, PrintError):
|
|||||||
def client_for_keystore(self, plugin, handler, keystore, force_pair):
|
def client_for_keystore(self, plugin, handler, keystore, force_pair):
|
||||||
self.print_error("getting client for keystore")
|
self.print_error("getting client for keystore")
|
||||||
if handler is None:
|
if handler is None:
|
||||||
raise BaseException(_("Handler not found for") + ' ' + plugin.name + '\n' + _("A library is probably missing."))
|
raise Exception(_("Handler not found for") + ' ' + plugin.name + '\n' + _("A library is probably missing."))
|
||||||
handler.update_status(False)
|
handler.update_status(False)
|
||||||
devices = self.scan_devices()
|
devices = self.scan_devices()
|
||||||
xpub = keystore.xpub
|
xpub = keystore.xpub
|
||||||
|
|||||||
@ -107,7 +107,7 @@ class SimpleConfig(PrintError):
|
|||||||
# Make directory if it does not yet exist.
|
# Make directory if it does not yet exist.
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
if os.path.islink(path):
|
if os.path.islink(path):
|
||||||
raise BaseException('Dangling link: ' + path)
|
raise Exception('Dangling link: ' + path)
|
||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ class SimpleConfig(PrintError):
|
|||||||
if cur_version > max_version:
|
if cur_version > max_version:
|
||||||
return False
|
return False
|
||||||
elif cur_version < min_version:
|
elif cur_version < min_version:
|
||||||
raise BaseException(
|
raise Exception(
|
||||||
('config upgrade: unexpected version %d (should be %d-%d)'
|
('config upgrade: unexpected version %d (should be %d-%d)'
|
||||||
% (cur_version, min_version, max_version)))
|
% (cur_version, min_version, max_version)))
|
||||||
else:
|
else:
|
||||||
@ -240,7 +240,7 @@ class SimpleConfig(PrintError):
|
|||||||
dirpath = os.path.join(self.path, "wallets")
|
dirpath = os.path.join(self.path, "wallets")
|
||||||
if not os.path.exists(dirpath):
|
if not os.path.exists(dirpath):
|
||||||
if os.path.islink(dirpath):
|
if os.path.islink(dirpath):
|
||||||
raise BaseException('Dangling link: ' + dirpath)
|
raise Exception('Dangling link: ' + dirpath)
|
||||||
os.mkdir(dirpath)
|
os.mkdir(dirpath)
|
||||||
os.chmod(dirpath, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
os.chmod(dirpath, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
||||||
|
|
||||||
|
|||||||
@ -583,7 +583,7 @@ class Transaction:
|
|||||||
elif isinstance(raw, dict):
|
elif isinstance(raw, dict):
|
||||||
self.raw = raw['hex']
|
self.raw = raw['hex']
|
||||||
else:
|
else:
|
||||||
raise BaseException("cannot initialize transaction", raw)
|
raise Exception("cannot initialize transaction", raw)
|
||||||
self._inputs = None
|
self._inputs = None
|
||||||
self._outputs = None
|
self._outputs = None
|
||||||
self.locktime = 0
|
self.locktime = 0
|
||||||
@ -747,7 +747,7 @@ class Transaction:
|
|||||||
else:
|
else:
|
||||||
witness = txin.get('witness', None)
|
witness = txin.get('witness', None)
|
||||||
if not witness:
|
if not witness:
|
||||||
raise BaseException('wrong txin type:', txin['type'])
|
raise Exception('wrong txin type:', txin['type'])
|
||||||
if self.is_txin_complete(txin) or estimate_size:
|
if self.is_txin_complete(txin) or estimate_size:
|
||||||
value_field = ''
|
value_field = ''
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -565,12 +565,12 @@ def parse_URI(uri, on_pr=None):
|
|||||||
|
|
||||||
if ':' not in uri:
|
if ':' not in uri:
|
||||||
if not bitcoin.is_address(uri):
|
if not bitcoin.is_address(uri):
|
||||||
raise BaseException("Not a bitcoin address")
|
raise Exception("Not a bitcoin address")
|
||||||
return {'address': uri}
|
return {'address': uri}
|
||||||
|
|
||||||
u = urllib.parse.urlparse(uri)
|
u = urllib.parse.urlparse(uri)
|
||||||
if u.scheme != 'bitcoin':
|
if u.scheme != 'bitcoin':
|
||||||
raise BaseException("Not a bitcoin URI")
|
raise Exception("Not a bitcoin URI")
|
||||||
address = u.path
|
address = u.path
|
||||||
|
|
||||||
# python for android fails to parse query
|
# python for android fails to parse query
|
||||||
@ -587,7 +587,7 @@ def parse_URI(uri, on_pr=None):
|
|||||||
out = {k: v[0] for k, v in pq.items()}
|
out = {k: v[0] for k, v in pq.items()}
|
||||||
if address:
|
if address:
|
||||||
if not bitcoin.is_address(address):
|
if not bitcoin.is_address(address):
|
||||||
raise BaseException("Invalid bitcoin address:" + address)
|
raise Exception("Invalid bitcoin address:" + address)
|
||||||
out['address'] = address
|
out['address'] = address
|
||||||
if 'amount' in out:
|
if 'amount' in out:
|
||||||
am = out['amount']
|
am = out['amount']
|
||||||
|
|||||||
@ -132,7 +132,7 @@ def sweep_preparations(privkeys, network, imax=100):
|
|||||||
# we also search for pay-to-pubkey outputs
|
# we also search for pay-to-pubkey outputs
|
||||||
find_utxos_for_privkey('p2pk', privkey, compressed)
|
find_utxos_for_privkey('p2pk', privkey, compressed)
|
||||||
if not inputs:
|
if not inputs:
|
||||||
raise BaseException(_('No inputs found. (Note that inputs need to be confirmed)'))
|
raise Exception(_('No inputs found. (Note that inputs need to be confirmed)'))
|
||||||
# FIXME actually inputs need not be confirmed now, see https://github.com/kyuupichan/electrumx/issues/365
|
# FIXME actually inputs need not be confirmed now, see https://github.com/kyuupichan/electrumx/issues/365
|
||||||
return inputs, keypairs
|
return inputs, keypairs
|
||||||
|
|
||||||
@ -145,9 +145,9 @@ def sweep(privkeys, network, config, recipient, fee=None, imax=100):
|
|||||||
tx = Transaction.from_io(inputs, outputs)
|
tx = Transaction.from_io(inputs, outputs)
|
||||||
fee = config.estimate_fee(tx.estimated_size())
|
fee = config.estimate_fee(tx.estimated_size())
|
||||||
if total - fee < 0:
|
if total - fee < 0:
|
||||||
raise BaseException(_('Not enough funds on address.') + '\nTotal: %d satoshis\nFee: %d'%(total, fee))
|
raise Exception(_('Not enough funds on address.') + '\nTotal: %d satoshis\nFee: %d'%(total, fee))
|
||||||
if total - fee < dust_threshold(network):
|
if total - fee < dust_threshold(network):
|
||||||
raise BaseException(_('Not enough funds on address.') + '\nTotal: %d satoshis\nFee: %d\nDust Threshold: %d'%(total, fee, dust_threshold(network)))
|
raise Exception(_('Not enough funds on address.') + '\nTotal: %d satoshis\nFee: %d\nDust Threshold: %d'%(total, fee, dust_threshold(network)))
|
||||||
|
|
||||||
outputs = [(TYPE_ADDRESS, recipient, total - fee)]
|
outputs = [(TYPE_ADDRESS, recipient, total - fee)]
|
||||||
locktime = network.get_local_height()
|
locktime = network.get_local_height()
|
||||||
@ -1197,10 +1197,10 @@ class Abstract_Wallet(PrintError):
|
|||||||
_type, data, value = o
|
_type, data, value = o
|
||||||
if _type == TYPE_ADDRESS:
|
if _type == TYPE_ADDRESS:
|
||||||
if not is_address(data):
|
if not is_address(data):
|
||||||
raise BaseException("Invalid bitcoin address: {}".format(data))
|
raise Exception("Invalid bitcoin address: {}".format(data))
|
||||||
if value == '!':
|
if value == '!':
|
||||||
if i_max is not None:
|
if i_max is not None:
|
||||||
raise BaseException("More than one output set to spend max")
|
raise Exception("More than one output set to spend max")
|
||||||
i_max = i
|
i_max = i
|
||||||
|
|
||||||
# Avoid index-out-of-range with inputs[0] below
|
# Avoid index-out-of-range with inputs[0] below
|
||||||
@ -1239,7 +1239,7 @@ class Abstract_Wallet(PrintError):
|
|||||||
elif callable(fixed_fee):
|
elif callable(fixed_fee):
|
||||||
fee_estimator = fixed_fee
|
fee_estimator = fixed_fee
|
||||||
else:
|
else:
|
||||||
raise BaseException('Invalid argument fixed_fee: %s' % fixed_fee)
|
raise Exception('Invalid argument fixed_fee: %s' % fixed_fee)
|
||||||
|
|
||||||
if i_max is None:
|
if i_max is None:
|
||||||
# Let the coin chooser select the coins to spend
|
# Let the coin chooser select the coins to spend
|
||||||
@ -1370,7 +1370,7 @@ class Abstract_Wallet(PrintError):
|
|||||||
|
|
||||||
def bump_fee(self, tx, delta):
|
def bump_fee(self, tx, delta):
|
||||||
if tx.is_final():
|
if tx.is_final():
|
||||||
raise BaseException(_('Cannot bump fee') + ': ' + _('transaction is final'))
|
raise Exception(_('Cannot bump fee') + ': ' + _('transaction is final'))
|
||||||
inputs = copy.deepcopy(tx.inputs())
|
inputs = copy.deepcopy(tx.inputs())
|
||||||
outputs = copy.deepcopy(tx.outputs())
|
outputs = copy.deepcopy(tx.outputs())
|
||||||
for txin in inputs:
|
for txin in inputs:
|
||||||
@ -1401,7 +1401,7 @@ class Abstract_Wallet(PrintError):
|
|||||||
if delta > 0:
|
if delta > 0:
|
||||||
continue
|
continue
|
||||||
if delta > 0:
|
if delta > 0:
|
||||||
raise BaseException(_('Cannot bump fee') + ': ' + _('could not find suitable outputs'))
|
raise Exception(_('Cannot bump fee') + ': ' + _('could not find suitable outputs'))
|
||||||
locktime = self.get_local_height()
|
locktime = self.get_local_height()
|
||||||
tx_new = Transaction.from_io(inputs, outputs, locktime=locktime)
|
tx_new = Transaction.from_io(inputs, outputs, locktime=locktime)
|
||||||
tx_new.BIP_LI01_sort()
|
tx_new.BIP_LI01_sort()
|
||||||
|
|||||||
@ -107,7 +107,7 @@ class DigitalBitbox_Client():
|
|||||||
xpub = serialize_xpub(xtype, c, cK, depth, fingerprint, child_number)
|
xpub = serialize_xpub(xtype, c, cK, depth, fingerprint, child_number)
|
||||||
return xpub
|
return xpub
|
||||||
else:
|
else:
|
||||||
raise BaseException('no reply')
|
raise Exception('no reply')
|
||||||
|
|
||||||
|
|
||||||
def dbb_has_password(self):
|
def dbb_has_password(self):
|
||||||
|
|||||||
@ -344,7 +344,7 @@ class KeepKeyCompatiblePlugin(HW_PluginBase):
|
|||||||
elif addrtype == constants.net.ADDRTYPE_P2SH:
|
elif addrtype == constants.net.ADDRTYPE_P2SH:
|
||||||
txoutputtype.script_type = self.types.PAYTOSCRIPTHASH
|
txoutputtype.script_type = self.types.PAYTOSCRIPTHASH
|
||||||
else:
|
else:
|
||||||
raise BaseException('addrtype: ' + str(addrtype))
|
raise Exception('addrtype: ' + str(addrtype))
|
||||||
txoutputtype.address = address
|
txoutputtype.address = address
|
||||||
return txoutputtype
|
return txoutputtype
|
||||||
|
|
||||||
|
|||||||
@ -72,10 +72,10 @@ class LabelsPlugin(BasePlugin):
|
|||||||
kwargs['headers']['Content-Type'] = 'application/json'
|
kwargs['headers']['Content-Type'] = 'application/json'
|
||||||
response = requests.request(method, url, **kwargs)
|
response = requests.request(method, url, **kwargs)
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
raise BaseException(response.status_code, response.text)
|
raise Exception(response.status_code, response.text)
|
||||||
response = response.json()
|
response = response.json()
|
||||||
if "error" in response:
|
if "error" in response:
|
||||||
raise BaseException(response["error"])
|
raise Exception(response["error"])
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def do_request_safe(self, *args, **kwargs):
|
def do_request_safe(self, *args, **kwargs):
|
||||||
|
|||||||
@ -188,7 +188,7 @@ class Ledger_Client():
|
|||||||
self.perform_hw1_preflight()
|
self.perform_hw1_preflight()
|
||||||
except BTChipException as e:
|
except BTChipException as e:
|
||||||
if (e.sw == 0x6d00 or e.sw == 0x6700):
|
if (e.sw == 0x6d00 or e.sw == 0x6700):
|
||||||
raise BaseException(_("Device not in Bitcoin mode")) from e
|
raise Exception(_("Device not in Bitcoin mode")) from e
|
||||||
raise e
|
raise e
|
||||||
self.preflightDone = True
|
self.preflightDone = True
|
||||||
|
|
||||||
|
|||||||
@ -406,7 +406,7 @@ class TrustedCoinPlugin(BasePlugin):
|
|||||||
xprv1, xpub1 = self.get_xkeys(seed, passphrase, "m/0'/")
|
xprv1, xpub1 = self.get_xkeys(seed, passphrase, "m/0'/")
|
||||||
xprv2, xpub2 = self.get_xkeys(seed, passphrase, "m/1'/")
|
xprv2, xpub2 = self.get_xkeys(seed, passphrase, "m/1'/")
|
||||||
else:
|
else:
|
||||||
raise BaseException('unrecognized seed length: {} words'.format(n))
|
raise Exception('unrecognized seed length: {} words'.format(n))
|
||||||
return xprv1, xpub1, xprv2, xpub2
|
return xprv1, xpub1, xprv2, xpub2
|
||||||
|
|
||||||
def create_keystore(self, wizard, seed, passphrase):
|
def create_keystore(self, wizard, seed, passphrase):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user