feat: add generic lnurl error response handler (#2638)
* feat: add generic lnurl error response handler this is used multiple times in extensions to safeguard `views_lnurl.py` endpoint to not return a wrong lnurl error response. you use it by just setting following on your lnurl router/view ``` withdraw_ext_lnurl = APIRouter(prefix="/api/v1/lnurl") withdraw_ext_lnurl.route_class = LNURLErrorResponseHandler ```
This commit is contained in:
+1
-12
@@ -25,6 +25,7 @@ from lnbits.decorators import (
|
||||
check_user_extension_access,
|
||||
require_admin_key,
|
||||
)
|
||||
from lnbits.exceptions import InvoiceError, PaymentError
|
||||
from lnbits.helpers import url_for
|
||||
from lnbits.lnurl import LnurlErrorResponse
|
||||
from lnbits.lnurl import decode as decode_lnurl
|
||||
@@ -70,18 +71,6 @@ from .helpers import to_valid_user_id
|
||||
from .models import BalanceDelta, Payment, PaymentState, User, UserConfig, Wallet
|
||||
|
||||
|
||||
class PaymentError(Exception):
|
||||
def __init__(self, message: str, status: str = "pending"):
|
||||
self.message = message
|
||||
self.status = status
|
||||
|
||||
|
||||
class InvoiceError(Exception):
|
||||
def __init__(self, message: str, status: str = "pending"):
|
||||
self.message = message
|
||||
self.status = status
|
||||
|
||||
|
||||
async def calculate_fiat_amounts(
|
||||
amount: float,
|
||||
wallet_id: str,
|
||||
|
||||
Reference in New Issue
Block a user