mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2025-01-19 05:33:47 +01:00
fix: don't call r.json()
until we know we have a response
This commit is contained in:
parent
0d517b884a
commit
4c739dbb90
@ -37,9 +37,13 @@ class LntxbotWallet(Wallet):
|
||||
def get_invoice_status(self, payment_hash: str, wait: bool = True) -> TxStatus:
|
||||
wait = "true" if wait else "false"
|
||||
r = post(url=f"{self.endpoint}/invoicestatus/{payment_hash}?wait={wait}", headers=self.auth_invoice)
|
||||
|
||||
if not r.ok:
|
||||
return TxStatus(r, None)
|
||||
|
||||
data = r.json()
|
||||
|
||||
if not r.ok or "error" in data:
|
||||
if "error" in data:
|
||||
return TxStatus(r, None)
|
||||
|
||||
if "preimage" not in data or not data["preimage"]:
|
||||
@ -49,9 +53,8 @@ class LntxbotWallet(Wallet):
|
||||
|
||||
def get_payment_status(self, payment_hash: str) -> TxStatus:
|
||||
r = post(url=f"{self.endpoint}/paymentstatus/{payment_hash}", headers=self.auth_invoice)
|
||||
data = r.json()
|
||||
|
||||
if not r.ok or "error" in data:
|
||||
if not r.ok or "error" in r.json():
|
||||
return TxStatus(r, None)
|
||||
|
||||
return TxStatus(r, {"complete": True, "failed": False, "unknown": None}[data.get("status", "unknown")])
|
||||
return TxStatus(r, {"complete": True, "failed": False, "unknown": None}[r.json().get("status", "unknown")])
|
||||
|
Loading…
Reference in New Issue
Block a user