Skip to content

feat(key-wallet): seed sync checkpoint from birth_height#693

Merged
xdustinface merged 1 commit into
devfrom
feat/feed-wallet-synced-height
Jul 7, 2026
Merged

feat(key-wallet): seed sync checkpoint from birth_height#693
xdustinface merged 1 commit into
devfrom
feat/feed-wallet-synced-height

Conversation

@xdustinface

@xdustinface xdustinface commented Apr 25, 2026

Copy link
Copy Markdown
Collaborator

WalletManager::import_wallet_from_extended_priv_key, import_wallet_from_xpub, and import_wallet_from_bytes (plus the matching FFI) gain a birth_height parameter so previously-used keys can rescan from a chosen height instead of being silently anchored at the chain tip.

Based on:

Summary by CodeRabbit

  • New Features

    • Wallet imports now support an explicit starting sync height, helping imported wallets begin from a chosen checkpoint instead of always starting from the beginning.
  • Bug Fixes

    • Updated wallet import behavior so imported wallet state is initialized consistently with the provided starting height.
    • Aligned related import flows and tests with the updated wallet import parameters.

@coderabbitai

coderabbitai Bot commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b1ec6ce0-5873-4734-ab28-7a865baff9d2

📥 Commits

Reviewing files that changed from the base of the PR and between 647fa98 and 848fdc8.

📒 Files selected for processing (8)
  • dash-spv-ffi/tests/test_wallet_manager.rs
  • key-wallet-ffi/FFI_API.md
  • key-wallet-ffi/src/wallet_manager.rs
  • key-wallet-ffi/src/wallet_manager_serialization_tests.rs
  • key-wallet-ffi/src/wallet_manager_tests.rs
  • key-wallet-ffi/tests/test_import_wallet.rs
  • key-wallet-manager/src/lib.rs
  • key-wallet-manager/tests/test_serialized_wallets.rs

📝 Walkthrough

Walkthrough

Wallet import APIs in key-wallet-manager (import_wallet_from_extended_priv_key, import_wallet_from_xpub, import_wallet_from_bytes) now require an explicit birth_height parameter used to seed ManagedWalletInfo. The corresponding FFI function and documentation are updated to add this parameter, and existing test call sites are updated accordingly.

Changes

Explicit birth_height for wallet import

Layer / File(s) Summary
WalletManager import functions accept birth_height
key-wallet-manager/src/lib.rs
import_wallet_from_extended_priv_key, import_wallet_from_xpub, and import_wallet_from_bytes gain a birth_height: CoreBlockHeight parameter, using it to seed ManagedWalletInfo instead of self.last_processed_height(), with updated doc comments.
FFI signature and docs
key-wallet-ffi/src/wallet_manager.rs, key-wallet-ffi/FFI_API.md
wallet_manager_import_wallet_from_bytes adds a birth_height: u32 parameter, forwards it to the underlying manager call, and updates safety docs and the documented C signature.
Test call sites updated
dash-spv-ffi/tests/test_wallet_manager.rs, key-wallet-ffi/src/wallet_manager_serialization_tests.rs, key-wallet-ffi/src/wallet_manager_tests.rs, key-wallet-ffi/tests/test_import_wallet.rs, key-wallet-manager/tests/test_serialized_wallets.rs
Existing tests pass an additional 0 (or 50_000) argument to wallet_manager_import_wallet_from_bytes/import_wallet_from_bytes, with a new test scenario asserting seeded birth_height, synced_height, and last_processed_height values after import.

Estimated code review effort: 2 (Simple) | ~12 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Test as test_serialized_wallets
  participant Manager as WalletManager
  participant Info as ManagedWalletInfo

  Test->>Manager: import_wallet_from_bytes(bytes, 50_000)
  Manager->>Manager: deserialize wallet, compute wallet_id
  Manager->>Info: init with birth_height=50_000
  Info-->>Manager: synced_height=49_999, last_processed_height=49_999
  Manager-->>Test: WalletId
Loading

Possibly related issues

