fix: lntips payment lookup error handling (#1374)
This commit is contained in:
parent
2b3b8cd85e
commit
9d3290cd9a
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user