qt history list: only offer "View Invoice" if still have invoice
fixes: #6343
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user