aboutsummaryrefslogtreecommitdiffstats
path: root/src/wallet.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-06-14 23:31:56 -0700
committerAdam Soltys <[email protected]>2026-06-14 23:31:56 -0700
commitf477756f5f04e65c68d2e51100c660c13505d1f2 (patch)
tree3c89ff413e2a9f2d5ef5928ef22b398dd5866cbe /src/wallet.js
parentdcd71b82beab1fe98506bd5ed31bc10cf039f233 (diff)
downloadcoinosv3-f477756f5f04e65c68d2e51100c660c13505d1f2.tar.gz
coinosv3-f477756f5f04e65c68d2e51100c660c13505d1f2.zip
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) <[email protected]>
Diffstat (limited to 'src/wallet.js')
-rw-r--r--src/wallet.js8
1 files changed, 7 insertions, 1 deletions
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 },