aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-09-05 00:14:09 -0700
committerAdam Soltys <[email protected]>2026-09-05 00:14:09 -0700
commit6d0baaebb09602305bf1cad3110d59323cce3c1a (patch)
tree652dcd95157098b2ed970388ca8c3c2efde6568a
parent87c7ab1802c6fb9ee45b3bd608f683d9c0804eb3 (diff)
downloadcoinosv3-6d0baaebb09602305bf1cad3110d59323cce3c1a.tar.gz
coinosv3-6d0baaebb09602305bf1cad3110d59323cce3c1a.zip
Handle lightning:lnurl1… links properly. Two faults: (1) an intent often arrives BEFORE the paying feature is ready — ark connects lazily, so zaps' matchSendText declined and the raw URI fell through into the recipient field as dead text; the intent dispatcher now keeps re-offering the text to the feature chain for up to 20s and sweeps the leftover raw text out of the recipient when a feature claims it (the zap amount screen takes over). (2) When the fallback button did render, it read "⚡ Zap lightning:lnurl1dp68gurn8ghj7…<overflow>" — zapDisplay now names targets like a human: the address when there is one, a shortened bech32 otherwise, on both the send-form button and the amount screen
Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MGzU12QrAA4G6BYGzGVdXz
-rw-r--r--src/app.js17
-rw-r--r--src/features/zaps.js15
2 files changed, 29 insertions, 3 deletions
diff --git a/src/app.js b/src/app.js
index a0ef79a..3961876 100644
--- a/src/app.js
+++ b/src/app.js
@@ -4985,6 +4985,23 @@ if (INTENT_URI) {
ui.tab = 'send';
render();
handleScanned(INTENT_URI);
+ // A lightning:lnurl… (or ln-address) intent often lands BEFORE the
+ // feature that pays it is ready — ark connects lazily, so zaps'
+ // matchSendText declines and the raw URI falls through into the
+ // recipient field. Keep re-offering the text to the feature chain for a
+ // while; when a feature finally claims it (the zap amount screen takes
+ // over), sweep the leftover raw text out of the recipient.
+ let tries = 0;
+ const retry = setInterval(() => {
+ const s = ui.send;
+ const pending = s && s.recipients.length === 1 && s.recipients[0].address === INTENT_URI;
+ if (!pending || ++tries > 20) return clearInterval(retry);
+ if (featureMatchSend(INTENT_URI)) {
+ clearInterval(retry);
+ s.recipients[0].address = '';
+ render();
+ }
+ }, 1000);
}, 500);
}
diff --git a/src/features/zaps.js b/src/features/zaps.js
index 29f2aa8..03b80e1 100644
--- a/src/features/zaps.js
+++ b/src/features/zaps.js
@@ -43,6 +43,16 @@ export function zapsFeature(ctx) {
}
const shortCode = (s) => s.slice(0, 12) + '…' + s.slice(-6);
+ // What a zap target is CALLED on buttons and the amount screen: a human
+ // address when there is one, a shortened bech32 otherwise — a raw
+ // lightning:lnurl1… blob (an intent from the Android wrapper, an NFC tag)
+ // is unreadable and overflows the button it lands on.
+ const zapDisplay = (target, raw) => {
+ if (target.kind === 'npub') return shortNpub(npubOf(target.pk) || String(raw || '').trim());
+ if (target.address) return target.address;
+ const s = String(raw || '').trim().replace(/^lightning:/i, '');
+ return s.length > 24 ? shortCode(s) : s;
+ };
// Begin the amount screen for a decoded offer. Fetching the actual invoice
// (via the ASP's CLN) and verifying it happens on confirm.
@@ -314,8 +324,7 @@ export function zapsFeature(ctx) {
// text is complete and advances immediately; npub/lnurl carry a bech32
// checksum and only ever match when complete.
if (typed && target.kind === 'lnaddr') return false;
- const display = target.kind === 'npub' ? shortNpub(npubOf(target.pk) || text.trim()) : (target.address || text.trim());
- begin(target, display);
+ begin(target, zapDisplay(target, text));
return true;
},
// The typed-lightning-address affordance on the send form.
@@ -323,7 +332,7 @@ export function zapsFeature(ctx) {
if (!canPay() || !ui.send || ui.send.recipients.length !== 1) return null;
const target = parseZapTarget(a);
if (!target || target.kind === 'npub') return null;
- const display = target.address || String(a || '').trim();
+ const display = zapDisplay(target, a);
return h('button', {
type: 'button', class: 'btn-primary btn-block',
onClick: () => begin(target, display),