Browse Source

Qt: let user edit tx label from tx_dialog

This allows users to edit labels from the utxo_dialog,
without having to search for the transaction in history.

Also, remove block hash from tx dialog: not very useful, and
available through block explorers. (the situation where this
could be useful is case of a chain fork, but in that case the
tx might be mined in both branches of the fork, and we would
want to know that).
master
ThomasV 3 years ago
parent
commit
660a8ebc7f
  1. 1
      electrum/gui/qt/main_window.py
  2. 29
      electrum/gui/qt/transaction_dialog.py
  3. 51
      electrum/gui/qt/utxo_dialog.py

1
electrum/gui/qt/main_window.py

@ -164,6 +164,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener):
computing_privkeys_signal = pyqtSignal()
show_privkeys_signal = pyqtSignal()
show_error_signal = pyqtSignal(str)
labels_changed_signal = pyqtSignal()
def __init__(self, gui_object: 'ElectrumGui', wallet: Abstract_Wallet):
QMainWindow.__init__(self)

29
electrum/gui/qt/transaction_dialog.py

@ -419,8 +419,20 @@ class TxDialog(QDialog, MessageBoxMixin):
vbox.addLayout(toolbar)
vbox.addWidget(QLabel(_("Transaction ID:")))
self.tx_hash_e = ShowQRLineEdit('', self.config, title='Transaction ID')
self.tx_hash_e = ShowQRLineEdit('', self.config, title=_('Transaction ID'))
vbox.addWidget(self.tx_hash_e)
self.tx_desc_label = QLabel(_("Description:"))
vbox.addWidget(self.tx_desc_label)
self.tx_desc = ButtonsLineEdit('')
def on_edited():
text = self.tx_desc.text()
if self.wallet.set_label(txid, text):
self.main_window.history_list.update()
self.main_window.utxo_list.update()
self.main_window.labels_changed_signal.emit()
self.tx_desc.editingFinished.connect(on_edited)
self.tx_desc.addCopyButton()
vbox.addWidget(self.tx_desc)
self.add_tx_stats(vbox)
@ -733,11 +745,13 @@ class TxDialog(QDialog, MessageBoxMixin):
# note: when not finalized, RBF and locktime changes do not trigger
# a make_tx, so the txid is unreliable, hence:
self.tx_hash_e.setText(_('Unknown'))
if not desc:
if not self.wallet.adb.get_transaction(txid):
self.tx_desc.hide()
self.tx_desc_label.hide()
else:
self.tx_desc.setText(_("Description") + ': ' + desc)
self.tx_desc.setText(desc)
self.tx_desc.show()
self.tx_desc_label.show()
self.status_label.setText(_('Status:') + ' ' + tx_details.status)
if tx_mined_status.timestamp:
@ -761,12 +775,9 @@ class TxDialog(QDialog, MessageBoxMixin):
self.rbf_label.setText(_('Replace by fee') + f": {not self.tx.is_final()}")
if tx_mined_status.header_hash:
self.block_hash_label.setText(_("Included in block: {}")
.format(tx_mined_status.header_hash))
self.block_height_label.setText(_("At block height: {}")
.format(tx_mined_status.height))
else:
self.block_hash_label.hide()
self.block_height_label.hide()
if amount is None and ln_amount is None:
amount_str = _("Transaction unrelated to your wallet")
@ -860,8 +871,6 @@ class TxDialog(QDialog, MessageBoxMixin):
# left column
vbox_left = QVBoxLayout()
self.tx_desc = TxDetailLabel(word_wrap=True)
vbox_left.addWidget(self.tx_desc)
self.status_label = TxDetailLabel()
vbox_left.addWidget(self.status_label)
self.date_label = TxDetailLabel()
@ -911,10 +920,6 @@ class TxDialog(QDialog, MessageBoxMixin):
vbox.addWidget(hbox_stats_w)
# below columns
self.block_hash_label = TxDetailLabel(word_wrap=True)
vbox.addWidget(self.block_hash_label)
# set visibility after parenting can be determined by Qt
self.rbf_label.setVisible(True)
self.locktime_final_label.setVisible(True)

