diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py index 9c043e2d..90deccea 100644 --- a/gui/qt/main_window.py +++ b/gui/qt/main_window.py @@ -2208,10 +2208,9 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): badkeys = [] addrlist = [] for key in text: - addr = self.wallet.import_key(key, password) try: addr = self.wallet.import_key(key, password) - except Exception as e: + except BaseException as e: badkeys.append(key) continue if not addr: diff --git a/lib/commands.py b/lib/commands.py index 502f19f1..1508b1a3 100644 --- a/lib/commands.py +++ b/lib/commands.py @@ -368,7 +368,7 @@ class Commands: try: addr = self.wallet.import_key(privkey, self._password) out = "Keypair imported: " + addr - except Exception as e: + except BaseException as e: out = "Error: " + str(e) return out diff --git a/lib/keystore.py b/lib/keystore.py index 9ca367e0..e3f68853 100644 --- a/lib/keystore.py +++ b/lib/keystore.py @@ -115,7 +115,9 @@ class Imported_KeyStore(Software_KeyStore): try: pubkey = public_key_from_private_key(sec) 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 return pubkey