From f477756f5f04e65c68d2e51100c660c13505d1f2 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sun, 14 Jun 2026 23:31:56 -0700 Subject: Reduce gap limit to 5; clarify receive-address note Since the wallet only ever exposes one unused receive address at a time, used addresses stay contiguous (gap never exceeds 1), so a gap limit of 5 is a safe margin and cuts a scan from ~40 to ~10 requests. Also reword the receive note: the address advances automatically (via the realtime WebSocket) when paid, so drop the confusing "scan again". Co-Authored-By: Claude Opus 4.8 (1M context) --- src/app.js | 2 +- src/wallet.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/app.js b/src/app.js index 7f15c96..378eddd 100644 --- a/src/app.js +++ b/src/app.js @@ -506,7 +506,7 @@ function receiveTab() { ), h('div', { class: 'path' }, `m/84'/${coin}'/0'/0/${fresh.index}`), h('p', { class: 'small muted center', style: 'margin:0' }, - 'A fresh address is shown for better privacy. After a payment arrives, scan again to advance to a new one.'), + 'A fresh address is shown for better privacy. When it receives a payment, a new one appears automatically.'), addressBook() ); } diff --git a/src/wallet.js b/src/wallet.js index 04f303a..21fbcf2 100644 --- a/src/wallet.js +++ b/src/wallet.js @@ -17,7 +17,13 @@ import { p2wpkh } from '@scure/btc-signer/payment'; import { Api, pool } from './api.js'; -const GAP_LIMIT = 20; // BIP44 standard gap limit +// The BIP44 standard gap limit is 20, but that means ~40 address lookups per +// scan. We can safely use a much smaller limit because this wallet only ever +// exposes ONE unused receive address at a time (freshReceive = first unused; +// there is no "generate another address" button). That keeps used addresses +// contiguous, so the gap between them is never more than 1 — a limit of 5 is a +// comfortable safety margin while cutting scan requests ~4x. +const GAP_LIMIT = 5; const NETS = { mainnet: { net: btc.NETWORK, coin: 0 }, -- cgit v1.2.3