Skip to content

feat(wallet): Rescan Filters button on the SPV status screen - #791

Merged
QuantumExplorer merged 1 commit into
swift-sdk-integrationfrom
feat/spv-rescan-filters
Jul 9, 2026
Merged

QuantumExplorer merged 1 commit into
swift-sdk-integrationfrom
feat/spv-rescan-filters

Conversation

@QuantumExplorer

Copy link
Copy Markdown
Member

Adds a Rescan Filters card to the SwiftDashSDK SPV status screen (Tools menu): re-check compact block filters for the active wallet's transactions from a chosen height, without wiping headers or SPV storage.

Mechanism

dash-spv already has an organic filter-rescan path: each sync tick, a wallet whose synced_height sits below the filters' committed height triggers reset_for_rescan() and the filter scan restarts from that wallet's height. The new SDK surface (platform 3a51cbd198, pin note item (f)) exposes the lever: platform_wallet_manager_spv_rescan_filters rewinds the wallet's synced height on the SAME Arc<RwLock<WalletManager>> the running sync loop reads — verified hop-by-hop from the FFI write to the sync loop's wallets_behind read, including that both paths resolve to the same metadata.synced_height field. (The originally-suggested update_wallet_synced_height trait lever turned out to be forward-only — the implementation follows the existing reconcile_dashpay_rescan unconditional-set precedent instead.) The rewind is deliberately in-memory: an interrupted rescan simply resumes nothing on relaunch (persisted cursors are monotonic-max guarded).

UX

Button enabled only while SPV is running with a bound wallet. Three explicit height options:

  • From wallet creation — PersistentWallet.birthHeight (a real stored birth height, not the synced high-water);
  • From height… — validated numeric entry;
  • Full rescan (from 0) — destructive-styled, with a genesis-scan slowness warning.

Success shows "Rescan started — watch the Filters row" (the same screen's filters sub-progress visibly drops and re-climbs); errors surface verbatim; a forward/equal height is a harmless no-op by design. The screen kept its existing no-ViewModel diagnostic structure (predates the SwiftUI-first rule) — SDK calls live in a @MainActor extension, not the view body.

Verification

  • Implemented by Opus subagents (SDK + app), each independently verified: propagation-chain claims re-checked against pinned rust-dashcore source, cargo check both crates clean, sim xcframework rebuilt with the new symbol confirmed via nm, independent dashpay arm64-sim build green (link-verifies the FFI symbol).
  • Pending: interactive smoke (PIN-gated): Tools → SPV status → Rescan Filters → watch the Filters row rewind and re-sync. Build installed on the QA sim.

Dependency

Requires ../platform at local/tx-decode-plus-v4.1-dev-dashwallet tip 3a51cbd198 (pushed) + xcframework rebuild — pin note updated in DASHSYNC_MIGRATION.md.

🤖 Generated with Claude Code

Adds a Rescan Filters button to the filters section of the SwiftDashSDK
SPV status screen. Tapping it rewinds the running wallet's compact-filter
scan checkpoint via the SDK FFI `spvRescanFilters(walletId:fromHeight:)`;
the running dash-spv filter sync detects the rewound synced-height on its
next tick and re-downloads/re-matches filters from that height,
rediscovering any missed wallet transactions. The call only lowers a
height (synchronous/cheap) — the Filters progress row on the same screen
visibly dropping and re-climbing is the user-facing feedback.

The button is enabled only when SPV is running (`manager.isSpvRunning()`)
AND a wallet is bound (`SwiftDashSDKHost.shared.wallet != nil`), the two
conditions the FFI needs for an immediate rescan.

Height options in the confirmation dialog:
  - From wallet creation — uses the bound wallet's persisted
    `PersistentWallet.birthHeight` (block height at creation), fetched
    from the host's ModelContainer. This is an honest birth-height
    source distinct from `syncedHeight` (the current high-water), so the
    option is included; it is omitted only when no wallet/row is
    readable rather than defaulted.
  - From height… — numeric entry validated to UInt32; a non-numeric or
    empty value is rejected with an error banner, never defaulted to 0.
  - Full rescan (from 0) — explicit destructive option, labelled with a
    slow-on-mainnet warning.

On a throw the error message is surfaced; success is never claimed if
the FFI call failed. All copy is NSLocalizedString. The rescan flow's
small amount of state and its FFI call live in a `@MainActor` extension
on the existing diagnostic screen (which predates the SwiftUI-first
ViewModel rule) rather than a wholesale rewrite.

Also records the SPV filter-rescan FFI as pin entry (f) in the platform
pin blockquote of DASHSYNC_MIGRATION.md.

Co-Authored-By: Claude Opus <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 585db910-c363-4e3f-892e-cc9cabb34ae1

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
  • Commit unit tests in branch feat/spv-rescan-filters

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.

@QuantumExplorer
QuantumExplorer merged commit 5781422 into swift-sdk-integration Jul 9, 2026
1 check passed
@QuantumExplorer
QuantumExplorer deleted the feat/spv-rescan-filters branch August 7, 2026 08:22
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