tpass both invoice and description to show_transaction - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 5c1340b7bd8bab9a5beb8e15b7b15ea26a334695 DIR parent 76c22f3e06fd1a7f4338223a4169daa6f043efb7 HTML Author: ThomasV <thomasv@electrum.org> Date: Thu, 24 Oct 2019 17:27:14 +0200 pass both invoice and description to show_transaction Diffstat: M electrum/gui/qt/main_window.py | 26 +++++++++++++------------- M electrum/gui/qt/transaction_dialog… | 9 +++++---- 2 files changed, 18 insertions(+), 17 deletions(-) --- DIR diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py t@@ -920,9 +920,9 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): d = address_dialog.AddressDialog(self, addr) d.exec_() - def show_transaction(self, tx, tx_desc = None): + def show_transaction(self, tx, *, invoice=None, tx_desc=None): '''tx_desc is set only for txs created in the Send tab''' - show_transaction(tx, self, tx_desc) + show_transaction(tx, self, invoice=invoice, desc=tx_desc) def create_receive_tab(self): # A 4-column grid layout. All the stretch is in the last column. t@@ -1739,9 +1739,8 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): invoice = self.read_invoice() if not invoice: return - if not preview: - self.wallet.save_invoice(invoice) - self.invoice_list.update() + self.wallet.save_invoice(invoice) + self.invoice_list.update() self.do_pay_invoice(invoice, preview) def do_pay_invoice(self, invoice, preview=False): t@@ -1791,7 +1790,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): return if preview: - self.show_transaction(tx, message) + self.show_transaction(tx, invoice=invoice) return if not self.network: t@@ -1829,9 +1828,9 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): if success: self.do_clear() if not tx.is_complete(): - self.show_transaction(tx) + self.show_transaction(tx, invoice=invoice) else: - self.broadcast_transaction(tx, message) + self.broadcast_transaction(tx, invoice=invoice) self.sign_tx_with_password(tx, sign_done, password) @protected t@@ -1856,7 +1855,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): msg = _('Signing transaction...') WaitingDialog(self, msg, task, on_success, on_failure) - def broadcast_transaction(self, tx, invoice=None): + def broadcast_transaction(self, tx, *, invoice=None, tx_desc=None): def broadcast_thread(): # non-GUI thread t@@ -1871,10 +1870,11 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): except BestEffortRequestFailed as e: return False, repr(e) # success + txid = tx.txid() + if tx_desc: + self.wallet.set_label(txid, tx_desc) if invoice: - key = invoice['id'] - txid = tx.txid() - self.wallet.set_paid(key, txid) + self.wallet.set_paid(invoice['id'], txid) self.wallet.set_label(txid, invoice['message']) if pr: self.payment_request = None t@@ -3255,7 +3255,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): return if is_final: new_tx.set_rbf(False) - self.show_transaction(new_tx, tx_label) + self.show_transaction(new_tx, tx_desc=tx_label) def save_transaction_into_wallet(self, tx): win = self.top_level_window() DIR diff --git a/electrum/gui/qt/transaction_dialog.py b/electrum/gui/qt/transaction_dialog.py t@@ -60,9 +60,9 @@ _logger = get_logger(__name__) dialogs = [] # Otherwise python randomly garbage collects the dialogs... -def show_transaction(tx, parent, desc=None, prompt_if_unsaved=False): +def show_transaction(tx, parent, *, invoice=None, desc=None, prompt_if_unsaved=False): try: - d = TxDialog(tx, parent, desc, prompt_if_unsaved) + d = TxDialog(tx, parent, invoice, desc, 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)) t@@ -73,7 +73,7 @@ def show_transaction(tx, parent, desc=None, prompt_if_unsaved=False): class TxDialog(QDialog, MessageBoxMixin): - def __init__(self, tx: Transaction, parent: 'ElectrumWindow', desc, prompt_if_unsaved): + def __init__(self, tx: Transaction, parent: 'ElectrumWindow', invoice, desc, prompt_if_unsaved): '''Transactions in the wallet will show their description. Pass desc to give a description for txs not yet in the wallet. ''' t@@ -92,6 +92,7 @@ class TxDialog(QDialog, MessageBoxMixin): self.prompt_if_unsaved = prompt_if_unsaved self.saved = False self.desc = desc + self.invoice = invoice # if the wallet can populate the inputs with more info, do it now. # as a result, e.g. we might learn an imported address tx is segwit, t@@ -161,7 +162,7 @@ class TxDialog(QDialog, MessageBoxMixin): def do_broadcast(self): self.main_window.push_top_level_window(self) try: - self.main_window.broadcast_transaction(self.tx, self.desc) + self.main_window.broadcast_transaction(self.tx, invoice=self.invoice, tx_desc=self.desc) finally: self.main_window.pop_top_level_window(self) self.saved = True