mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-03 08:07:21 +00:00
The LNURL-pay endpoint is chosen by the recipient, so a hostile author decides what invoice their zappers are handed — including how much it charges. Nothing in the old flow ever read the invoice: `useZaps` passed the string straight to `sendPayment` or WebLN, so a user who approved 776 sats could be billed 5,000,000 with no indication anything was off. Decode the BOLT11 and require it to charge exactly the approved amount before any wallet is touched, and re-assert in `sendPayment` so no future caller can bypass the check. Amountless invoices are rejected outright. Resolving the endpoint moves off `nip57.getZapEndpoint`, which discards the `minSendable`/`maxSendable` bounds and the `metadata` string needed to confirm the invoice was issued for this request; `lib/lnurlPay.ts` keeps them and pins both the LNURL and its callback to HTTPS. Building the callback query with `URLSearchParams` also fixes comments containing `&`, `+` or `#` corrupting the request under `encodeURI`.