From 68edd804f1696aa412da2357a469c013f0a3e92d Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 27 Jun 2026 15:01:06 -0700 Subject: Wire silent-payment receiving into the wallet (scan + balance + UI) wallet.js: scanSilentPayments() pulls the indexer's /scan range, matches outputs on-device, and verifies each is unspent via the chain backend; spUtxos + balance are tracked in their own bucket (one-time taproot keys), persisted in the cache. silentPaymentsAvailable()/spBalance() expose state. app.js: the Receive tab shows the reusable sp address (QR + copy), a 'Scan for silent payments' button, and the found amount; Settings gains a per-network SP indexer picker (under Data source) with custom/self-host support. sp-indexer.js: added /scan/{from} so a client fetches a whole range in one request instead of one fetch per block. Receiving verified end-to-end on regtest (scan finds the output, 49,999,800 sat confirmed). Spending SP outputs is the remaining piece. Co-Authored-By: Claude Opus 4.8 (1M context) --- tools/sp-indexer.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tools') diff --git a/tools/sp-indexer.js b/tools/sp-indexer.js index 12f76f7..d573ab9 100644 --- a/tools/sp-indexer.js +++ b/tools/sp-indexer.js @@ -109,6 +109,18 @@ Bun.serve({ const b = blocks.get(Number(m[1])); return json(b ? b.items.map((i) => i.tweak) : []); } + // All SP-eligible tx items from height `from` to the tip, in one response — + // each tagged with its height. Lets a client scan a range without one fetch + // per block. (Regtest-scale; mainnet would page or use BIP-158 filters.) + if ((m = p.match(/^\/scan\/(\d+)$/))) { + const from = Number(m[1]); + const items = []; + for (let h = from; h <= indexed; h++) { + const b = blocks.get(h); + if (b) for (const it of b.items) items.push({ height: h, ...it }); + } + return json({ tip: indexed, items }); + } return json({ error: 'not found' }, 404); }, }); -- cgit v1.2.3