tlnworker.get_invoice_status: test if invoice is expired - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit f9a2e7eeb40a18d06acb2d83e7ab29f0c9a16246 DIR parent cac1e872861b8cb0ce9cd9e942e46c42dbe43ee0 HTML Author: ThomasV <thomasv@electrum.org> Date: Tue, 30 Jul 2019 13:28:01 +0200 lnworker.get_invoice_status: test if invoice is expired Diffstat: M electrum/lnaddr.py | 4 +++- M electrum/lnworker.py | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) --- DIR diff --git a/electrum/lnaddr.py b/electrum/lnaddr.py t@@ -272,7 +272,9 @@ class LnAddr(object): def get_expiry(self): return int(self.get_tag('x') or '3600') - + def is_expired(self): + now = time.time() + return now > self.get_expiry() + self.date def lndecode(a, verbose=False, expected_hrp=None): if expected_hrp is None: DIR diff --git a/electrum/lnworker.py b/electrum/lnworker.py t@@ -397,7 +397,13 @@ class LNWallet(LNWorker): if key not in self.invoices: return PR_UNKNOWN invoice, direction, is_paid = self.invoices[key] - return PR_PAID if is_paid else PR_UNPAID + lnaddr = lndecode(invoice, expected_hrp=constants.net.SEGWIT_HRP) + if is_paid: + return PR_PAID + elif lnaddr.is_expired(): + return PR_EXPIRED + else: + return PR_UNPAID def get_payments(self): # return one item per payment_hash