diff --git a/lnbits/wallets/lntxbot.py b/lnbits/wallets/lntxbot.py index d5da1d0..afcac09 100644 --- a/lnbits/wallets/lntxbot.py +++ b/lnbits/wallets/lntxbot.py @@ -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")])