Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LndRestWallet: catch http errors #2133

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 14 additions & 6 deletions lnbits/wallets/lndrest.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,22 @@ async def pay_invoice(self, bolt11: str, fee_limit_msat: int) -> PaymentResponse
lnrpcFeeLimit = dict()
lnrpcFeeLimit["fixed_msat"] = f"{fee_limit_msat}"

r = await self.client.post(
url="/v1/channels/transactions",
json={"payment_request": bolt11, "fee_limit": lnrpcFeeLimit},
timeout=None,
)
try:
r = await self.client.post(
url="/v1/channels/transactions",
json={"payment_request": bolt11, "fee_limit": lnrpcFeeLimit},
timeout=None,
)
r.raise_for_status()
except Exception as exc:
logger.warning(f"LndRestWallet pay_invoice POST error: {exc}.")
return PaymentResponse(None, None, None, None, str(exc))

data = r.json()

if r.is_error or r.json().get("payment_error"):
if data.get("payment_error"):
error_message = r.json().get("payment_error") or r.text
logger.warning(f"LndRestWallet pay_invoice payment_error: {error_message}.")
return PaymentResponse(False, None, None, None, error_message)

data = r.json()
Expand Down