try except for check payment status (#820)
This commit is contained in:
parent
9c19b61e4a
commit
d841690460
1 changed files with 10 additions and 4 deletions
|
|
@ -133,17 +133,23 @@ class CoreLightningWallet(Wallet):
|
||||||
)
|
)
|
||||||
|
|
||||||
async def get_invoice_status(self, checking_id: str) -> PaymentStatus:
|
async def get_invoice_status(self, checking_id: str) -> PaymentStatus:
|
||||||
|
try:
|
||||||
r = self.ln.listinvoices(payment_hash=checking_id)
|
r = self.ln.listinvoices(payment_hash=checking_id)
|
||||||
|
except:
|
||||||
|
return PaymentStatus(None)
|
||||||
if not r["invoices"]:
|
if not r["invoices"]:
|
||||||
return PaymentStatus(False)
|
return PaymentStatus(None)
|
||||||
if r["invoices"][0]["payment_hash"] == checking_id:
|
if r["invoices"][0]["payment_hash"] == checking_id:
|
||||||
return PaymentStatus(r["invoices"][0]["status"] == "paid")
|
return PaymentStatus(r["invoices"][0]["status"] == "paid")
|
||||||
raise KeyError("supplied an invalid checking_id")
|
raise KeyError("supplied an invalid checking_id")
|
||||||
|
|
||||||
async def get_payment_status(self, checking_id: str) -> PaymentStatus:
|
async def get_payment_status(self, checking_id: str) -> PaymentStatus:
|
||||||
|
try:
|
||||||
r = self.ln.call("listpays", {"payment_hash": checking_id})
|
r = self.ln.call("listpays", {"payment_hash": checking_id})
|
||||||
|
except:
|
||||||
|
return PaymentStatus(None)
|
||||||
if not r["pays"]:
|
if not r["pays"]:
|
||||||
return PaymentStatus(False)
|
return PaymentStatus(None)
|
||||||
if r["pays"][0]["payment_hash"] == checking_id:
|
if r["pays"][0]["payment_hash"] == checking_id:
|
||||||
status = r["pays"][0]["status"]
|
status = r["pays"][0]["status"]
|
||||||
if status == "complete":
|
if status == "complete":
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue