fix: enforce check minimum (#72)
Some checks failed
lint / lint (push) Has been cancelled

This commit is contained in:
dni ⚡ 2026-03-31 10:54:41 +02:00 committed by GitHub
commit 2e52400f52
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,6 +3,7 @@ from datetime import datetime
import httpx import httpx
import shortuuid import shortuuid
from bolt11 import decode as decode_bolt11
from fastapi import APIRouter, Request from fastapi import APIRouter, Request
from fastapi.responses import JSONResponse from fastapi.responses import JSONResponse
from lnbits.core.crud import update_payment from lnbits.core.crud import update_payment
@ -96,6 +97,16 @@ async def api_lnurl_callback(
if not link.enabled: if not link.enabled:
return LnurlErrorResponse(reason="Withdraw link is disabled.") return LnurlErrorResponse(reason="Withdraw link is disabled.")
bolt11 = decode_bolt11(pr)
if not bolt11.amount_msat:
return LnurlErrorResponse(reason="0 amount invoices are not supported.")
if (
link.min_withdrawable * 1000 > bolt11.amount_msat
or bolt11.amount_msat > link.max_withdrawable * 1000
):
return LnurlErrorResponse(reason="Amount not within limits.")
if link.is_spent: if link.is_spent:
return LnurlErrorResponse(reason="withdraw is spent.") return LnurlErrorResponse(reason="withdraw is spent.")