Skip to content

refactor(key-wallet-manager): move key-wallet-manager crate into key-wallet#503

Open
ZocoLini wants to merge 1 commit intov0.42-devfrom
refactor/manager-crate-moved
Open

refactor(key-wallet-manager): move key-wallet-manager crate into key-wallet#503
ZocoLini wants to merge 1 commit intov0.42-devfrom
refactor/manager-crate-moved

Conversation

@ZocoLini
Copy link
Collaborator

@ZocoLini ZocoLini commented Mar 9, 2026

Just moved key-wallet-manager into the new key-wallet manager module.

  • We should open PRs moving wallet stuff that was defined in key-wallet into the right wallet module
  • Coverage complains about having less coverage but I didn't remove any test or logic :/
  • Merged the READMEs relevant info and moved a couple more documents as they were
  • Coderabbit complains about not supporting no-std builds but key-wallet-manager didn't support that, here we can do two things, we can ignore coderabbit and remove no-std support so we can eventually add it once is requested (wasm and embedded no-std support should be treated with two different flags) or I can make the manager module no compile in no-std builds

Summary by CodeRabbit

  • Refactor

    • Core wallet APIs reorganized under a new manager module for clearer crate structure.
  • Chores

    • Workspace and crate manifests updated to remove the separate high-level wallet crate and consolidate its surfaces.
  • New Features

    • Test utilities (mock wallets and helpers) added to the public test utilities to simplify local testing.
  • Documentation

    • READMEs and docs consolidated and expanded to reflect multi-wallet, transaction, and wallet-manager guidance.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 9, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Removed the standalone key-wallet-manager crate; folded its public API and test utilities into a new manager module in key-wallet; updated workspace and crate manifests and replaced imports across FFI, dash-spv, examples, and tests to reference key_wallet::manager or crate-local paths.

Changes

Cohort / File(s) Summary
Workspace & root manifests
Cargo.toml, key-wallet/Cargo.toml, key-wallet-ffi/Cargo.toml, dash-spv/Cargo.toml, dash-spv-ffi/Cargo.toml
Removed key-wallet-manager from workspace and dependencies; adjusted dependencies/features (moved tokio, added rayon, updated bincode feature targets).
Removed crate files
key-wallet-manager/Cargo.toml, key-wallet-manager/README.md, key-wallet-manager/src/lib.rs, key-wallet-manager/src/**
Deleted key-wallet-manager manifest, README, public lib surface, and test utility source files. Review for any remaining references or CI/coverage entries.
New manager module & test utils
key-wallet/src/lib.rs, key-wallet/src/manager/..., key-wallet/src/test_utils/*
Added manager module and re-exports (WalletManager, WalletInterface, WalletEvent, FilterMatchKey, etc.) and moved/added MockWallet and NonMatchingMockWallet test utilities into key-wallet.
FFI updates
key-wallet-ffi/src/*, key-wallet-ffi/Cargo.toml, dash-spv-ffi/src/*, dash-spv-ffi/Cargo.toml
Removed key-wallet-manager dependency; updated imports, error conversions, and types to key_wallet::manager (WalletManager, WalletInterface, WalletError, WalletEvent); adjusted FeeRate and bincode references. Check FFI signatures and From impls.
dash-spv code & examples
dash-spv/Cargo.toml, dash-spv/src/**, dash-spv/examples/*, dash-spv/tests/*
Replaced key_wallet_manager::... paths with key_wallet::manager::... or crate-local equivalents across client, sync, filters, validation, examples, and tests.
Tests & integration updates
key-wallet/tests/*, key-wallet-ffi/tests/*, dash-spv-ffi/tests/*, dash-spv/tests/*
Updated test imports and error-conversion tests to reference key_wallet::manager and new WalletError paths; adjusted FFI error mapping tests. Verify test fixtures and mock behavior moved to new test utils.
Repository metadata & docs
.codecov.yml, .github/ci-groups.yml, README.md, key-wallet/README.md, key-wallet/TODO.md, key-wallet/missing_tests.md, key-wallet/src/missing_tests.md
Removed key-wallet-manager from CI/coverage configs; consolidated and updated wallet-related docs and TODOs to reflect new module layout.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I hopped through crates both old and new,
Nestled managers into key-wallet's view.
Mock wallets pranced into tests with glee,
Paths rewired so the builds agree.
A tiny hop — repo tidy and true.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: refactoring by moving the key-wallet-manager crate's contents into the key-wallet crate as a new manager module. This is the primary and most significant structural change across all files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/manager-crate-moved

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (3)
key-wallet/src/test_utils/wallet.rs (1)

20-130: Add colocated smoke tests for the new mock wallets.

MockWallet and NonMatchingMockWallet now define behavior that other tests will rely on, but this file does not lock any of that behavior down locally. A small #[cfg(test)] module covering set_effect, block/tx recording, and synced-height updates would make these shared fixtures much safer to reuse.

As per coding guidelines, **/*.rs: Keep unit tests in the source code alongside implementation using #[cfg(test)] modules and Write unit tests for new functionality.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@key-wallet/src/test_utils/wallet.rs` around lines 20 - 130, Add a small
#[cfg(test)] mod tests in this file that asserts the key behaviors of MockWallet
and NonMatchingMockWallet: use MockWallet::new(), call set_effect(txid, net,
addresses) and verify transaction_effect(tx) returns the tuple; call
process_block(...) and process_mempool_transaction(...) and verify
processed_blocks and processed_transactions contain the expected items; check
synced_height() before and after update_synced_height(...); and add a sanity
test for NonMatchingMockWallet::new() that ensures
process_block/process_mempool_transaction return defaults and
synced_height/update_synced_height behave as expected. Ensure tests reference
the exact symbols MockWallet::set_effect, MockWallet::process_block,
MockWallet::process_mempool_transaction, MockWallet::transaction_effect,
MockWallet::processed_blocks, MockWallet::processed_transactions,
MockWallet::synced_height, MockWallet::update_synced_height, and
NonMatchingMockWallet similarly.
key-wallet-ffi/src/wallet_manager.rs (1)

1-1: Outdated comment references the old crate name.

The comment still refers to "key-wallet-manager crate" but this module has been moved into key-wallet.

