Skip to content

Commit 2e52400

Browse files
authored
fix: enforce check minimum (#72)
1 parent 74852e3 commit 2e52400

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

views_lnurl.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import httpx
55
import shortuuid
6+
from bolt11 import decode as decode_bolt11
67
from fastapi import APIRouter, Request
78
from fastapi.responses import JSONResponse
89
from lnbits.core.crud import update_payment
@@ -96,6 +97,16 @@ async def api_lnurl_callback(
9697
if not link.enabled:
9798
return LnurlErrorResponse(reason="Withdraw link is disabled.")
9899

100+
bolt11 = decode_bolt11(pr)
101+
if not bolt11.amount_msat:
102+
return LnurlErrorResponse(reason="0 amount invoices are not supported.")
103+
104+
if (
105+
link.min_withdrawable * 1000 > bolt11.amount_msat
106+
or bolt11.amount_msat > link.max_withdrawable * 1000
107+
):
108+
return LnurlErrorResponse(reason="Amount not within limits.")
109+
99110
if link.is_spent:
100111
return LnurlErrorResponse(reason="withdraw is spent.")
101112

0 commit comments

Comments
 (0)