Suggested labels: ready-for-review

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main change: seeding wallet sync checkpoints from birth_height.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/feed-wallet-synced-height

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.

@codecov

codecov Bot commented Apr 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.66%. Comparing base (647fa98) to head (848fdc8).

Files with missing lines Patch % Lines
key-wallet-manager/src/lib.rs 33.33% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #693      +/-   ##
==========================================
+ Coverage   73.34%   73.66%   +0.31%     
==========================================
  Files         324      324              
  Lines       72923    72927       +4     
==========================================
+ Hits        53486    53722     +236     
+ Misses      19437    19205     -232     
Flag Coverage Δ
core 76.94% <ø> (ø)
ffi 47.89% <100.00%> (+2.39%) ⬆️
rpc 20.00% <ø> (ø)
spv 90.63% <ø> (+0.04%) ⬆️
wallet 72.96% <33.33%> (-0.01%) ⬇️
Files with missing lines Coverage Δ
key-wallet-ffi/src/wallet_manager.rs 71.84% <100.00%> (-1.86%) ⬇️
key-wallet-manager/src/lib.rs 74.82% <33.33%> (-0.44%) ⬇️

... and 16 files with indirect coverage changes

@xdustinface xdustinface force-pushed the refactor/birth-height-construction branch from 973115f to 5ee6537 Compare April 28, 2026 01:30
@github-actions github-actions Bot added the merge-conflict The PR conflicts with the target branch. label Apr 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them.

@xdustinface xdustinface force-pushed the refactor/birth-height-construction branch from 5ee6537 to 0a49ef4 Compare April 28, 2026 13:14
Base automatically changed from refactor/birth-height-construction to v0.42-dev April 29, 2026 23:19
@xdustinface xdustinface force-pushed the feat/feed-wallet-synced-height branch from 50c6a0d to 92aa0ba Compare April 29, 2026 23:22
@github-actions github-actions Bot added merge-conflict The PR conflicts with the target branch. and removed merge-conflict The PR conflicts with the target branch. labels Apr 29, 2026
@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them.

Move sync checkpoint seeding into `ManagedWalletInfo` construction so it can't be forgotten, and let callers control the scan range when importing.

- `WalletInfoInterface::from_wallet` now takes `birth_height` and seeds `synced_height` and `last_processed_height` to `birth_height.saturating_sub(1)`. Previously every wallet-add path had to remember to call `set_birth_height` separately, and forgetting it dragged `WalletManager::synced_height` (a min across wallets) back to genesis on every add.
- `WalletManager::import_wallet_from_extended_priv_key`, `import_wallet_from_xpub`, and `import_wallet_from_bytes` (plus the matching FFI) gain a `birth_height` parameter so previously-used keys can rescan from a chosen height instead of being silently anchored at the chain tip.
- Unused `ManagedWalletInfo::with_birth_height` removed.
@xdustinface xdustinface force-pushed the feat/feed-wallet-synced-height branch from 92aa0ba to 848fdc8 Compare July 6, 2026 15:01
@github-actions github-actions Bot removed the merge-conflict The PR conflicts with the target branch. label Jul 6, 2026
@xdustinface xdustinface marked this pull request as ready for review July 6, 2026 15:06
@github-actions github-actions Bot added the ready-for-review CodeRabbit has approved this PR label Jul 6, 2026
@xdustinface xdustinface requested a review from ZocoLini July 7, 2026 10:15

@ZocoLini ZocoLini left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If we are going this way we also need method to expose the latest known and valid height before starting sync (ergo latest checkpoint)

@xdustinface

Copy link
Copy Markdown
Collaborator Author

If we are going this way we also need method to expose the latest known and valid height before starting sync (ergo latest checkpoint)

How is it related or neccessary for this PR? This is just a preparation PR. I have a few coming.

@xdustinface xdustinface merged commit 49c243a into dev Jul 7, 2026
40 checks passed
@xdustinface xdustinface deleted the feat/feed-wallet-synced-height branch July 7, 2026 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review CodeRabbit has approved this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants