electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 35dad3c10ef7e2de3aa86cdc467ac251db38f524
parent 9b3f165212c2f63d3a2e13b6d16b008e350d044a
Author: SomberNight <somber.night@protonmail.com>
Date:   Wed,  8 Jul 2020 01:19:23 +0200

qt history list: only offer "View Invoice" if still have invoice

fixes: #6343

Diffstat:
Melectrum/gui/qt/history_list.py | 5+++--
Melectrum/wallet.py | 8+++++---
2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/electrum/gui/qt/history_list.py b/electrum/gui/qt/history_list.py @@ -675,7 +675,7 @@ class HistoryList(MyTreeView, AcceptFileDragDrop): tx_URL = block_explorer_URL(self.config, 'tx', tx_hash) tx_details = self.wallet.get_tx_info(tx) is_unconfirmed = tx_details.tx_mined_status.height <= 0 - invoice_keys = self.wallet._get_relevant_invoice_keys_for_tx(tx) + invoice_keys = self.wallet.get_relevant_invoice_keys_for_tx(tx) menu = QMenu() if tx_details.can_remove: menu.addAction(_("Remove"), lambda: self.remove_local_tx(tx_hash)) @@ -701,7 +701,8 @@ class HistoryList(MyTreeView, AcceptFileDragDrop): menu.addAction(_("Child pays for parent"), lambda: self.parent.cpfp(tx, child_tx)) for key in invoice_keys: invoice = self.parent.wallet.get_invoice(key) - menu.addAction(_("View invoice"), lambda: self.parent.show_onchain_invoice(invoice)) + if invoice: + menu.addAction(_("View invoice"), lambda: self.parent.show_onchain_invoice(invoice)) if tx_URL: menu.addAction(_("View on block explorer"), lambda: webopen(tx_URL)) menu.exec_(self.viewport().mapToGlobal(position)) diff --git a/electrum/wallet.py b/electrum/wallet.py @@ -764,11 +764,13 @@ class Abstract_Wallet(AddressSynchronizer, ABC): def export_invoices(self, path): write_json_file(path, list(self.invoices.values())) - def _get_relevant_invoice_keys_for_tx(self, tx: Transaction) -> Set[str]: + def get_relevant_invoice_keys_for_tx(self, tx: Transaction) -> Set[str]: relevant_invoice_keys = set() for txout in tx.outputs(): for invoice_key in self._invoices_from_scriptpubkey_map.get(txout.scriptpubkey, set()): - relevant_invoice_keys.add(invoice_key) + # note: the invoice might have been deleted since, so check now: + if invoice_key in self.invoices: + relevant_invoice_keys.add(invoice_key) return relevant_invoice_keys def _prepare_onchain_invoice_paid_detection(self): @@ -809,7 +811,7 @@ class Abstract_Wallet(AddressSynchronizer, ABC): tx_hash = tx.txid() with self.transaction_lock: labels = [] - for invoice_key in self._get_relevant_invoice_keys_for_tx(tx): + for invoice_key in self.get_relevant_invoice_keys_for_tx(tx): invoice = self.invoices.get(invoice_key) if invoice is None: continue assert isinstance(invoice, OnchainInvoice)