try except for check payment status (#820)

This commit is contained in:
calle 2022-08-01 16:51:19 +02:00 committed by GitHub
parent 9c19b61e4a
commit d841690460
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -133,17 +133,23 @@ class CoreLightningWallet(Wallet):
)
async def get_invoice_status(self, checking_id: str) -> PaymentStatus:
try:
r = self.ln.listinvoices(payment_hash=checking_id)
except:
return PaymentStatus(None)
if not r["invoices"]:
return PaymentStatus(False)
return PaymentStatus(None)
if r["invoices"][0]["payment_hash"] == checking_id:
return PaymentStatus(r["invoices"][0]["status"] == "paid")
raise KeyError("supplied an invalid checking_id")
async def get_payment_status(self, checking_id: str) -> PaymentStatus:
try:
r = self.ln.call("listpays", {"payment_hash": checking_id})
except:
return PaymentStatus(None)
if not r["pays"]:
return PaymentStatus(False)
return PaymentStatus(None)
if r["pays"][0]["payment_hash"] == checking_id:
status = r["pays"][0]["status"]
if status == "complete":