Skip to content

fix(bitcoin-wallet-snap): use BIP44 gap limit for full account scans - #224

Open
jeremytsng wants to merge 3 commits into
mainfrom
fix/btc-snap-stopgap-scan
Open

fix(bitcoin-wallet-snap): use BIP44 gap limit for full account scans#224
jeremytsng wants to merge 3 commits into
mainfrom
fix/btc-snap-stopgap-scan

Conversation

@jeremytsng

Copy link
Copy Markdown
Contributor

Explanation

First of three PRs splitting #201 per review feedback. This one only splits the chain stopGap configuration.

stopGap served two jobs with opposite cost profiles: probing many candidate accounts at boot (wants a cheap, small gap) and scanning an account the user owns (wants the BIP44 gap limit, because quitting early means missing the user's funds). The single value of 5 — a quarter of the BIP44 limit of 20 — meant a full scan could stop before reaching a coin parked behind 5 consecutive unused addresses.

  • ChainConfig.stopGap becomes { discovery: 5, scan: 20 }.
  • BlockchainClient.fullScan gains a mode parameter, defaulting to 'scan'; discover() passes 'discovery'.

Note for reviewers: on its own this changes little in the field, because a full scan currently runs only at account creation. It becomes load-bearing with the follow-up PRs (reveal-at-sign, one-time repair rescan).

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Split the chain stopGap config into { discovery: 5, scan: 20 }. Account
discovery keeps the cheap 5-address probe; a full scan of an account the
user owns walks until 20 consecutive empty addresses, the BIP44 gap
limit, so it cannot stop before funds parked deeper in the address
chain.
@jeremytsng
jeremytsng requested a review from a team as a code owner August 27, 2026 17:20
@jeremytsng
jeremytsng deployed to default-branch August 27, 2026 17:20 — with GitHub Actions Active
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant