Fixed error reporting for lntxbot source

This commit is contained in:
benarc
2021-11-12 10:16:15 +00:00
parent 267dea4f75
commit 78f7a3914f
2 changed files with 5 additions and 4 deletions

View File

@ -63,7 +63,7 @@ class LNbitsWallet(Wallet):
async with httpx.AsyncClient() as client: async with httpx.AsyncClient() as client:
r = await client.post( r = await client.post(
url=f"{self.endpoint}/api/v1/payments", headers=self.key, json=data url=f"{self.endpoint}/api/v1/payments", headers=self.key, json=data,
) )
ok, checking_id, payment_request, error_message = ( ok, checking_id, payment_request, error_message = (
not r.is_error, not r.is_error,
@ -85,7 +85,8 @@ class LNbitsWallet(Wallet):
r = await client.post( r = await client.post(
url=f"{self.endpoint}/api/v1/payments", url=f"{self.endpoint}/api/v1/payments",
headers=self.key, headers=self.key,
json={"out": True, "bolt11": bolt11}, json={"out": True, "bolt11": bolt11},
timeout=100,
) )
ok, checking_id, fee_msat, error_message = not r.is_error, None, 0, None ok, checking_id, fee_msat, error_message = not r.is_error, None, 0, None

View File

@ -80,10 +80,10 @@ class LntxbotWallet(Wallet):
f"{self.endpoint}/payinvoice", f"{self.endpoint}/payinvoice",
headers=self.auth, headers=self.auth,
json={"invoice": bolt11}, json={"invoice": bolt11},
timeout=40, timeout=100,
) )
if r.is_error: if "error" in r.json():
try: try:
data = r.json() data = r.json()
error_message = data["message"] error_message = data["message"]