From b357391c4806acbc3d34a907b8f414601276b5fe Mon Sep 17 00:00:00 2001 From: MrNaif2018 <39452697+MrNaif2018@users.noreply.github.com> Date: Thu, 10 Nov 2022 20:48:00 +0300 Subject: [PATCH] Add `tx_hashes` to exported payment requests (#7936) * Add `tx_hashes` to payment requests * Apply patch * Fix for missing lnworker --- electrum/wallet.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/electrum/wallet.py b/electrum/wallet.py index 3c00968ed..9a8cbe2fa 100644 --- a/electrum/wallet.py +++ b/electrum/wallet.py @@ -2399,6 +2399,7 @@ class Abstract_Wallet(ABC, Logger, EventListener): 'status': status, 'status_str': status_str, 'request_id': key, + "tx_hashes": [] } if is_lightning: d['rhash'] = x.rhash @@ -2407,12 +2408,16 @@ class Abstract_Wallet(ABC, Logger, EventListener): if self.lnworker and status == PR_UNPAID: d['can_receive'] = self.lnworker.can_receive_invoice(x) if address: - paid, conf = self.is_onchain_invoice_paid(x) d['amount_sat'] = int(x.get_amount_sat()) d['address'] = address d['URI'] = self.get_request_URI(x) - if conf is not None: - d['confirmations'] = conf + # if request was paid onchain, add relevant fields + # note: addr is reused when getting paid on LN! so we check for that. + is_paid, conf, tx_hashes = self._is_onchain_invoice_paid(x) + if is_paid and (not self.lnworker or self.lnworker.get_invoice_status(x) != PR_PAID): + if conf is not None: + d['confirmations'] = conf + d['tx_hashes'] = tx_hashes run_hook('wallet_export_request', d, key) return d