📝 Suggested fix
-//! FFI bindings for WalletManager from key-wallet-manager crate
+//! FFI bindings for WalletManager from the key-wallet crate's manager module
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@key-wallet-ffi/src/wallet_manager.rs` at line 1, Update the outdated
module-level doc comment that currently says "FFI bindings for WalletManager
from key-wallet-manager crate" to reflect the new crate name "key-wallet"; edit
the top-of-file/module doc comment in wallet_manager.rs (the FFI bindings
comment) so it references "key-wallet" instead of "key-wallet-manager" and
ensure any other inline docs in the same file mentioning the old crate name
(e.g., in comments around WalletManager) are updated likewise.
key-wallet/src/manager/mod.rs (1)

603-765: Consider extracting common address generation logic.

get_receive_address and get_change_address share nearly identical structure with repeated AccountTypePreference matching logic. This is existing code not introduced by this PR, but worth noting for future cleanup.

A helper method could unify the common pattern:

fn get_address_with_preference<F>(
    &mut self,
    wallet_id: &WalletId,
    account_index: u32,
    account_type_pref: AccountTypePreference,
    mark_as_used: bool,
    address_fn: F,
) -> Result<AddressGenerationResult, WalletError>
where
    F: Fn(&mut ManagedAccount, &ExtendedPubKey) -> Result<Address, ...>

Also applies to: 768-929

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@key-wallet/src/manager/mod.rs` around lines 603 - 765, The
get_receive_address and get_change_address functions duplicate the
AccountTypePreference matching and address selection/marking logic; extract that
shared flow into a generic helper (suggested name get_address_with_preference)
that accepts parameters wallet_id, account_index, account_type_pref,
mark_as_used and a small address_fn closure (to call
ManagedAccount::next_receive_address or next_change_address using the wallet
account's account_xpub), returns AddressGenerationResult, and performs the same
AccountTypeUsed handling and mark-as-used behavior; update get_receive_address
to call this new helper (and likewise get_change_address) and reuse the existing
enums/types (AccountTypePreference, AccountTypeUsed, AddressGenerationResult,
ManagedAccount methods) to keep behavior identical.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@key-wallet/Cargo.toml`:
- Around line 48-49: Cargo manifest must enable tokio's sync feature and gate
tokio and rayon behind the crate's std feature: in Cargo.toml update the tokio
dependency to include features = ["macros", "rt", "sync"] and make both tokio
and rayon optional = true, then add them to the std feature (e.g., features.std
= ["tokio", "rayon"]); this will satisfy uses of tokio::sync::broadcast in
key-wallet/src/manager/mod.rs and tokio::sync::Mutex in
key-wallet/src/test_utils/wallet.rs while preserving no_std compatibility
declared in src/lib.rs.

In `@key-wallet/src/lib.rs`:
- Line 46: The module `manager` is exposed unconditionally but depends on
std/tokio/rayon; guard its declaration so it is only compiled when the "std"
feature is enabled by adding a cfg attribute to the `pub mod manager;` line
(e.g., use #[cfg(feature = "std")] before the declaration) and ensure any
internal files (`mod.rs`, `matching.rs`, `process_block.rs`) that use
std/tokio/rayon are likewise behind the same feature flag if they contain
standalone declarations; keep the symbol name `manager` unchanged so references
resolve when the "std" feature is active.

---

Nitpick comments:
In `@key-wallet-ffi/src/wallet_manager.rs`:
- Line 1: Update the outdated module-level doc comment that currently says "FFI
bindings for WalletManager from key-wallet-manager crate" to reflect the new
crate name "key-wallet"; edit the top-of-file/module doc comment in
wallet_manager.rs (the FFI bindings comment) so it references "key-wallet"
instead of "key-wallet-manager" and ensure any other inline docs in the same
file mentioning the old crate name (e.g., in comments around WalletManager) are
updated likewise.

In `@key-wallet/src/manager/mod.rs`:
- Around line 603-765: The get_receive_address and get_change_address functions
duplicate the AccountTypePreference matching and address selection/marking
logic; extract that shared flow into a generic helper (suggested name
get_address_with_preference) that accepts parameters wallet_id, account_index,
account_type_pref, mark_as_used and a small address_fn closure (to call
ManagedAccount::next_receive_address or next_change_address using the wallet
account's account_xpub), returns AddressGenerationResult, and performs the same
AccountTypeUsed handling and mark-as-used behavior; update get_receive_address
to call this new helper (and likewise get_change_address) and reuse the existing
enums/types (AccountTypePreference, AccountTypeUsed, AddressGenerationResult,
ManagedAccount methods) to keep behavior identical.

In `@key-wallet/src/test_utils/wallet.rs`:
- Around line 20-130: Add a small #[cfg(test)] mod tests in this file that
asserts the key behaviors of MockWallet and NonMatchingMockWallet: use
MockWallet::new(), call set_effect(txid, net, addresses) and verify
transaction_effect(tx) returns the tuple; call process_block(...) and
process_mempool_transaction(...) and verify processed_blocks and
processed_transactions contain the expected items; check synced_height() before
and after update_synced_height(...); and add a sanity test for
NonMatchingMockWallet::new() that ensures
process_block/process_mempool_transaction return defaults and
synced_height/update_synced_height behave as expected. Ensure tests reference
the exact symbols MockWallet::set_effect, MockWallet::process_block,
MockWallet::process_mempool_transaction, MockWallet::transaction_effect,
MockWallet::processed_blocks, MockWallet::processed_transactions,
MockWallet::synced_height, MockWallet::update_synced_height, and
NonMatchingMockWallet similarly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9f3f374e-9049-400c-87d6-46b71367e0cc

📥 Commits

Reviewing files that changed from the base of the PR and between ebba180 and 082afca.

📒 Files selected for processing (62)
  • Cargo.toml
  • dash-spv-ffi/Cargo.toml
  • dash-spv-ffi/src/callbacks.rs
  • dash-spv-ffi/src/client.rs
  • dash-spv-ffi/tests/test_wallet_manager.rs
  • dash-spv/Cargo.toml
  • dash-spv/examples/filter_sync.rs
  • dash-spv/examples/simple_sync.rs
  • dash-spv/examples/spv_with_wallet.rs
  • dash-spv/src/client/core.rs
  • dash-spv/src/client/events.rs
  • dash-spv/src/client/lifecycle.rs
  • dash-spv/src/client/mempool.rs
  • dash-spv/src/client/mod.rs
  • dash-spv/src/client/queries.rs
  • dash-spv/src/client/sync_coordinator.rs
  • dash-spv/src/client/transactions.rs
  • dash-spv/src/lib.rs
  • dash-spv/src/main.rs
  • dash-spv/src/sync/blocks/manager.rs
  • dash-spv/src/sync/blocks/pipeline.rs
  • dash-spv/src/sync/blocks/sync_manager.rs
  • dash-spv/src/sync/events.rs
  • dash-spv/src/sync/filters/batch.rs
  • dash-spv/src/sync/filters/batch_tracker.rs
  • dash-spv/src/sync/filters/manager.rs
  • dash-spv/src/sync/filters/pipeline.rs
  • dash-spv/src/sync/filters/sync_manager.rs
  • dash-spv/src/sync/sync_coordinator.rs
  • dash-spv/src/validation/filter.rs
  • dash-spv/tests/dashd_sync/helpers.rs
  • dash-spv/tests/dashd_sync/setup.rs
  • dash-spv/tests/dashd_sync/tests_basic.rs
  • dash-spv/tests/peer_test.rs
  • dash-spv/tests/wallet_integration_test.rs
  • key-wallet-ffi/Cargo.toml
  • key-wallet-ffi/src/error.rs
  • key-wallet-ffi/src/transaction.rs
  • key-wallet-ffi/src/wallet_manager.rs
  • key-wallet-ffi/src/wallet_manager_tests.rs
  • key-wallet-ffi/tests/test_error_conversions.rs
  • key-wallet-manager/Cargo.toml
  • key-wallet-manager/README.md
  • key-wallet-manager/src/lib.rs
  • key-wallet-manager/src/test_utils/mod.rs
  • key-wallet-manager/src/test_utils/wallet.rs
  • key-wallet/Cargo.toml
  • key-wallet/README.md
  • key-wallet/TODO.md
  • key-wallet/examples/wallet_creation.rs
  • key-wallet/missing_tests.md
  • key-wallet/src/lib.rs
  • key-wallet/src/manager/events.rs
  • key-wallet/src/manager/matching.rs
  • key-wallet/src/manager/mod.rs
  • key-wallet/src/manager/process_block.rs
  • key-wallet/src/manager/wallet_interface.rs
  • key-wallet/src/test_utils/mod.rs
  • key-wallet/src/test_utils/wallet.rs
  • key-wallet/tests/integration_test.rs
  • key-wallet/tests/spv_integration_tests.rs
  • key-wallet/tests/test_serialized_wallets.rs
💤 Files with no reviewable changes (6)
  • dash-spv-ffi/Cargo.toml
  • key-wallet-manager/src/test_utils/mod.rs
  • key-wallet-manager/README.md
  • key-wallet-manager/src/lib.rs
  • key-wallet-manager/src/test_utils/wallet.rs
  • key-wallet-manager/Cargo.toml

Comment on lines +48 to +49
tokio = { version = "1", features = ["macros", "rt"] }
rayon = { version = "1.11" }
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🌐 Web query:

In Tokio 1.x, is tokio::sync::Mutexgated behind thesync feature, and do Tokio/Rayon require the Rust standard library?

💡 Result:

  • Yes. In Tokio 1.x, tokio::sync::Mutex (and tokio::sync generally) is only available when the crate feature sync is enabled. [1][2]
  • Yes, both Tokio and Rayon require Rust’s standard library (std).
    • Tokio’s crate code uses std APIs (e.g., std::task, std::future, std::os) and it is not a #![no_std] crate. [3]
    • Rayon is fundamentally built around the standard library’s threading support (e.g., its releases reference use of std::thread::scope, and the crate’s docs explicitly frame Rayon as extending/mirroring std). [4][5]

Sources

  1. Tokio docs for tokio::sync::Mutex (feature-gated to sync). (docs.rs)
  2. Tokio tokio::sync module docs (feature-gated to sync). (docs.rs)
  3. Tokio source showing direct std::... usage. (docs.rs)
  4. Rayon release notes referencing std::thread::scope. (docs.rs)
  5. Rayon crate docs describing mirroring/extending std. (docs.rs)

Citations:


🏁 Script executed:

# Check the Cargo.toml structure and features
cd key-wallet && cat -n Cargo.toml | head -60

Repository: dashpay/rust-dashcore

Length of output: 3159


🏁 Script executed:

# Verify tokio::sync::Mutex usage in test_utils
grep -r "tokio::sync::Mutex" key-wallet/src/test_utils/ || echo "Not found"

Repository: dashpay/rust-dashcore

Length of output: 124


🏁 Script executed:

# Check if there are any references to no_std or std feature gating
grep -r "no_std\|#!\[no_std\]" key-wallet/src/ || echo "No no_std references"

Repository: dashpay/rust-dashcore

Length of output: 497


🏁 Script executed:

# Check where rayon is used
grep -r "rayon" key-wallet/src/ --include="*.rs" || echo "No rayon references in src/"

Repository: dashpay/rust-dashcore

Length of output: 161


🏁 Script executed:

# Check where tokio is used
grep -r "tokio" key-wallet/src/ --include="*.rs" | head -20

Repository: dashpay/rust-dashcore

Length of output: 1768


🏁 Script executed:

# Check if test-utils are conditionally compiled
grep -B2 -A2 "mod test_utils\|test-utils" key-wallet/src/lib.rs

Repository: dashpay/rust-dashcore

Length of output: 159


Add Tokio's sync feature and gate both dependencies behind the std feature.

tokio::sync::broadcast is used in key-wallet/src/manager/mod.rs (production code) and tokio::sync::Mutex is used in key-wallet/src/test_utils/wallet.rs, but the manifest only enables macros and rt for tokio—the missing sync feature will cause compilation failures. Additionally, both tokio and rayon are unconditional dependencies that require the standard library, which breaks the crate's declared no_std support (see src/lib.rs:1). These dependencies should be gated behind the std feature.

Example fix
-tokio = { version = "1", features = ["macros", "rt"] }
-rayon = { version = "1.11" }

And update the std feature (line 13) to include them:

-std = ["dashcore_hashes/std", "secp256k1/std", "bip39/std", "getrandom", "dash-network/std", "rand"]
+std = ["dashcore_hashes/std", "secp256k1/std", "bip39/std", "getrandom", "dash-network/std", "rand", "tokio", "rayon"]
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@key-wallet/Cargo.toml` around lines 48 - 49, Cargo manifest must enable
tokio's sync feature and gate tokio and rayon behind the crate's std feature: in
Cargo.toml update the tokio dependency to include features = ["macros", "rt",
"sync"] and make both tokio and rayon optional = true, then add them to the std
feature (e.g., features.std = ["tokio", "rayon"]); this will satisfy uses of
tokio::sync::broadcast in key-wallet/src/manager/mod.rs and tokio::sync::Mutex
in key-wallet/src/test_utils/wallet.rs while preserving no_std compatibility
declared in src/lib.rs.

pub mod error;
pub mod gap_limit;
pub mod managed_account;
pub mod manager;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== key-wallet/Cargo.toml features =="
sed -n '1,220p' key-wallet/Cargo.toml

echo
echo "== key-wallet/src/lib.rs =="
sed -n '1,90p' key-wallet/src/lib.rs

echo
echo "== std/tokio/rayon usage under key-wallet/src/manager =="
fd . key-wallet/src/manager -e rs -x sh -c '
  file="$1"
  echo "--- ${file}"
  rg -n "use std::|std::|tokio|rayon" "$file" || true
' sh {}

Repository: dashpay/rust-dashcore

Length of output: 5825


Guard manager behind the std feature flag.

The manager module directly uses std, tokio, and rayon (visible in mod.rs, matching.rs, and process_block.rs), yet it is exposed unconditionally at line 46 while the crate declares no_std support on line 7. This creates a mismatch: users building with default-features = false will encounter a module that depends on unavailable APIs.

Wrap the module declaration with:

- pub mod manager;
+ #[cfg(feature = "std")]
+ pub mod manager;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
pub mod manager;
#[cfg(feature = "std")]
pub mod manager;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@key-wallet/src/lib.rs` at line 46, The module `manager` is exposed
unconditionally but depends on std/tokio/rayon; guard its declaration so it is
only compiled when the "std" feature is enabled by adding a cfg attribute to the
`pub mod manager;` line (e.g., use #[cfg(feature = "std")] before the
declaration) and ensure any internal files (`mod.rs`, `matching.rs`,
`process_block.rs`) that use std/tokio/rayon are likewise behind the same
feature flag if they contain standalone declarations; keep the symbol name
`manager` unchanged so references resolve when the "std" feature is active.

@codecov
Copy link

codecov bot commented Mar 9, 2026

Codecov Report

❌ Patch coverage is 62.50000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.56%. Comparing base (98988cc) to head (2e685ae).
⚠️ Report is 6 commits behind head on v0.42-dev.

Files with missing lines Patch % Lines
key-wallet/src/manager/mod.rs 60.00% 4 Missing ⚠️
key-wallet-ffi/src/wallet_manager.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##           v0.42-dev     #503      +/-   ##
=============================================
- Coverage      66.86%   66.56%   -0.31%     
=============================================
  Files            313      318       +5     
  Lines          64775    65830    +1055     
=============================================
+ Hits           43314    43819     +505     
- Misses         21461    22011     +550     
Flag Coverage Δ *Carryforward flag
core 74.93% <ø> (ø)
dash-network 74.92% <ø> (ø) Carriedforward from 98988cc
dash-network-ffi 34.73% <ø> (-0.01%) ⬇️ Carriedforward from 98988cc
dash-spv 68.18% <ø> (ø) Carriedforward from 98988cc
dash-spv-ffi 34.73% <ø> (-0.01%) ⬇️ Carriedforward from 98988cc
dashcore 74.92% <ø> (ø) Carriedforward from 98988cc
dashcore-private 74.92% <ø> (ø) Carriedforward from 98988cc
dashcore-rpc 19.92% <ø> (ø) Carriedforward from 98988cc
dashcore-rpc-json 19.92% <ø> (ø) Carriedforward from 98988cc
dashcore_hashes 74.92% <ø> (ø) Carriedforward from 98988cc
ffi 36.45% <60.00%> (+0.46%) ⬆️
key-wallet 65.69% <ø> (ø) Carriedforward from 98988cc
key-wallet-ffi 34.73% <ø> (-0.01%) ⬇️ Carriedforward from 98988cc
key-wallet-manager 65.69% <ø> (ø) Carriedforward from 98988cc
rpc 19.92% <ø> (ø)
spv 81.11% <ø> (+0.10%) ⬆️
wallet 66.03% <63.63%> (+0.34%) ⬆️

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
dash-spv-ffi/src/callbacks.rs 63.47% <100.00%> (ø)
dash-spv-ffi/src/client.rs 60.66% <100.00%> (ø)
dash-spv/src/client/core.rs 44.89% <ø> (ø)
dash-spv/src/client/events.rs 100.00% <ø> (ø)
dash-spv/src/client/lifecycle.rs 63.46% <ø> (ø)
dash-spv/src/client/mempool.rs 57.57% <ø> (ø)
dash-spv/src/client/mod.rs 98.64% <ø> (ø)
dash-spv/src/client/queries.rs 14.28% <ø> (ø)
dash-spv/src/client/sync_coordinator.rs 74.28% <ø> (ø)
dash-spv/src/client/transactions.rs 0.00% <ø> (ø)
... and 20 more

... and 18 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ZocoLini ZocoLini force-pushed the refactor/manager-crate-moved branch 2 times, most recently from faf9db2 to 9db818d Compare March 9, 2026 18:18
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
key-wallet/README.md (1)

36-47: Consider consolidating duplicate "Watch-Only" documentation.

The "Watch-Only Support" feature is documented in both the new "Wallet Manager" section (line 44) and the existing "Account Types" section (line 59). Consider consolidating these references to avoid redundancy and improve documentation maintainability.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@key-wallet/README.md` around lines 36 - 47, Remove the duplicate "Watch-Only
Support" text by consolidating the description into a single canonical place:
either keep the concise bullet under "Wallet Manager" (the "Watch-Only Support"
bullet) or the more detailed entry under "Account Types", then remove the other
duplicate reference; update the retained entry to mention both wallet-level
watch-only monitoring and account-level watch-only behavior so consumers can
find all relevant info in one spot, and add a cross-reference line in the other
section ("Wallet Manager" or "Account Types") pointing to the canonical section.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@key-wallet/README.md`:
- Around line 36-47: Remove the duplicate "Watch-Only Support" text by
consolidating the description into a single canonical place: either keep the
concise bullet under "Wallet Manager" (the "Watch-Only Support" bullet) or the
more detailed entry under "Account Types", then remove the other duplicate
reference; update the retained entry to mention both wallet-level watch-only
monitoring and account-level watch-only behavior so consumers can find all
relevant info in one spot, and add a cross-reference line in the other section
("Wallet Manager" or "Account Types") pointing to the canonical section.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8e8c176c-1384-4fd0-aea4-8f6c9e60ccd8

📥 Commits

Reviewing files that changed from the base of the PR and between 082afca and faf9db2.

📒 Files selected for processing (62)
  • Cargo.toml
  • dash-spv-ffi/Cargo.toml
  • dash-spv-ffi/src/callbacks.rs
  • dash-spv-ffi/src/client.rs
  • dash-spv-ffi/tests/test_wallet_manager.rs
  • dash-spv/Cargo.toml
  • dash-spv/examples/filter_sync.rs
  • dash-spv/examples/simple_sync.rs
  • dash-spv/examples/spv_with_wallet.rs
  • dash-spv/src/client/core.rs
  • dash-spv/src/client/events.rs
  • dash-spv/src/client/lifecycle.rs
  • dash-spv/src/client/mempool.rs
  • dash-spv/src/client/mod.rs
  • dash-spv/src/client/queries.rs
  • dash-spv/src/client/sync_coordinator.rs
  • dash-spv/src/client/transactions.rs
  • dash-spv/src/lib.rs
  • dash-spv/src/main.rs
  • dash-spv/src/sync/blocks/manager.rs
  • dash-spv/src/sync/blocks/pipeline.rs
  • dash-spv/src/sync/blocks/sync_manager.rs
  • dash-spv/src/sync/events.rs
  • dash-spv/src/sync/filters/batch.rs
  • dash-spv/src/sync/filters/batch_tracker.rs
  • dash-spv/src/sync/filters/manager.rs
  • dash-spv/src/sync/filters/pipeline.rs
  • dash-spv/src/sync/filters/sync_manager.rs
  • dash-spv/src/sync/sync_coordinator.rs
  • dash-spv/src/validation/filter.rs
  • dash-spv/tests/dashd_sync/helpers.rs
  • dash-spv/tests/dashd_sync/setup.rs
  • dash-spv/tests/dashd_sync/tests_basic.rs
  • dash-spv/tests/peer_test.rs
  • dash-spv/tests/wallet_integration_test.rs
  • key-wallet-ffi/Cargo.toml
  • key-wallet-ffi/src/error.rs
  • key-wallet-ffi/src/transaction.rs
  • key-wallet-ffi/src/wallet_manager.rs
  • key-wallet-ffi/src/wallet_manager_tests.rs
  • key-wallet-ffi/tests/test_error_conversions.rs
  • key-wallet-manager/Cargo.toml
  • key-wallet-manager/README.md
  • key-wallet-manager/src/lib.rs
  • key-wallet-manager/src/test_utils/mod.rs
  • key-wallet-manager/src/test_utils/wallet.rs
  • key-wallet/Cargo.toml
  • key-wallet/README.md
  • key-wallet/TODO.md
  • key-wallet/examples/wallet_creation.rs
  • key-wallet/missing_tests.md
  • key-wallet/src/lib.rs
  • key-wallet/src/manager/events.rs
  • key-wallet/src/manager/matching.rs
  • key-wallet/src/manager/mod.rs
  • key-wallet/src/manager/process_block.rs
  • key-wallet/src/manager/wallet_interface.rs
  • key-wallet/src/test_utils/mod.rs
  • key-wallet/src/test_utils/wallet.rs
  • key-wallet/tests/integration_test.rs
  • key-wallet/tests/spv_integration_tests.rs
  • key-wallet/tests/test_serialized_wallets.rs
💤 Files with no reviewable changes (6)
  • key-wallet-manager/src/test_utils/mod.rs
  • dash-spv-ffi/Cargo.toml
  • key-wallet-manager/Cargo.toml
  • key-wallet-manager/README.md
  • key-wallet-manager/src/lib.rs
  • key-wallet-manager/src/test_utils/wallet.rs
✅ Files skipped from review due to trivial changes (1)
  • dash-spv/src/sync/blocks/pipeline.rs
🚧 Files skipped from review as they are similar to previous changes (28)
  • dash-spv/src/sync/events.rs
  • key-wallet-ffi/src/transaction.rs
  • dash-spv/src/sync/filters/sync_manager.rs
  • dash-spv/tests/dashd_sync/setup.rs
  • dash-spv/src/client/core.rs
  • dash-spv/src/sync/filters/batch.rs
  • dash-spv-ffi/src/client.rs
  • dash-spv/src/client/transactions.rs
  • dash-spv/src/client/sync_coordinator.rs
  • dash-spv/src/validation/filter.rs
  • dash-spv/src/sync/blocks/manager.rs
  • dash-spv/src/sync/filters/pipeline.rs
  • dash-spv/src/sync/blocks/sync_manager.rs
  • dash-spv/src/sync/filters/batch_tracker.rs
  • key-wallet/Cargo.toml
  • key-wallet/src/lib.rs
  • Cargo.toml
  • key-wallet-ffi/src/wallet_manager.rs
  • key-wallet-ffi/tests/test_error_conversions.rs
  • key-wallet/src/manager/events.rs
  • dash-spv/tests/dashd_sync/tests_basic.rs
  • key-wallet/src/test_utils/mod.rs
  • dash-spv/src/client/queries.rs
  • dash-spv/examples/simple_sync.rs
  • dash-spv/tests/wallet_integration_test.rs
  • dash-spv/src/client/lifecycle.rs
  • dash-spv/src/main.rs
  • key-wallet-ffi/Cargo.toml

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
key-wallet/README.md (2)

226-236: ⚠️ Potential issue | 🟡 Minor

Add the manager module to the Key Modules section.

The "Key Modules" section doesn't list the manager module, which now contains the wallet manager functionality moved from the key-wallet-manager crate. This should be documented alongside the other core modules.

📚 Suggested addition
 - `utxo`: UTXO set management
 - `gap_limit`: Address discovery gap limit tracking
+- `manager`: Multi-wallet management and coordination
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@key-wallet/README.md` around lines 226 - 236, The README's "Key Modules" list
is missing the new manager module; add an entry for `manager` alongside the
other modules to document the wallet manager functionality migrated from the
key-wallet-manager crate — update the Key Modules bullet list to include
`manager`: Wallet manager (e.g., "manager: Wallet manager and coordination of
wallets/accounts") so readers can find the module and its purpose.

74-201: ⚠️ Potential issue | 🟠 Major

Update code examples to match the actual refactored API.

The README examples contain multiple API incompatibilities that will fail to compile:

  1. Line 93: Import is incorrect. Change use key_wallet::managed_account::ManagedAccount; to use key_wallet::managed_account::ManagedCoreAccount; (the exported type name is ManagedCoreAccount, not ManagedAccount)

  2. Line 96: Update instantiation from ManagedAccount::from_account(&account) to ManagedCoreAccount::from_account(&account)

  3. Line 101: Method signature changed. generate_receive_addresses(10) should be next_receive_addresses(Some(&account.extended_public_key()), 10, true) (requires the extended public key, count, and whether to add to state)

  4. Line 82: wallet.create_account() doesn't exist on Wallet. The method is on Manager instead.

  5. Line 147: derive_address_at_pool() does not exist. For CoinJoin accounts, use the address pools from the ManagedAccountType::CoinJoin variant directly, or use next_address() method on the managed account.

  6. Line 187: Change wallet.to_managed_wallet_info() to ManagedWalletInfo::from_wallet(&wallet) (static constructor, not instance method)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@key-wallet/README.md` around lines 74 - 201, The README code examples use
outdated API names and call sites: replace ManagedAccount with
ManagedCoreAccount (change import
key_wallet::managed_account::ManagedCoreAccount and use
ManagedCoreAccount::from_account(&account)); update address generation to call
next_receive_addresses(Some(&account.extended_public_key()), count,
add_to_state) instead of generate_receive_addresses; stop calling
wallet.create_account(...) — create accounts via Manager (use
Manager::create_account or the Manager instance method); for CoinJoin accounts
use the ManagedAccountType::CoinJoin address pools or call the managed account's
next_address() rather than derive_address_at_pool(); and replace
wallet.to_managed_wallet_info() with ManagedWalletInfo::from_wallet(&wallet).
Ensure all examples reference these symbols (ManagedCoreAccount,
next_receive_addresses, Manager::create_account, ManagedAccountType::CoinJoin /
next_address, ManagedWalletInfo::from_wallet) so they compile against the
refactored API.
♻️ Duplicate comments (1)
key-wallet/Cargo.toml (1)

48-49: ⚠️ Potential issue | 🟠 Major

Gate tokio and rayon behind the std feature for no_std compatibility.

The crate declares #![no_std] support in src/lib.rs, but both tokio and rayon require the standard library. While the code using these dependencies is already feature-gated with #[cfg(feature = "std")] (e.g., broadcast::Sender in manager/mod.rs and rayon in manager/matching.rs), the dependencies themselves are unconditional, which will pull in std even when the std feature is disabled.

🛠️ Proposed fix
-tokio = { version = "1", features = ["macros", "rt", "sync"] }
-rayon = { version = "1.11" }
+tokio = { version = "1", features = ["macros", "rt", "sync"], optional = true }
+rayon = { version = "1.11", optional = true }

Then update the std feature to include them:

-std = ["dashcore_hashes/std", "secp256k1/std", "bip39/std", "getrandom", "dash-network/std", "rand"]
+std = ["dashcore_hashes/std", "secp256k1/std", "bip39/std", "getrandom", "dash-network/std", "rand", "tokio", "rayon"]
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@key-wallet/Cargo.toml` around lines 48 - 49, Make the Cargo.toml
conditionalize the tokio and rayon dependencies behind the "std" feature so they
aren't pulled into no_std builds; update the dependency declarations for tokio
and rayon to be optional or feature-gated and add them to the "std" feature
list, ensuring the existing code guarded by #[cfg(feature = "std")] (e.g.,
usages like broadcast::Sender in manager::mod and rayon in manager::matching)
still compiles when "std" is enabled.
🧹 Nitpick comments (5)
key-wallet/src/test_utils/wallet.rs (2)

109-109: Use CoreBlockHeight type alias for consistency.

Same issue as MockWallet::process_block - use the type alias for consistency with the trait signature and other methods.

Suggested fix
-    async fn process_block(&mut self, _block: &Block, _height: u32) -> BlockProcessingResult {
+    async fn process_block(&mut self, _block: &Block, _height: CoreBlockHeight) -> BlockProcessingResult {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@key-wallet/src/test_utils/wallet.rs` at line 109, The process_block signature
in MockWallet uses a raw u32 for the height parameter; change the parameter type
to the CoreBlockHeight type alias to match the trait and other implementations
by updating async fn process_block(&mut self, _block: &Block, _height: u32) ->
BlockProcessingResult to use _height: CoreBlockHeight (keep parameter name and
async/return types unchanged) so the signature is consistent with the trait and
other methods.

55-55: Use CoreBlockHeight type alias for consistency.

The height parameter uses u32 directly, but the trait signature uses CoreBlockHeight (see wallet_interface.rs:40), and other methods in this impl (synced_height, update_synced_height) correctly use the type alias. Using the alias maintains consistency and adapts automatically if the underlying type changes.

Suggested fix
-    async fn process_block(&mut self, block: &Block, height: u32) -> BlockProcessingResult {
+    async fn process_block(&mut self, block: &Block, height: CoreBlockHeight) -> BlockProcessingResult {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@key-wallet/src/test_utils/wallet.rs` at line 55, The parameter type for
process_block currently uses u32; change it to the CoreBlockHeight type alias to
match the trait signature and other methods (e.g., synced_height,
update_synced_height) so the impl remains consistent and resilient to future
alias changes—update the function signature async fn process_block(&mut self,
block: &Block, height: CoreBlockHeight) -> BlockProcessingResult and adjust any
internal usages of height if necessary to compile.
key-wallet/src/manager/mod.rs (1)

1104-1137: Handle feature-gated crate::Error variants explicitly.

The fallback arm at Line 1135 now absorbs Error::Slip10 and Error::BLS whenever those features are enabled, and it will also silently genericize any future crate::Error variants. Please map those variants explicitly and drop the wildcard so this conversion stays intentional and compile-time checked.

♻️ Suggested direction
         match err {
             Error::InvalidMnemonic(msg) => WalletError::InvalidMnemonic(msg),
             Error::InvalidDerivationPath(msg) => {
                 WalletError::InvalidParameter(format!("Invalid derivation path: {}", msg))
             }
@@
             Error::Serialization(msg) => {
                 WalletError::InvalidParameter(format!("Serialization error: {}", msg))
             }
             Error::Bip32(e) => WalletError::AccountCreation(format!("BIP32 error: {}", e)),
+            #[cfg(feature = "eddsa")]
+            Error::Slip10(e) => WalletError::AccountCreation(format!("SLIP-0010 error: {}", e)),
+            #[cfg(feature = "bls")]
+            Error::BLS(e) => WalletError::AccountCreation(format!("BLS error: {}", e)),
             Error::Secp256k1(e) => WalletError::AccountCreation(format!("Secp256k1 error: {}", e)),
             Error::Base58 => WalletError::InvalidParameter("Base58 decoding error".to_string()),
             Error::NoKeySource => {
                 WalletError::InvalidParameter("No key source available".to_string())
             }
-            #[allow(unreachable_patterns)]
-            _ => WalletError::InvalidParameter(format!("Key wallet error: {}", err)),
         }
As per coding guidelines "Use proper error types (thiserror) and propagate errors appropriately".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@key-wallet/src/manager/mod.rs` around lines 1104 - 1137, The
From<crate::Error> impl for WalletError currently uses a wildcard arm that
swallows feature-gated variants (e.g., Error::Slip10, Error::BLS) and future
errors; update the match in the From<crate::Error> for WalletError (the
conversion function) to explicitly handle Error::Slip10 and Error::BLS (and any
other current crate::Error variants) with appropriate WalletError constructors
(e.g., map to WalletError::AccountCreation or WalletError::InvalidParameter as
appropriate), and remove the trailing wildcard arm so all crate::Error variants
are exhaustively matched at compile time.
key-wallet/README.md (2)

42-47: Add usage examples for the wallet manager.

The "Wallet Manager" subsection documents new functionality but lacks concrete usage examples. Consider adding a code example in the "Usage Examples" section showing how to use the manager module APIs (e.g., creating a WalletManager, managing multiple wallets, etc.).

Would you like me to draft an example usage section for the wallet manager functionality?

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@key-wallet/README.md` around lines 42 - 47, Add concrete usage examples for
the Wallet Manager by creating a short "Usage Examples" snippet that
demonstrates the manager module APIs: show instantiation of WalletManager (e.g.,
new WalletManager(...)), creating/managing multiple wallets (methods like
createWallet, importWallet, listWallets), configuring watch-only accounts and
BIP44 account creation (methods like enableWatchOnly, createBIP44Account), and
performing common ops (getBalance, sync, removeWallet). Place this example under
the "Usage Examples" section in README.md, use realistic argument placeholders
and brief comments to illustrate flow, and reference the WalletManager class and
its key methods so readers can map the example to the implementation.

22-22: Clarify that multi-wallet management is in the manager module.

The architecture point mentions multi-wallet management but doesn't indicate this functionality is provided by a specific module. Consider updating to reference the manager module explicitly.

📝 Suggested clarification
-- **Multi-wallet management**: Manages multiple wallets, each containing multiple accounts
+- **Multi-wallet management** (`manager` module): Manages multiple wallets, each containing multiple accounts
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@key-wallet/README.md` at line 22, Update the README bullet to state that
multi-wallet management is implemented in the manager module; specifically
change the line "**Multi-wallet management**: Manages multiple wallets, each
containing multiple accounts" to mention the manager module (e.g.,
"**Multi-wallet management (manager module)**: The manager module handles
multiple wallets, each containing multiple accounts") and optionally add a short
pointer to the manager module's API or docs for more details.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@key-wallet-ffi/src/error.rs`:
- Around line 194-196: Update the doc comment above the impl From for FFIError
to reference the moved type path key_wallet::manager::WalletError (instead of
key_wallet::WalletError); locate the impl From<key_wallet::manager::WalletError>
for FFIError and change the comment text to accurately state that it converts
key_wallet::manager::WalletError to FFIError so readers are pointed to the
correct API.

---

Outside diff comments:
In `@key-wallet/README.md`:
- Around line 226-236: The README's "Key Modules" list is missing the new
manager module; add an entry for `manager` alongside the other modules to
document the wallet manager functionality migrated from the key-wallet-manager
crate — update the Key Modules bullet list to include `manager`: Wallet manager
(e.g., "manager: Wallet manager and coordination of wallets/accounts") so
readers can find the module and its purpose.
- Around line 74-201: The README code examples use outdated API names and call
sites: replace ManagedAccount with ManagedCoreAccount (change import
key_wallet::managed_account::ManagedCoreAccount and use
ManagedCoreAccount::from_account(&account)); update address generation to call
next_receive_addresses(Some(&account.extended_public_key()), count,
add_to_state) instead of generate_receive_addresses; stop calling
wallet.create_account(...) — create accounts via Manager (use
Manager::create_account or the Manager instance method); for CoinJoin accounts
use the ManagedAccountType::CoinJoin address pools or call the managed account's
next_address() rather than derive_address_at_pool(); and replace
wallet.to_managed_wallet_info() with ManagedWalletInfo::from_wallet(&wallet).
Ensure all examples reference these symbols (ManagedCoreAccount,
next_receive_addresses, Manager::create_account, ManagedAccountType::CoinJoin /
next_address, ManagedWalletInfo::from_wallet) so they compile against the
refactored API.

---

Duplicate comments:
In `@key-wallet/Cargo.toml`:
- Around line 48-49: Make the Cargo.toml conditionalize the tokio and rayon
dependencies behind the "std" feature so they aren't pulled into no_std builds;
update the dependency declarations for tokio and rayon to be optional or
feature-gated and add them to the "std" feature list, ensuring the existing code
guarded by #[cfg(feature = "std")] (e.g., usages like broadcast::Sender in
manager::mod and rayon in manager::matching) still compiles when "std" is
enabled.

---

Nitpick comments:
In `@key-wallet/README.md`:
- Around line 42-47: Add concrete usage examples for the Wallet Manager by
creating a short "Usage Examples" snippet that demonstrates the manager module
APIs: show instantiation of WalletManager (e.g., new WalletManager(...)),
creating/managing multiple wallets (methods like createWallet, importWallet,
listWallets), configuring watch-only accounts and BIP44 account creation
(methods like enableWatchOnly, createBIP44Account), and performing common ops
(getBalance, sync, removeWallet). Place this example under the "Usage Examples"
section in README.md, use realistic argument placeholders and brief comments to
illustrate flow, and reference the WalletManager class and its key methods so
readers can map the example to the implementation.
- Line 22: Update the README bullet to state that multi-wallet management is
implemented in the manager module; specifically change the line "**Multi-wallet
management**: Manages multiple wallets, each containing multiple accounts" to
mention the manager module (e.g., "**Multi-wallet management (manager module)**:
The manager module handles multiple wallets, each containing multiple accounts")
and optionally add a short pointer to the manager module's API or docs for more
details.

In `@key-wallet/src/manager/mod.rs`:
- Around line 1104-1137: The From<crate::Error> impl for WalletError currently
uses a wildcard arm that swallows feature-gated variants (e.g., Error::Slip10,
Error::BLS) and future errors; update the match in the From<crate::Error> for
WalletError (the conversion function) to explicitly handle Error::Slip10 and
Error::BLS (and any other current crate::Error variants) with appropriate
WalletError constructors (e.g., map to WalletError::AccountCreation or
WalletError::InvalidParameter as appropriate), and remove the trailing wildcard
arm so all crate::Error variants are exhaustively matched at compile time.

In `@key-wallet/src/test_utils/wallet.rs`:
- Line 109: The process_block signature in MockWallet uses a raw u32 for the
height parameter; change the parameter type to the CoreBlockHeight type alias to
match the trait and other implementations by updating async fn
process_block(&mut self, _block: &Block, _height: u32) -> BlockProcessingResult
to use _height: CoreBlockHeight (keep parameter name and async/return types
unchanged) so the signature is consistent with the trait and other methods.
- Line 55: The parameter type for process_block currently uses u32; change it to
the CoreBlockHeight type alias to match the trait signature and other methods
(e.g., synced_height, update_synced_height) so the impl remains consistent and
resilient to future alias changes—update the function signature async fn
process_block(&mut self, block: &Block, height: CoreBlockHeight) ->
BlockProcessingResult and adjust any internal usages of height if necessary to
compile.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f133b11a-a075-4c24-b627-a4b0fbdbf750

📥 Commits

Reviewing files that changed from the base of the PR and between faf9db2 and 9db818d.

📒 Files selected for processing (62)
  • Cargo.toml
  • dash-spv-ffi/Cargo.toml
  • dash-spv-ffi/src/callbacks.rs
  • dash-spv-ffi/src/client.rs
  • dash-spv-ffi/tests/test_wallet_manager.rs
  • dash-spv/Cargo.toml
  • dash-spv/examples/filter_sync.rs
  • dash-spv/examples/simple_sync.rs
  • dash-spv/examples/spv_with_wallet.rs
  • dash-spv/src/client/core.rs
  • dash-spv/src/client/events.rs
  • dash-spv/src/client/lifecycle.rs
  • dash-spv/src/client/mempool.rs
  • dash-spv/src/client/mod.rs
  • dash-spv/src/client/queries.rs
  • dash-spv/src/client/sync_coordinator.rs
  • dash-spv/src/client/transactions.rs
  • dash-spv/src/lib.rs
  • dash-spv/src/main.rs
  • dash-spv/src/sync/blocks/manager.rs
  • dash-spv/src/sync/blocks/pipeline.rs
  • dash-spv/src/sync/blocks/sync_manager.rs
  • dash-spv/src/sync/events.rs
  • dash-spv/src/sync/filters/batch.rs
  • dash-spv/src/sync/filters/batch_tracker.rs
  • dash-spv/src/sync/filters/manager.rs
  • dash-spv/src/sync/filters/pipeline.rs
  • dash-spv/src/sync/filters/sync_manager.rs
  • dash-spv/src/sync/sync_coordinator.rs
  • dash-spv/src/validation/filter.rs
  • dash-spv/tests/dashd_sync/helpers.rs
  • dash-spv/tests/dashd_sync/setup.rs
  • dash-spv/tests/dashd_sync/tests_basic.rs
  • dash-spv/tests/peer_test.rs
  • dash-spv/tests/wallet_integration_test.rs
  • key-wallet-ffi/Cargo.toml
  • key-wallet-ffi/src/error.rs
  • key-wallet-ffi/src/transaction.rs
  • key-wallet-ffi/src/wallet_manager.rs
  • key-wallet-ffi/src/wallet_manager_tests.rs
  • key-wallet-ffi/tests/test_error_conversions.rs
  • key-wallet-manager/Cargo.toml
  • key-wallet-manager/README.md
  • key-wallet-manager/src/lib.rs
  • key-wallet-manager/src/test_utils/mod.rs
  • key-wallet-manager/src/test_utils/wallet.rs
  • key-wallet/Cargo.toml
  • key-wallet/README.md
  • key-wallet/TODO.md
  • key-wallet/examples/wallet_creation.rs
  • key-wallet/missing_tests.md
  • key-wallet/src/lib.rs
  • key-wallet/src/manager/events.rs
  • key-wallet/src/manager/matching.rs
  • key-wallet/src/manager/mod.rs
  • key-wallet/src/manager/process_block.rs
  • key-wallet/src/manager/wallet_interface.rs
  • key-wallet/src/test_utils/mod.rs
  • key-wallet/src/test_utils/wallet.rs
  • key-wallet/tests/integration_test.rs
  • key-wallet/tests/spv_integration_tests.rs
  • key-wallet/tests/test_serialized_wallets.rs
💤 Files with no reviewable changes (6)
  • key-wallet-manager/src/test_utils/mod.rs
  • dash-spv-ffi/Cargo.toml
  • key-wallet-manager/Cargo.toml
  • key-wallet-manager/README.md
  • key-wallet-manager/src/test_utils/wallet.rs
  • key-wallet-manager/src/lib.rs
✅ Files skipped from review due to trivial changes (2)
  • dash-spv/src/client/mempool.rs
  • dash-spv/src/sync/blocks/pipeline.rs
🚧 Files skipped from review as they are similar to previous changes (16)
  • key-wallet/src/lib.rs
  • dash-spv-ffi/src/client.rs
  • key-wallet-ffi/src/transaction.rs
  • dash-spv/src/sync/filters/batch_tracker.rs
  • dash-spv-ffi/src/callbacks.rs
  • dash-spv/src/sync/filters/pipeline.rs
  • dash-spv/src/sync/blocks/manager.rs
  • dash-spv/tests/dashd_sync/tests_basic.rs
  • dash-spv/src/sync/filters/batch.rs
  • key-wallet-ffi/Cargo.toml
  • key-wallet/tests/integration_test.rs
  • dash-spv-ffi/tests/test_wallet_manager.rs
  • key-wallet-ffi/src/wallet_manager.rs
  • dash-spv/examples/spv_with_wallet.rs
  • key-wallet/src/test_utils/mod.rs
  • dash-spv/tests/dashd_sync/helpers.rs

@ZocoLini ZocoLini force-pushed the refactor/manager-crate-moved branch from 9db818d to 6933ecd Compare March 9, 2026 18:29
@ZocoLini ZocoLini changed the title refactor(key-wallet-manager): )move key-wallet-manager crate into key-wallet refactor(key-wallet-manager): move key-wallet-manager crate into key-wallet Mar 9, 2026
@ZocoLini ZocoLini force-pushed the refactor/manager-crate-moved branch from 6933ecd to 158b247 Compare March 9, 2026 18:38
@github-actions github-actions bot added the merge-conflict The PR conflicts with the target branch. label Mar 10, 2026
@github-actions
Copy link

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

@ZocoLini ZocoLini force-pushed the refactor/manager-crate-moved branch from 158b247 to d356618 Compare March 10, 2026 16:50
@ZocoLini ZocoLini requested a review from xdustinface March 10, 2026 16:57
@github-actions github-actions bot removed the merge-conflict The PR conflicts with the target branch. label Mar 10, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
key-wallet/src/manager/mod.rs (1)

382-410: ⚠️ Potential issue | 🟠 Major

Reject imported xprvs whose network does not match the manager.

This import path inserts the derived wallet without checking that its embedded network matches self.network. A mainnet xprv can therefore be added to a testnet manager and later participate in the wrong address/filter flow.

Suggested fix
         let wallet = Wallet::from_extended_key(extended_priv_key, account_creation_options)
             .map_err(|e| WalletError::WalletCreation(e.to_string()))?;
+
+        if wallet.network != self.network {
+            return Err(WalletError::InvalidNetwork);
+        }
 
         // Compute wallet ID from the wallet's root public key
         let wallet_id = wallet.compute_wallet_id();

Please mirror the same guard in the xpub/bytes import entry points as well. As per coding guidelines, "Always validate network consistency when deriving or validating addresses; never mix mainnet and testnet operations".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@key-wallet/src/manager/mod.rs` around lines 382 - 410, In
import_wallet_from_extended_priv_key, after parsing the ExtendedPrivKey
(ExtendedPrivKey::from_str) and before creating the Wallet
(Wallet::from_extended_key), validate that the extended private key's network
equals the manager's network (self.network) and return an appropriate
WalletError (e.g., WalletError::InvalidParameter or a network-specific error) if
it does not match; apply the same network-consistency guard to the xpub and
raw-bytes import entry points (the corresponding import_xpub... /
import_wallet_from_bytes... functions) so no mainnet keys can be added to a
testnet manager or vice versa.
♻️ Duplicate comments (1)
key-wallet/Cargo.toml (1)

47-48: ⚠️ Potential issue | 🟠 Major

Gate tokio and rayon behind the std feature to preserve no_std compatibility.

Both tokio and rayon require the standard library, but they're added as unconditional dependencies while key-wallet declares no_std support. The manager module uses these dependencies unconditionally (e.g., rayon::prelude in matching.rs, tokio::sync::broadcast in mod.rs), which will break no_std builds.

Proposed fix
 [features]
 default = ["std"]
-std = ["dashcore_hashes/std", "secp256k1/std", "bip39/std", "getrandom", "rand"]
+std = ["dashcore_hashes/std", "secp256k1/std", "bip39/std", "getrandom", "rand", "tokio", "rayon"]
 ...
-tokio = { version = "1", features = ["macros", "rt", "sync"] }
-rayon = { version = "1.11" }
+tokio = { version = "1", features = ["macros", "rt", "sync"], optional = true }
+rayon = { version = "1.11", optional = true }

Additionally, the manager module declaration in lib.rs should be gated with #[cfg(feature = "std")].

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@key-wallet/Cargo.toml` around lines 47 - 48, Gate the tokio and rayon
dependencies behind the std feature in Cargo.toml (make them optional and
#[cfg(feature = "std")]-only consumers) and protect all uses in the manager
module: add #[cfg(feature = "std")] to the manager module declaration in lib.rs
and wrap std-only imports/usages in manager/mod.rs and manager/matching.rs
(e.g., rayon::prelude and tokio::sync::broadcast) with the same feature gate so
no_std builds never pull those symbols.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@key-wallet/missing_tests.md`:
- Around line 1-3: Update the checklist references to use the new module paths
under the reorganized key-wallet crate: replace any old top-level mentions of
wallet_manager.rs or wallet.rs with their post-move module paths (e.g.,
key_wallet::manager::wallet_manager or key_wallet::wallet::wallet) and verify
items that reference functions/structs (such as WalletManager, Wallet,
Manager::new, Wallet::load) use the fully qualified names in the new hierarchy;
scan the document for all occurrences of old paths and update them to
key_wallet::manager::* or key_wallet::wallet::* as appropriate so the checklist
matches the new module structure.

In `@key-wallet/src/manager/mod.rs`:
- Around line 12-35: The file currently imports std::collections::BTreeSet and
std::str::FromStr unconditionally which breaks no_std builds; either gate the
entire manager module behind the "std" feature by adding #[cfg(feature = "std")]
at the top of this manager module, or (preferably) add #[cfg(feature = "std")]
to the two problematic imports (the lines importing BTreeSet and FromStr) so
those symbols are only pulled in when feature = "std"; update any code that
depends on those imports accordingly (look for references to BTreeSet and
FromStr in this module such as usages in functions and types).

In `@README.md`:
- Around line 29-35: Remove the Git conflict markers (<<<<<<<, =======, >>>>>>>)
in the README table and resolve the merge by keeping the incoming change: the
"wallet" row should list only "key-wallet" (remove "key-wallet-manager"), and
the "ffi" row should list "dash-network-ffi, dash-spv-ffi, key-wallet-ffi";
ensure the codecov badge links remain unchanged and that there are no leftover
conflict markers anywhere in the file.

---

Outside diff comments:
In `@key-wallet/src/manager/mod.rs`:
- Around line 382-410: In import_wallet_from_extended_priv_key, after parsing
the ExtendedPrivKey (ExtendedPrivKey::from_str) and before creating the Wallet
(Wallet::from_extended_key), validate that the extended private key's network
equals the manager's network (self.network) and return an appropriate
WalletError (e.g., WalletError::InvalidParameter or a network-specific error) if
it does not match; apply the same network-consistency guard to the xpub and
raw-bytes import entry points (the corresponding import_xpub... /
import_wallet_from_bytes... functions) so no mainnet keys can be added to a
testnet manager or vice versa.

---

Duplicate comments:
In `@key-wallet/Cargo.toml`:
- Around line 47-48: Gate the tokio and rayon dependencies behind the std
feature in Cargo.toml (make them optional and #[cfg(feature = "std")]-only
consumers) and protect all uses in the manager module: add #[cfg(feature =
"std")] to the manager module declaration in lib.rs and wrap std-only
imports/usages in manager/mod.rs and manager/matching.rs (e.g., rayon::prelude
and tokio::sync::broadcast) with the same feature gate so no_std builds never
pull those symbols.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8fda84d9-c1ed-4311-9b47-6fb65fd5728d

📥 Commits

Reviewing files that changed from the base of the PR and between 9db818d and d356618.

📒 Files selected for processing (66)
  • .codecov.yml
  • .github/ci-groups.yml
  • Cargo.toml
  • README.md
  • dash-spv-ffi/Cargo.toml
  • dash-spv-ffi/src/callbacks.rs
  • dash-spv-ffi/src/client.rs
  • dash-spv-ffi/tests/test_wallet_manager.rs
  • dash-spv/Cargo.toml
  • dash-spv/examples/filter_sync.rs
  • dash-spv/examples/simple_sync.rs
  • dash-spv/examples/spv_with_wallet.rs
  • dash-spv/src/client/core.rs
  • dash-spv/src/client/events.rs
  • dash-spv/src/client/lifecycle.rs
  • dash-spv/src/client/mempool.rs
  • dash-spv/src/client/mod.rs
  • dash-spv/src/client/queries.rs
  • dash-spv/src/client/sync_coordinator.rs
  • dash-spv/src/client/transactions.rs
  • dash-spv/src/lib.rs
  • dash-spv/src/main.rs
  • dash-spv/src/sync/blocks/manager.rs
  • dash-spv/src/sync/blocks/pipeline.rs
  • dash-spv/src/sync/blocks/sync_manager.rs
  • dash-spv/src/sync/events.rs
  • dash-spv/src/sync/filters/batch.rs
  • dash-spv/src/sync/filters/batch_tracker.rs
  • dash-spv/src/sync/filters/manager.rs
  • dash-spv/src/sync/filters/pipeline.rs
  • dash-spv/src/sync/filters/sync_manager.rs
  • dash-spv/src/sync/sync_coordinator.rs
  • dash-spv/src/validation/filter.rs
  • dash-spv/tests/dashd_sync/helpers.rs
  • dash-spv/tests/dashd_sync/setup.rs
  • dash-spv/tests/dashd_sync/tests_basic.rs
  • dash-spv/tests/peer_test.rs
  • dash-spv/tests/wallet_integration_test.rs
  • key-wallet-ffi/Cargo.toml
  • key-wallet-ffi/src/error.rs
  • key-wallet-ffi/src/transaction.rs
  • key-wallet-ffi/src/wallet_manager.rs
  • key-wallet-ffi/src/wallet_manager_tests.rs
  • key-wallet-ffi/tests/test_error_conversions.rs
  • key-wallet-manager/Cargo.toml
  • key-wallet-manager/README.md
  • key-wallet-manager/src/lib.rs
  • key-wallet-manager/src/test_utils/mod.rs
  • key-wallet-manager/src/test_utils/wallet.rs
  • key-wallet/Cargo.toml
  • key-wallet/README.md
  • key-wallet/TODO.md
  • key-wallet/examples/wallet_creation.rs
  • key-wallet/missing_tests.md
  • key-wallet/src/lib.rs
  • key-wallet/src/manager/events.rs
  • key-wallet/src/manager/matching.rs
  • key-wallet/src/manager/mod.rs
  • key-wallet/src/manager/process_block.rs
  • key-wallet/src/manager/wallet_interface.rs
  • key-wallet/src/missing_tests.md
  • key-wallet/src/test_utils/mod.rs
  • key-wallet/src/test_utils/wallet.rs
  • key-wallet/tests/integration_test.rs
  • key-wallet/tests/spv_integration_tests.rs
  • key-wallet/tests/test_serialized_wallets.rs
💤 Files with no reviewable changes (10)
  • dash-spv-ffi/Cargo.toml
  • key-wallet-manager/README.md
  • key-wallet/src/missing_tests.md
  • .codecov.yml
  • .github/ci-groups.yml
  • key-wallet-manager/src/test_utils/wallet.rs
  • key-wallet/TODO.md
  • key-wallet-manager/Cargo.toml
  • key-wallet-manager/src/lib.rs
  • key-wallet-manager/src/test_utils/mod.rs
✅ Files skipped from review due to trivial changes (1)
  • dash-spv/src/lib.rs
🚧 Files skipped from review as they are similar to previous changes (26)
  • dash-spv/src/sync/filters/pipeline.rs
  • dash-spv/tests/dashd_sync/helpers.rs
  • dash-spv/src/sync/filters/sync_manager.rs
  • key-wallet/src/lib.rs
  • dash-spv/src/sync/events.rs
  • dash-spv/src/client/lifecycle.rs
  • key-wallet/examples/wallet_creation.rs
  • key-wallet/src/manager/events.rs
  • key-wallet-ffi/src/error.rs
  • key-wallet/tests/spv_integration_tests.rs
  • key-wallet-ffi/src/wallet_manager_tests.rs
  • dash-spv/examples/simple_sync.rs
  • dash-spv/src/client/transactions.rs
  • Cargo.toml
  • dash-spv/examples/filter_sync.rs
  • dash-spv/tests/peer_test.rs
  • dash-spv/src/client/sync_coordinator.rs
  • dash-spv/src/sync/filters/batch_tracker.rs
  • dash-spv/examples/spv_with_wallet.rs
  • dash-spv-ffi/src/callbacks.rs
  • key-wallet/src/test_utils/mod.rs
  • dash-spv/src/client/core.rs
  • key-wallet/src/test_utils/wallet.rs
  • key-wallet-ffi/Cargo.toml
  • dash-spv/src/client/events.rs
  • key-wallet-ffi/tests/test_error_conversions.rs

Comment on lines +1 to +3
# Missing Tests in key-wallet

## 1. WalletManager Multi-Wallet Tests (`wallet_manager.rs`)
## 1. WalletManager Multi-Wallet Tests
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify where the manager-related files live after the crate move.
# Expected: either the listed filenames still exist under key-wallet,
# or the search shows the new module paths that this doc should reference.

fd 'wallet_manager\.rs|transaction_builder\.rs|utxo\.rs|coin_selection\.rs|fee\.rs|integration_tests\.rs' .

printf '\n--- manager module declarations/usages ---\n'
rg -n --type=rust -C2 '\bmod manager\b|\bpub mod manager\b|\bkey_wallet::manager\b|\bWalletManager\b'

Repository: dashpay/rust-dashcore

Length of output: 50377


Verify that referenced module paths align with the new manager structure.

The files exist post-move under key-wallet, but are now organized as submodules within the manager and wallet hierarchies (e.g., wallet_manager.rs is now part of key_wallet::manager). Please confirm the checklist items reference the correct post-merge paths using the new module structure for clarity.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@key-wallet/missing_tests.md` around lines 1 - 3, Update the checklist
references to use the new module paths under the reorganized key-wallet crate:
replace any old top-level mentions of wallet_manager.rs or wallet.rs with their
post-move module paths (e.g., key_wallet::manager::wallet_manager or
key_wallet::wallet::wallet) and verify items that reference functions/structs
(such as WalletManager, Wallet, Manager::new, Wallet::load) use the fully
qualified names in the new hierarchy; scan the document for all occurrences of
old paths and update them to key_wallet::manager::* or key_wallet::wallet::* as
appropriate so the checklist matches the new module structure.

Comment on lines +12 to 35
mod events;
mod matching;
mod process_block;

pub use crate::wallet_manager::matching::{check_compact_filters_for_addresses, FilterMatchKey};
mod wallet_interface;

pub use events::WalletEvent;
pub use matching::{check_compact_filters_for_addresses, FilterMatchKey};
pub use wallet_interface::{BlockProcessingResult, WalletInterface};

use crate::account::AccountCollection;
use crate::transaction_checking::TransactionContext;
use crate::wallet::managed_wallet_info::transaction_building::AccountTypePreference;
use crate::wallet::managed_wallet_info::wallet_info_interface::WalletInfoInterface;
use crate::wallet::managed_wallet_info::{ManagedWalletInfo, TransactionRecord};
use crate::Utxo;
use crate::{Account, AccountType, Address, ExtendedPrivKey, Mnemonic, Network, Wallet};
use crate::{ExtendedPubKey, WalletCoreBalance};
use alloc::collections::BTreeMap;
use alloc::string::String;
use alloc::vec::Vec;
use dashcore::blockdata::transaction::Transaction;
use dashcore::prelude::CoreBlockHeight;
use key_wallet::account::AccountCollection;
use key_wallet::transaction_checking::TransactionContext;
use key_wallet::wallet::managed_wallet_info::transaction_building::AccountTypePreference;
use key_wallet::wallet::managed_wallet_info::wallet_info_interface::WalletInfoInterface;
use key_wallet::wallet::managed_wallet_info::{ManagedWalletInfo, TransactionRecord};
use key_wallet::wallet::WalletType;
use key_wallet::Utxo;
use key_wallet::{Account, AccountType, Address, ExtendedPrivKey, Mnemonic, Network, Wallet};
use key_wallet::{ExtendedPubKey, WalletCoreBalance};
use std::collections::BTreeSet;
use std::str::FromStr;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Gate the moved manager module for std or remove the remaining unconditional std imports.

This module is now part of key-wallet, but it still pulls in std::collections::BTreeSet / std::str::FromStr while the rest of the file is clearly written to support alloc and #[cfg(feature = "std")]. That will break the crate's no_std build as soon as manager is compiled there.

Suggested fix
-use std::collections::BTreeSet;
-use std::str::FromStr;
+use alloc::collections::BTreeSet;
+use core::str::FromStr;

As per coding guidelines, "Use conditional compilation with feature flags for optional features".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@key-wallet/src/manager/mod.rs` around lines 12 - 35, The file currently
imports std::collections::BTreeSet and std::str::FromStr unconditionally which
breaks no_std builds; either gate the entire manager module behind the "std"
feature by adding #[cfg(feature = "std")] at the top of this manager module, or
(preferably) add #[cfg(feature = "std")] to the two problematic imports (the
lines importing BTreeSet and FromStr) so those symbols are only pulled in when
feature = "std"; update any code that depends on those imports accordingly (look
for references to BTreeSet and FromStr in this module such as usages in
functions and types).

@ZocoLini ZocoLini force-pushed the refactor/manager-crate-moved branch from d356618 to 2e685ae Compare March 10, 2026 17:07
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
key-wallet/src/manager/mod.rs (1)

205-286: ⚠️ Potential issue | 🟠 Major

Do not export full wallets as raw bincode.

When downgrade_to_pubkey_wallet is false, Line 273 serializes the full Wallet, so this API still returns private key material as plain bytes. Please keep this API pubkey-only, or move full-wallet export behind an explicit encrypted-backup path instead.

🔐 Minimal guard
 pub fn create_wallet_from_mnemonic_return_serialized_bytes(
     &mut self,
     mnemonic: &str,
     passphrase: &str,
     birth_height: CoreBlockHeight,
     account_creation_options: crate::wallet::initialization::WalletAccountCreationOptions,
     downgrade_to_pubkey_wallet: bool,
     allow_external_signing: bool,
 ) -> Result<(Vec<u8>, WalletId), WalletError> {
+    if !downgrade_to_pubkey_wallet {
+        return Err(WalletError::InvalidParameter(
+            "serializing wallets with private key material is not supported".to_string(),
+        ));
+    }
+
     use crate::wallet::WalletType;
     use zeroize::Zeroize;

As per coding guidelines, "Never serialize or log private keys in production; use public keys or key fingerprints for identification instead".

♻️ Duplicate comments (2)
key-wallet/missing_tests.md (1)

1-3: ⚠️ Potential issue | 🟡 Minor

Update the checklist to match the post-move module layout.

After renaming this document to key-wallet, the checklist still points to the old filename-centric layout (wallet_manager.rs, transaction_builder.rs, etc.), which no longer reflects the manager-module structure introduced by this PR. Please rewrite these entries to reference the current key_wallet::manager / in-crate module locations so the doc stays actionable.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@key-wallet/missing_tests.md` around lines 1 - 3, Update the checklist entries
in this document to reference the new in-crate module layout instead of old
filename-centric names: replace mentions of files like wallet_manager.rs and
transaction_builder.rs with their module paths under key_wallet (e.g.,
key_wallet::manager::WalletManager, key_wallet::manager::TransactionBuilder or
other types now under key_wallet::manager), adjust any test targets to point to
the manager module tests, and ensure each checklist item maps to the current
public API symbols (e.g., WalletManager, TransactionBuilder methods) so the
checklist is actionable with the post-move module structure.
key-wallet/src/lib.rs (1)

46-46: ⚠️ Potential issue | 🟠 Major

Gate manager behind std.

This still exposes key_wallet::manager in no_std builds even though the moved module depends on std-only pieces. Please keep the public module behind feature = "std" until the manager code is actually no_std-safe.

🧩 Minimal fix
- pub mod manager;
+ #[cfg(feature = "std")]
+ pub mod manager;

As per coding guidelines, "Use conditional compilation with feature flags for optional features".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@key-wallet/src/lib.rs` at line 46, The public module declaration `pub mod
manager;` is exposed in no_std builds but depends on std; wrap that declaration
with conditional compilation so it is only compiled when the "std" feature is
enabled (use #[cfg(feature = "std")] on the `pub mod manager;` line), and add
#[cfg_attr(docsrs, doc(cfg(feature = "std")))] if you want the docs to show the
requirement; also make any uses or re-exports of `manager` conditional on the
same feature so nothing references it in no_std builds.
🧹 Nitpick comments (2)
key-wallet/src/manager/process_block.rs (1)

1-5: Import paths correctly updated for crate-internal references.

The import path changes align with the module restructuring. One minor style note: line 3 uses the full submodule path transaction_router::TransactionRouter, while TransactionRouter is re-exported directly from crate::transaction_checking (per mod.rs line 14). This is consistent with how TransactionContext is imported on line 4.

💡 Optional: Use re-exported path for consistency
-use crate::transaction_checking::transaction_router::TransactionRouter;
+use crate::transaction_checking::TransactionRouter;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@key-wallet/src/manager/process_block.rs` around lines 1 - 5, The import of
TransactionRouter should use the re-exported path for consistency with
TransactionContext: replace the explicit submodule import of
transaction_router::TransactionRouter with importing TransactionRouter directly
from crate::transaction_checking (same module used for TransactionContext) so
both types are imported via the same re-exported module; update the use
statement importing TransactionRouter at the top of process_block.rs
accordingly.
key-wallet-ffi/src/wallet_manager.rs (1)

470-494: Avoid drifting from the canonical WalletErrorFFIError conversion.

This partial match duplicates key-wallet-ffi/src/error.rs and the _ arm collapses any other WalletError variant into a generic wallet error. That makes the FFI contract drift as soon as WalletError changes again.

♻️ Possible simplification
         Err(e) => {
-            // Convert the error to FFI error
-            match e {
-                key_wallet::manager::WalletError::WalletExists(_) => {
-                    FFIError::set_error(
-                        error,
-                        FFIErrorCode::InvalidState,
-                        "Wallet already exists in the manager".to_string(),
-                    );
-                }
-                key_wallet::manager::WalletError::InvalidParameter(msg) => {
-                    FFIError::set_error(
-                        error,
-                        FFIErrorCode::SerializationError,
-                        format!("Failed to deserialize wallet: {}", msg),
-                    );
-                }
-                _ => {
-                    FFIError::set_error(
-                        error,
-                        FFIErrorCode::WalletError,
-                        format!("Failed to import wallet: {:?}", e),
-                    );
-                }
-            }
+            let ffi_error = match e {
+                key_wallet::manager::WalletError::InvalidParameter(msg) => FFIError::error(
+                    FFIErrorCode::SerializationError,
+                    format!("Failed to deserialize wallet: {}", msg),
+                ),
+                other => other.into(),
+            };
+            if !error.is_null() {
+                unsafe {
+                    *error = ffi_error;
+                }
+            }
             false
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@key-wallet-ffi/src/wallet_manager.rs` around lines 470 - 494, This code
duplicates and collapses WalletError mapping; instead of matching WalletError
variants inline, call the canonical converter in key-wallet-ffi/src/error.rs
that maps key_wallet::manager::WalletError into the proper FFIError/FFIErrorCode
and sets the provided error pointer (i.e., delegate to the shared
WalletError→FFI conversion helper rather than using the local match with
FFIError::set_error and the generic `_` arm) so all WalletError variants remain
covered centrally and future variants are handled consistently.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@key-wallet/tests/integration_test.rs`:
- Around line 6-7: The manager module is unconditionally exported but depends on
std; update the crate root so the manager module is only compiled when the std
feature is enabled by adding a cfg gate for feature = "std" before the pub mod
manager declaration (i.e., change the unconditional pub mod manager to be behind
#[cfg(feature = "std")]); also review uses of key_wallet::manager in integration
tests and either enable the std feature for those tests or gate the test imports
with #[cfg(feature = "std")] so references to WalletManager, WalletInterface,
and WalletError only occur when the std feature is active.

---

Duplicate comments:
In `@key-wallet/missing_tests.md`:
- Around line 1-3: Update the checklist entries in this document to reference
the new in-crate module layout instead of old filename-centric names: replace
mentions of files like wallet_manager.rs and transaction_builder.rs with their
module paths under key_wallet (e.g., key_wallet::manager::WalletManager,
key_wallet::manager::TransactionBuilder or other types now under
key_wallet::manager), adjust any test targets to point to the manager module
tests, and ensure each checklist item maps to the current public API symbols
(e.g., WalletManager, TransactionBuilder methods) so the checklist is actionable
with the post-move module structure.

In `@key-wallet/src/lib.rs`:
- Line 46: The public module declaration `pub mod manager;` is exposed in no_std
builds but depends on std; wrap that declaration with conditional compilation so
it is only compiled when the "std" feature is enabled (use #[cfg(feature =
"std")] on the `pub mod manager;` line), and add #[cfg_attr(docsrs,
doc(cfg(feature = "std")))] if you want the docs to show the requirement; also
make any uses or re-exports of `manager` conditional on the same feature so
nothing references it in no_std builds.

---

Nitpick comments:
In `@key-wallet-ffi/src/wallet_manager.rs`:
- Around line 470-494: This code duplicates and collapses WalletError mapping;
instead of matching WalletError variants inline, call the canonical converter in
key-wallet-ffi/src/error.rs that maps key_wallet::manager::WalletError into the
proper FFIError/FFIErrorCode and sets the provided error pointer (i.e., delegate
to the shared WalletError→FFI conversion helper rather than using the local
match with FFIError::set_error and the generic `_` arm) so all WalletError
variants remain covered centrally and future variants are handled consistently.

In `@key-wallet/src/manager/process_block.rs`:
- Around line 1-5: The import of TransactionRouter should use the re-exported
path for consistency with TransactionContext: replace the explicit submodule
import of transaction_router::TransactionRouter with importing TransactionRouter
directly from crate::transaction_checking (same module used for
TransactionContext) so both types are imported via the same re-exported module;
update the use statement importing TransactionRouter at the top of
process_block.rs accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ef79b28b-5a34-4681-8dc1-b1f21d868c23

📥 Commits

Reviewing files that changed from the base of the PR and between d356618 and 2e685ae.

📒 Files selected for processing (66)
  • .codecov.yml
  • .github/ci-groups.yml
  • Cargo.toml
  • README.md
  • dash-spv-ffi/Cargo.toml
  • dash-spv-ffi/src/callbacks.rs
  • dash-spv-ffi/src/client.rs
  • dash-spv-ffi/tests/test_wallet_manager.rs
  • dash-spv/Cargo.toml
  • dash-spv/examples/filter_sync.rs
  • dash-spv/examples/simple_sync.rs
  • dash-spv/examples/spv_with_wallet.rs
  • dash-spv/src/client/core.rs
  • dash-spv/src/client/events.rs
  • dash-spv/src/client/lifecycle.rs
  • dash-spv/src/client/mempool.rs
  • dash-spv/src/client/mod.rs
  • dash-spv/src/client/queries.rs
  • dash-spv/src/client/sync_coordinator.rs
  • dash-spv/src/client/transactions.rs
  • dash-spv/src/lib.rs
  • dash-spv/src/main.rs
  • dash-spv/src/sync/blocks/manager.rs
  • dash-spv/src/sync/blocks/pipeline.rs
  • dash-spv/src/sync/blocks/sync_manager.rs
  • dash-spv/src/sync/events.rs
  • dash-spv/src/sync/filters/batch.rs
  • dash-spv/src/sync/filters/batch_tracker.rs
  • dash-spv/src/sync/filters/manager.rs
  • dash-spv/src/sync/filters/pipeline.rs
  • dash-spv/src/sync/filters/sync_manager.rs
  • dash-spv/src/sync/sync_coordinator.rs
  • dash-spv/src/validation/filter.rs
  • dash-spv/tests/dashd_sync/helpers.rs
  • dash-spv/tests/dashd_sync/setup.rs
  • dash-spv/tests/dashd_sync/tests_basic.rs
  • dash-spv/tests/peer_test.rs
  • dash-spv/tests/wallet_integration_test.rs
  • key-wallet-ffi/Cargo.toml
  • key-wallet-ffi/src/error.rs
  • key-wallet-ffi/src/transaction.rs
  • key-wallet-ffi/src/wallet_manager.rs
  • key-wallet-ffi/src/wallet_manager_tests.rs
  • key-wallet-ffi/tests/test_error_conversions.rs
  • key-wallet-manager/Cargo.toml
  • key-wallet-manager/README.md
  • key-wallet-manager/src/lib.rs
  • key-wallet-manager/src/test_utils/mod.rs
  • key-wallet-manager/src/test_utils/wallet.rs
  • key-wallet/Cargo.toml
  • key-wallet/README.md
  • key-wallet/TODO.md
  • key-wallet/examples/wallet_creation.rs
  • key-wallet/missing_tests.md
  • key-wallet/src/lib.rs
  • key-wallet/src/manager/events.rs
  • key-wallet/src/manager/matching.rs
  • key-wallet/src/manager/mod.rs
  • key-wallet/src/manager/process_block.rs
  • key-wallet/src/manager/wallet_interface.rs
  • key-wallet/src/missing_tests.md
  • key-wallet/src/test_utils/mod.rs
  • key-wallet/src/test_utils/wallet.rs
  • key-wallet/tests/integration_test.rs
  • key-wallet/tests/spv_integration_tests.rs
  • key-wallet/tests/test_serialized_wallets.rs
💤 Files with no reviewable changes (10)
  • .github/ci-groups.yml
  • key-wallet/src/missing_tests.md
  • .codecov.yml
  • dash-spv-ffi/Cargo.toml
  • key-wallet-manager/src/test_utils/wallet.rs
  • key-wallet-manager/Cargo.toml
  • key-wallet-manager/src/test_utils/mod.rs
  • key-wallet/TODO.md
  • key-wallet-manager/README.md
  • key-wallet-manager/src/lib.rs
🚧 Files skipped from review as they are similar to previous changes (20)
  • dash-spv/src/sync/filters/pipeline.rs
  • dash-spv-ffi/src/callbacks.rs
  • dash-spv/src/lib.rs
  • key-wallet/src/manager/events.rs
  • key-wallet/src/test_utils/mod.rs
  • dash-spv/src/client/transactions.rs
  • key-wallet-ffi/Cargo.toml
  • dash-spv/tests/wallet_integration_test.rs
  • dash-spv/src/sync/filters/batch.rs
  • key-wallet-ffi/src/transaction.rs
  • dash-spv/src/validation/filter.rs
  • key-wallet/examples/wallet_creation.rs
  • Cargo.toml
  • key-wallet/tests/spv_integration_tests.rs
  • dash-spv/examples/filter_sync.rs
  • dash-spv-ffi/tests/test_wallet_manager.rs
  • dash-spv/src/main.rs
  • dash-spv/src/client/lifecycle.rs
  • key-wallet/src/test_utils/wallet.rs
  • key-wallet-ffi/tests/test_error_conversions.rs

Comment on lines +6 to +7
use key_wallet::manager::WalletInterface;
use key_wallet::manager::{WalletError, WalletManager};
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== key-wallet features =="
sed -n '/^\[features\]/,/^\[/p' key-wallet/Cargo.toml || true

echo
echo "== key-wallet crate attrs / manager export =="
rg -n -C3 '#!\[no_std\]|pub mod manager|mod manager|cfg\(feature *= *"std"\)|cfg\(not\(feature *= *"std"\)\)' \
  key-wallet/src/lib.rs

echo
echo "== manager module std-only usage =="
fd -e rs . key-wallet/src | xargs rg -n -C1 'tokio|std::|std::sync|cfg\(feature *= *"std"\)|cfg\(not\(feature *= *"std"\)\)' | \
  rg 'manager|wallet_manager|managed_wallet'

Repository: dashpay/rust-dashcore

Length of output: 7975


Gate key_wallet::manager behind the std feature to preserve no_std support.

The manager module is exported unconditionally at key-wallet/src/lib.rs:46 (pub mod manager;), but contains unconditional std imports that break compilation when the std feature is disabled. For example, manager/mod.rs has unconditional use std::collections::BTreeSet and use std::str::FromStr, while manager/matching.rs has unconditional use std::collections::{BTreeSet, HashMap}. This contradicts the crate's stated no_std support (the std feature is optional and not required by default in some contexts).

Change line 46 in key-wallet/src/lib.rs to:

#[cfg(feature = "std")]
pub mod manager;

This matches how other std-only functionality (like transaction building) is gated, and aligns with the coding guideline: "Use conditional compilation with feature flags for optional features."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@key-wallet/tests/integration_test.rs` around lines 6 - 7, The manager module
is unconditionally exported but depends on std; update the crate root so the
manager module is only compiled when the std feature is enabled by adding a cfg
gate for feature = "std" before the pub mod manager declaration (i.e., change
the unconditional pub mod manager to be behind #[cfg(feature = "std")]); also
review uses of key_wallet::manager in integration tests and either enable the
std feature for those tests or gate the test imports with #[cfg(feature =
"std")] so references to WalletManager, WalletInterface, and WalletError only
occur when the std feature is active.

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