From f53e70ed98eb723479b4276c5b621b599fe570a0 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 6 Oct 2026 21:12:19 -0700 Subject: payments: lowercase payreq before looking up our own invoices An uppercase bolt11 for a coinos invoice missed the getInvoice lookup, so it was paid over lightning to our own node instead of internally. The listener then saw the sender's payment pointer for that bolt11 and skipped crediting the recipient. Normalize in POST /payments and nwc pay_invoice. Co-Authored-By: Claude Opus 5.5 --- lib/nwc.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/nwc.ts b/lib/nwc.ts index 5dba6e97..21bab0a7 100644 --- a/lib/nwc.ts +++ b/lib/nwc.ts @@ -634,7 +634,13 @@ const checkBudget = async (app, amount) => { const handle = (method, params, ev, app, user) => ({ async pay_invoice() { - const { invoice: pr, metadata, amount: reqAmountMsat } = params; + const { metadata, amount: reqAmountMsat } = params; + // Lowercase so getInvoice() finds our own invoices below (see create() + // in routes/payments.ts). + const pr = + typeof params.invoice === "string" + ? params.invoice.replace(/\s/g, "").toLowerCase() + : params.invoice; const { amount_msat, payee } = await ln.decode(pr); const { id } = await ln.getinfo(); // For an amountless bolt11, the invoice carries no amount — NIP-47 lets the -- cgit v1.2.3