diff --git a/electrum/gui/qt/channel_details.py b/electrum/gui/qt/channel_details.py index 65d8a3f0f..970ce9ed9 100644 --- a/electrum/gui/qt/channel_details.py +++ b/electrum/gui/qt/channel_details.py @@ -172,7 +172,7 @@ class ChannelDetailsDialog(QtWidgets.QDialog, MessageBoxMixin, QtEventListener): if not tx: self.show_error(_("Transaction not found.")) return - self.window.show_transaction(tx, tx_desc=_('Transaction')) + self.window.show_transaction(tx) def get_common_form(self, chan): form = QtWidgets.QFormLayout(None) diff --git a/electrum/gui/qt/history_list.py b/electrum/gui/qt/history_list.py index 66476723f..59c7dc3ef 100644 --- a/electrum/gui/qt/history_list.py +++ b/electrum/gui/qt/history_list.py @@ -676,12 +676,7 @@ class HistoryList(MyTreeView, AcceptFileDragDrop): tx = self.wallet.adb.get_transaction(tx_hash) if not tx: return - self.show_transaction(tx_item, tx) - - def show_transaction(self, tx_item, tx): - tx_hash = tx_item['txid'] - label = self.wallet.get_label_for_txid(tx_hash) or None # prefer 'None' if not defined (force tx dialog to hide Description field if missing) - self.parent.show_transaction(tx, tx_desc=label) + self.parent.show_transaction(tx) def add_copy_menu(self, menu, idx): cc = menu.addMenu(_("Copy")) @@ -735,7 +730,7 @@ class HistoryList(MyTreeView, AcceptFileDragDrop): # TODO use siblingAtColumn when min Qt version is >=5.11 persistent = QPersistentModelIndex(org_idx.sibling(org_idx.row(), c)) menu_edit.addAction(_("{}").format(label), lambda p=persistent: self.edit(QModelIndex(p))) - menu.addAction(_("View Transaction"), lambda: self.show_transaction(tx_item, tx)) + menu.addAction(_("View Transaction"), lambda: self.parent.show_transaction(tx)) channel_id = tx_item.get('channel_id') if channel_id and self.wallet.lnworker and (chan := self.wallet.lnworker.get_channel_by_id(bytes.fromhex(channel_id))): menu.addAction(_("View Channel"), lambda: self.parent.show_channel_details(chan)) diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py index 18590f936..f71d09f82 100644 --- a/electrum/gui/qt/main_window.py +++ b/electrum/gui/qt/main_window.py @@ -1074,9 +1074,8 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener): from .channel_details import ChannelDetailsDialog ChannelDetailsDialog(self, chan).show() - def show_transaction(self, tx, *, tx_desc=None): - '''tx_desc is set only for txs created in the Send tab''' - show_transaction(tx, parent=self, desc=tx_desc) + def show_transaction(self, tx: Transaction): + show_transaction(tx, parent=self) def show_lightning_transaction(self, tx_item): from .lightning_tx_dialog import LightningTxDialog diff --git a/electrum/gui/qt/transaction_dialog.py b/electrum/gui/qt/transaction_dialog.py index 11303fb9b..0c6ee566b 100644 --- a/electrum/gui/qt/transaction_dialog.py +++ b/electrum/gui/qt/transaction_dialog.py @@ -346,9 +346,9 @@ class TxInOutWidget(QWidget): -def show_transaction(tx: Transaction, *, parent: 'ElectrumWindow', desc=None, prompt_if_unsaved=False): +def show_transaction(tx: Transaction, *, parent: 'ElectrumWindow', prompt_if_unsaved=False): try: - d = TxDialog(tx, parent=parent, desc=desc, prompt_if_unsaved=prompt_if_unsaved) + d = TxDialog(tx, parent=parent, prompt_if_unsaved=prompt_if_unsaved) except SerializationError as e: _logger.exception('unable to deserialize the transaction') parent.show_critical(_("Electrum was unable to deserialize the transaction:") + "\n" + str(e)) @@ -360,7 +360,7 @@ def show_transaction(tx: Transaction, *, parent: 'ElectrumWindow', desc=None, pr class TxDialog(QDialog, MessageBoxMixin): - def __init__(self, tx: Transaction, *, parent: 'ElectrumWindow', desc, prompt_if_unsaved, external_keypairs=None): + def __init__(self, tx: Transaction, *, parent: 'ElectrumWindow', prompt_if_unsaved, external_keypairs=None): '''Transactions in the wallet will show their description. Pass desc to give a description for txs not yet in the wallet. ''' @@ -373,7 +373,9 @@ class TxDialog(QDialog, MessageBoxMixin): self.wallet = parent.wallet self.prompt_if_unsaved = prompt_if_unsaved self.saved = False - self.desc = desc + self.desc = None + if txid := tx.txid(): + self.desc = self.wallet.get_label_for_txid(txid) or None self.setMinimumWidth(640) self.psbt_only_widgets = [] # type: List[QWidget] diff --git a/electrum/gui/qt/utxo_dialog.py b/electrum/gui/qt/utxo_dialog.py index 3979d075c..8a37d2cd5 100644 --- a/electrum/gui/qt/utxo_dialog.py +++ b/electrum/gui/qt/utxo_dialog.py @@ -130,5 +130,4 @@ class UTXODialog(WindowModalDialog): tx = self.wallet.adb.get_transaction(txid) if not tx: return - label = self.wallet.get_label_for_txid(txid) - self.main_window.show_transaction(tx, tx_desc=label) + self.main_window.show_transaction(tx)