Skip to content

Skip initial full scan for freshly generated wallets - #857

Open
Supremesv715 wants to merge 1 commit into
bitcoinppl:masterfrom
Supremesv715:skip
Open

Skip initial full scan for freshly generated wallets#857
Supremesv715 wants to merge 1 commit into
bitcoinppl:masterfrom
Supremesv715:skip

Conversation

@Supremesv715

Copy link
Copy Markdown

Summary

Generated (in-app) wallets no longer run the 150-address full scan — a new mnemonic can't have history. Added a generated_in_app marker set only at creation time; import paths (mnemonic, xpub, hardware, TapSigner) still get the full scan. #848

Testing

Added unit tests for routing + migration + spend-readiness. Full cargo test -p cove --lib suite passes.

Platform Coverage

  • Tested on iOS device
  • Tested on Android device
  • Tested on iOS simulator
  • Tested on Android simulator
  • [*] Not tested

Checklist

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 16a50316-4dfd-433c-bdb5-b7fb62e8b66d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

// perform that scanning in a background task
let addr = self.addr.clone();
match initial_scan_route(completed_initial_scan) {
match initial_scan_route(completed_initial_scan, self.wallet_generated_in_app()) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Ledger state never completes

When a generated wallet completes its initial incremental scan, performed_full_scan_at remains unset, so the shared ledger state stays InitialScanIncomplete; this leaves the balance provisional and the UI loading or scanning indefinitely, while manager-level spend readiness can still reject the wallet.

Knowledge Base Used: Wallet Manager and Wallet State

Comment on lines +82 to +89
#[serde(default)]
/// True only for wallets whose key material was generated by Cove itself
/// (never imported/typed/scanned in). A freshly generated seed cannot have
/// on-chain history, so wallets marked here can skip the initial full scan.
///
/// Must only be set at creation time by `WalletMetadata::new_cove_created_wallet`,
/// never inferred from other state (e.g. `discovery_state`).
pub generated_in_app: bool,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Freshness marker survives reconstruction

When a generated wallet is restored from backup or its BDK store is recreated during an address-type switch, generated_in_app remains true even though local scan state is cleared. Startup then uses the 30-address incremental gap instead of the initial 150-address full scan, omitting historical transactions, balance, or spendable outputs beyond that gap.

Knowledge Base Used: Wallet Manager and Wallet State

@greptile-apps

greptile-apps Bot commented Jul 28, 2026

Copy link
Copy Markdown

Greptile Summary

The PR adds a persisted generated-wallet marker and uses it to bypass the initial full scan and actor-level spend guard.

  • Marks wallets created from newly generated Cove key material.
  • Routes marked wallets directly to incremental synchronization.
  • Adds serialization, migration, routing, and spend-readiness tests.

Confidence Score: 2/5

The PR should not merge until generated wallets can reach a consistent completed ledger state and restored or reconstructed wallets no longer reuse the fresh-creation scan bypass.

Incremental completion never satisfies the existing performed_full_scan_at-based state model, while the persisted marker survives backup restoration and BDK-store recreation where the assumption of no history is no longer valid.

Files Needing Attention: rust/src/manager/wallet_manager/actor.rs, rust/src/wallet/metadata.rs

Important Files Changed

Filename Overview
rust/src/manager/wallet_manager/actor.rs Adds generated-wallet scan and spend exceptions, but does not integrate the exception with shared ledger completion and trusts the marker after reconstructed wallet lifecycles.
rust/src/wallet/metadata.rs Adds a backward-compatible persisted creation marker, but preserves it when local scan state is cleared even though downstream code treats it as proof of freshness.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Create wallet in Cove] --> B[generated_in_app = true]
  B --> C{Fresh local wallet?}
  C -->|Initial creation| D[Incremental scan]
  C -->|Backup restore or store recreation| E[Marker remains true]
  E --> D
  D --> F[performed_full_scan_at remains unset]
  F --> G[Shared ledger state remains incomplete]
  E --> H[Historical scan uses 30-address gap]
  H --> I[History beyond gap may be omitted]
Loading

Reviews (1): Last reviewed commit: "Skip initial full scan for freshly gener..." | Re-trigger Greptile

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