From e40c5eb1918f41130022f73e3db8a3087837f02f Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 23 Nov 2026 09:21:29 -0700 Subject: names: LUD-21 verify for invoices our node mints A name's LNURL-pay callback now returns a `verify` URL when the invoice comes from our node (the recipient's wallet was not listening), and GET /lnurlp/verify/ answers {status, settled, preimage, pr} from CLN. The v3.coinos.io//receive pay page (coinosv3) polls it to say "Paid". An invoice the recipient's own wallet minted has no verify URL: only that wallet knows when it is paid. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01VMan6Upic5L6MMJzkTn8zg --- names/server.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'names/server.js') diff --git a/names/server.js b/names/server.js index 4d7a81c..683702c 100644 --- a/names/server.js +++ b/names/server.js @@ -1882,6 +1882,21 @@ Bun.serve({ }); } + // LUD-21 verify for an invoice our node minted for a name (see below) + const vm = url.pathname.match(/^\/lnurlp\/verify\/([0-9a-f]{64})$/); + if (vm && req.method === 'GET') { + if (!rateOk(ip, 120)) return json({ status: 'ERROR', reason: 'rate limited' }, 429); + const rec = (state.invoices || {})[vm[1]]; + if (!rec || !ln) return json({ status: 'ERROR', reason: 'Not found' }, 404); + try { + const inv = (await ln.call('listinvoices', { payment_hash: vm[1] })).invoices?.[0]; + if (!inv) return json({ status: 'ERROR', reason: 'Not found' }, 404); + const settled = inv.status === 'paid'; + return json({ status: 'OK', settled, preimage: settled ? inv.payment_preimage || null : null, pr: inv.bolt11 || rec.bolt11 }); + } catch { + return json({ status: 'ERROR', reason: 'could not check the invoice' }, 500); + } + } const cb = url.pathname.match(/^\/lnurlp\/([a-z0-9._-]{1,30})\/cb$/i); if (cb && req.method === 'GET') { const name = cb[1].toLowerCase(); @@ -1955,7 +1970,10 @@ Bun.serve({ } persist(); log(`lnurl ${key}: issued ${sat} sat (forwarding on settle)`); - return json({ pr: inv.bolt11, routes: [] }); + // LUD-21: our node knows when its own invoice is paid, so the payer + // (the v3.coinos.io//receive page) can be told. An invoice the + // recipient's wallet minted has no such URL: only that wallet knows. + return json({ pr: inv.bolt11, routes: [], verify: `${PUBLIC_BASE}/lnurlp/verify/${inv.payment_hash}` }); } catch (e) { log('lnurl invoice failed: ' + e.message); return json({ status: 'ERROR', reason: 'could not create an invoice' }, 500); -- cgit v1.2.3