mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
better error messages
This commit is contained in:
parent
6143625f41
commit
dceb4b04ea
3 changed files with 11 additions and 10 deletions
2
app.fil
2
app.fil
|
@ -1,2 +0,0 @@
|
||||||
lib/gui_qt.py
|
|
||||||
lib/gui.py
|
|
9
electrum
9
electrum
|
@ -215,11 +215,12 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
if cmd == 'import':
|
if cmd == 'import':
|
||||||
keypair = args[1]
|
keypair = args[1]
|
||||||
if wallet.import_key(keypair,password):
|
try:
|
||||||
print "keypair imported"
|
wallet.import_key(keypair,password)
|
||||||
else:
|
|
||||||
print "error"
|
|
||||||
wallet.save()
|
wallet.save()
|
||||||
|
print "keypair imported"
|
||||||
|
except BaseException, e:
|
||||||
|
print( 'Error:' + str(e) )
|
||||||
|
|
||||||
if cmd=='help':
|
if cmd=='help':
|
||||||
cmd2 = firstarg
|
cmd2 = firstarg
|
||||||
|
|
|
@ -326,17 +326,19 @@ class Wallet:
|
||||||
|
|
||||||
def import_key(self, keypair, password):
|
def import_key(self, keypair, password):
|
||||||
address, key = keypair.split(':')
|
address, key = keypair.split(':')
|
||||||
if not self.is_valid(address): return False
|
if not self.is_valid(address):
|
||||||
if address in self.all_addresses(): return False
|
raise BaseException('Invalid Bitcoin address')
|
||||||
|
if address in self.all_addresses():
|
||||||
|
raise BaseException('Address already in wallet')
|
||||||
b = ASecretToSecret( key )
|
b = ASecretToSecret( key )
|
||||||
if not b: return False
|
if not b: return False
|
||||||
secexp = int( b.encode('hex'), 16)
|
secexp = int( b.encode('hex'), 16)
|
||||||
private_key = ecdsa.SigningKey.from_secret_exponent( secexp, curve=SECP256k1 )
|
private_key = ecdsa.SigningKey.from_secret_exponent( secexp, curve=SECP256k1 )
|
||||||
# sanity check
|
# sanity check
|
||||||
public_key = private_key.get_verifying_key()
|
public_key = private_key.get_verifying_key()
|
||||||
if not address == public_key_to_bc_address( '04'.decode('hex') + public_key.to_string() ): return False
|
if not address == public_key_to_bc_address( '04'.decode('hex') + public_key.to_string() ):
|
||||||
|
raise BaseException('Address does not match private key')
|
||||||
self.imported_keys[address] = self.pw_encode( key, password )
|
self.imported_keys[address] = self.pw_encode( key, password )
|
||||||
return True
|
|
||||||
|
|
||||||
def new_seed(self, password):
|
def new_seed(self, password):
|
||||||
seed = "%032x"%ecdsa.util.randrange( pow(2,128) )
|
seed = "%032x"%ecdsa.util.randrange( pow(2,128) )
|
||||||
|
|
Loading…
Add table
Reference in a new issue