mirror of
https://github.com/lnbits/lnbits.git
synced 2025-10-09 20:12:34 +02:00
fix: lntips payment lookup error handling (#1374)
This commit is contained in:
@@ -113,31 +113,37 @@ class LnTipsWallet(Wallet):
|
|||||||
return PaymentResponse(True, checking_id, fee_msat, preimage, None)
|
return PaymentResponse(True, checking_id, fee_msat, preimage, None)
|
||||||
|
|
||||||
async def get_invoice_status(self, checking_id: str) -> PaymentStatus:
|
async def get_invoice_status(self, checking_id: str) -> PaymentStatus:
|
||||||
async with httpx.AsyncClient() as client:
|
try:
|
||||||
r = await client.post(
|
async with httpx.AsyncClient() as client:
|
||||||
f"{self.endpoint}/api/v1/invoicestatus/{checking_id}",
|
r = await client.post(
|
||||||
headers=self.auth,
|
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)
|
return PaymentStatus(None)
|
||||||
|
|
||||||
data = r.json()
|
|
||||||
return PaymentStatus(data["paid"])
|
|
||||||
|
|
||||||
async def get_payment_status(self, checking_id: str) -> PaymentStatus:
|
async def get_payment_status(self, checking_id: str) -> PaymentStatus:
|
||||||
async with httpx.AsyncClient() as client:
|
try:
|
||||||
r = await client.post(
|
async with httpx.AsyncClient() as client:
|
||||||
url=f"{self.endpoint}/api/v1/paymentstatus/{checking_id}",
|
r = await client.post(
|
||||||
headers=self.auth,
|
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)
|
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]:
|
async def paid_invoices_stream(self) -> AsyncGenerator[str, None]:
|
||||||
last_connected = None
|
last_connected = None
|
||||||
|
Reference in New Issue
Block a user