fix: handle all lnurl exceptions on lnurlscan endpoint (#3451)
This commit is contained in:
parent
ca8264b1f5
commit
2856803ca7
1 changed files with 7 additions and 6 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue