bug: propergate LnurlErrorResponse in lnurl service and dont checks for redundant LnurlPayActionResponse (#3314)
This commit is contained in:
parent
5e03707be5
commit
0ba81ec719
1 changed files with 5 additions and 4 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
from lnurl import (
|
from lnurl import (
|
||||||
|
LnurlErrorResponse,
|
||||||
LnurlPayActionResponse,
|
LnurlPayActionResponse,
|
||||||
LnurlPayResponse,
|
LnurlPayResponse,
|
||||||
LnurlResponseException,
|
LnurlResponseException,
|
||||||
|
|
@ -13,6 +14,8 @@ from lnbits.utils.exchange_rates import fiat_amount_as_satoshis
|
||||||
|
|
||||||
async def get_pr_from_lnurl(lnurl: str, amount_msat: int) -> str:
|
async def get_pr_from_lnurl(lnurl: str, amount_msat: int) -> str:
|
||||||
res = await handle(lnurl, user_agent=settings.user_agent, timeout=10)
|
res = await handle(lnurl, user_agent=settings.user_agent, timeout=10)
|
||||||
|
if isinstance(res, LnurlErrorResponse):
|
||||||
|
raise LnurlResponseException(res.reason)
|
||||||
if not isinstance(res, LnurlPayResponse):
|
if not isinstance(res, LnurlPayResponse):
|
||||||
raise LnurlResponseException(
|
raise LnurlResponseException(
|
||||||
"Invalid LNURL response. Expected LnurlPayResponse."
|
"Invalid LNURL response. Expected LnurlPayResponse."
|
||||||
|
|
@ -23,10 +26,8 @@ async def get_pr_from_lnurl(lnurl: str, amount_msat: int) -> str:
|
||||||
user_agent=settings.user_agent,
|
user_agent=settings.user_agent,
|
||||||
timeout=10,
|
timeout=10,
|
||||||
)
|
)
|
||||||
if not isinstance(res, LnurlPayActionResponse):
|
if isinstance(res2, LnurlErrorResponse):
|
||||||
raise LnurlResponseException(
|
raise LnurlResponseException(res2.reason)
|
||||||
"Invalid LNURL pay response. Expected LnurlPayActionResponse."
|
|
||||||
)
|
|
||||||
return res2.pr
|
return res2.pr
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue