electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 22861b70ee20e98f0c6306055ee93801ecd56035
parent 6703521f5610df3f267c35289326b7f6f4c637bd
Author: SomberNight <somber.night@protonmail.com>
Date:   Thu, 27 Feb 2020 03:14:13 +0100

Qt tx dialog: make "export with xpubs" option always available

not just if one of the keystores is a coldcard

related: https://github.com/spesmilo/electrum/issues/5969#issuecomment-591441399

Diffstat:
Melectrum/gui/qt/transaction_dialog.py | 10++++++++++
Melectrum/plugins/coldcard/qt.py | 18------------------
2 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/electrum/gui/qt/transaction_dialog.py b/electrum/gui/qt/transaction_dialog.py @@ -151,6 +151,9 @@ class BaseTxDialog(QDialog, MessageBoxMixin): export_submenu = export_actions_menu.addMenu(_("For CoinJoin; strip privates")) self.add_export_actions_to_menu(export_submenu, gettx=self._gettx_for_coinjoin) self.psbt_only_widgets.append(export_submenu) + export_submenu = export_actions_menu.addMenu(_("For hardware device; include xpubs")) + self.add_export_actions_to_menu(export_submenu, gettx=self._gettx_for_hardware_device) + self.psbt_only_widgets.append(export_submenu) self.export_actions_button = QToolButton() self.export_actions_button.setText(_("Export")) @@ -258,6 +261,13 @@ class BaseTxDialog(QDialog, MessageBoxMixin): tx.prepare_for_export_for_coinjoin() return tx + def _gettx_for_hardware_device(self) -> PartialTransaction: + if not isinstance(self.tx, PartialTransaction): + raise Exception("Can only export partial transactions for hardware device.") + tx = copy.deepcopy(self.tx) + tx.add_info_from_wallet(self.wallet, include_xpubs_and_full_paths=True) + return tx + def copy_to_clipboard(self, *, tx: Transaction = None): if tx is None: tx = self.tx diff --git a/electrum/plugins/coldcard/qt.py b/electrum/plugins/coldcard/qt.py @@ -70,24 +70,6 @@ class Plugin(ColdcardPlugin, QtPluginBase): ColdcardPlugin.export_ms_wallet(wallet, f, basename) main_window.show_message(_("Wallet setup file exported successfully")) - @hook - def transaction_dialog(self, dia: TxDialog): - # if not a Coldcard wallet, hide feature - if not any(type(ks) == self.keystore_class for ks in dia.wallet.get_keystores()): - return - - def gettx_for_coldcard_export() -> PartialTransaction: - if not isinstance(dia.tx, PartialTransaction): - raise Exception("Can only export partial transactions for {}.".format(self.device)) - tx = copy.deepcopy(dia.tx) - tx.add_info_from_wallet(dia.wallet, include_xpubs_and_full_paths=True) - return tx - - # add a new "export" option - export_submenu = dia.export_actions_menu.addMenu(_("For {}; include xpubs").format(self.device)) - dia.add_export_actions_to_menu(export_submenu, gettx=gettx_for_coldcard_export) - dia.psbt_only_widgets.append(export_submenu) - def show_settings_dialog(self, window, keystore): # When they click on the icon for CC we come here. # - doesn't matter if device not connected, continue