You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: enforce invoice amount matches order amount on payouts (#831)
* feat: enforce invoice amount matches order amount on payouts
Adds defense-in-depth so the bot never pays an invoice whose amount
differs from the order amount, closing a path where a malicious
LNURL/Lightning Address endpoint could return an inflated invoice and
be paid more than was held from the seller.
- ln/pay_request.ts: payRequest refuses to pay when the invoice encodes
an amount that does not equal the expected amount, returning an
AMOUNT_MISMATCH error. payToBuyer treats AMOUNT_MISMATCH as a
structural failure: it alerts and does NOT schedule a retry.
- lnurl/lnurl-pay.ts: resolvLightningAddress parses the returned invoice
and rejects it (returns false) unless it encodes exactly the requested
msat amount, instead of trusting the server's min/maxSendable.
- jobs/pending_payments.ts: stop retrying a pending payment whose amount
no longer matches the order amount (marks it as non-retryable). Also
fixes early `return` -> `continue` so one skipped pending payment no
longer aborts processing of the rest of the queue.
- bot/scenes.ts: in both addInvoice wizards, bail out with the
unavailable_lightning_address notice when the LNURL resolution returns
no usable invoice, instead of dereferencing a missing pr.
- bot/commands.ts: correct the unavailable-address guard to also handle
a null/undefined resolution result (!laRes || !laRes.pr).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* refactor: remove redundant pending.save() in amount-mismatch branch
The finally block already persists pending on every iteration, so the
explicit save inside the amount-mismatch guard was a duplicate DB write.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments