Page MenuHomePhabricator

D14842.id.diff
No OneTemporary

D14842.id.diff

diff --git a/electrum/electrumabc_gui/qt/avalanche/delegation_editor.py b/electrum/electrumabc_gui/qt/avalanche/delegation_editor.py
--- a/electrum/electrumabc_gui/qt/avalanche/delegation_editor.py
+++ b/electrum/electrumabc_gui/qt/avalanche/delegation_editor.py
@@ -153,11 +153,14 @@
"a Bitcoin ABC node."
)
d = AuxiliaryKeysDialog(self.wallet, self._pwd, self, additional_info)
- d.exec_()
+ if not d.exec_() or not d.get_hex_public_key():
+ # Aux key dialog was cancelled or did not show any key (can happen
+ # if the password prompt is cancelled)
+ return
pubkey_hex = d.get_hex_public_key()
- self.suggested_delegated_key_and_index = (pubkey_hex, d.get_key_index())
self.pubkey_edit.setText(pubkey_hex)
+ self.suggested_delegated_key_and_index = (pubkey_hex, d.get_key_index())
def maybe_increment_aux_key_index(self):
"""Increment the index if the suggested key was used as a delegated key,
diff --git a/electrum/electrumabc_gui/qt/avalanche/util.py b/electrum/electrumabc_gui/qt/avalanche/util.py
--- a/electrum/electrumabc_gui/qt/avalanche/util.py
+++ b/electrum/electrumabc_gui/qt/avalanche/util.py
@@ -18,18 +18,18 @@
wallet: DeterministicWallet,
key_index: int = 0,
pwd: Optional[str] = None,
-) -> str:
+) -> Optional[str]:
"""Get a deterministic private key derived from a BIP44 path that is not used
by the wallet to generate addresses.
- Return it in WIF format, or return an empty string on failure (pwd dialog
+ Return it in WIF format, or return None on failure (pwd dialog
cancelled).
"""
# Use BIP44 change_index 2, which is not used by any application.
privkey_index = (2, key_index)
if wallet.has_password() and pwd is None:
- raise RuntimeError("Wallet password required")
+ return None
return wallet.export_private_key_for_index(privkey_index, pwd)
@@ -163,6 +163,13 @@
def set_keys_for_index(self, index: int):
wif_key = get_auxiliary_privkey(self.wallet, index, self.pwd)
+ if wif_key is None:
+ QtWidgets.QMessageBox.warning(
+ self,
+ "Failed to generate key",
+ "If this wallet is encrypted, you must provide the password to export a private key.",
+ )
+ return
self.key_widget.setPrivkey(wif_key)
def get_wif_private_key(self) -> str:

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 1, 11:24 (8 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5187235
Default Alt Text
D14842.id.diff (2 KB)

Event Timeline