bug: propergate LnurlErrorResponse in lnurl service and dont checks for redundant LnurlPayActionResponse (#3314)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from lnurl import (
|
||||
LnurlErrorResponse,
|
||||
LnurlPayActionResponse,
|
||||
LnurlPayResponse,
|
||||
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:
|
||||
res = await handle(lnurl, user_agent=settings.user_agent, timeout=10)
|
||||
if isinstance(res, LnurlErrorResponse):
|
||||
raise LnurlResponseException(res.reason)
|
||||
if not isinstance(res, LnurlPayResponse):
|
||||
raise LnurlResponseException(
|
||||
"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,
|
||||
timeout=10,
|
||||
)
|
||||
if not isinstance(res, LnurlPayActionResponse):
|
||||
raise LnurlResponseException(
|
||||
"Invalid LNURL pay response. Expected LnurlPayActionResponse."
|
||||
)
|
||||
if isinstance(res2, LnurlErrorResponse):
|
||||
raise LnurlResponseException(res2.reason)
|
||||
return res2.pr
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user