Skip to content

Conversation

@QuantumExplorer
Copy link
Member

@QuantumExplorer QuantumExplorer commented Sep 29, 2025

Summary by CodeRabbit

  • New Features

    • Typed FFI wallet-manager handle with explicit free function; wallet-manager describe API returning C strings plus a string-free helper.
    • Client API to clear compact filters with matching storage and sync reset endpoints.
  • Improvements

    • More verbose logging when compact filters do not match.
  • Tests

    • New/expanded tests covering shared wallet manager, imports, and cross-FFI interactions.
  • Documentation

    • Updated FFI docs and examples reflecting the typed handle and lifecycle rules.
  • Chores

    • Updated external dependency revisions; removed an explicit git patch entry.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 29, 2025

Walkthrough

The PR introduces a typed FFIWalletManager handle returned by the SPV client, adds dash_spv_ffi_wallet_manager_free, adds wallet-manager describe/string-free FFI APIs, adds a clear_filters API across client/storage/sync, adjusts block-processor logging/lock timing, updates headers/docs/examples/tests, and bumps a few dependency revisions.

Changes

Cohort / File(s) Summary
Dash SPV FFI: typed wallet manager + lifecycle
dash-spv-ffi/FFI_API.md, dash-spv-ffi/dash_spv_ffi.h, dash-spv-ffi/include/dash_spv_ffi.h, dash-spv-ffi/src/client.rs, dash-spv-ffi/scripts/generate_ffi_docs.py, swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
dash_spv_ffi_client_get_wallet_manager now returns *mut FFIWalletManager (typed opaque handle) instead of void *; new dash_spv_ffi_wallet_manager_free(FFIWalletManager*) added; docs, headers and docgen updated.
Examples & SPV FFI tests
dash-spv-ffi/examples/wallet_manager_usage.rs, dash-spv-ffi/tests/test_wallet_manager.rs
Update examples/tests to use typed FFIWalletManager*; replace prior free with dash_spv_ffi_wallet_manager_free; exercise wallet import/IDs/describe helpers and adjust cleanup.
Key Wallet FFI: describe + string free
key-wallet-ffi/FFI_API.md, key-wallet-ffi/include/key_wallet_ffi.h, key-wallet-ffi/src/lib.rs, key-wallet-ffi/src/wallet_manager.rs, swift-dash-core-sdk/Sources/KeyWalletFFI/include/key_wallet_ffi.h
Add wallet_manager_describe(manager*, network, error) -> char* that returns an allocated C string and wallet_manager_free_string(char*) to free it; expose and document both.
WalletInterface & WalletManager description
key-wallet-manager/src/wallet_interface.rs, key-wallet-manager/src/wallet_manager/process_block.rs
Add async describe(&self, Network) -> String to WalletInterface (default impl) and implement for WalletManager to produce a human-readable wallet summary.
Filter reset API (client/storage/sync/tests)
dash-spv/src/client/mod.rs, dash-spv/src/storage/mod.rs, dash-spv/src/storage/disk.rs, dash-spv/src/storage/memory.rs, dash-spv/src/sync/filters.rs, dash-spv/tests/error_handling_test.rs, dash-spv/tests/error_recovery_integration_test.rs
Add StorageManager::clear_filters to trait and implementations (disk & memory); add FilterSyncManager::clear_filter_state; add DashSpvClient::clear_filters; update mocks/tests to implement/handle clear_filters.
BlockProcessor: logging & lock timing
dash-spv/src/client/block_processor.rs, dash-spv/src/client/block_processor_test.rs
Move wallet lock release after branch handling; on non-match await wallet.describe(network) for verbose debug; add describe to test wallet mocks.
FFI types
dash-spv-ffi/src/types.rs, dash-spv-ffi/include/dash_spv_ffi.h
Add opaque FFIWalletManager zero-sized handle type for C FFI.
Build / deps
Cargo.toml, dash-spv/Cargo.toml, dash/Cargo.toml
Remove git branch pin for elliptic-curve-tools in top-level Cargo.toml; update agora-blsful dependency commit in dash-spv/Cargo.toml and dash/Cargo.toml.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor App
  participant SPVFFI as dash-spv-ffi
  participant KWF as key-wallet-ffi

  App->>SPVFFI: dash_spv_ffi_client_get_wallet_manager(client)
  note right of SPVFFI #E8F5E9: returns typed FFIWalletManager* (cloned Arc)
  App->>KWF: wallet_manager_describe(manager*, network, &err)
  KWF-->>App: *char (C string) or null + error
  App->>KWF: wallet_manager_free_string(cstr)
  App->>SPVFFI: dash_spv_ffi_wallet_manager_free(manager*)
Loading
sequenceDiagram
  autonumber
  actor App
  participant Client as DashSpvClient
  participant Storage
  participant Sync as FilterSyncManager

  App->>Client: clear_filters()
  Client->>Storage: clear_filters()
  Storage-->>Client: Ok
  Client->>Sync: clear_filter_state()
  Sync-->>Client: done
  Client-->>App: Ok(())
  note over Client,Storage #F3F4F6: in-memory and persisted filter state cleared
Loading
sequenceDiagram
  autonumber
  participant BP as BlockProcessor
  participant Wallet

  BP->>Wallet: try match compact filter
  alt match
    BP-->>BP: normal processing
  else no match
    BP->>Wallet: await describe(network)
    Wallet-->>BP: description string
    BP-->>BP: debug log includes block hash + description
  end
  note over BP #FFF7E6: wallet lock released after branches
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Poem

A rabbit tweaks the FFI vine,
Typed handles bloom where voids once twined. 🐇
Strings narrate each wallet's line,
Filters cleared and logs aligned.
Hop, code—neat bindings now defined.

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title Check ❓ Inconclusive The title “feat: small fixes” is overly generic and does not convey the substantial FFI redesign and new API additions in this pull request, which primarily migrate the wallet manager FFI to a typed handle with an explicit free function and introduce clear_filters and describe methods across multiple modules. Please update the title to clearly reflect the main changes, for example “feat: migrate wallet manager FFI to typed handle with explicit free and add clear_filters API”.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/smallfixes

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 40cea47 and 827ae97.

