mirror of
https://github.com/lnbits/lnbits.git
synced 2025-09-20 13:04:23 +02:00
Merge pull request #1155 from lnbits/fix/response_status_code_decode
Send BAD REQUEST response
This commit is contained in:
@@ -12,7 +12,7 @@ from urllib.parse import ParseResult, parse_qs, urlencode, urlparse, urlunparse
|
|||||||
import async_timeout
|
import async_timeout
|
||||||
import httpx
|
import httpx
|
||||||
import pyqrcode
|
import pyqrcode
|
||||||
from fastapi import Depends, Header, Query, Request
|
from fastapi import Depends, Header, Query, Request, Response
|
||||||
from fastapi.exceptions import HTTPException
|
from fastapi.exceptions import HTTPException
|
||||||
from fastapi.params import Body
|
from fastapi.params import Body
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
@@ -584,8 +584,8 @@ class DecodePayment(BaseModel):
|
|||||||
data: str
|
data: str
|
||||||
|
|
||||||
|
|
||||||
@core_app.post("/api/v1/payments/decode")
|
@core_app.post("/api/v1/payments/decode", status_code=HTTPStatus.OK)
|
||||||
async def api_payments_decode(data: DecodePayment):
|
async def api_payments_decode(data: DecodePayment, response: Response):
|
||||||
payment_str = data.data
|
payment_str = data.data
|
||||||
try:
|
try:
|
||||||
if payment_str[:5] == "LNURL":
|
if payment_str[:5] == "LNURL":
|
||||||
@@ -606,6 +606,7 @@ async def api_payments_decode(data: DecodePayment):
|
|||||||
"min_final_cltv_expiry": invoice.min_final_cltv_expiry,
|
"min_final_cltv_expiry": invoice.min_final_cltv_expiry,
|
||||||
}
|
}
|
||||||
except:
|
except:
|
||||||
|
response.status_code = HTTPStatus.BAD_REQUEST
|
||||||
return {"message": "Failed to decode"}
|
return {"message": "Failed to decode"}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user