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
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user