fix: make descriptor scanning usable on mainnet - #26
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
--rescan-since <unix-ts>on the CLI,rescan_sinceon the API scan body. It flows through EngineSettings into each imported descriptor. Default behavior is unchanged (full rescan).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.