Merge pull request #386 from WyseNynja/dont_use_base_exception
replace BaseException with Exception
This commit is contained in:
commit
9056865bde
2
electrum
2
electrum
|
@ -103,7 +103,7 @@ def run_command(cmd, password = None, args = []):
|
||||||
cmd_runner.password = password
|
cmd_runner.password = password
|
||||||
try:
|
try:
|
||||||
result = func(*args[1:])
|
result = func(*args[1:])
|
||||||
except BaseException, e:
|
except Exception as e:
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc(file=sys.stdout)
|
traceback.print_exc(file=sys.stdout)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
|
@ -458,7 +458,7 @@ def pay_to(recipient, amount, fee, label):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
tx = wallet.mktx( [(recipient, amount)], password, fee)
|
tx = wallet.mktx( [(recipient, amount)], password, fee)
|
||||||
except BaseException, e:
|
except Exception as e:
|
||||||
modal_dialog('error', e.message)
|
modal_dialog('error', e.message)
|
||||||
droid.dialogDismiss()
|
droid.dialogDismiss()
|
||||||
return
|
return
|
||||||
|
|
|
@ -807,7 +807,7 @@ class ElectrumWindow:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
tx = self.wallet.mktx( [(to_address, amount)], password, fee )
|
tx = self.wallet.mktx( [(to_address, amount)], password, fee )
|
||||||
except BaseException, e:
|
except Exception as e:
|
||||||
self.show_message(str(e))
|
self.show_message(str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -750,7 +750,7 @@ class MiniActuator:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
tx = self.g.wallet.mktx([(dest_address, amount)], password, fee)
|
tx = self.g.wallet.mktx([(dest_address, amount)], password, fee)
|
||||||
except BaseException as error:
|
except Exception as error:
|
||||||
QMessageBox.warning(parent_window, _('Error'), str(error), _('OK'))
|
QMessageBox.warning(parent_window, _('Error'), str(error), _('OK'))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -778,7 +778,7 @@ class MiniActuator:
|
||||||
with open(fileName,'w') as f:
|
with open(fileName,'w') as f:
|
||||||
f.write(json.dumps(tx.as_dict(),indent=4) + '\n')
|
f.write(json.dumps(tx.as_dict(),indent=4) + '\n')
|
||||||
QMessageBox.information(QWidget(), _('Unsigned transaction created'), _("Unsigned transaction was saved to file:") + " " +fileName, _('OK'))
|
QMessageBox.information(QWidget(), _('Unsigned transaction created'), _("Unsigned transaction was saved to file:") + " " +fileName, _('OK'))
|
||||||
except BaseException as e:
|
except Exception as e:
|
||||||
QMessageBox.warning(QWidget(), _('Error'), _('Could not write transaction to file: %s' % e), _('OK'))
|
QMessageBox.warning(QWidget(), _('Error'), _('Could not write transaction to file: %s' % e), _('OK'))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -889,7 +889,7 @@ class ElectrumWindow(QMainWindow):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
tx = self.wallet.mktx_from_account( [(to_address, amount)], password, fee, self.current_account)
|
tx = self.wallet.mktx_from_account( [(to_address, amount)], password, fee, self.current_account)
|
||||||
except BaseException, e:
|
except Exception as e:
|
||||||
traceback.print_exc(file=sys.stdout)
|
traceback.print_exc(file=sys.stdout)
|
||||||
self.show_message(str(e))
|
self.show_message(str(e))
|
||||||
return
|
return
|
||||||
|
@ -1635,7 +1635,7 @@ class ElectrumWindow(QMainWindow):
|
||||||
if not address: return
|
if not address: return
|
||||||
try:
|
try:
|
||||||
pk_list = self.wallet.get_private_key(address, password)
|
pk_list = self.wallet.get_private_key(address, password)
|
||||||
except BaseException, e:
|
except Exception as e:
|
||||||
self.show_message(str(e))
|
self.show_message(str(e))
|
||||||
return
|
return
|
||||||
QMessageBox.information(self, _('Private key'), _('Address')+ ': ' + address + '\n\n' + _('Private key') + ': ' + '\n'.join(pk_list), _('OK'))
|
QMessageBox.information(self, _('Private key'), _('Address')+ ': ' + address + '\n\n' + _('Private key') + ': ' + '\n'.join(pk_list), _('OK'))
|
||||||
|
@ -1648,7 +1648,7 @@ class ElectrumWindow(QMainWindow):
|
||||||
try:
|
try:
|
||||||
sig = self.wallet.sign_message(str(address.text()), message, password)
|
sig = self.wallet.sign_message(str(address.text()), message, password)
|
||||||
signature.setText(sig)
|
signature.setText(sig)
|
||||||
except BaseException, e:
|
except Exception as e:
|
||||||
self.show_message(str(e))
|
self.show_message(str(e))
|
||||||
|
|
||||||
def sign_message(self, address):
|
def sign_message(self, address):
|
||||||
|
@ -1840,7 +1840,7 @@ class ElectrumWindow(QMainWindow):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
tx = self.wallet.make_unsigned_transaction(outputs, None, None)
|
tx = self.wallet.make_unsigned_transaction(outputs, None, None)
|
||||||
except BaseException, e:
|
except Exception as e:
|
||||||
self.show_message(str(e))
|
self.show_message(str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -1893,7 +1893,7 @@ class ElectrumWindow(QMainWindow):
|
||||||
export_error_label = _("Electrum was unable to produce a private key-export.")
|
export_error_label = _("Electrum was unable to produce a private key-export.")
|
||||||
QMessageBox.critical(None, _("Unable to create csv"), export_error_label + "\n" + str(reason))
|
QMessageBox.critical(None, _("Unable to create csv"), export_error_label + "\n" + str(reason))
|
||||||
|
|
||||||
except BaseException, e:
|
except Exception as e:
|
||||||
self.show_message(str(e))
|
self.show_message(str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -1946,7 +1946,7 @@ class ElectrumWindow(QMainWindow):
|
||||||
for key in text:
|
for key in text:
|
||||||
try:
|
try:
|
||||||
addr = self.wallet.import_key(key, password)
|
addr = self.wallet.import_key(key, password)
|
||||||
except BaseException as e:
|
except Exception as e:
|
||||||
badkeys.append(key)
|
badkeys.append(key)
|
||||||
continue
|
continue
|
||||||
if not addr:
|
if not addr:
|
||||||
|
|
|
@ -198,7 +198,7 @@ class ElectrumGui:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
tx = self.wallet.mktx( [(self.str_recipient, amount)], password, fee)
|
tx = self.wallet.mktx( [(self.str_recipient, amount)], password, fee)
|
||||||
except BaseException, e:
|
except Exception as e:
|
||||||
print(str(e))
|
print(str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -309,7 +309,7 @@ class ElectrumGui:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
tx = self.wallet.mktx( [(self.str_recipient, amount)], password, fee)
|
tx = self.wallet.mktx( [(self.str_recipient, amount)], password, fee)
|
||||||
except BaseException, e:
|
except Exception as e:
|
||||||
self.show_message(str(e))
|
self.show_message(str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ class OldAccount(Account):
|
||||||
master_public_key = master_private_key.get_verifying_key().to_string()
|
master_public_key = master_private_key.get_verifying_key().to_string()
|
||||||
if master_public_key != self.mpk:
|
if master_public_key != self.mpk:
|
||||||
print_error('invalid password (mpk)')
|
print_error('invalid password (mpk)')
|
||||||
raise BaseException('Invalid password')
|
raise Exception('Invalid password')
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def redeem_script(self, sequence):
|
def redeem_script(self, sequence):
|
||||||
|
|
|
@ -115,7 +115,7 @@ def hash_160(public_key):
|
||||||
md = hashlib.new('ripemd160')
|
md = hashlib.new('ripemd160')
|
||||||
md.update(hashlib.sha256(public_key).digest())
|
md.update(hashlib.sha256(public_key).digest())
|
||||||
return md.digest()
|
return md.digest()
|
||||||
except:
|
except Exception:
|
||||||
import ripemd
|
import ripemd
|
||||||
md = ripemd.new(hashlib.sha256(public_key).digest())
|
md = ripemd.new(hashlib.sha256(public_key).digest())
|
||||||
return md.digest()
|
return md.digest()
|
||||||
|
@ -268,7 +268,7 @@ def is_valid(addr):
|
||||||
if not ADDRESS_RE.match(addr): return False
|
if not ADDRESS_RE.match(addr): return False
|
||||||
try:
|
try:
|
||||||
addrtype, h = bc_address_to_hash_160(addr)
|
addrtype, h = bc_address_to_hash_160(addr)
|
||||||
except:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
return addr == hash_160_to_bc_address(h, addrtype)
|
return addr == hash_160_to_bc_address(h, addrtype)
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ def is_valid(addr):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from ecdsa.ecdsa import curve_secp256k1, generator_secp256k1
|
from ecdsa.ecdsa import curve_secp256k1, generator_secp256k1
|
||||||
except:
|
except Exception:
|
||||||
print "cannot import ecdsa.curve_secp256k1. You probably need to upgrade ecdsa.\nTry: sudo pip install --upgrade ecdsa"
|
print "cannot import ecdsa.curve_secp256k1. You probably need to upgrade ecdsa.\nTry: sudo pip install --upgrade ecdsa"
|
||||||
exit()
|
exit()
|
||||||
from ecdsa.curves import SECP256k1
|
from ecdsa.curves import SECP256k1
|
||||||
|
@ -294,7 +294,7 @@ def verify_message(address, signature, message):
|
||||||
try:
|
try:
|
||||||
EC_KEY.verify_message(address, signature, message)
|
EC_KEY.verify_message(address, signature, message)
|
||||||
return True
|
return True
|
||||||
except BaseException as e:
|
except Exception as e:
|
||||||
print_error("Verification error: {0}".format(e))
|
print_error("Verification error: {0}".format(e))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -316,10 +316,10 @@ class EC_KEY(object):
|
||||||
try:
|
try:
|
||||||
self.verify_message( address, sig, message)
|
self.verify_message( address, sig, message)
|
||||||
return sig
|
return sig
|
||||||
except:
|
except Exception:
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
raise BaseException("error: cannot sign message")
|
raise Exception("error: cannot sign message")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def verify_message(self, address, signature, message):
|
def verify_message(self, address, signature, message):
|
||||||
|
@ -331,11 +331,11 @@ class EC_KEY(object):
|
||||||
order = G.order()
|
order = G.order()
|
||||||
# extract r,s from signature
|
# extract r,s from signature
|
||||||
sig = base64.b64decode(signature)
|
sig = base64.b64decode(signature)
|
||||||
if len(sig) != 65: raise BaseException("Wrong encoding")
|
if len(sig) != 65: raise Exception("Wrong encoding")
|
||||||
r,s = util.sigdecode_string(sig[1:], order)
|
r,s = util.sigdecode_string(sig[1:], order)
|
||||||
nV = ord(sig[0])
|
nV = ord(sig[0])
|
||||||
if nV < 27 or nV >= 35:
|
if nV < 27 or nV >= 35:
|
||||||
raise BaseException("Bad encoding")
|
raise Exception("Bad encoding")
|
||||||
if nV >= 31:
|
if nV >= 31:
|
||||||
compressed = True
|
compressed = True
|
||||||
nV -= 4
|
nV -= 4
|
||||||
|
@ -364,7 +364,7 @@ class EC_KEY(object):
|
||||||
# check that we get the original signing address
|
# check that we get the original signing address
|
||||||
addr = public_key_to_bc_address( encode_point(public_key, compressed) )
|
addr = public_key_to_bc_address( encode_point(public_key, compressed) )
|
||||||
if address != addr:
|
if address != addr:
|
||||||
raise BaseException("Bad signature")
|
raise Exception("Bad signature")
|
||||||
|
|
||||||
|
|
||||||
###################################### BIP32 ##############################
|
###################################### BIP32 ##############################
|
||||||
|
|
|
@ -119,7 +119,7 @@ class Blockchain(threading.Thread):
|
||||||
assert prev_hash == header.get('prev_block_hash')
|
assert prev_hash == header.get('prev_block_hash')
|
||||||
assert bits == header.get('bits')
|
assert bits == header.get('bits')
|
||||||
assert eval('0x'+_hash) < target
|
assert eval('0x'+_hash) < target
|
||||||
except:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
prev_header = header
|
prev_header = header
|
||||||
|
@ -176,7 +176,7 @@ class Blockchain(threading.Thread):
|
||||||
assert prev_hash == header.get('prev_block_hash')
|
assert prev_hash == header.get('prev_block_hash')
|
||||||
assert bits == header.get('bits')
|
assert bits == header.get('bits')
|
||||||
assert eval('0x'+_hash) < target
|
assert eval('0x'+_hash) < target
|
||||||
except:
|
except Exception:
|
||||||
# this can be caused by a reorg.
|
# this can be caused by a reorg.
|
||||||
print_error("verify header failed"+ repr(header))
|
print_error("verify header failed"+ repr(header))
|
||||||
verifier.undo_verifications()
|
verifier.undo_verifications()
|
||||||
|
@ -227,7 +227,7 @@ class Blockchain(threading.Thread):
|
||||||
print_error("downloading ", self.headers_url )
|
print_error("downloading ", self.headers_url )
|
||||||
urllib.urlretrieve(self.headers_url, filename)
|
urllib.urlretrieve(self.headers_url, filename)
|
||||||
print_error("done.")
|
print_error("done.")
|
||||||
except:
|
except Exception:
|
||||||
print_error( "download failed. creating file", filename )
|
print_error( "download failed. creating file", filename )
|
||||||
open(filename,'wb+').close()
|
open(filename,'wb+').close()
|
||||||
|
|
||||||
|
@ -411,7 +411,7 @@ class Blockchain(threading.Thread):
|
||||||
index = params[0]
|
index = params[0]
|
||||||
try:
|
try:
|
||||||
self.verify_chunk(index, result)
|
self.verify_chunk(index, result)
|
||||||
except:
|
except Exception:
|
||||||
print_error('Verify chunk failed!!')
|
print_error('Verify chunk failed!!')
|
||||||
return False
|
return False
|
||||||
requested_chunks.remove(index)
|
requested_chunks.remove(index)
|
||||||
|
|
|
@ -228,7 +228,7 @@ class Commands:
|
||||||
try:
|
try:
|
||||||
addr = self.wallet.import_key(sec,self.password)
|
addr = self.wallet.import_key(sec,self.password)
|
||||||
out = "Keypair imported: ", addr
|
out = "Keypair imported: ", addr
|
||||||
except BaseException as e:
|
except Exception as e:
|
||||||
out = "Error: Keypair import failed: " + str(e)
|
out = "Error: Keypair import failed: " + str(e)
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
@ -245,19 +245,19 @@ class Commands:
|
||||||
|
|
||||||
for to_address, amount in outputs:
|
for to_address, amount in outputs:
|
||||||
if not is_valid(to_address):
|
if not is_valid(to_address):
|
||||||
raise BaseException("Invalid Bitcoin address", to_address)
|
raise Exception("Invalid Bitcoin address", to_address)
|
||||||
|
|
||||||
if change_addr:
|
if change_addr:
|
||||||
if not is_valid(change_addr):
|
if not is_valid(change_addr):
|
||||||
raise BaseException("Invalid Bitcoin address", change_addr)
|
raise Exception("Invalid Bitcoin address", change_addr)
|
||||||
|
|
||||||
if domain is not None:
|
if domain is not None:
|
||||||
for addr in domain:
|
for addr in domain:
|
||||||
if not is_valid(addr):
|
if not is_valid(addr):
|
||||||
raise BaseException("invalid Bitcoin address", addr)
|
raise Exception("invalid Bitcoin address", addr)
|
||||||
|
|
||||||
if not self.wallet.is_mine(addr):
|
if not self.wallet.is_mine(addr):
|
||||||
raise BaseException("address not in wallet", addr)
|
raise Exception("address not in wallet", addr)
|
||||||
|
|
||||||
for k, v in self.wallet.labels.items():
|
for k, v in self.wallet.labels.items():
|
||||||
if change_addr and v == change_addr:
|
if change_addr and v == change_addr:
|
||||||
|
@ -306,7 +306,7 @@ class Commands:
|
||||||
tx_hash, conf, is_mine, value, fee, balance, timestamp = item
|
tx_hash, conf, is_mine, value, fee, balance, timestamp = item
|
||||||
try:
|
try:
|
||||||
time_str = datetime.datetime.fromtimestamp( timestamp).isoformat(' ')[:-3]
|
time_str = datetime.datetime.fromtimestamp( timestamp).isoformat(' ')[:-3]
|
||||||
except:
|
except Exception:
|
||||||
time_str = "----"
|
time_str = "----"
|
||||||
|
|
||||||
label, is_default_label = self.wallet.get_label(tx_hash)
|
label, is_default_label = self.wallet.get_label(tx_hash)
|
||||||
|
|
|
@ -49,7 +49,7 @@ def check_cert(host, cert):
|
||||||
def cert_has_expired(cert_path):
|
def cert_has_expired(cert_path):
|
||||||
try:
|
try:
|
||||||
import OpenSSL
|
import OpenSSL
|
||||||
except:
|
except Exception:
|
||||||
print_error("Warning: cannot import OpenSSL")
|
print_error("Warning: cannot import OpenSSL")
|
||||||
return False
|
return False
|
||||||
from OpenSSL import crypto as c
|
from OpenSSL import crypto as c
|
||||||
|
@ -112,12 +112,12 @@ class Interface(threading.Thread):
|
||||||
try:
|
try:
|
||||||
host, port, protocol = self.server.split(':')
|
host, port, protocol = self.server.split(':')
|
||||||
port = int(port)
|
port = int(port)
|
||||||
except:
|
except Exception:
|
||||||
self.server = None
|
self.server = None
|
||||||
return
|
return
|
||||||
|
|
||||||
if protocol not in 'ghst':
|
if protocol not in 'ghst':
|
||||||
raise BaseException('Unknown protocol: %s'%protocol)
|
raise Exception('Unknown protocol: %s'%protocol)
|
||||||
|
|
||||||
self.host = host
|
self.host = host
|
||||||
self.port = port
|
self.port = port
|
||||||
|
@ -196,7 +196,7 @@ class Interface(threading.Thread):
|
||||||
self.connection_msg = ('https' if self.use_ssl else 'http') + '://%s:%d'%( self.host, self.port )
|
self.connection_msg = ('https' if self.use_ssl else 'http') + '://%s:%d'%( self.host, self.port )
|
||||||
try:
|
try:
|
||||||
self.poll()
|
self.poll()
|
||||||
except:
|
except Exception:
|
||||||
print_error("http init session failed")
|
print_error("http init session failed")
|
||||||
self.is_connected = False
|
self.is_connected = False
|
||||||
return
|
return
|
||||||
|
@ -218,7 +218,7 @@ class Interface(threading.Thread):
|
||||||
break
|
break
|
||||||
except socket.error:
|
except socket.error:
|
||||||
break
|
break
|
||||||
except:
|
except Exception:
|
||||||
traceback.print_exc(file=sys.stdout)
|
traceback.print_exc(file=sys.stdout)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -265,7 +265,7 @@ class Interface(threading.Thread):
|
||||||
try:
|
try:
|
||||||
req = urllib2.Request(self.connection_msg, data_json, headers)
|
req = urllib2.Request(self.connection_msg, data_json, headers)
|
||||||
response_stream = urllib2.urlopen(req, timeout=DEFAULT_TIMEOUT)
|
response_stream = urllib2.urlopen(req, timeout=DEFAULT_TIMEOUT)
|
||||||
except:
|
except Exception:
|
||||||
return
|
return
|
||||||
|
|
||||||
for index, cookie in enumerate(cj):
|
for index, cookie in enumerate(cj):
|
||||||
|
@ -318,7 +318,7 @@ class Interface(threading.Thread):
|
||||||
s = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
|
s = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
|
||||||
try:
|
try:
|
||||||
s.connect((self.host, self.port))
|
s.connect((self.host, self.port))
|
||||||
except:
|
except Exception:
|
||||||
# print_error("failed to connect", self.host, self.port)
|
# print_error("failed to connect", self.host, self.port)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -346,7 +346,7 @@ class Interface(threading.Thread):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
s.connect(( self.host.encode('ascii'), int(self.port)))
|
s.connect(( self.host.encode('ascii'), int(self.port)))
|
||||||
except:
|
except Exception:
|
||||||
print_error("failed to connect", self.host, self.port)
|
print_error("failed to connect", self.host, self.port)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -370,7 +370,7 @@ class Interface(threading.Thread):
|
||||||
else:
|
else:
|
||||||
print_msg("wrong certificate", self.host)
|
print_msg("wrong certificate", self.host)
|
||||||
return
|
return
|
||||||
except:
|
except Exception:
|
||||||
print_error("wrap_socket failed", self.host)
|
print_error("wrap_socket failed", self.host)
|
||||||
traceback.print_exc(file=sys.stdout)
|
traceback.print_exc(file=sys.stdout)
|
||||||
return
|
return
|
||||||
|
@ -424,7 +424,7 @@ class Interface(threading.Thread):
|
||||||
c = json.loads(c)
|
c = json.loads(c)
|
||||||
self.queue_json_response(c)
|
self.queue_json_response(c)
|
||||||
|
|
||||||
except:
|
except Exception:
|
||||||
traceback.print_exc(file=sys.stdout)
|
traceback.print_exc(file=sys.stdout)
|
||||||
|
|
||||||
self.is_connected = False
|
self.is_connected = False
|
||||||
|
|
|
@ -385,7 +385,7 @@ class Network(threading.Thread):
|
||||||
if pruning_level == '': pruning_level = '0'
|
if pruning_level == '': pruning_level = '0'
|
||||||
try:
|
try:
|
||||||
is_recent = float(version)>=float(PROTOCOL_VERSION)
|
is_recent = float(version)>=float(PROTOCOL_VERSION)
|
||||||
except:
|
except Exception:
|
||||||
is_recent = False
|
is_recent = False
|
||||||
|
|
||||||
if out and is_recent:
|
if out and is_recent:
|
||||||
|
|
|
@ -24,7 +24,7 @@ def init_plugins(self):
|
||||||
for name, p in zip(plugin_names, plugin_modules):
|
for name, p in zip(plugin_names, plugin_modules):
|
||||||
try:
|
try:
|
||||||
plugins.append( p.Plugin(self, name) )
|
plugins.append( p.Plugin(self, name) )
|
||||||
except:
|
except Exception:
|
||||||
print_msg(_("Error: cannot initialize plugin"),p)
|
print_msg(_("Error: cannot initialize plugin"),p)
|
||||||
traceback.print_exc(file=sys.stdout)
|
traceback.print_exc(file=sys.stdout)
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ def run_hook(name, *args):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
f(*args)
|
f(*args)
|
||||||
except:
|
except Exception:
|
||||||
print_error("Plugin error")
|
print_error("Plugin error")
|
||||||
traceback.print_exc(file=sys.stdout)
|
traceback.print_exc(file=sys.stdout)
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ a SimpleConfig instance then reads the wallet file.
|
||||||
import ast
|
import ast
|
||||||
try:
|
try:
|
||||||
out = ast.literal_eval(out)
|
out = ast.literal_eval(out)
|
||||||
except:
|
except Exception:
|
||||||
print "type error for '%s': using default value"%key
|
print "type error for '%s': using default value"%key
|
||||||
out = default
|
out = default
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ a SimpleConfig instance then reads the wallet file.
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
d = ast.literal_eval( data ) #parse raw data from reading wallet file
|
d = ast.literal_eval( data ) #parse raw data from reading wallet file
|
||||||
except:
|
except Exception:
|
||||||
raise IOError("Cannot read config file.")
|
raise IOError("Cannot read config file.")
|
||||||
|
|
||||||
self.user_config = d
|
self.user_config = d
|
||||||
|
|
|
@ -298,7 +298,7 @@ def match_decoded(decoded, to_match):
|
||||||
def get_address_from_input_script(bytes):
|
def get_address_from_input_script(bytes):
|
||||||
try:
|
try:
|
||||||
decoded = [ x for x in script_GetOp(bytes) ]
|
decoded = [ x for x in script_GetOp(bytes) ]
|
||||||
except:
|
except Exception:
|
||||||
# coinbase transactions raise an exception
|
# coinbase transactions raise an exception
|
||||||
print_error("cannot find address in input script", bytes.encode('hex'))
|
print_error("cannot find address in input script", bytes.encode('hex'))
|
||||||
return [], [], "(None)"
|
return [], [], "(None)"
|
||||||
|
|
|
@ -49,7 +49,7 @@ def user_dir():
|
||||||
elif 'ANDROID_DATA' in os.environ:
|
elif 'ANDROID_DATA' in os.environ:
|
||||||
return "/sdcard/electrum/"
|
return "/sdcard/electrum/"
|
||||||
else:
|
else:
|
||||||
#raise BaseException("No home directory found in environment variables.")
|
#raise Exception("No home directory found in environment variables.")
|
||||||
return
|
return
|
||||||
|
|
||||||
def appdata_dir():
|
def appdata_dir():
|
||||||
|
|
|
@ -55,8 +55,8 @@ def pw_decode(s, password):
|
||||||
secret = Hash(password)
|
secret = Hash(password)
|
||||||
try:
|
try:
|
||||||
d = DecodeAES(secret, s)
|
d = DecodeAES(secret, s)
|
||||||
except:
|
except Exception:
|
||||||
raise BaseException('Invalid password')
|
raise Exception('Invalid password')
|
||||||
return d
|
return d
|
||||||
else:
|
else:
|
||||||
return s
|
return s
|
||||||
|
@ -117,7 +117,7 @@ class WalletStorage:
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
d = ast.literal_eval( data ) #parse raw data from reading wallet file
|
d = ast.literal_eval( data ) #parse raw data from reading wallet file
|
||||||
except:
|
except Exception:
|
||||||
raise IOError("Cannot read wallet file.")
|
raise IOError("Cannot read wallet file.")
|
||||||
|
|
||||||
self.data = d
|
self.data = d
|
||||||
|
@ -192,7 +192,7 @@ class Wallet:
|
||||||
for k,v in tx_list.items():
|
for k,v in tx_list.items():
|
||||||
try:
|
try:
|
||||||
tx = Transaction(v)
|
tx = Transaction(v)
|
||||||
except:
|
except Exception:
|
||||||
print_msg("Warning: Cannot deserialize transactions. skipping")
|
print_msg("Warning: Cannot deserialize transactions. skipping")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -256,11 +256,11 @@ class Wallet:
|
||||||
seed = self.get_seed(password)
|
seed = self.get_seed(password)
|
||||||
try:
|
try:
|
||||||
address = address_from_private_key(sec)
|
address = address_from_private_key(sec)
|
||||||
except:
|
except Exception:
|
||||||
raise BaseException('Invalid private key')
|
raise Exception('Invalid private key')
|
||||||
|
|
||||||
if self.is_mine(address):
|
if self.is_mine(address):
|
||||||
raise BaseException('Address already in wallet')
|
raise Exception('Address already in wallet')
|
||||||
|
|
||||||
# store the originally requested keypair into the imported keys table
|
# store the originally requested keypair into the imported keys table
|
||||||
self.imported_keys[address] = pw_encode(sec, password )
|
self.imported_keys[address] = pw_encode(sec, password )
|
||||||
|
@ -296,7 +296,7 @@ class Wallet:
|
||||||
import mnemonic
|
import mnemonic
|
||||||
|
|
||||||
if self.seed:
|
if self.seed:
|
||||||
raise BaseException("a seed exists")
|
raise Exception("a seed exists")
|
||||||
|
|
||||||
if not seed:
|
if not seed:
|
||||||
self.seed = random_seed(128)
|
self.seed = random_seed(128)
|
||||||
|
@ -314,7 +314,7 @@ class Wallet:
|
||||||
self.seed_version = 4
|
self.seed_version = 4
|
||||||
self.seed = str(seed)
|
self.seed = str(seed)
|
||||||
return
|
return
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
words = seed.split()
|
words = seed.split()
|
||||||
|
@ -324,7 +324,7 @@ class Wallet:
|
||||||
#try:
|
#try:
|
||||||
# mnemonic.mn_decode(words)
|
# mnemonic.mn_decode(words)
|
||||||
# uses_electrum_words = True
|
# uses_electrum_words = True
|
||||||
#except:
|
#except Exception:
|
||||||
# uses_electrum_words = False
|
# uses_electrum_words = False
|
||||||
#
|
#
|
||||||
#if uses_electrum_words and len(words) != 13:
|
#if uses_electrum_words and len(words) != 13:
|
||||||
|
@ -438,7 +438,7 @@ class Wallet:
|
||||||
elif account_type == '2of3':
|
elif account_type == '2of3':
|
||||||
return "m/3'/%d & m/4'/%d & m/5'/%d"%(i,i,i)
|
return "m/3'/%d & m/4'/%d & m/5'/%d"%(i,i,i)
|
||||||
else:
|
else:
|
||||||
raise BaseException('unknown account type')
|
raise Exception('unknown account type')
|
||||||
|
|
||||||
|
|
||||||
def num_accounts(self, account_type):
|
def num_accounts(self, account_type):
|
||||||
|
@ -608,8 +608,8 @@ class Wallet:
|
||||||
try:
|
try:
|
||||||
K, Kc = get_pubkeys_from_secret(master_k.decode('hex'))
|
K, Kc = get_pubkeys_from_secret(master_k.decode('hex'))
|
||||||
assert K.encode('hex') == master_K
|
assert K.encode('hex') == master_K
|
||||||
except:
|
except Exception:
|
||||||
raise BaseException("Invalid password")
|
raise Exception("Invalid password")
|
||||||
return master_k
|
return master_k
|
||||||
|
|
||||||
|
|
||||||
|
@ -628,7 +628,7 @@ class Wallet:
|
||||||
if v == address:
|
if v == address:
|
||||||
return k, (0,0)
|
return k, (0,0)
|
||||||
|
|
||||||
raise BaseException("Address not found", address)
|
raise Exception("Address not found", address)
|
||||||
|
|
||||||
|
|
||||||
def get_roots(self, account):
|
def get_roots(self, account):
|
||||||
|
@ -1110,7 +1110,7 @@ class Wallet:
|
||||||
if h == ['*']: continue
|
if h == ['*']: continue
|
||||||
for tx_hash, tx_height in h:
|
for tx_hash, tx_height in h:
|
||||||
tx = self.transactions.get(tx_hash)
|
tx = self.transactions.get(tx_hash)
|
||||||
if tx is None: raise BaseException("Wallet not synchronized")
|
if tx is None: raise Exception("Wallet not synchronized")
|
||||||
is_coinbase = tx.inputs[0].get('prevout_hash') == '0'*64
|
is_coinbase = tx.inputs[0].get('prevout_hash') == '0'*64
|
||||||
for output in tx.d.get('outputs'):
|
for output in tx.d.get('outputs'):
|
||||||
if output.get('address') != addr: continue
|
if output.get('address') != addr: continue
|
||||||
|
@ -1245,7 +1245,7 @@ class Wallet:
|
||||||
def receive_history_callback(self, addr, hist):
|
def receive_history_callback(self, addr, hist):
|
||||||
|
|
||||||
if not self.check_new_history(addr, hist):
|
if not self.check_new_history(addr, hist):
|
||||||
raise BaseException("error: received history for %s is not consistent with known transactions"%addr)
|
raise Exception("error: received history for %s is not consistent with known transactions"%addr)
|
||||||
|
|
||||||
with self.lock:
|
with self.lock:
|
||||||
self.history[addr] = hist
|
self.history[addr] = hist
|
||||||
|
@ -1754,12 +1754,12 @@ class WalletSynchronizer(threading.Thread):
|
||||||
hist.append( (tx_hash, item['height']) )
|
hist.append( (tx_hash, item['height']) )
|
||||||
|
|
||||||
if len(hist) != len(result):
|
if len(hist) != len(result):
|
||||||
raise BaseException("error: server sent history with non-unique txid", result)
|
raise Exception("error: server sent history with non-unique txid", result)
|
||||||
|
|
||||||
# check that the status corresponds to what was announced
|
# check that the status corresponds to what was announced
|
||||||
rs = requested_histories.pop(addr)
|
rs = requested_histories.pop(addr)
|
||||||
if self.wallet.get_status(hist) != rs:
|
if self.wallet.get_status(hist) != rs:
|
||||||
raise BaseException("error: status mismatch: %s"%addr)
|
raise Exception("error: status mismatch: %s"%addr)
|
||||||
|
|
||||||
# store received history
|
# store received history
|
||||||
self.wallet.receive_history_callback(addr, hist)
|
self.wallet.receive_history_callback(addr, hist)
|
||||||
|
|
|
@ -52,7 +52,7 @@ class Plugin(BasePlugin):
|
||||||
def get_alias(self, alias, interactive = False, show_message=None, question = None):
|
def get_alias(self, alias, interactive = False, show_message=None, question = None):
|
||||||
try:
|
try:
|
||||||
target, signing_address, auth_name = read_alias(self, alias)
|
target, signing_address, auth_name = read_alias(self, alias)
|
||||||
except BaseException, e:
|
except Exception as e:
|
||||||
# raise exception if verify fails (verify the chain)
|
# raise exception if verify fails (verify the chain)
|
||||||
if interactive:
|
if interactive:
|
||||||
show_message("Alias error: " + str(e))
|
show_message("Alias error: " + str(e))
|
||||||
|
|
|
@ -110,7 +110,7 @@ class Plugin(BasePlugin):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
tx = self.gui.main_window.wallet.mktx( [(to_address, amount)], None, fee)
|
tx = self.gui.main_window.wallet.mktx( [(to_address, amount)], None, fee)
|
||||||
except BaseException, e:
|
except Exception as e:
|
||||||
self.gui.main_window.show_message(str(e))
|
self.gui.main_window.show_message(str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -126,13 +126,13 @@ class Plugin(BasePlugin):
|
||||||
|
|
||||||
input_info = []
|
input_info = []
|
||||||
|
|
||||||
except BaseException, e:
|
except Exception as e:
|
||||||
self.gui.main_window.show_message(str(e))
|
self.gui.main_window.show_message(str(e))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
json_text = json.dumps(tx.as_dict()).replace(' ', '')
|
json_text = json.dumps(tx.as_dict()).replace(' ', '')
|
||||||
self.show_tx_qrcode(json_text, 'Unsigned Transaction')
|
self.show_tx_qrcode(json_text, 'Unsigned Transaction')
|
||||||
except BaseException, e:
|
except Exception as e:
|
||||||
self.gui.main_window.show_message(str(e))
|
self.gui.main_window.show_message(str(e))
|
||||||
|
|
||||||
def show_tx_qrcode(self, data, title):
|
def show_tx_qrcode(self, data, title):
|
||||||
|
@ -235,7 +235,7 @@ class Plugin(BasePlugin):
|
||||||
self.gui.main_window.wallet.signrawtransaction(tx, input_info, [], password)
|
self.gui.main_window.wallet.signrawtransaction(tx, input_info, [], password)
|
||||||
txtext = json.dumps(tx.as_dict()).replace(' ', '')
|
txtext = json.dumps(tx.as_dict()).replace(' ', '')
|
||||||
self.show_tx_qrcode(txtext, 'Signed Transaction')
|
self.show_tx_qrcode(txtext, 'Signed Transaction')
|
||||||
except BaseException, e:
|
except Exception as e:
|
||||||
self.gui.main_window.show_message(str(e))
|
self.gui.main_window.show_message(str(e))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue