|
|
|
|
@ -65,7 +65,7 @@ from .util import (MessageBoxMixin, read_QIcon, Buttons, icon_path,
|
|
|
|
|
BlockingWaitingDialog, getSaveFileName, ColorSchemeItem, |
|
|
|
|
get_iconname_qrcode, VLine) |
|
|
|
|
from .rate_limiter import rate_limited |
|
|
|
|
from .my_treeview import create_toolbar_with_menu |
|
|
|
|
from .my_treeview import create_toolbar_with_menu, QMenuWithConfig |
|
|
|
|
|
|
|
|
|
if TYPE_CHECKING: |
|
|
|
|
from .main_window import ElectrumWindow |
|
|
|
|
@ -456,7 +456,7 @@ class TxDialog(QDialog, MessageBoxMixin):
|
|
|
|
|
self.desc = self.wallet.get_label_for_txid(txid) or None |
|
|
|
|
self.setMinimumWidth(640) |
|
|
|
|
|
|
|
|
|
self.psbt_only_widgets = [] # type: List[QWidget] |
|
|
|
|
self.psbt_only_widgets = [] # type: List[Union[QWidget, QAction]] |
|
|
|
|
|
|
|
|
|
vbox = QVBoxLayout() |
|
|
|
|
self.setLayout(vbox) |
|
|
|
|
@ -502,15 +502,15 @@ class TxDialog(QDialog, MessageBoxMixin):
|
|
|
|
|
b.clicked.connect(self.close) |
|
|
|
|
b.setDefault(True) |
|
|
|
|
|
|
|
|
|
self.export_actions_menu = export_actions_menu = QMenu() |
|
|
|
|
self.export_actions_menu = export_actions_menu = QMenuWithConfig(config=self.config) |
|
|
|
|
self.add_export_actions_to_menu(export_actions_menu) |
|
|
|
|
export_actions_menu.addSeparator() |
|
|
|
|
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) |
|
|
|
|
export_option = export_actions_menu.addConfig( |
|
|
|
|
self.config.cv.GUI_QT_TX_DIALOG_EXPORT_STRIP_SENSITIVE_METADATA) |
|
|
|
|
self.psbt_only_widgets.append(export_option) |
|
|
|
|
export_option = export_actions_menu.addConfig( |
|
|
|
|
self.config.cv.GUI_QT_TX_DIALOG_EXPORT_INCLUDE_GLOBAL_XPUBS) |
|
|
|
|
self.psbt_only_widgets.append(export_option) |
|
|
|
|
|
|
|
|
|
self.export_actions_button = QToolButton() |
|
|
|
|
self.export_actions_button.setText(_("Share")) |
|
|
|
|
@ -604,9 +604,17 @@ class TxDialog(QDialog, MessageBoxMixin):
|
|
|
|
|
# Override escape-key to close normally (and invoke closeEvent) |
|
|
|
|
self.close() |
|
|
|
|
|
|
|
|
|
def add_export_actions_to_menu(self, menu: QMenu, *, gettx: Callable[[], Transaction] = None) -> None: |
|
|
|
|
if gettx is None: |
|
|
|
|
gettx = lambda: None |
|
|
|
|
def add_export_actions_to_menu(self, menu: QMenu) -> None: |
|
|
|
|
def gettx() -> Transaction: |
|
|
|
|
if not isinstance(self.tx, PartialTransaction): |
|
|
|
|
return self.tx |
|
|
|
|
tx = copy.deepcopy(self.tx) |
|
|
|
|
if self.config.GUI_QT_TX_DIALOG_EXPORT_INCLUDE_GLOBAL_XPUBS: |
|
|
|
|
Network.run_from_another_thread( |
|
|
|
|
tx.prepare_for_export_for_hardware_device(self.wallet)) |
|
|
|
|
if self.config.GUI_QT_TX_DIALOG_EXPORT_STRIP_SENSITIVE_METADATA: |
|
|
|
|
tx.prepare_for_export_for_coinjoin() |
|
|
|
|
return tx |
|
|
|
|
|
|
|
|
|
action = QAction(_("Copy to clipboard"), self) |
|
|
|
|
action.triggered.connect(lambda: self.copy_to_clipboard(tx=gettx())) |
|
|
|
|
@ -620,21 +628,6 @@ class TxDialog(QDialog, MessageBoxMixin):
|
|
|
|
|
action.triggered.connect(lambda: self.export_to_file(tx=gettx())) |
|
|
|
|
menu.addAction(action) |
|
|
|
|
|
|
|
|
|
def _gettx_for_coinjoin(self) -> PartialTransaction: |
|
|
|
|
if not isinstance(self.tx, PartialTransaction): |
|
|
|
|
raise Exception("Can only export partial transactions for coinjoins.") |
|
|
|
|
tx = copy.deepcopy(self.tx) |
|
|
|
|
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) |
|
|
|
|
Network.run_from_another_thread( |
|
|
|
|
tx.prepare_for_export_for_hardware_device(self.wallet)) |
|
|
|
|
return tx |
|
|
|
|
|
|
|
|
|
def copy_to_clipboard(self, *, tx: Transaction = None): |
|
|
|
|
if tx is None: |
|
|
|
|
tx = self.tx |
|
|
|
|
|