importprivkey: do not import the same key twice
This commit is contained in:
parent
2e9cfb9800
commit
5733a5d125
|
@ -2208,10 +2208,9 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
||||||
badkeys = []
|
badkeys = []
|
||||||
addrlist = []
|
addrlist = []
|
||||||
for key in text:
|
for key in text:
|
||||||
addr = self.wallet.import_key(key, password)
|
|
||||||
try:
|
try:
|
||||||
addr = self.wallet.import_key(key, password)
|
addr = self.wallet.import_key(key, password)
|
||||||
except Exception as e:
|
except BaseException as e:
|
||||||
badkeys.append(key)
|
badkeys.append(key)
|
||||||
continue
|
continue
|
||||||
if not addr:
|
if not addr:
|
||||||
|
|
|
@ -368,7 +368,7 @@ class Commands:
|
||||||
try:
|
try:
|
||||||
addr = self.wallet.import_key(privkey, self._password)
|
addr = self.wallet.import_key(privkey, self._password)
|
||||||
out = "Keypair imported: " + addr
|
out = "Keypair imported: " + addr
|
||||||
except Exception as e:
|
except BaseException as e:
|
||||||
out = "Error: " + str(e)
|
out = "Error: " + str(e)
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,9 @@ class Imported_KeyStore(Software_KeyStore):
|
||||||
try:
|
try:
|
||||||
pubkey = public_key_from_private_key(sec)
|
pubkey = public_key_from_private_key(sec)
|
||||||
except Exception:
|
except Exception:
|
||||||
raise Exception('Invalid private key')
|
raise BaseException('Invalid private key')
|
||||||
|
if pubkey in self.keypairs:
|
||||||
|
raise BaseException('Private key already in keystore')
|
||||||
self.keypairs[pubkey] = sec
|
self.keypairs[pubkey] = sec
|
||||||
return pubkey
|
return pubkey
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue