LndResWallet: catch http errors (#2133)
This commit is contained in:
parent
abbcfbeb6a
commit
165d7499ea
1 changed files with 14 additions and 6 deletions
|
|
@ -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()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue