Skip to content

fix: make descriptor scanning usable on mainnet - #26

Merged
LORDBABUINO merged 1 commit into
mainfrom
fix/mainnet-descriptor-rescan
Aug 31, 2026
Merged

fix: make descriptor scanning usable on mainnet#26
LORDBABUINO merged 1 commit into
mainfrom
fix/mainnet-descriptor-rescan

Conversation

@LORDBABUINO

Copy link
Copy Markdown
Collaborator

Descriptor scans were effectively regtest-only. On mainnet, importdescriptors rescans from genesis (the import timestamp was hardcoded to 0) and the RPC client gave up after reqwest's default 30 seconds, killing the call mid-rescan and leaving the temporary scan wallet loaded and rescanning on the node.

This PR makes three changes:

  1. The RPC client no longer sets a timeout. Descriptor imports block on Core's synchronous rescan, which legitimately takes minutes on a large chain.
  2. A birth timestamp can now bound the rescan: --rescan-since <unix-ts> on the CLI, rescan_since on the API scan body. It flows through EngineSettings into each imported descriptor. Default behavior is unchanged (full rescan).
  3. The temp wallet guard now calls abortrescan before unloadwallet, so a scan that fails mid-rescan cleans up after itself instead of leaving a ghost wallet churning on the node.

Verified against a real mainnet node (height 953137, txindex): with a birth timestamp the rescan starts at the right block instead of genesis, and the scan completes. Tests: unit tests for the timestamp plumbing and CLI flag, an API contract test, and a regtest integration test that mines year-old blocks under mocktime and asserts the cutoff excludes them. Full suite passes 37/37 with clippy -D warnings clean.

Known follow-up (tracked in the roadmap): ancestor fetching still issues thousands of sequential getrawtransaction calls for batch-heavy transactions, so descriptor scans of busy wallets are slow even with a bounded rescan.

The RPC client used reqwest's default 30s timeout, which aborted
importdescriptors calls mid-rescan on mainnet and left the temporary
scan wallet loaded and rescanning on the node.

- disable the client timeout: descriptor imports block on Core's
  synchronous rescan, which can run for minutes on large chains
- thread an optional rescan-since birth timestamp through the scan
  path (CLI --rescan-since, API rescan_since) down to
  importdescriptors, bounding the rescan to the wallet's lifetime
  instead of always starting from genesis
- abort any in-progress rescan before unloading the temp wallet so
  failed scans stop leaving ghost wallets behind
@LORDBABUINO
LORDBABUINO merged commit 95c1dbe into main Aug 31, 2026
3 checks passed
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