URI: 
       twallet: use height to determine request status (similar to outgoing invoices) - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 43614af2c4557726daa4576a381fe63f8387c542
   DIR parent 7fdedd5c4071e687bb5b3fa2b17a851e45947a97
  HTML Author: ThomasV <thomasv@electrum.org>
       Date:   Wed, 16 Dec 2020 12:25:41 +0100
       
       wallet: use height to determine request status (similar to outgoing invoices)
       
       Diffstat:
         M electrum/wallet.py                  |      20 ++++++++++++--------
       
       1 file changed, 12 insertions(+), 8 deletions(-)
       ---
   DIR diff --git a/electrum/wallet.py b/electrum/wallet.py
       t@@ -1737,13 +1737,19 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
            def delete_address(self, address: str) -> None:
                raise Exception("this wallet cannot delete addresses")
        
       -    def get_payment_status(self, address, amount):
       +    def get_onchain_request_status(self, r):
       +        address = r.get_address()
       +        amount = r.get_amount_sat()
                received, sent = self.get_addr_io(address)
                l = []
                for txo, x in received.items():
                    h, v, is_cb = x
                    txid, n = txo.split(':')
       -            conf = self.get_tx_height(txid).conf
       +            tx_height = self.get_tx_height(txid)
       +            height = tx_height.height
       +            if height > 0 and height <= r.height:
       +                continue
       +            conf = tx_height.conf
                    l.append((conf, v))
                vsum = 0
                for conf, v in reversed(sorted(l)):
       t@@ -1792,7 +1798,7 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
                    status = self.lnworker.get_payment_status(bfh(r.rhash)) if self.lnworker else PR_UNKNOWN
                else:
                    assert isinstance(r, OnchainInvoice)
       -            paid, conf = self.get_payment_status(r.get_address(), r.get_amount_sat())
       +            paid, conf = self.get_onchain_request_status(r)
                    status = PR_PAID if paid else PR_UNPAID
                return self.check_expired_status(r, status)
        
       t@@ -1832,11 +1838,9 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
                        d['can_receive'] = self.lnworker.can_receive_invoice(x)
                else:
                    assert isinstance(x, OnchainInvoice)
       -            amount_sat = x.get_amount_sat()
       -            addr = x.get_address()
       -            paid, conf = self.get_payment_status(addr, amount_sat)
       -            d['amount_sat'] = amount_sat
       -            d['address'] = addr
       +            paid, conf = self.get_onchain_request_status(x)
       +            d['amount_sat'] = x.get_amount_sat()
       +            d['address'] = x.get_address()
                    d['URI'] = self.get_request_URI(x)
                    if conf is not None:
                        d['confirmations'] = conf