fix: handle all lnurl exceptions on lnurlscan endpoint (#3451)
This commit is contained in:
@@ -6,16 +6,17 @@ from fastapi import (
|
|||||||
Depends,
|
Depends,
|
||||||
HTTPException,
|
HTTPException,
|
||||||
)
|
)
|
||||||
from lnurl import LnurlResponseException
|
from lnurl import (
|
||||||
from lnurl import execute_login as lnurlauth
|
|
||||||
from lnurl import handle as lnurl_handle
|
|
||||||
from lnurl.models import (
|
|
||||||
LnurlAuthResponse,
|
LnurlAuthResponse,
|
||||||
LnurlErrorResponse,
|
LnurlErrorResponse,
|
||||||
|
LnurlException,
|
||||||
LnurlPayResponse,
|
LnurlPayResponse,
|
||||||
LnurlResponseModel,
|
LnurlResponseException,
|
||||||
LnurlWithdrawResponse,
|
LnurlWithdrawResponse,
|
||||||
)
|
)
|
||||||
|
from lnurl import execute_login as lnurlauth
|
||||||
|
from lnurl import handle as lnurl_handle
|
||||||
|
from lnurl.models import LnurlResponseModel
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
from lnbits.core.models import Payment
|
from lnbits.core.models import Payment
|
||||||
@@ -38,7 +39,7 @@ async def _handle(lnurl: str) -> LnurlResponseModel:
|
|||||||
res = await lnurl_handle(lnurl, user_agent=settings.user_agent, timeout=5)
|
res = await lnurl_handle(lnurl, user_agent=settings.user_agent, timeout=5)
|
||||||
if isinstance(res, LnurlErrorResponse):
|
if isinstance(res, LnurlErrorResponse):
|
||||||
raise HTTPException(status_code=HTTPStatus.BAD_REQUEST, detail=res.reason)
|
raise HTTPException(status_code=HTTPStatus.BAD_REQUEST, detail=res.reason)
|
||||||
except LnurlResponseException as exc:
|
except LnurlException as exc:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=HTTPStatus.BAD_REQUEST, detail=str(exc)
|
status_code=HTTPStatus.BAD_REQUEST, detail=str(exc)
|
||||||
) from exc
|
) from exc
|
||||||
|
|||||||
Reference in New Issue
Block a user