#31668 Added rescan option for import descriptors

full analysis

https://github.com/bitcoin/bitcoin/pull/31668 · saikiran57 · +200/-29 in 2 files, 1 commits · labels: Needs rebase

Goal

  • Allow importing descriptors without triggering any blockchain rescan
  • Avoids the mandatory two-hour rescan delay when importing newly created descriptors

Adds a "never" string option to the `timestamp` parameter in the `importdescriptors` RPC method. This allows callers to import descriptors without triggering any blockchain rescan, and validates that numeric timestamps cannot be negative.

Problem: When importing descriptors known to be new or unused, specifying timestamp="now" still rescans blocks within the two-hour median-time window, imposing unnecessary delays during descriptor imports.

Category: Wallet (#44 of 84)

P3 · new feature

  • P3 because it saves time during imports of newly generated descriptors
  • Eliminates the mandatory two-hour rescan window for users importing unused descriptors

Worthwhile quality-of-life feature for wallet users. Eliminates the mandatory two-hour rescan window when importing newly generated descriptors, saving significant time during bulk watch-only imports without endangering wallet funds.

Membership: Modifies descriptor import logic and rescan triggering in src/wallet/rpc/backup.cpp.

Factors: security/stability 0, bug 0, performance 1, user value 2, leverage 0

Reviewability: Stale: Needs rebase

  • Merge conflicts with master require a rebase before review

The PR has merge conflicts with master and requires a rebase before further review.

Author status: active, requested final review after updating test cases and rebasing in August 2026

Resolved concerns:

  • Parameter design debated between a separate rescan boolean or a special timestamp string; reviewers converged on timestamp="never" (maflcko, furszy).
  • Handling of negative timestamps and avoiding magic -1 numbers using std::optional (maflcko, furszy, achow101, rkrux).
  • Test case coverage distinguishing 'now' rescans from 'never' behavior (achow101, rkrux).

Agreement: Positive

  • General agreement on avoiding rescans when the user requests it
  • Concept approval to allow skipping rescan on import (rkrux)
  • Reviewers converged on using never as the timestamp parameter value (maflcko, furszy)
  • Feedback on test coverage and avoiding magic numbers was addressed (achow101, furszy)

Concept supported with agreement on using 'never' for timestamp; prior review feedback addressed.

Reviewers agreed on the concept and guided the implementation towards std::optional and cleaner tests. There are no blocking concept or approach objections.

  • rkrux Concept ACK'd the intent to avoid rescanning when user specifies so
  • achow101 and furszy requested test coverage and cleaner optional handling, which author addressed

Review verdicts (DrahtBot): 0

Files

161 lines under test/bench/ci.

  • test/functional/wallet_importdescriptors.py +157/-4
  • src/wallet/rpc/backup.cpp +43/-25

Card

Adds a "never" option to the timestamp argument of importdescriptors, allowing users to import descriptors without triggering a blockchain rescan. This solves an inconvenience for users importing fresh watch-only or batch descriptors where the default "now" still rescans recent blocks. The concept is supported and extensive code review feedback on tests and error handling has been incorporated. The PR currently needs a rebase due to merge conflicts with master.

Data

dossier JSON · extract JSON · model openrouter/google/gemini-3.8-flash, generated 2026-09-17T15:48, confidence high, input hash 2fe268608a058081