📒 Files selected for processing (7)
  • dash-spv-ffi/include/dash_spv_ffi.h (2 hunks)
  • dash-spv-ffi/src/client.rs (3 hunks)
  • dash-spv-ffi/src/types.rs (1 hunks)
  • dash-spv-ffi/tests/test_wallet_manager.rs (2 hunks)
  • dash-spv/src/client/mod.rs (3 hunks)
  • swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h (2 hunks)
  • swift-dash-core-sdk/Sources/KeyWalletFFI/include/key_wallet_ffi.h (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • swift-dash-core-sdk/Sources/KeyWalletFFI/include/key_wallet_ffi.h
🧰 Additional context used
📓 Path-based instructions (10)
dash-spv-ffi/src/**/*.rs

📄 CodeRabbit inference engine (dash-spv-ffi/CLAUDE.md)

dash-spv-ffi/src/**/*.rs: FFI functions must be declared with #[no_mangle] extern "C"
Expose complex Rust types to C as opaque pointers (e.g., FFIDashSpvClient*)
Provide corresponding _destroy() functions for all FFI-owned types to enforce explicit memory management
Return Rust strings to C as *const c_char; allocate so the caller can free with dash_string_free
Accept input strings from C as *const c_char (borrowed; do not free inputs)
Functions returning pointers transfer ownership to the caller; functions taking pointers only borrow
Add cbindgen annotations for complex types so headers are generated correctly

Files:

  • dash-spv-ffi/src/types.rs
  • dash-spv-ffi/src/client.rs
**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.rs: Use proper error types with thiserror and propagate errors appropriately
Use the tokio runtime for async operations in Rust
Use conditional compilation feature flags for optional features (#[cfg(feature = ...)])
Format Rust code with cargo fmt (and enforce via cargo fmt --check)
Run clippy with -D warnings and fix all lints
Adhere to MSRV Rust 1.89 (avoid features requiring newer compiler)

**/*.rs: Format Rust code with rustfmt (per rustfmt.toml); run cargo fmt --all before commits
Lint with clippy; treat warnings as errors in CI
Follow Rust naming: snake_case for functions/variables, UpperCamelCase for types/traits, SCREAMING_SNAKE_CASE for consts
Prefer async using tokio where applicable

Files:

  • dash-spv-ffi/src/types.rs
  • dash-spv-ffi/src/client.rs
  • dash-spv/src/client/mod.rs
  • dash-spv-ffi/tests/test_wallet_manager.rs
{dash-network-ffi,dash-spv-ffi,key-wallet-ffi,swift-dash-core-sdk}/**/*.{rs,c,h,swift}

📄 CodeRabbit inference engine (CLAUDE.md)

Be careful with memory management at FFI boundaries (C/Swift interop)

Files:

  • dash-spv-ffi/src/types.rs
  • dash-spv-ffi/include/dash_spv_ffi.h
  • swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
  • dash-spv-ffi/src/client.rs
  • dash-spv-ffi/tests/test_wallet_manager.rs
**/src/**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

**/src/**/*.rs: Each crate keeps sources in src/
Avoid unwrap()/expect() in library code; use proper error types (e.g., thiserror)
Place unit tests alongside code with #[cfg(test)]

Files:

  • dash-spv-ffi/src/types.rs
  • dash-spv-ffi/src/client.rs
  • dash-spv/src/client/mod.rs
*-ffi/**

📄 CodeRabbit inference engine (AGENTS.md)

FFI bindings live in *-ffi crates

Files:

  • dash-spv-ffi/src/types.rs
  • dash-spv-ffi/include/dash_spv_ffi.h
  • dash-spv-ffi/src/client.rs
  • dash-spv-ffi/tests/test_wallet_manager.rs
dash-spv-ffi/include/dash_spv_ffi.h

📄 CodeRabbit inference engine (dash-spv-ffi/CLAUDE.md)

The public C header is generated; ensure it reflects FFI changes after builds

Files:

  • dash-spv-ffi/include/dash_spv_ffi.h
swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h

📄 CodeRabbit inference engine (swift-dash-core-sdk/CLAUDE.md)

After updating dash-spv-ffi, synchronize the generated header into the Swift SDK using ./sync-headers.sh so Sources/DashSPVFFI/include/dash_spv_ffi.h stays up to date

Files:

  • swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
swift-dash-core-sdk/**

📄 CodeRabbit inference engine (AGENTS.md)

Mobile SDK code resides in swift-dash-core-sdk/

Files:

  • swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
dash-spv/**/*.rs

📄 CodeRabbit inference engine (dash-spv/CLAUDE.md)

dash-spv/**/*.rs: Enforce Rust formatting via cargo fmt --check on all Rust source files
All code must be clippy-clean: run cargo clippy --all-targets --all-features -- -D warnings

Files:

  • dash-spv/src/client/mod.rs
**/tests/**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

Use proptest for property-based testing where appropriate

**/tests/**/*.rs: Integration tests must live under tests/ (e.g., rpc-integration-test)
Use descriptive test names (e.g., test_parse_address_mainnet) for integration tests
Mark network-dependent or long-running tests with #[ignore] and run with -- --ignored
Add regression tests for fixes; consider property tests (e.g., proptest) where valuable
Keep test vectors deterministic

Files:

  • dash-spv-ffi/tests/test_wallet_manager.rs
🧠 Learnings (17)
📓 Common learnings
Learnt from: DCG-Claude
PR: dashpay/rust-dashcore#0
File: :0-0
Timestamp: 2025-06-26T16:01:37.609Z
Learning: The mempool tracking infrastructure (UnconfirmedTransaction, MempoolState, configuration, and mempool_filter.rs) is fully implemented and integrated in the Dash SPV client as of this PR, including client logic, FFI APIs, and tests.
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/src/**/*.rs : Expose complex Rust types to C as opaque pointers (e.g., FFIDashSpvClient*)

Applied to files:

  • dash-spv-ffi/src/types.rs
  • dash-spv-ffi/src/client.rs
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/src/**/*.rs : Provide corresponding _destroy() functions for all FFI-owned types to enforce explicit memory management

Applied to files:

  • dash-spv-ffi/src/types.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/src/ffi/**/*.rs : Expose safe C FFI with #[no_mangle] extern "C" functions only for vetted APIs

Applied to files:

  • dash-spv-ffi/src/types.rs
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/src/**/*.rs : FFI functions must be declared with #[no_mangle] extern "C"

Applied to files:

  • dash-spv-ffi/src/types.rs
📚 Learning: 2025-08-29T04:00:14.154Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-29T04:00:14.154Z
Learning: Applies to {dash-network-ffi,dash-spv-ffi,key-wallet-ffi,swift-dash-core-sdk}/**/*.{rs,c,h,swift} : Be careful with memory management at FFI boundaries (C/Swift interop)

Applied to files:

  • dash-spv-ffi/src/types.rs
  • dash-spv-ffi/include/dash_spv_ffi.h
  • swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
  • dash-spv-ffi/src/client.rs
📚 Learning: 2025-08-21T05:01:58.949Z
Learnt from: QuantumExplorer
PR: dashpay/rust-dashcore#108
File: key-wallet-ffi/src/wallet_manager.rs:270-318
Timestamp: 2025-08-21T05:01:58.949Z
Learning: In the key-wallet-ffi design, wallets retrieved from the wallet manager via lookup functions should return const pointers (*const FFIWallet) to enforce read-only access and prevent unintended modifications. The wallet manager should control wallet lifecycle and mutations through specific APIs rather than allowing external mutation of retrieved wallet references.

Applied to files:

  • dash-spv-ffi/src/types.rs
  • dash-spv-ffi/include/dash_spv_ffi.h
  • swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
  • dash-spv-ffi/src/client.rs
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/include/dash_spv_ffi.h : The public C header is generated; ensure it reflects FFI changes after builds

Applied to files:

  • dash-spv-ffi/include/dash_spv_ffi.h
  • swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
📚 Learning: 2025-08-16T04:15:57.225Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: swift-dash-core-sdk/Examples/DashHDWalletExample/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:15:57.225Z
Learning: Applies to swift-dash-core-sdk/Examples/DashHDWalletExample/**/*.swift : When accessing SPV functionality, use DashSDK public APIs instead of direct client access; add public wrapper methods to DashSDK if needed

Applied to files:

  • swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
📚 Learning: 2025-08-16T04:15:29.335Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: swift-dash-core-sdk/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:15:29.335Z
Learning: Applies to swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h : After updating dash-spv-ffi, synchronize the generated header into the Swift SDK using ./sync-headers.sh so Sources/DashSPVFFI/include/dash_spv_ffi.h stays up to date

Applied to files:

  • swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
📚 Learning: 2025-06-26T16:01:37.609Z
Learnt from: DCG-Claude
PR: dashpay/rust-dashcore#0
File: :0-0
Timestamp: 2025-06-26T16:01:37.609Z
Learning: The mempool tracking infrastructure (UnconfirmedTransaction, MempoolState, configuration, and mempool_filter.rs) is fully implemented and integrated in the Dash SPV client as of this PR, including client logic, FFI APIs, and tests.

Applied to files:

  • dash-spv/src/client/mod.rs
📚 Learning: 2025-08-29T04:00:14.154Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-29T04:00:14.154Z
Learning: Applies to {dash-spv,rpc-integration-test}/tests/**/*.rs : Provide integration tests for network operations

Applied to files:

  • dash-spv/src/client/mod.rs
  • dash-spv-ffi/tests/test_wallet_manager.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/tests/**/*.rs : Include integration tests that cover full wallet workflows

Applied to files:

  • dash-spv/src/client/mod.rs
  • dash-spv-ffi/tests/test_wallet_manager.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/tests/**/*.rs : Keep test vectors in sync with Dash Core releases

Applied to files:

  • dash-spv/src/client/mod.rs
  • dash-spv-ffi/tests/test_wallet_manager.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/tests/bip32_tests.rs : Organize unit tests so key-derivation correctness lives in tests/bip32_tests.rs

Applied to files:

  • dash-spv-ffi/tests/test_wallet_manager.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/tests/mnemonic_tests.rs : Place mnemonic generation and validation tests in tests/mnemonic_tests.rs

Applied to files:

  • dash-spv-ffi/tests/test_wallet_manager.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/tests/address_tests.rs : Place address generation and validation tests in tests/address_tests.rs

Applied to files:

  • dash-spv-ffi/tests/test_wallet_manager.rs
🧬 Code graph analysis (5)
dash-spv-ffi/include/dash_spv_ffi.h (1)
dash-spv-ffi/src/client.rs (2)
  • dash_spv_ffi_client_get_wallet_manager (1503-1524)
  • dash_spv_ffi_wallet_manager_free (1536-1542)
swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h (1)
dash-spv-ffi/src/client.rs (2)
  • dash_spv_ffi_client_get_wallet_manager (1503-1524)
  • dash_spv_ffi_wallet_manager_free (1536-1542)
dash-spv-ffi/src/client.rs (1)
key-wallet-ffi/src/wallet_manager.rs (2)
  • from_arc (37-45)
  • wallet_manager_free (903-909)
dash-spv/src/client/mod.rs (5)
dash-spv/src/storage/mod.rs (2)
  • clear_filters (158-158)
  • stats (161-161)
dash-spv/src/storage/memory.rs (3)
  • clear_filters (310-314)
  • stats (316-376)
  • new (30-42)
dash-spv/src/storage/disk.rs (3)
  • clear_filters (1634-1653)
  • stats (1655-1686)
  • new (210-324)
dash-spv/src/types.rs (5)
  • default (57-70)
  • default (423-425)
  • default (572-601)
  • new (184-186)
  • new (880-900)
dash-spv/src/sync/filters.rs (1)
  • new (266-297)
dash-spv-ffi/tests/test_wallet_manager.rs (3)
key-wallet-ffi/src/wallet_manager.rs (5)
  • wallet_manager_free_wallet_ids (920-927)
  • wallet_manager_get_wallet_ids (516-555)
  • wallet_manager_import_wallet_from_bytes (433-504)
  • wallet_manager_describe (55-88)
  • wallet_manager_free_string (98-104)
dash-spv-ffi/src/client.rs (4)
  • dash_spv_ffi_wallet_manager_free (1536-1542)
  • dash_spv_ffi_client_destroy (1286-1324)
  • dash_spv_ffi_client_get_wallet_manager (1503-1524)
  • new (80-84)
dash-spv-ffi/src/config.rs (2)
  • dash_spv_ffi_config_destroy (345-354)
  • dash_spv_ffi_config_testnet (54-61)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
  • GitHub Check: fuzz (hashes_sha1)
  • GitHub Check: fuzz (dash_deserialize_script)
  • GitHub Check: fuzz (hashes_sha512_256)
  • GitHub Check: fuzz (hashes_cbor)
  • GitHub Check: fuzz (dash_deserialize_amount)
  • GitHub Check: fuzz (hashes_ripemd160)
  • GitHub Check: fuzz (hashes_sha512)
  • GitHub Check: fuzz (dash_deserialize_witness)
  • GitHub Check: fuzz (dash_deser_net_msg)
  • GitHub Check: fuzz (hashes_json)
  • GitHub Check: fuzz (dash_outpoint_string)
  • GitHub Check: RPC Tests (stable, true)
  • GitHub Check: SPV Components Tests
  • GitHub Check: Strict Warnings and Clippy Checks
  • GitHub Check: Core Components Tests
🔇 Additional comments (21)
dash-spv/src/client/mod.rs (3)

567-622: LGTM! Comprehensive test of wallet manager exposure.

The test validates:

  • Client correctly exposes the shared wallet manager via wallet()
  • Initial state (empty manager)
  • Wallet import from serialized bytes
  • Description reflects imported wallet

The test pattern (create temp manager, serialize, import, verify) is sound and covers the Arc<RwLock<>> sharing semantics.


549-558: LGTM! Clean test imports.

The added imports support the new wallet manager test and are all necessary.


122-156: LGTM: clear_filters correctly resets storage, in-memory state, sync manager, and stats, and the required async methods are present.

swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h (3)

164-173: LGTM! Correct opaque handle typedef.

The typedef properly defines the opaque handle with:

  • Zero-sized private array matching the Rust definition
  • Clear documentation explaining its purpose

543-560: LGTM! Typed pointer improves FFI safety.

The function now returns struct FFIWalletManager * instead of void *, providing better type safety at the C/FFI boundary. The documentation is clear about ownership and lifetime management.


562-573: No action needed: headers are synchronized.

dash-spv-ffi/src/types.rs (1)

7-15: Approve: opaque handle casting verified Casting in dash_spv_ffi_client_get_wallet_manager and dash_spv_ffi_wallet_manager_free correctly converts between FFIWalletManager and KeyWalletFFIWalletManager, so no further changes needed.

dash-spv-ffi/include/dash_spv_ffi.h (3)

164-173: LGTM! Opaque handle typedef properly introduced.

The zero-sized opaque struct typedef for FFIWalletManager is correctly placed before its use in function signatures, resolving the prior build-breaker concern. The documentation clearly explains the handle semantics.


543-560: LGTM! Typed wallet manager getter with clear lifetime docs.

The function signature now returns a typed struct FFIWalletManager* pointer, and the documentation clearly explains the wrapper semantics, Arc cloning behavior, and references the correct destructor (dash_spv_ffi_wallet_manager_free).


562-573: LGTM! Dedicated free function with proper forwarding.

The new dash_spv_ffi_wallet_manager_free function is well-documented, clearly states the forwarding to key-wallet-ffi, and includes appropriate safety notes about pointer validity and lifecycle management.

dash-spv-ffi/tests/test_wallet_manager.rs (8)

4-15: LGTM! Imports aligned with test requirements.

The new imports support native wallet creation, serialization, and FFI operations tested in the new test case. All imports are appropriately scoped and necessary.


41-44: LGTM! Cleanup updated to new API.

The test correctly uses dash_spv_ffi_wallet_manager_free instead of the old approach, and the cleanup order (manager → client → config) is appropriate.


47-58: LGTM! Test setup follows proper initialization pattern.

The test correctly creates a testnet config, initializes the client, retrieves the wallet manager, and validates all pointers before proceeding.


60-72: LGTM! Native wallet creation for test fixtures.

The test creates a wallet using the native WalletManager API with deterministic parameters (standard BIP-39 test mnemonic) and obtains both the serialized bytes and expected wallet ID for verification.


74-85: LGTM! FFI import validation with proper error handling.

The test imports the serialized wallet through the FFI boundary, checks the result, and validates that the imported wallet ID matches the expected value.


87-102: LGTM! Wallet ID retrieval and validation with proper cleanup.

The test correctly:

  • Fetches wallet IDs via FFI
  • Validates the count and pointer
  • Verifies the imported wallet ID
  • Frees the IDs buffer with the appropriate destructor

104-118: LGTM! Describe helper validation with proper string cleanup.

The test uses the wallet_manager_describe FFI function to verify the shared wallet manager state, properly checks for success, validates the description content, and frees the returned string.


120-123: LGTM! Complete resource cleanup.

All FFI resources (wallet manager, client, config) are properly freed in the correct order.

dash-spv-ffi/src/client.rs (3)

1-6: LGTM! Type imports and alias for FFI clarity.

The addition of FFIWalletManager to the crate's type list and the KeyWalletFFIWalletManager alias from key_wallet_ffi properly distinguish the local opaque handle from the key-wallet implementation, preventing name conflicts.


1486-1524: LGTM! Typed wallet manager getter with proper Arc semantics.

The function correctly:

  • Returns a typed *mut FFIWalletManager instead of void*
  • Clones the Arc to the wallet manager for independent lifetime management
  • Constructs the wrapper using KeyWalletFFIWalletManager::from_arc
  • Includes comprehensive documentation referencing the correct destructor
  • Handles null client state appropriately

1526-1542: LGTM! Dedicated free function with proper forwarding.

The new dash_spv_ffi_wallet_manager_free function:

  • Properly handles null pointers
  • Correctly casts and forwards to key_wallet_ffi::wallet_manager::wallet_manager_free
  • Maintains consistent lifetime management across FFI boundaries
  • Includes clear documentation of ownership semantics

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
🧪 Early access (Sonnet 4.5): enabled

We are currently testing the Sonnet 4.5 model, which is expected to improve code review quality. However, this model may lead to increased noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience.

Note:

  • Public repositories are always opted into early access features.
  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.

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

Caution

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

⚠️ Outside diff range comments (2)
dash-spv/src/client/block_processor.rs (1)

178-200: Avoid holding the write lock across async calls
Refactor block_processor.rs so that self.wallet.write().await is only held for check_compact_filter, then dropped before any further .await (e.g., wallet.describe), using a read lock for logging if needed.

dash-spv-ffi/scripts/generate_ffi_docs.py (1)

290-324: Document the matching dash_spv_ffi_wallet_manager_free call in the example.

The example now advertises a shared-ownership FFIWalletManager*, but it never shows the mandatory dash_spv_ffi_wallet_manager_free(wallet_manager); call. That contradicts the new bullet point and will leak the handle for anyone following the snippet verbatim. Please add the free call (ideally before destroying the client) so the docs stay self-consistent with the API contract.

🧹 Nitpick comments (9)
key-wallet-manager/src/wallet_manager/process_block.rs (2)

142-165: New describe() API: solid; consider stable ordering and simpler hex formatting.

  • For predictable logs across runs, sort details by name or wallet_id before join.
  • Hex encode wallet_id via a helper (e.g., hashes::hex::ToHex) to avoid manual write loop if available under your no_std profile.
-        for (wallet_id, info) in &self.wallet_infos {
+        let mut entries: Vec<_> = self.wallet_infos.iter().collect();
+        entries.sort_by_key(|(id, info)| info.name().unwrap_or("unnamed"));
+        for (wallet_id, info) in entries {
             let name = info.name().unwrap_or("unnamed");
-            let mut wallet_id_hex = String::with_capacity(wallet_id.len() * 2);
-            for byte in wallet_id {
-                let _ = write!(&mut wallet_id_hex, "{:02x}", byte);
-            }
+            let mut wallet_id_hex = String::with_capacity(wallet_id.len() * 2);
+            for byte in wallet_id { let _ = write!(&mut wallet_id_hex, "{:02x}", byte); }
             let script_count = info.monitored_addresses(network).len();
             let summary = format!("{} scripts", script_count);
             details.push(format!("{} ({}): {}", name, wallet_id_hex, summary));
         }

96-116: Avoid silently swallowing filter matching errors.

Using unwrap_or(false) suppresses why matching failed. Log at least at debug when an error occurs to aid diagnosis.

-            filter
-                .match_any(block_hash, &mut script_bytes.iter().map(|s| s.as_slice()))
-                .unwrap_or(false)
+            match filter.match_any(block_hash, &mut script_bytes.iter().map(|s| s.as_slice())) {
+                Ok(v) => v,
+                Err(e) => { tracing::debug!("compact-filter match_any error for {}: {}", block_hash, e); false }
+            }
swift-dash-core-sdk/Sources/KeyWalletFFI/include/key_wallet_ffi.h (1)

3730-3748: New wallet_manager_describe/free_string look good; ensure callers use the right freer.

Swift/FFI callers must pair wallet_manager_describe() with wallet_manager_free_string(). Optionally document that string_free is equivalent to avoid confusion.

dash-spv/src/sync/filters.rs (1)

3470-3476: Scope and verbosity nits for clear_filter_state

Consider reducing API surface and log noise:

  • Make method crate-visible; it’s only used internally by the client reset path.
  • Downgrade the log to debug to avoid info-level chatter during resets.
-    pub async fn clear_filter_state(&mut self) {
+    pub(crate) async fn clear_filter_state(&mut self) {
         self.reset_pending_requests();
         let mut heights = self.received_filter_heights.lock().await;
         heights.clear();
-        tracing::info!("Cleared filter sync state and received heights");
+        tracing::debug!("Cleared filter sync state and received heights");
     }
key-wallet-ffi/include/key_wallet_ffi.h (1)

3730-3748: Avoid duplicating string free APIs; document or alias to string_free for consistency.

wallet_manager_free_string duplicates string_free semantics (both free CString::from_raw). Prefer reusing string_free or explicitly documenting they are equivalent to reduce surface area and prevent misuse across crates. If keeping both, consider making one an alias in C headers to avoid divergence.
Based on learnings

dash-spv-ffi/tests/test_wallet_manager.rs (1)

47-123: Good cross-FFI coverage and cleanup ordering

Solid end-to-end: native wallet serialize → FFI import → list/describe → free/destroy. Cleanup order is correct and error paths are checked.

Minor robustness ideas (optional):

  • Consider asserting description_error is success before deref.
  • If future tests pre-populate wallets, assert inclusion of expected_wallet_id rather than strict count.
key-wallet-ffi/src/wallet_manager.rs (3)

65-68: Avoid unnecessary Arc clones

You can borrow the Arcs instead of cloning to avoid atomic inc/dec and reduce noise.

Apply:

-    let runtime = manager_ref.runtime.clone();
-    let manager_arc = manager_ref.manager.clone();
+    let runtime = &manager_ref.runtime;
+    let manager_arc = &manager_ref.manager;

70-72: Don’t hold an RwLock across an .await

let guard = manager_arc.read().await; guard.describe(...).await holds a read guard over an await point, which can starve writers and complicate scheduling. Prefer taking a snapshot outside the lock or refactoring describe to avoid borrowing &self across await (e.g., a describe_snapshot that builds owned data under the lock, then formats without the lock).

Confirm describe does not perform operations that might indirectly require a write lock while this read lock is held.


92-98: Ergonomics: accept *const c_char in free to avoid caller casts

C headers usually expose frees as taking const char* to spare callers from casting. Internally you can cast back to *mut for from_raw.

Apply:

-#[no_mangle]
-pub unsafe extern "C" fn wallet_manager_free_string(value: *mut c_char) {
+#[no_mangle]
+pub unsafe extern "C" fn wallet_manager_free_string(value: *const c_char) {
     if value.is_null() {
         return;
     }
 
-    drop(CString::from_raw(value));
+    drop(CString::from_raw(value as *mut c_char));
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c44c91b and af64bc4.

📒 Files selected for processing (24)
  • dash-spv-ffi/FFI_API.md (8 hunks)
  • dash-spv-ffi/dash_spv_ffi.h (1 hunks)
  • dash-spv-ffi/examples/wallet_manager_usage.rs (3 hunks)
  • dash-spv-ffi/include/dash_spv_ffi.h (1 hunks)
  • dash-spv-ffi/scripts/generate_ffi_docs.py (2 hunks)
  • dash-spv-ffi/src/client.rs (2 hunks)
  • dash-spv-ffi/tests/test_wallet_manager.rs (2 hunks)
  • dash-spv/src/client/block_processor.rs (1 hunks)
  • dash-spv/src/client/block_processor_test.rs (2 hunks)
  • dash-spv/src/client/mod.rs (3 hunks)
  • dash-spv/src/storage/disk.rs (1 hunks)
  • dash-spv/src/storage/memory.rs (1 hunks)
  • dash-spv/src/storage/mod.rs (1 hunks)
  • dash-spv/src/sync/filters.rs (1 hunks)
  • dash-spv/tests/error_handling_test.rs (1 hunks)
  • dash-spv/tests/error_recovery_integration_test.rs (1 hunks)
  • key-wallet-ffi/FFI_API.md (5 hunks)
  • key-wallet-ffi/include/key_wallet_ffi.h (1 hunks)
  • key-wallet-ffi/src/lib.rs (1 hunks)
  • key-wallet-ffi/src/wallet_manager.rs (2 hunks)
  • key-wallet-manager/src/wallet_interface.rs (2 hunks)
  • key-wallet-manager/src/wallet_manager/process_block.rs (2 hunks)
  • swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h (1 hunks)
  • swift-dash-core-sdk/Sources/KeyWalletFFI/include/key_wallet_ffi.h (1 hunks)
🧰 Additional context used
📓 Path-based instructions (13)
dash-spv/**/*.rs

📄 CodeRabbit inference engine (dash-spv/CLAUDE.md)

dash-spv/**/*.rs: Enforce Rust formatting via cargo fmt --check on all Rust source files
All code must be clippy-clean: run cargo clippy --all-targets --all-features -- -D warnings

Files:

  • dash-spv/src/storage/mod.rs
  • dash-spv/src/sync/filters.rs
  • dash-spv/tests/error_recovery_integration_test.rs
  • dash-spv/src/client/block_processor.rs
  • dash-spv/src/storage/memory.rs
  • dash-spv/src/storage/disk.rs
  • dash-spv/src/client/mod.rs
  • dash-spv/src/client/block_processor_test.rs
  • dash-spv/tests/error_handling_test.rs
dash-spv/src/storage/**/*.rs

📄 CodeRabbit inference engine (dash-spv/CLAUDE.md)

Provide both MemoryStorageManager and DiskStorageManager behind the StorageManager trait

Files:

  • dash-spv/src/storage/mod.rs
  • dash-spv/src/storage/memory.rs
  • dash-spv/src/storage/disk.rs
**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.rs: Use proper error types with thiserror and propagate errors appropriately
Use the tokio runtime for async operations in Rust
Use conditional compilation feature flags for optional features (#[cfg(feature = ...)])
Format Rust code with cargo fmt (and enforce via cargo fmt --check)
Run clippy with -D warnings and fix all lints
Adhere to MSRV Rust 1.89 (avoid features requiring newer compiler)

**/*.rs: Format Rust code with rustfmt (per rustfmt.toml); run cargo fmt --all before commits
Lint with clippy; treat warnings as errors in CI
Follow Rust naming: snake_case for functions/variables, UpperCamelCase for types/traits, SCREAMING_SNAKE_CASE for consts
Prefer async using tokio where applicable

Files:

  • dash-spv/src/storage/mod.rs
  • dash-spv/src/sync/filters.rs
  • dash-spv/tests/error_recovery_integration_test.rs
  • dash-spv/src/client/block_processor.rs
  • key-wallet-ffi/src/lib.rs
  • dash-spv/src/storage/memory.rs
  • dash-spv/src/storage/disk.rs
  • key-wallet-manager/src/wallet_manager/process_block.rs
  • dash-spv/src/client/mod.rs
  • key-wallet-manager/src/wallet_interface.rs
  • key-wallet-ffi/src/wallet_manager.rs
  • dash-spv-ffi/src/client.rs
  • dash-spv-ffi/examples/wallet_manager_usage.rs
  • dash-spv-ffi/tests/test_wallet_manager.rs
  • dash-spv/src/client/block_processor_test.rs
  • dash-spv/tests/error_handling_test.rs
**/src/**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

**/src/**/*.rs: Each crate keeps sources in src/
Avoid unwrap()/expect() in library code; use proper error types (e.g., thiserror)
Place unit tests alongside code with #[cfg(test)]

Files:

  • dash-spv/src/storage/mod.rs
  • dash-spv/src/sync/filters.rs
  • dash-spv/src/client/block_processor.rs
  • key-wallet-ffi/src/lib.rs
  • dash-spv/src/storage/memory.rs
  • dash-spv/src/storage/disk.rs
  • key-wallet-manager/src/wallet_manager/process_block.rs
  • dash-spv/src/client/mod.rs
  • key-wallet-manager/src/wallet_interface.rs
  • key-wallet-ffi/src/wallet_manager.rs
  • dash-spv-ffi/src/client.rs
  • dash-spv/src/client/block_processor_test.rs
{dash-network-ffi,dash-spv-ffi,key-wallet-ffi,swift-dash-core-sdk}/**/*.{rs,c,h,swift}

📄 CodeRabbit inference engine (CLAUDE.md)

Be careful with memory management at FFI boundaries (C/Swift interop)

Files:

  • swift-dash-core-sdk/Sources/KeyWalletFFI/include/key_wallet_ffi.h
  • key-wallet-ffi/include/key_wallet_ffi.h
  • key-wallet-ffi/src/lib.rs
  • key-wallet-ffi/src/wallet_manager.rs
  • dash-spv-ffi/src/client.rs
  • dash-spv-ffi/dash_spv_ffi.h
  • dash-spv-ffi/examples/wallet_manager_usage.rs
  • dash-spv-ffi/tests/test_wallet_manager.rs
  • dash-spv-ffi/include/dash_spv_ffi.h
  • swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
swift-dash-core-sdk/**

📄 CodeRabbit inference engine (AGENTS.md)

Mobile SDK code resides in swift-dash-core-sdk/

Files:

  • swift-dash-core-sdk/Sources/KeyWalletFFI/include/key_wallet_ffi.h
  • swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
dash-spv/tests/**/*.rs

📄 CodeRabbit inference engine (dash-spv/CLAUDE.md)

Place integration tests under the tests/ directory

Files:

  • dash-spv/tests/error_recovery_integration_test.rs
  • dash-spv/tests/error_handling_test.rs
{dash-spv,rpc-integration-test}/tests/**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

Provide integration tests for network operations

Files:

  • dash-spv/tests/error_recovery_integration_test.rs
  • dash-spv/tests/error_handling_test.rs
**/tests/**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

Use proptest for property-based testing where appropriate

**/tests/**/*.rs: Integration tests must live under tests/ (e.g., rpc-integration-test)
Use descriptive test names (e.g., test_parse_address_mainnet) for integration tests
Mark network-dependent or long-running tests with #[ignore] and run with -- --ignored
Add regression tests for fixes; consider property tests (e.g., proptest) where valuable
Keep test vectors deterministic

Files:

  • dash-spv/tests/error_recovery_integration_test.rs
  • dash-spv-ffi/tests/test_wallet_manager.rs
  • dash-spv/tests/error_handling_test.rs
*-ffi/**

📄 CodeRabbit inference engine (AGENTS.md)

FFI bindings live in *-ffi crates

Files:

  • key-wallet-ffi/include/key_wallet_ffi.h
  • dash-spv-ffi/FFI_API.md
  • key-wallet-ffi/src/lib.rs
  • key-wallet-ffi/FFI_API.md
  • key-wallet-ffi/src/wallet_manager.rs
  • dash-spv-ffi/src/client.rs
  • dash-spv-ffi/dash_spv_ffi.h
  • dash-spv-ffi/examples/wallet_manager_usage.rs
  • dash-spv-ffi/tests/test_wallet_manager.rs
  • dash-spv-ffi/include/dash_spv_ffi.h
  • dash-spv-ffi/scripts/generate_ffi_docs.py
dash-spv-ffi/src/**/*.rs

📄 CodeRabbit inference engine (dash-spv-ffi/CLAUDE.md)

dash-spv-ffi/src/**/*.rs: FFI functions must be declared with #[no_mangle] extern "C"
Expose complex Rust types to C as opaque pointers (e.g., FFIDashSpvClient*)
Provide corresponding _destroy() functions for all FFI-owned types to enforce explicit memory management
Return Rust strings to C as *const c_char; allocate so the caller can free with dash_string_free
Accept input strings from C as *const c_char (borrowed; do not free inputs)
Functions returning pointers transfer ownership to the caller; functions taking pointers only borrow
Add cbindgen annotations for complex types so headers are generated correctly

Files:

  • dash-spv-ffi/src/client.rs
dash-spv-ffi/include/dash_spv_ffi.h

📄 CodeRabbit inference engine (dash-spv-ffi/CLAUDE.md)

The public C header is generated; ensure it reflects FFI changes after builds

Files:

  • dash-spv-ffi/include/dash_spv_ffi.h
swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h

📄 CodeRabbit inference engine (swift-dash-core-sdk/CLAUDE.md)

After updating dash-spv-ffi, synchronize the generated header into the Swift SDK using ./sync-headers.sh so Sources/DashSPVFFI/include/dash_spv_ffi.h stays up to date

Files:

  • swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
🧠 Learnings (36)
📓 Common learnings
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/src/{managed_account,transaction_checking}/**/*.rs : Update wallet state atomically: add transaction, update UTXOs, recalculate balance, and mark addresses used in a single operation
Learnt from: QuantumExplorer
PR: dashpay/rust-dashcore#108
File: key-wallet-ffi/src/wallet_manager.rs:270-318
Timestamp: 2025-08-21T05:01:58.949Z
Learning: In the key-wallet-ffi design, wallets retrieved from the wallet manager via lookup functions should return const pointers (*const FFIWallet) to enforce read-only access and prevent unintended modifications. The wallet manager should control wallet lifecycle and mutations through specific APIs rather than allowing external mutation of retrieved wallet references.
Learnt from: DCG-Claude
PR: dashpay/rust-dashcore#0
File: :0-0
Timestamp: 2025-06-26T16:01:37.609Z
Learning: The mempool tracking infrastructure (UnconfirmedTransaction, MempoolState, configuration, and mempool_filter.rs) is fully implemented and integrated in the Dash SPV client as of this PR, including client logic, FFI APIs, and tests.
📚 Learning: 2025-08-25T17:15:59.361Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-08-25T17:15:59.361Z
Learning: Applies to dash-spv/src/storage/**/*.rs : Provide both `MemoryStorageManager` and `DiskStorageManager` behind the `StorageManager` trait

Applied to files:

  • dash-spv/src/storage/mod.rs
  • dash-spv/tests/error_recovery_integration_test.rs
  • dash-spv/src/storage/memory.rs
  • dash-spv/src/storage/disk.rs
  • dash-spv/src/client/mod.rs
  • dash-spv/tests/error_handling_test.rs
📚 Learning: 2025-06-26T15:54:02.509Z
Learnt from: DCG-Claude
PR: dashpay/rust-dashcore#0
File: :0-0
Timestamp: 2025-06-26T15:54:02.509Z
Learning: The `StorageManager` trait in `dash-spv/src/storage/mod.rs` uses `&mut self` methods but is also `Send + Sync`, and implementations often use interior mutability for concurrency. This can be confusing, so explicit documentation should clarify thread-safety expectations and the rationale for the API design.

Applied to files:

  • dash-spv/src/storage/mod.rs
  • dash-spv/tests/error_recovery_integration_test.rs
  • dash-spv/src/storage/memory.rs
  • dash-spv/src/storage/disk.rs
  • dash-spv/src/client/mod.rs
  • dash-spv/tests/error_handling_test.rs
📚 Learning: 2025-08-21T05:01:58.949Z
Learnt from: QuantumExplorer
PR: dashpay/rust-dashcore#108
File: key-wallet-ffi/src/wallet_manager.rs:270-318
Timestamp: 2025-08-21T05:01:58.949Z
Learning: In the key-wallet-ffi design, wallets retrieved from the wallet manager via lookup functions should return const pointers (*const FFIWallet) to enforce read-only access and prevent unintended modifications. The wallet manager should control wallet lifecycle and mutations through specific APIs rather than allowing external mutation of retrieved wallet references.

Applied to files:

  • swift-dash-core-sdk/Sources/KeyWalletFFI/include/key_wallet_ffi.h
  • key-wallet-ffi/include/key_wallet_ffi.h
  • dash-spv-ffi/FFI_API.md
  • key-wallet-ffi/src/lib.rs
  • key-wallet-ffi/FFI_API.md
  • key-wallet-ffi/src/wallet_manager.rs
  • dash-spv-ffi/src/client.rs
  • dash-spv-ffi/dash_spv_ffi.h
  • dash-spv-ffi/examples/wallet_manager_usage.rs
  • dash-spv-ffi/tests/test_wallet_manager.rs
  • dash-spv-ffi/include/dash_spv_ffi.h
  • dash-spv-ffi/scripts/generate_ffi_docs.py
  • swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
📚 Learning: 2025-08-29T04:00:14.154Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-29T04:00:14.154Z
Learning: Applies to {dash-network-ffi,dash-spv-ffi,key-wallet-ffi,swift-dash-core-sdk}/**/*.{rs,c,h,swift} : Be careful with memory management at FFI boundaries (C/Swift interop)

Applied to files:

  • swift-dash-core-sdk/Sources/KeyWalletFFI/include/key_wallet_ffi.h
  • dash-spv-ffi/FFI_API.md
  • dash-spv-ffi/src/client.rs
  • dash-spv-ffi/dash_spv_ffi.h
  • dash-spv-ffi/examples/wallet_manager_usage.rs
  • dash-spv-ffi/tests/test_wallet_manager.rs
  • dash-spv-ffi/include/dash_spv_ffi.h
  • dash-spv-ffi/scripts/generate_ffi_docs.py
  • swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
📚 Learning: 2025-06-26T16:01:37.609Z
Learnt from: DCG-Claude
PR: dashpay/rust-dashcore#0
File: :0-0
Timestamp: 2025-06-26T16:01:37.609Z
Learning: The mempool tracking infrastructure (UnconfirmedTransaction, MempoolState, configuration, and mempool_filter.rs) is fully implemented and integrated in the Dash SPV client as of this PR, including client logic, FFI APIs, and tests.

Applied to files:

  • dash-spv/src/sync/filters.rs
  • dash-spv/src/client/block_processor.rs
  • dash-spv/src/client/mod.rs
📚 Learning: 2025-08-29T04:00:14.154Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-29T04:00:14.154Z
Learning: Applies to {dash-spv,rpc-integration-test}/tests/**/*.rs : Provide integration tests for network operations

Applied to files:

  • dash-spv/tests/error_recovery_integration_test.rs
  • dash-spv/src/client/mod.rs
  • dash-spv-ffi/tests/test_wallet_manager.rs
  • dash-spv/src/client/block_processor_test.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/src/{managed_account,transaction_checking}/**/*.rs : Update wallet state atomically: add transaction, update UTXOs, recalculate balance, and mark addresses used in a single operation

Applied to files:

  • dash-spv/src/client/block_processor.rs
  • key-wallet-ffi/src/lib.rs
  • dash-spv/src/client/mod.rs
  • dash-spv-ffi/examples/wallet_manager_usage.rs
  • dash-spv-ffi/tests/test_wallet_manager.rs
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/include/dash_spv_ffi.h : The public C header is generated; ensure it reflects FFI changes after builds

Applied to files:

  • dash-spv-ffi/FFI_API.md
  • dash-spv-ffi/src/client.rs
  • dash-spv-ffi/dash_spv_ffi.h
  • dash-spv-ffi/examples/wallet_manager_usage.rs
  • dash-spv-ffi/include/dash_spv_ffi.h
  • dash-spv-ffi/scripts/generate_ffi_docs.py
  • swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/src/**/*.rs : Expose complex Rust types to C as opaque pointers (e.g., FFIDashSpvClient*)

Applied to files:

  • dash-spv-ffi/FFI_API.md
  • key-wallet-ffi/src/lib.rs
  • dash-spv-ffi/src/client.rs
  • dash-spv-ffi/dash_spv_ffi.h
  • dash-spv-ffi/examples/wallet_manager_usage.rs
  • dash-spv-ffi/include/dash_spv_ffi.h
  • dash-spv-ffi/scripts/generate_ffi_docs.py
📚 Learning: 2025-08-16T04:15:57.225Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: swift-dash-core-sdk/Examples/DashHDWalletExample/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:15:57.225Z
Learning: Applies to swift-dash-core-sdk/Examples/DashHDWalletExample/**/*.swift : When accessing SPV functionality, use DashSDK public APIs instead of direct client access; add public wrapper methods to DashSDK if needed

Applied to files:

  • dash-spv-ffi/FFI_API.md
  • dash-spv/src/client/mod.rs
  • dash-spv-ffi/src/client.rs
  • dash-spv-ffi/dash_spv_ffi.h
  • dash-spv-ffi/examples/wallet_manager_usage.rs
  • dash-spv-ffi/include/dash_spv_ffi.h
  • dash-spv-ffi/scripts/generate_ffi_docs.py
  • swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/src/**/*.rs : Provide corresponding _destroy() functions for all FFI-owned types to enforce explicit memory management

Applied to files:

  • dash-spv-ffi/FFI_API.md
  • dash-spv-ffi/src/client.rs
  • dash-spv-ffi/dash_spv_ffi.h
  • dash-spv-ffi/examples/wallet_manager_usage.rs
  • dash-spv-ffi/include/dash_spv_ffi.h
  • dash-spv-ffi/scripts/generate_ffi_docs.py
  • swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/src/**/*.rs : Functions returning pointers transfer ownership to the caller; functions taking pointers only borrow

Applied to files:

  • dash-spv-ffi/FFI_API.md
  • dash-spv-ffi/src/client.rs
  • dash-spv-ffi/dash_spv_ffi.h
  • dash-spv-ffi/examples/wallet_manager_usage.rs
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/src/**/*.rs : Return Rust strings to C as *const c_char; allocate so the caller can free with dash_string_free

Applied to files:

  • dash-spv-ffi/FFI_API.md
  • dash-spv-ffi/src/client.rs
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/src/**/*.rs : Accept input strings from C as *const c_char (borrowed; do not free inputs)

Applied to files:

  • dash-spv-ffi/FFI_API.md
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/tests/c_tests/**/*.c : In C code, free all strings returned by the FFI using dash_string_free

Applied to files:

  • dash-spv-ffi/FFI_API.md
  • dash-spv-ffi/include/dash_spv_ffi.h
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/src/**/*.rs : FFI functions must be declared with #[no_mangle] extern "C"

Applied to files:

  • dash-spv-ffi/FFI_API.md
  • dash-spv-ffi/src/client.rs
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/tests/unit/**/*.rs : Add a corresponding Rust unit test for each new FFI function

Applied to files:

  • dash-spv-ffi/FFI_API.md
  • dash-spv-ffi/tests/test_wallet_manager.rs
  • dash-spv/src/client/block_processor_test.rs
📚 Learning: 2025-08-16T04:15:29.335Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: swift-dash-core-sdk/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:15:29.335Z
Learning: Applies to swift-dash-core-sdk/Sources/**/FFIBridge.swift : Manage FFI pointers manually using RAII-style wrappers and defer blocks to ensure cleanup

Applied to files:

  • dash-spv-ffi/FFI_API.md
  • swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
📚 Learning: 2025-08-16T04:15:57.225Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: swift-dash-core-sdk/Examples/DashHDWalletExample/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:15:57.225Z
Learning: Applies to swift-dash-core-sdk/Examples/DashHDWalletExample/**/SPVClient.swift : Do not place type definitions in SPVClient.swift; keep types in dedicated files instead

Applied to files:

  • dash-spv-ffi/FFI_API.md
  • dash-spv-ffi/scripts/generate_ffi_docs.py
  • swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/src/ffi/**/*.rs : Expose safe C FFI with #[no_mangle] extern "C" functions only for vetted APIs

Applied to files:

  • key-wallet-ffi/src/lib.rs
  • key-wallet-ffi/src/wallet_manager.rs
📚 Learning: 2025-08-25T17:15:59.361Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-08-25T17:15:59.361Z
Learning: Applies to dash-spv/**/*.rs : All code must be clippy-clean: run `cargo clippy --all-targets --all-features -- -D warnings`

Applied to files:

  • dash-spv/src/client/mod.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/tests/**/*.rs : Include integration tests that cover full wallet workflows

Applied to files:

  • dash-spv/src/client/mod.rs
  • dash-spv-ffi/tests/test_wallet_manager.rs
  • dash-spv/src/client/block_processor_test.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/tests/**/*.rs : Keep test vectors in sync with Dash Core releases

Applied to files:

  • dash-spv/src/client/mod.rs
  • dash-spv-ffi/examples/wallet_manager_usage.rs
  • dash-spv-ffi/tests/test_wallet_manager.rs
  • dash-spv/src/client/block_processor_test.rs
📚 Learning: 2025-08-25T17:15:59.361Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-08-25T17:15:59.361Z
Learning: Applies to dash-spv/tests/**/*.rs : Place integration tests under the `tests/` directory

Applied to files:

  • dash-spv/src/client/mod.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/tests/bip32_tests.rs : Organize unit tests so key-derivation correctness lives in tests/bip32_tests.rs

Applied to files:

  • dash-spv/src/client/mod.rs
  • dash-spv-ffi/tests/test_wallet_manager.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/tests/mnemonic_tests.rs : Place mnemonic generation and validation tests in tests/mnemonic_tests.rs

Applied to files:

  • dash-spv/src/client/mod.rs
  • dash-spv-ffi/tests/test_wallet_manager.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/tests/address_tests.rs : Place address generation and validation tests in tests/address_tests.rs

Applied to files:

  • dash-spv/src/client/mod.rs
  • dash-spv-ffi/tests/test_wallet_manager.rs
📚 Learning: 2025-08-25T17:15:59.361Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-08-25T17:15:59.361Z
Learning: Applies to dash-spv/tests/integration_real_node_test.rs : Integration tests that connect to a live Dash Core node must gracefully skip when the node at 127.0.0.1:9999 is unavailable

Applied to files:

  • dash-spv/src/client/mod.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/src/**/*.rs : Always validate network consistency; never mix mainnet and testnet operations

Applied to files:

  • dash-spv/src/client/mod.rs
  • dash-spv-ffi/tests/test_wallet_manager.rs
  • dash-spv/src/client/block_processor_test.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/src/{bip32.rs,dip9.rs} : Keep Dash-specific derivation paths up to date (e.g., DIP-9) in bip32.rs and dip9.rs

Applied to files:

  • dash-spv-ffi/src/client.rs
  • dash-spv-ffi/examples/wallet_manager_usage.rs
  • dash-spv-ffi/tests/test_wallet_manager.rs
  • dash-spv/src/client/block_processor_test.rs
📚 Learning: 2025-08-16T04:15:29.335Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: swift-dash-core-sdk/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:15:29.335Z
Learning: Applies to swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h : After updating dash-spv-ffi, synchronize the generated header into the Swift SDK using ./sync-headers.sh so Sources/DashSPVFFI/include/dash_spv_ffi.h stays up to date

Applied to files:

  • dash-spv-ffi/dash_spv_ffi.h
  • dash-spv-ffi/include/dash_spv_ffi.h
  • dash-spv-ffi/scripts/generate_ffi_docs.py
  • swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/tests/psbt.rs : Place PSBT serialization/deserialization tests in tests/psbt.rs

Applied to files:

  • dash-spv-ffi/tests/test_wallet_manager.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/tests/derivation_tests.rs : Place path derivation tests in tests/derivation_tests.rs

Applied to files:

  • dash-spv-ffi/tests/test_wallet_manager.rs
📚 Learning: 2025-06-15T15:31:44.136Z
Learnt from: QuantumExplorer
PR: dashpay/rust-dashcore#74
File: key-wallet/src/address.rs:30-40
Timestamp: 2025-06-15T15:31:44.136Z
Learning: In the key-wallet crate, QuantumExplorer prefers keeping wildcard arms that default unknown Network variants to testnet prefixes rather than using exhaustive matches or panics. This fallback behavior is intentional.

Applied to files:

  • dash-spv/src/client/block_processor_test.rs
📚 Learning: 2025-08-16T04:15:29.335Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: swift-dash-core-sdk/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:15:29.335Z
Learning: Applies to swift-dash-core-sdk/Sources/**/FFIBridge.swift : Add a Swift wrapper in FFIBridge.swift for each new FFI function, handling type conversions and cross-language error mapping

Applied to files:

  • swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
🧬 Code graph analysis (20)
dash-spv/src/storage/mod.rs (5)
dash-spv/src/client/mod.rs (1)
  • clear_filters (123-156)
dash-spv/src/storage/disk.rs (1)
  • clear_filters (1634-1653)
dash-spv/src/storage/memory.rs (1)
  • clear_filters (310-314)
dash-spv/tests/error_handling_test.rs (1)
  • clear_filters (383-388)
dash-spv/tests/error_recovery_integration_test.rs (1)
  • clear_filters (658-660)
swift-dash-core-sdk/Sources/KeyWalletFFI/include/key_wallet_ffi.h (1)
key-wallet-ffi/src/wallet_manager.rs (2)
  • wallet_manager_describe (55-88)
  • wallet_manager_free_string (92-98)
dash-spv/tests/error_recovery_integration_test.rs (5)
dash-spv/src/client/mod.rs (1)
  • clear_filters (123-156)
dash-spv/src/storage/disk.rs (1)
  • clear_filters (1634-1653)
dash-spv/src/storage/memory.rs (1)
  • clear_filters (310-314)
dash-spv/src/storage/mod.rs (1)
  • clear_filters (158-158)
dash-spv/tests/error_handling_test.rs (1)
  • clear_filters (383-388)
key-wallet-ffi/include/key_wallet_ffi.h (1)
key-wallet-ffi/src/wallet_manager.rs (2)
  • wallet_manager_describe (55-88)
  • wallet_manager_free_string (92-98)
dash-spv/src/client/block_processor.rs (3)
key-wallet-manager/src/wallet_manager/process_block.rs (1)
  • describe (143-165)
dash-spv/src/client/block_processor_test.rs (2)
  • describe (64-66)
  • describe (244-246)
key-wallet-manager/src/wallet_interface.rs (1)
  • describe (58-60)
key-wallet-ffi/src/lib.rs (1)
key-wallet-ffi/src/wallet_manager.rs (3)
  • wallet_manager_describe (55-88)
  • wallet_manager_free (897-903)
  • wallet_manager_free_string (92-98)
dash-spv/src/storage/memory.rs (5)
dash-spv/src/client/mod.rs (1)
  • clear_filters (123-156)
dash-spv/src/storage/disk.rs (1)
  • clear_filters (1634-1653)
dash-spv/src/storage/mod.rs (1)
  • clear_filters (158-158)
dash-spv/tests/error_handling_test.rs (1)
  • clear_filters (383-388)
dash-spv/tests/error_recovery_integration_test.rs (1)
  • clear_filters (658-660)
dash-spv/src/storage/disk.rs (5)
dash-spv/src/client/mod.rs (1)
  • clear_filters (123-156)
dash-spv/src/storage/memory.rs (1)
  • clear_filters (310-314)
dash-spv/src/storage/mod.rs (1)
  • clear_filters (158-158)
dash-spv/tests/error_handling_test.rs (1)
  • clear_filters (383-388)
dash-spv/tests/error_recovery_integration_test.rs (1)
  • clear_filters (658-660)
key-wallet-manager/src/wallet_manager/process_block.rs (3)
dash-spv/src/client/block_processor_test.rs (2)
  • describe (64-66)
  • describe (244-246)
key-wallet-manager/src/wallet_interface.rs (1)
  • describe (58-60)
key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs (4)
  • wallet_id (30-30)
  • wallet_id (122-124)
  • name (33-33)
  • name (126-128)
dash-spv/src/client/mod.rs (5)
dash-spv/src/storage/disk.rs (2)
  • clear_filters (1634-1653)
  • new (210-324)
dash-spv/src/storage/memory.rs (2)
  • clear_filters (310-314)
  • new (30-42)
dash-spv/src/storage/mod.rs (1)
  • clear_filters (158-158)
dash-spv/src/types.rs (5)
  • default (57-70)
  • default (423-425)
  • default (572-601)
  • new (184-186)
  • new (880-900)
dash-spv/src/sync/filters.rs (1)
  • new (266-297)
key-wallet-manager/src/wallet_interface.rs (2)
key-wallet-manager/src/wallet_manager/process_block.rs (1)
  • describe (143-165)
dash-spv/src/client/block_processor_test.rs (2)
  • describe (64-66)
  • describe (244-246)
key-wallet-ffi/src/wallet_manager.rs (1)
key-wallet-ffi/src/error.rs (3)
  • error (44-49)
  • set_error (53-59)
  • set_success (63-69)
dash-spv-ffi/src/client.rs (2)
dash-spv-ffi/src/error.rs (1)
  • set_last_error (26-31)
key-wallet-ffi/src/wallet_manager.rs (1)
  • wallet_manager_free (897-903)
dash-spv-ffi/dash_spv_ffi.h (1)
dash-spv-ffi/src/client.rs (2)
  • dash_spv_ffi_client_get_wallet_manager (1503-1524)
  • dash_spv_ffi_wallet_manager_free (1536-1542)
dash-spv-ffi/examples/wallet_manager_usage.rs (2)
key-wallet-ffi/src/wallet_manager.rs (1)
  • wallet_manager_wallet_count (867-887)
dash-spv-ffi/src/client.rs (2)
  • dash_spv_ffi_client_get_wallet_manager (1503-1524)
  • dash_spv_ffi_wallet_manager_free (1536-1542)
dash-spv-ffi/tests/test_wallet_manager.rs (3)
key-wallet-ffi/src/wallet_manager.rs (6)
  • wallet_manager_free_wallet_ids (914-921)
  • wallet_manager_get_wallet_ids (510-549)
  • wallet_manager_import_wallet_from_bytes (427-498)
  • wallet_manager_wallet_count (867-887)
  • wallet_manager_describe (55-88)
  • wallet_manager_free_string (92-98)
dash-spv-ffi/src/client.rs (5)
  • dash_spv_ffi_wallet_manager_free (1536-1542)
  • dash_spv_ffi_client_destroy (1286-1324)
  • dash_spv_ffi_client_new (140-210)
  • dash_spv_ffi_client_get_wallet_manager (1503-1524)
  • new (80-84)
dash-spv-ffi/src/config.rs (2)
  • dash_spv_ffi_config_destroy (345-354)
  • dash_spv_ffi_config_testnet (54-61)
dash-spv-ffi/include/dash_spv_ffi.h (1)
dash-spv-ffi/src/client.rs (2)
  • dash_spv_ffi_client_get_wallet_manager (1503-1524)
  • dash_spv_ffi_wallet_manager_free (1536-1542)
dash-spv/src/client/block_processor_test.rs (2)
key-wallet-manager/src/wallet_manager/process_block.rs (1)
  • describe (143-165)
key-wallet-manager/src/wallet_interface.rs (1)
  • describe (58-60)
swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h (1)
dash-spv-ffi/src/client.rs (2)
  • dash_spv_ffi_client_get_wallet_manager (1503-1524)
  • dash_spv_ffi_wallet_manager_free (1536-1542)
dash-spv/tests/error_handling_test.rs (5)
dash-spv/src/client/mod.rs (1)
  • clear_filters (123-156)
dash-spv/src/storage/disk.rs (1)
  • clear_filters (1634-1653)
dash-spv/src/storage/memory.rs (1)
  • clear_filters (310-314)
dash-spv/src/storage/mod.rs (1)
  • clear_filters (158-158)
dash-spv/tests/error_recovery_integration_test.rs (1)
  • clear_filters (658-660)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: fuzz (dash_deserialize_script)
  • GitHub Check: fuzz (hashes_sha512_256)
  • GitHub Check: fuzz (dash_deserialize_amount)
  • GitHub Check: Key Wallet Components Tests
  • GitHub Check: fuzz (hashes_cbor)
  • GitHub Check: fuzz (dash_deser_net_msg)
  • GitHub Check: fuzz (dash_outpoint_string)
  • GitHub Check: Clippy (Non-strict)
🔇 Additional comments (16)
dash-spv/src/storage/memory.rs (1)

310-314: clear_filters() implementation matches trait intent; LGTM.

Clears both filter_headers and filters; consistent with client reset flow.

dash-spv/src/storage/mod.rs (1)

157-159: clear_filters implemented in all StorageManager impls

dash-spv/tests/error_recovery_integration_test.rs (1)

658-660: No-op clear_filters for mock looks good

Implements the new trait method to unblock compilation of ignored tests. Matches the trait contract and keeps behavior simple for this integration test scaffold.

dash-spv/tests/error_handling_test.rs (1)

383-389: Mock clear_filters mirrors write-failure path — OK

Consistent with other mock write ops (e.g., clear, store_*). This keeps tests deterministic when fail_on_write is set.

dash-spv/src/storage/disk.rs (1)

1634-1653: LGTM! Clean filter reset implementation.

The clear_filters implementation correctly follows the established pattern, properly stopping the background worker before filesystem operations to prevent concurrent writes, clearing all filter-related state, and restarting the worker afterward.

dash-spv-ffi/examples/wallet_manager_usage.rs (2)

8-8: LGTM! Correctly updated to use the new typed wallet manager API.

The changes properly align with the new wallet management lifecycle API, using the typed FFIWalletManager pointer returned by dash_spv_ffi_client_get_wallet_manager.

Also applies to: 24-29


36-39: LGTM! Proper memory management with the new API.

The cast to *const FFIWalletManager correctly enforces read-only access as per the FFI design principles. The use of dash_spv_ffi_wallet_manager_free ensures proper cleanup of the typed wallet manager handle.

Based on learnings

Also applies to: 69-69

dash-spv/src/client/mod.rs (2)

122-156: LGTM! Comprehensive filter state reset implementation.

The clear_filters method properly coordinates the reset across all components - storage, in-memory state, sync manager, and statistics. Good use of scoped blocks to minimize lock duration.


2567-2620: LGTM! Well-structured test for wallet manager integration.

The test effectively validates the shared wallet manager functionality, demonstrating proper wallet import and description retrieval through the new typed API.

dash-spv-ffi/src/client.rs (2)

1536-1542: Forwarder free is fine; ensure symbol visibility from key-wallet-ffi.

Calling key_wallet_ffi::wallet_manager::wallet_manager_free(manager) keeps lifetime rules centralized. Confirm the wallet_manager module is pub in key-wallet-ffi so this path resolves; if not, call the crate-root re-export (e.g., key_wallet_ffi::wallet_manager_free).


1503-1524: Exports and headers are correct; no action needed. FFIWalletManager::from_arc is public under key_wallet_ffi::FFIWalletManager, and the headers expose dash_spv_ffi_client_get_wallet_manager returning FFIWalletManager*.

dash-spv-ffi/tests/test_wallet_manager.rs (1)

41-45: Use the new free function — LGTM

Switch to dash_spv_ffi_wallet_manager_free is appropriate and aligns lifetimes across crates.

swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h (1)

534-550: Qualify FFIWalletManager pointer as struct and sync headers

  • Change the signature in dash-spv-ffi/include/dash_spv_ffi.h (line 549) from
    FFIWalletManager *dash_spv_ffi_client_get_wallet_manager(struct FFIDashSpvClient *client);
    to
    struct FFIWalletManager *dash_spv_ffi_client_get_wallet_manager(struct FFIDashSpvClient *client);
  • Run ./sync-headers.sh to propagate this change into
    swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h so both headers stay in lockstep.
⛔ Skipped due to learnings
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: swift-dash-core-sdk/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:15:29.335Z
Learning: Applies to swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h : After updating dash-spv-ffi, synchronize the generated header into the Swift SDK using ./sync-headers.sh so Sources/DashSPVFFI/include/dash_spv_ffi.h stays up to date
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/include/dash_spv_ffi.h : The public C header is generated; ensure it reflects FFI changes after builds
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-29T04:00:14.154Z
Learning: Applies to {dash-network-ffi,dash-spv-ffi,key-wallet-ffi,swift-dash-core-sdk}/**/*.{rs,c,h,swift} : Be careful with memory management at FFI boundaries (C/Swift interop)
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: swift-dash-core-sdk/Examples/DashHDWalletExample/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:15:57.225Z
Learning: Applies to swift-dash-core-sdk/Examples/DashHDWalletExample/**/*.swift : When accessing SPV functionality, use DashSDK public APIs instead of direct client access; add public wrapper methods to DashSDK if needed
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: swift-dash-core-sdk/Examples/DashHDWalletExample/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:15:57.225Z
Learning: Applies to swift-dash-core-sdk/Examples/DashHDWalletExample/**/SPVClient.swift : Do not place type definitions in SPVClient.swift; keep types in dedicated files instead
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: swift-dash-core-sdk/Examples/DashHDWalletExample/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:15:57.225Z
Learning: Applies to swift-dash-core-sdk/Examples/DashHDWalletExample/**/HDWalletModels.swift : Define SwiftData models (HDWallet, HDAccount, WatchedAddress, SyncState) in HDWalletModels.swift
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/src/**/*.rs : Expose complex Rust types to C as opaque pointers (e.g., FFIDashSpvClient*)
Learnt from: QuantumExplorer
PR: dashpay/rust-dashcore#108
File: key-wallet-ffi/src/wallet_manager.rs:270-318
Timestamp: 2025-08-21T05:01:58.949Z
Learning: In the key-wallet-ffi design, wallets retrieved from the wallet manager via lookup functions should return const pointers (*const FFIWallet) to enforce read-only access and prevent unintended modifications. The wallet manager should control wallet lifecycle and mutations through specific APIs rather than allowing external mutation of retrieved wallet references.
key-wallet-ffi/src/wallet_manager.rs (3)

22-22: Good: trait import enables describe method resolution

Bringing WalletInterface into scope is required for the extension method; this is correct.


69-69: Reentrancy risk: Runtime::block_on if already on this runtime

If this FFI is ever called from a task running on the same Tokio runtime, block_on can panic or deadlock. Consider documenting that these FFI calls must be invoked off-runtime threads, or gate with a check/fallback (e.g., delegate to async path exposed elsewhere).

Can you confirm these FFI entrypoints are never invoked from within the same runtime?


74-87: CString creation and error propagation look correct

Converts to a C string with NUL-checking and sets FFIError appropriately. LGTM.

Comment on lines +534 to +550
* Returns a pointer to an `FFIWalletManager` wrapper that clones the underlying
* `Arc<RwLock<WalletManager>>`. This allows direct interaction with the wallet
* manager without going back through the client for each call.
*
* # Safety
*
* The caller must ensure that:
* - The client pointer is valid
* - The returned pointer is freed using `wallet_manager_free` from key-wallet-ffi
* - The returned pointer is released exactly once using
* `dash_spv_ffi_wallet_manager_free`
*
* # Returns
*
* An opaque pointer (void*) to the wallet manager, or NULL if the client is not initialized.
* Swift should treat this as an OpaquePointer.
* Get a handle to the wallet manager owned by this client.
* A pointer to the wallet manager wrapper, or NULL if the client is not initialized.
*/
FFIWalletManager *dash_spv_ffi_client_get_wallet_manager(struct FFIDashSpvClient *client) ;

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

Blocker: FFIWalletManager not declared in this header — switch prototypes to struct-qualified to avoid compile error

FFIWalletManager is used but no typedef/forward-declaration exists in this file. C/Swift consumers will see “unknown type name ‘FFIWalletManager’”. Fix locally by using struct-qualified pointers in the signatures. Apply:

- FFIWalletManager *dash_spv_ffi_client_get_wallet_manager(struct FFIDashSpvClient *client) ;
+ struct FFIWalletManager *dash_spv_ffi_client_get_wallet_manager(struct FFIDashSpvClient *client) ;

Optionally, also re-export the type in dash-spv-ffi (e.g., pub use key_wallet_ffi::FFIWalletManager;) so cbindgen emits a proper typedef on future generations. Based on learnings.

Comment on lines +551 to 563
/**
* Release a wallet manager obtained from `dash_spv_ffi_client_get_wallet_manager`.
*
* This simply forwards to `wallet_manager_free` in key-wallet-ffi so that
* lifetime management is consistent between direct key-wallet usage and the
* SPV client pathway.
*
* # Safety
* - `client` must be a valid, non-null pointer.
* - `manager` must either be null or a pointer previously returned by
* `dash_spv_ffi_client_get_wallet_manager`.
*/

void *dash_spv_ffi_client_get_wallet_manager(struct FFIDashSpvClient *client)
;
void dash_spv_ffi_wallet_manager_free(FFIWalletManager *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 | 🔴 Critical

🧩 Analysis chain

Make free signature struct-qualified as well for consistency and C-compat

Mirror the change in the free function to avoid the same undefined type:

- void dash_spv_ffi_wallet_manager_free(FFIWalletManager *manager) ;
+ void dash_spv_ffi_wallet_manager_free(struct FFIWalletManager *manager) ;

Also re-run header generation and sync to SDK after adjusting. Based on learnings.

Run to verify header health:


🏁 Script executed:

#!/bin/bash
set -euo pipefail
echo "Check FFIWalletManager usage:"
rg -n "FFIWalletManager" dash-spv-ffi/dash_spv_ffi.h | sed -n '1,200p'
echo "Ensure a declaration exists (typedef or struct-qualified usage):"
rg -nP 'typedef\s+struct\s+FFIWalletManager|struct\s+FFIWalletManager\s*\*' dash-spv-ffi/dash_spv_ffi.h

echo "Check FFINetwork is declared (required by many functions):"
rg -nP 'typedef\s+enum\s+FFINetwork|enum\s+FFINetwork\b' dash-spv-ffi/dash_spv_ffi.h

Length of output: 348


🏁 Script executed:

#!/bin/bash
set -euo pipefail
echo "Search for inline struct definition in header:"
rg -nP 'struct\s+FFIWalletManager\s*\{' dash-spv-ffi/dash_spv_ffi.h || echo "No inline struct definition found."
echo
echo "Search for typedef alias in header:"
rg -nP 'typedef\s+struct\s+FFIWalletManager\s+FFIWalletManager' dash-spv-ffi/dash_spv_ffi.h || echo "No typedef alias found."
echo
echo "Search entire dash-spv-ffi directory for any struct/typedef of FFIWalletManager:"
rg -nH -n 'FFIWalletManager' -C2 dash-spv-ffi

Length of output: 10333


Qualify FFIWalletManager as an opaque struct in the C header

In dash_spv_ffi_wallet_manager_free, change the parameter from a bare FFIWalletManager* to struct FFIWalletManager* to match other opaque types (e.g. struct FFIClientConfig*) and avoid undefined-type errors:

- void dash_spv_ffi_wallet_manager_free(FFIWalletManager *manager);
+ void dash_spv_ffi_wallet_manager_free(struct FFIWalletManager *manager);

After applying this, re-generate the C header and re-run ./sync-headers.sh to update the Swift SDK.

📝 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
/**
* Release a wallet manager obtained from `dash_spv_ffi_client_get_wallet_manager`.
*
* This simply forwards to `wallet_manager_free` in key-wallet-ffi so that
* lifetime management is consistent between direct key-wallet usage and the
* SPV client pathway.
*
* # Safety
* - `client` must be a valid, non-null pointer.
* - `manager` must either be null or a pointer previously returned by
* `dash_spv_ffi_client_get_wallet_manager`.
*/
void *dash_spv_ffi_client_get_wallet_manager(struct FFIDashSpvClient *client)
;
void dash_spv_ffi_wallet_manager_free(FFIWalletManager *manager) ;
/**
* Release a wallet manager obtained from `dash_spv_ffi_client_get_wallet_manager`.
*
* This simply forwards to `wallet_manager_free` in key-wallet-ffi so that
* lifetime management is consistent between direct key-wallet usage and the
* SPV client pathway.
*
* # Safety
* - `manager` must either be null or a pointer previously returned by
* `dash_spv_ffi_client_get_wallet_manager`.
*/
void dash_spv_ffi_wallet_manager_free(struct FFIWalletManager *manager);
🤖 Prompt for AI Agents
In dash-spv-ffi/dash_spv_ffi.h around lines 551 to 563, the function parameter
uses a bare FFIWalletManager* which is inconsistent with other opaque types and
can trigger undefined-type errors; change the signature to accept struct
FFIWalletManager* instead of FFIWalletManager* to match the header's opaque type
declarations, then re-generate the C header and run ./sync-headers.sh to
propagate the updated declaration to the Swift SDK.

Comment on lines +1309 to 1311
// Get wallet manager (shares ownership with the client)
FFIWalletManager* wallet_manager = dash_spv_ffi_client_get_wallet_manager(client);
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

Example leaks the wallet manager; add a free call.

The “Basic SPV Client Usage” example obtains FFIWalletManager* but never frees it. This encourages leaks in client code. Add dash_spv_ffi_wallet_manager_free(wallet_manager); (before destroying the client or right after use).

Apply this diff to the example:

 // Get wallet manager (shares ownership with the client)
 FFIWalletManager* wallet_manager = dash_spv_ffi_client_get_wallet_manager(client);

+// Free the wallet manager when done
+dash_spv_ffi_wallet_manager_free(wallet_manager);
+wallet_manager = NULL;
📝 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
// Get wallet manager (shares ownership with the client)
FFIWalletManager* wallet_manager = dash_spv_ffi_client_get_wallet_manager(client);
// Get wallet manager (shares ownership with the client)
FFIWalletManager* wallet_manager = dash_spv_ffi_client_get_wallet_manager(client);
// Free the wallet manager when done
dash_spv_ffi_wallet_manager_free(wallet_manager);
wallet_manager = NULL;
🤖 Prompt for AI Agents
In dash-spv-ffi/FFI_API.md around lines 1309 to 1311, the example obtains an
FFIWalletManager* via dash_spv_ffi_client_get_wallet_manager(client) but never
frees it; add a call to dash_spv_ffi_wallet_manager_free(wallet_manager) after
you finish using the wallet_manager (either immediately after its last use in
the example or before destroying the client) to avoid leaking the wallet
manager.

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)
Cargo.toml (1)

5-6: Add rust-version field to comply with MSRV requirement.

Per coding guidelines, the MSRV is 1.89 and should be set in Cargo.toml.

As per coding guidelines.

Apply this diff to add the required field:

 [workspace.package]
 version = "0.40.0"
+rust-version = "1.89"
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between af64bc4 and 8547d5c.

📒 Files selected for processing (1)
  • Cargo.toml (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/Cargo.toml

📄 CodeRabbit inference engine (AGENTS.md)

MSRV is 1.89; set and respect rust-version = "1.89" in Cargo.toml

Files:

  • Cargo.toml
🪛 GitHub Actions: Continuous integration
Cargo.toml

[warning] 1-1: Patch elliptic-curve-tools was not used in the crate graph. Check patch version compatibility and run cargo update if needed.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: fuzz (hashes_sha1)

@github-actions
Copy link

⚠️ FFI Documentation Update Required

The FFI API documentation is out of date. Please regenerate it by running:

For key-wallet-ffi:

cd key-wallet-ffi
make update-docs

For dash-spv-ffi:

cd dash-spv-ffi
make update-docs

Then commit the changes:

git add */FFI_API.md
git commit -m "docs: update FFI API documentation"

This ensures the documentation stays in sync with the actual FFI functions.

@QuantumExplorer QuantumExplorer merged commit e44b1fb into v0.40-dev Sep 30, 2025
32 checks passed
@QuantumExplorer QuantumExplorer deleted the feat/smallfixes branch September 30, 2025 09:50
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.

2 participants