Browse Source

qt tx dialog: remove "desc" field, just use wallet.get_label_for_txid

master
SomberNight 3 years ago
parent
commit
958191013b
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 2
      electrum/gui/qt/channel_details.py
  2. 9
      electrum/gui/qt/history_list.py
  3. 5
      electrum/gui/qt/main_window.py
  4. 10
      electrum/gui/qt/transaction_dialog.py
  5. 3
      electrum/gui/qt/utxo_dialog.py

2
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)

9
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))

5
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

10
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]

3
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)

Loading…
Cancel
Save