Repository navigation
feat(wallet): Rescan Filters button on the SPV status screen - #791
Merged
Merged
Conversation
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]>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
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.
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_heightsits below the filters' committed height triggersreset_for_rescan()and the filter scan restarts from that wallet's height. The new SDK surface (platform3a51cbd198, pin note item (f)) exposes the lever:platform_wallet_manager_spv_rescan_filtersrewinds the wallet's synced height on the SAMEArc<RwLock<WalletManager>>the running sync loop reads — verified hop-by-hop from the FFI write to the sync loop'swallets_behindread, including that both paths resolve to the samemetadata.synced_heightfield. (The originally-suggestedupdate_wallet_synced_heighttrait lever turned out to be forward-only — the implementation follows the existingreconcile_dashpay_rescanunconditional-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:
PersistentWallet.birthHeight(a real stored birth height, not the synced high-water);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
@MainActorextension, not the view body.Verification
cargo checkboth crates clean, sim xcframework rebuilt with the new symbol confirmed vianm, independentdashpayarm64-sim build green (link-verifies the FFI symbol).Dependency
Requires
../platformatlocal/tx-decode-plus-v4.1-dev-dashwallettip3a51cbd198(pushed) + xcframework rebuild — pin note updated in DASHSYNC_MIGRATION.md.🤖 Generated with Claude Code