51
electrum/gui/qt/utxo_dialog.py

@ -41,8 +41,6 @@ if TYPE_CHECKING:
from electrum.transaction import PartialTxInput
from .main_window import ElectrumWindow
# todo:
# - edit label in tx detail window
class UTXODialog(WindowModalDialog):
@ -54,11 +52,6 @@ class UTXODialog(WindowModalDialog):
self.wallet = window.wallet
self.utxo = utxo
txid = self.utxo.prevout.txid.hex()
parents = self.wallet.get_tx_parents(txid)
num_parents = len(parents)
parents_copy = copy.deepcopy(parents)
self.parents_list = QTextBrowserWithDefaultSize(800, 400)
self.parents_list.setOpenLinks(False) # disable automatic link opening
self.parents_list.anchorClicked.connect(self.open_tx) # send links to our handler
@ -70,6 +63,29 @@ class UTXODialog(WindowModalDialog):
self.txo_color_uncle = TxOutputColoring(
legend=_("Address reuse"), color=ColorScheme.RED, tooltip=_("Address reuse"))
vbox = QVBoxLayout()
vbox.addWidget(QLabel(_("Output point") + ": " + str(self.utxo.short_id)))
vbox.addWidget(QLabel(_("Amount") + ": " + self.main_window.format_amount_and_units(self.utxo.value_sats())))
self.stats_label = WWLabel()
vbox.addWidget(self.stats_label)
vbox.addWidget(self.parents_list)
legend_hbox = QHBoxLayout()
legend_hbox.setContentsMargins(0, 0, 0, 0)
legend_hbox.addStretch(2)
legend_hbox.addWidget(self.txo_color_parent.legend_label)
legend_hbox.addWidget(self.txo_color_uncle.legend_label)
vbox.addLayout(legend_hbox)
vbox.addLayout(Buttons(CloseButton(self)))
self.setLayout(vbox)
self.update()
self.main_window.labels_changed_signal.connect(self.update)
def update(self):
txid = self.utxo.prevout.txid.hex()
parents = self.wallet.get_tx_parents(txid)
num_parents = len(parents)
parents_copy = copy.deepcopy(parents)
cursor = self.parents_list.textCursor()
ext = QTextCharFormat()
@ -84,6 +100,10 @@ class UTXODialog(WindowModalDialog):
ASCII_PIPE = ''
ASCII_SPACE = ' '
# set cursor to top
cursor.setPosition(0)
self.parents_list.clear()
self.parents_list.setTextCursor(cursor)
self.num_reuse = 0
def print_ascii_tree(_txid, prefix, is_last, is_uncle):
if _txid not in parents:
@ -118,27 +138,12 @@ class UTXODialog(WindowModalDialog):
# recursively build the tree
print_ascii_tree(txid, '', False, False)
vbox = QVBoxLayout()
vbox.addWidget(QLabel(_("Output point") + ": " + str(self.utxo.short_id)))
vbox.addWidget(QLabel(_("Amount") + ": " + self.main_window.format_amount_and_units(self.utxo.value_sats())))
msg = _("This UTXO has {} parent transactions in your wallet.").format(num_parents)
if self.num_reuse:
msg += '\n' + _('This does not include transactions that are downstream of address reuse.')
vbox.addWidget(WWLabel(msg))
vbox.addWidget(self.parents_list)
legend_hbox = QHBoxLayout()
legend_hbox.setContentsMargins(0, 0, 0, 0)
legend_hbox.addStretch(2)
legend_hbox.addWidget(self.txo_color_parent.legend_label)
legend_hbox.addWidget(self.txo_color_uncle.legend_label)
vbox.addLayout(legend_hbox)
self.stats_label.setText(msg)
self.txo_color_parent.legend_label.setVisible(True)
self.txo_color_uncle.legend_label.setVisible(bool(self.num_reuse))
vbox.addLayout(Buttons(CloseButton(self)))
self.setLayout(vbox)
# set cursor to top
cursor.setPosition(0)
self.parents_list.setTextCursor(cursor)
def open_tx(self, txid):
if isinstance(txid, QUrl):

Loading…
Cancel
Save