fix: lntips payment lookup error handling (#1374)

This commit is contained in:
calle 2023-01-18 12:02:32 +01:00 committed by GitHub
parent 2b3b8cd85e
commit 9d3290cd9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -113,31 +113,37 @@ class LnTipsWallet(Wallet):
return PaymentResponse(True, checking_id, fee_msat, preimage, None)
async def get_invoice_status(self, checking_id: str) -> PaymentStatus:
async with httpx.AsyncClient() as client:
r = await client.post(
f"{self.endpoint}/api/v1/invoicestatus/{checking_id}",
headers=self.auth,
)
try:
async with httpx.AsyncClient() as client:
r = await client.post(
f"{self.endpoint}/api/v1/invoicestatus/{checking_id}",
headers=self.auth,
)
if r.is_error or len(r.text) == 0:
if r.is_error or len(r.text) == 0:
raise Exception
data = r.json()
return PaymentStatus(data["paid"])
except:
return PaymentStatus(None)
data = r.json()
return PaymentStatus(data["paid"])
async def get_payment_status(self, checking_id: str) -> PaymentStatus:
async with httpx.AsyncClient() as client:
r = await client.post(
url=f"{self.endpoint}/api/v1/paymentstatus/{checking_id}",
headers=self.auth,
)
try:
async with httpx.AsyncClient() as client:
r = await client.post(
url=f"{self.endpoint}/api/v1/paymentstatus/{checking_id}",
headers=self.auth,
)
if r.is_error:
if r.is_error:
raise Exception
data = r.json()
paid_to_status = {False: None, True: True}
return PaymentStatus(paid_to_status[data.get("paid")])
except:
return PaymentStatus(None)
data = r.json()
paid_to_status = {False: None, True: True}
return PaymentStatus(paid_to_status[data.get("paid")])
async def paid_invoices_stream(self) -> AsyncGenerator[str, None]:
last_connected = None