LndResWallet: catch http errors (#2133)

This commit is contained in:
callebtc 2023-12-19 16:33:18 +01:00 committed by GitHub
parent abbcfbeb6a
commit 165d7499ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -139,14 +139,22 @@ class LndRestWallet(Wallet):
lnrpcFeeLimit = dict() lnrpcFeeLimit = dict()
lnrpcFeeLimit["fixed_msat"] = f"{fee_limit_msat}" lnrpcFeeLimit["fixed_msat"] = f"{fee_limit_msat}"
r = await self.client.post( try:
url="/v1/channels/transactions", r = await self.client.post(
json={"payment_request": bolt11, "fee_limit": lnrpcFeeLimit}, url="/v1/channels/transactions",
timeout=None, 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))
if r.is_error or r.json().get("payment_error"): data = r.json()
if data.get("payment_error"):
error_message = r.json().get("payment_error") or r.text 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) return PaymentResponse(False, None, None, None, error_message)
data = r.json() data = r.json()