mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-31 17:31:36 +00:00
lnworker.get_invoice_status: test if invoice is expired
This commit is contained in:
parent
cac1e87286
commit
f9a2e7eeb4
2 changed files with 10 additions and 2 deletions
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue