From ac1999d50b83bd7a8d5068abebcb0e1756a63eeb Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 3 Dec 2026 21:34:11 -0700 Subject: names: a Lightning address callback with a second "?" still finds the name. "Payment failed: Unable to generate invoice from sh4rk@coinos.io (HTTP 500: Error processing request: HTTP error! status: 404)" from aqstr.com (Shark, relayed by Adam 2026-12-04). Some LNURL clients add the amount with "?" instead of "&", so our callback "cb?domain=coinos.io" arrived as "cb?domain=coinos.io?amount=21000": the domain read as "coinos.io?amount=21000", no name matched, and the payer got 404 "unknown address". On /lnurlp/ and /.well-known/lnurlp/ paths a literal "?" inside the query is now read as "&" (a real one in a value arrives encoded as %3F), and the first occurrence of a parameter wins. New lnurl-params.test.js passes. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01VMan6WoqaQDYdpWkatPCar --- names/lnurl-params.test.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 names/lnurl-params.test.js (limited to 'names/lnurl-params.test.js') diff --git a/names/lnurl-params.test.js b/names/lnurl-params.test.js new file mode 100644 index 0000000..c198853 --- /dev/null +++ b/names/lnurl-params.test.js @@ -0,0 +1,22 @@ +// bun test names/lnurl-params.test.js +import { test, expect } from 'bun:test'; +import { tolerantParams } from './lnurl-params.js'; + +const p = (q) => tolerantParams(new URL('https://x/lnurlp/a/cb' + q).search); + +test('a well-formed callback is read as is', () => { + const r = p('?domain=coinos.io&amount=21000&comment=hi%3F'); + expect(r.get('domain')).toBe('coinos.io'); + expect(r.get('amount')).toBe('21000'); + expect(r.get('comment')).toBe('hi?'); +}); +test('a second ? (amount appended with ? instead of &) still finds the name and amount', () => { + const r = p('?domain=coinos.io?amount=21000&nostr=%7B%7D'); + expect(r.get('domain')).toBe('coinos.io'); + expect(r.get('amount')).toBe('21000'); + expect(r.get('nostr')).toBe('{}'); +}); +test("parameters already in the URL aren't overridden", () => { + const r = p('?amount=5000&domain=coinos.io?amount=21000'); + expect(r.get('amount')).toBe('5000'); +}); -- cgit v1.2.3