Skip to content

Conversation

@QuantumExplorer
Copy link
Member

@QuantumExplorer QuantumExplorer commented Nov 12, 2025

Summary by CodeRabbit

  • New Features

    • Added DashPay receiving and external account support, including retrieval and adding accounts (xpub-based watch-only support).
  • Improvements

    • Transaction checking now requires an explicit mutable wallet and an update-state flag.
    • Better immature coinbase handling with automatic maturation when chain height advances.
  • Documentation

    • Public API docs and safety notes updated to cover new DashPay endpoints and the mutable-wallet transaction-checking semantics.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 12, 2025

Walkthrough

Adds DashPay account types and storage across core and FFI layers, exposes FFI APIs to add and look up DashPay accounts (including xpub paths), requires a mutable wallet plus explicit update_state for transaction checking, and implements immature coinbase detection, maturation, and chain-height-driven promotion.

Changes

Cohort / File(s) Summary
FFI: API surface & types
key-wallet-ffi/include/key_wallet_ffi.h, key-wallet-ffi/src/types.rs, key-wallet-ffi/FFI_API.md
Added FFIAccountType variants DashpayReceivingFunds (11) and DashpayExternalAccount (12); documented and exported new FFI functions for DashPay get/add (including xpub variants); updated managed_wallet_check_transaction to accept *mut FFIWallet and explicit update_state; adjusted safety notes.
FFI: Managed account & wallet impl
key-wallet-ffi/src/managed_account.rs, key-wallet-ffi/src/wallet.rs, key-wallet-ffi/src/address_pool.rs
Added managed_wallet_get_dashpay_receiving_account and managed_wallet_get_dashpay_external_account; added wallet_add_dashpay_receiving_account and wallet_add_dashpay_external_account_with_xpub_bytes; added generic xpub account-add helpers; address-pool lookups and mark-used extended to consider DashPay maps.
FFI: Transaction checking glue
key-wallet-ffi/src/transaction_checking.rs, key-wallet-ffi/src/transaction.rs
Enforced non-null mutable wallet retrieval (Arc ownership checks) and pass &mut Wallet into managed check logic; removed prior optional-wallet branch; translate/return DashPay account matches.
Core: Account types & collections
key-wallet/src/account/account_type.rs, key-wallet/src/account/account_collection.rs, key-wallet/src/dip9.rs
Added AccountType variants for DashPay (receiving/external) with identity fields; introduced DashpayAccountKey and two BTreeMap stores; added DashPay root derivation path constants.
Core: Managed account types & collections
key-wallet/src/managed_account/managed_account_type.rs, key-wallet/src/managed_account/managed_account_collection.rs, key-wallet/src/managed_account/mod.rs
Added ManagedAccountType variants for DashPay with address pools; extended managed collections to store/convert DashPay accounts and include them in address-pool/gap-limit accessors and next-address logic.
Core: Transaction checking & routing
key-wallet/src/transaction_checking/wallet_checker.rs, key-wallet/src/transaction_checking/account_checker.rs, key-wallet/src/transaction_checking/transaction_router/mod.rs
Changed WalletTransactionChecker / check_transaction to accept &mut Wallet + update_state: bool; added immature coinbase detection/maturation and promotion logic; added DashPay account match variants and included them in routing.
Core: Wallet helpers & managed wallet interface
key-wallet/src/wallet/helper.rs, key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs
extended_public_key_for_account_type returns None for DashPay types; added update_chain_height to WalletInfoInterface / ManagedWalletInfo to trigger matured-transaction processing.
Manager & tests
key-wallet-manager/src/wallet_manager/mod.rs, key-wallet/src/transaction_checking/transaction_router/tests/...
Adjusted manager borrowing to split mutable borrows; updated many tests to use mutable wallet and pass update_state flag; tests adapted for immaturity/maturation behavior and relaxed some strict assertions.
Misc: dash-spv-ffi
dash-spv-ffi/include/dash_spv_ffi.h
Moved FFIMempoolStrategy typedef declaration order (no behavioral change).

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant FFI as FFI Layer
    participant Manager as Wallet Manager
    participant Wallet as Wallet Core
    participant Accounts as Account Collections

    rect rgb(240,248,255)
    note over FFI,Accounts: DashPay account lookup / add
    Caller->>FFI: managed_wallet_get_dashpay_receiving_account(manager,wid,net,idx,user,friend)
    FFI->>Manager: resolve wallet info
    Manager->>Accounts: lookup `DashpayAccountKey`
    Accounts-->>FFI: account or NotFound
    FFI-->>Caller: FFIManagedAccountResult
    end

    rect rgb(235,255,235)
    note over FFI,Wallet: Transaction check (mut wallet + update_state)
    Caller->>FFI: managed_wallet_check_transaction(mw, wallet_ptr, tx, net, update_state)
    FFI->>Wallet: obtain &mut Wallet (null/Arc checks)
    alt update_state == true
        FFI->>Wallet: check_transaction(tx, net, ctx, &mut wallet, true)
        Wallet->>Wallet: mutate state (UTXOs, addresses, balances)
    else
        FFI->>Wallet: check_transaction(tx, net, ctx, &mut wallet, false)
        Wallet->>Wallet: read-only checks
    end
    Wallet-->>FFI: TransactionCheckResult (including DashPay matches)
    FFI-->>Caller: result
    end

    rect rgb(255,250,235)
    note over Wallet: Immature coinbase path
    Wallet->>Wallet: detect immature coinbase -> store ImmatureTransaction
    Wallet->>Wallet: on update_chain_height -> promote matured transactions
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Areas requiring extra attention:

  • Transaction-checking refactor and immature coinbase maturation/promotion ordering (key-wallet/src/transaction_checking/wallet_checker.rs, related tests).
  • FFI mutable-wallet handling, Arc ownership and null-safety (key-wallet-ffi/src/transaction_checking.rs, key-wallet-ffi/src/transaction.rs).
  • DashPay composite-key construction, BTreeMap key ordering and equality (key-wallet/src/account/account_collection.rs, key-wallet/src/managed_account/managed_account_collection.rs).
  • New FFI xpub decoding and error paths in key-wallet-ffi/src/wallet.rs.

Possibly related PRs

Poem

🐇
I nibble bytes and hop through trees,
Two DashPay doors now swing with ease,
Mutable paws tend coins that bloom,
Immature hops wait for their room,
The rabbit signs — wallets hum a tune.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: dashpay support' accurately summarizes the main objective of the pull request, which is to add comprehensive DashPay support across multiple files and modules.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/dashpaySupport

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.

@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.

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 (3)
key-wallet/src/account/account_collection.rs (2)

352-386: DashPay accounts are invisible to aggregation helpers

The new DashPay maps never feed into all_accounts / all_accounts_mut, so anything iterating via these helpers (balance summaries, transaction routing, FFI projections, etc.) will never see the DashPay accounts. That cascades into incorrect counts and prevents downstream features from working. Please include both DashPay maps in these aggregators.

         if let Some(account) = &self.provider_owner_keys {
             accounts.push(account);
         }
 
+        accounts.extend(self.dashpay_receival_accounts.values());
+        accounts.extend(self.dashpay_external_accounts.values());
         accounts
     }
 
     /// Get all ECDSA accounts mutably (excludes BLS and EdDSA accounts)
     pub fn all_accounts_mut(&mut self) -> Vec<&mut Account> {
@@
         if let Some(account) = &mut self.provider_owner_keys {
             accounts.push(account);
         }
 
+        accounts.extend(self.dashpay_receival_accounts.values_mut());
+        accounts.extend(self.dashpay_external_accounts.values_mut());
         accounts
     }

Also applies to: 388-422


496-541: DashPay state survives is_empty / clear

is_empty() ignores the DashPay maps and clear() never drains them. After adding DashPay accounts the collection will report empty and clear() leaves stale entries behind, breaking wallet resets and any logic that checks emptiness. Please fold the DashPay maps into both helpers.

         #[cfg(feature = "eddsa")]
         {
             is_empty = is_empty && self.provider_platform_keys.is_none();
         }
 
-        is_empty
+        is_empty
+            && self.dashpay_receival_accounts.is_empty()
+            && self.dashpay_external_accounts.is_empty()
     }
 
     /// Clear all accounts
     pub fn clear(&mut self) {
         self.standard_bip44_accounts.clear();
@@
         #[cfg(feature = "eddsa")]
         {
             self.provider_platform_keys = None;
         }
+        self.dashpay_receival_accounts.clear();
+        self.dashpay_external_accounts.clear();
     }
key-wallet-ffi/include/key_wallet_ffi.h (1)

651-668: Fix FFITransactionCheckResult layout mismatch.
The Rust FFI code (managed_wallet_check_transaction) now writes both total_received_for_credit_conversion and the affected_accounts pointer into FFITransactionCheckResult, but this header still exposes the old four-field layout. C/Swift callers will read garbage for affected_accounts_count, and the struct size no longer matches the Rust side, leading to memory corruption. Regenerate the header (cbindgen) or update the struct here to include the new fields in the same order as the Rust definition before shipping.

🧹 Nitpick comments (2)
key-wallet-manager/src/wallet_manager/mod.rs (1)

518-523: Clarify the comment terminology.

The comment on line 519 refers to "split borrowing," but this pattern is actually obtaining separate mutable references from two distinct BTreeMap collections (self.wallets and self.wallet_infos). Split borrowing typically refers to borrowing different fields of the same struct simultaneously. The refactoring itself is correct and necessary to avoid simultaneous mutable borrows of self.

Consider updating the comment for precision:

-            // Get mutable references to both wallet and wallet_info
-            // We need to use split borrowing to get around Rust's borrow checker
+            // Get separate mutable references to wallet and wallet_info from different maps
+            // This avoids simultaneous mutable borrows of self
             let wallet_opt = self.wallets.get_mut(&wallet_id);
             let wallet_info_opt = self.wallet_infos.get_mut(&wallet_id);
key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs (1)

359-371: LGTM! Implementation correctly integrates with existing maturation logic.

The implementation properly delegates to process_matured_transactions which atomically updates accounts, transactions, and balance. The structured logging with conditional output is appropriate for tracking coinbase maturation events.

Optional: Consider exposing matured transactions.

If callers might want to react to matured transactions (e.g., for UI updates or notifications), consider returning the Vec<ImmatureTransaction>:

-    fn update_chain_height(&mut self, network: Network, current_height: u32);
+    fn update_chain_height(&mut self, network: Network, current_height: u32) -> Vec<ImmatureTransaction>;
     fn update_chain_height(&mut self, network: Network, current_height: u32) {
         // Process any matured transactions for this network
         let matured = self.process_matured_transactions(network, current_height);

         if !matured.is_empty() {
             tracing::info!(
                 network = ?network,
                 current_height = current_height,
                 matured_count = matured.len(),
                 "Processed matured coinbase transactions"
             );
         }
+
+        matured
     }

However, the current design is simpler and sufficient if callers don't need this information.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 618213d and da8c2a2.

📒 Files selected for processing (25)
  • key-wallet-ffi/include/key_wallet_ffi.h (4 hunks)
  • key-wallet-ffi/src/address_pool.rs (3 hunks)
  • key-wallet-ffi/src/managed_account.rs (5 hunks)
  • key-wallet-ffi/src/transaction.rs (1 hunks)
  • key-wallet-ffi/src/transaction_checking.rs (3 hunks)
  • key-wallet-ffi/src/types.rs (3 hunks)
  • key-wallet-ffi/src/wallet.rs (2 hunks)
  • key-wallet-manager/src/wallet_manager/mod.rs (1 hunks)
  • key-wallet/src/account/account_collection.rs (7 hunks)
  • key-wallet/src/account/account_type.rs (5 hunks)
  • key-wallet/src/dip9.rs (1 hunks)
  • key-wallet/src/managed_account/managed_account_collection.rs (11 hunks)
  • key-wallet/src/managed_account/managed_account_type.rs (7 hunks)
  • key-wallet/src/managed_account/mod.rs (4 hunks)
  • key-wallet/src/transaction_checking/account_checker.rs (6 hunks)
  • key-wallet/src/transaction_checking/transaction_router/mod.rs (4 hunks)
  • key-wallet/src/transaction_checking/transaction_router/tests/asset_unlock.rs (4 hunks)
  • key-wallet/src/transaction_checking/transaction_router/tests/coinbase.rs (9 hunks)
  • key-wallet/src/transaction_checking/transaction_router/tests/identity_transactions.rs (3 hunks)
  • key-wallet/src/transaction_checking/transaction_router/tests/provider.rs (12 hunks)
  • key-wallet/src/transaction_checking/transaction_router/tests/routing.rs (8 hunks)
  • key-wallet/src/transaction_checking/transaction_router/tests/standard_transactions.rs (0 hunks)
  • key-wallet/src/transaction_checking/wallet_checker.rs (14 hunks)
  • key-wallet/src/wallet/helper.rs (1 hunks)
  • key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs (2 hunks)
💤 Files with no reviewable changes (1)
  • key-wallet/src/transaction_checking/transaction_router/tests/standard_transactions.rs
🧰 Additional context used
📓 Path-based instructions (12)
**/*.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:

  • key-wallet-ffi/src/address_pool.rs
  • key-wallet/src/account/account_type.rs
  • key-wallet/src/wallet/helper.rs
  • key-wallet/src/managed_account/mod.rs
  • key-wallet/src/dip9.rs
  • key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/routing.rs
  • key-wallet-ffi/src/transaction_checking.rs
  • key-wallet-ffi/src/transaction.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/identity_transactions.rs
  • key-wallet/src/managed_account/managed_account_type.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/coinbase.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/asset_unlock.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/provider.rs
  • key-wallet/src/transaction_checking/transaction_router/mod.rs
  • key-wallet-ffi/src/types.rs
  • key-wallet-manager/src/wallet_manager/mod.rs
  • key-wallet/src/transaction_checking/account_checker.rs
  • key-wallet/src/transaction_checking/wallet_checker.rs
  • key-wallet/src/account/account_collection.rs
  • key-wallet-ffi/src/managed_account.rs
  • key-wallet-ffi/src/wallet.rs
  • key-wallet/src/managed_account/managed_account_collection.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:

  • key-wallet-ffi/src/address_pool.rs
  • key-wallet-ffi/src/transaction_checking.rs
  • key-wallet-ffi/src/transaction.rs
  • key-wallet-ffi/src/types.rs
  • key-wallet-ffi/src/managed_account.rs
  • key-wallet-ffi/src/wallet.rs
  • key-wallet-ffi/include/key_wallet_ffi.h
**/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:

  • key-wallet-ffi/src/address_pool.rs
  • key-wallet/src/account/account_type.rs
  • key-wallet/src/wallet/helper.rs
  • key-wallet/src/managed_account/mod.rs
  • key-wallet/src/dip9.rs
  • key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/routing.rs
  • key-wallet-ffi/src/transaction_checking.rs
  • key-wallet-ffi/src/transaction.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/identity_transactions.rs
  • key-wallet/src/managed_account/managed_account_type.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/coinbase.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/asset_unlock.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/provider.rs
  • key-wallet/src/transaction_checking/transaction_router/mod.rs
  • key-wallet-ffi/src/types.rs
  • key-wallet-manager/src/wallet_manager/mod.rs
  • key-wallet/src/transaction_checking/account_checker.rs
  • key-wallet/src/transaction_checking/wallet_checker.rs
  • key-wallet/src/account/account_collection.rs
  • key-wallet-ffi/src/managed_account.rs
  • key-wallet-ffi/src/wallet.rs
  • key-wallet/src/managed_account/managed_account_collection.rs
*-ffi/**

📄 CodeRabbit inference engine (AGENTS.md)

FFI bindings live in *-ffi crates

Files:

  • key-wallet-ffi/src/address_pool.rs
  • key-wallet-ffi/src/transaction_checking.rs
  • key-wallet-ffi/src/transaction.rs
  • key-wallet-ffi/src/types.rs
  • key-wallet-ffi/src/managed_account.rs
  • key-wallet-ffi/src/wallet.rs
  • key-wallet-ffi/include/key_wallet_ffi.h
{key-wallet,swift-dash-core-sdk}/**/*.{rs,swift}

📄 CodeRabbit inference engine (CLAUDE.md)

Never log or expose private keys

Files:

  • key-wallet/src/account/account_type.rs
  • key-wallet/src/wallet/helper.rs
  • key-wallet/src/managed_account/mod.rs
  • key-wallet/src/dip9.rs
  • key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/routing.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/identity_transactions.rs
  • key-wallet/src/managed_account/managed_account_type.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/coinbase.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/asset_unlock.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/provider.rs
  • key-wallet/src/transaction_checking/transaction_router/mod.rs
  • key-wallet/src/transaction_checking/account_checker.rs
  • key-wallet/src/transaction_checking/wallet_checker.rs
  • key-wallet/src/account/account_collection.rs
  • key-wallet/src/managed_account/managed_account_collection.rs
key-wallet/**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

Use secure random number generation for key material

Files:

  • key-wallet/src/account/account_type.rs
  • key-wallet/src/wallet/helper.rs
  • key-wallet/src/managed_account/mod.rs
  • key-wallet/src/dip9.rs
  • key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/routing.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/identity_transactions.rs
  • key-wallet/src/managed_account/managed_account_type.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/coinbase.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/asset_unlock.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/provider.rs
  • key-wallet/src/transaction_checking/transaction_router/mod.rs
  • key-wallet/src/transaction_checking/account_checker.rs
  • key-wallet/src/transaction_checking/wallet_checker.rs
  • key-wallet/src/account/account_collection.rs
  • key-wallet/src/managed_account/managed_account_collection.rs
key-wallet/src/**/*.rs

📄 CodeRabbit inference engine (key-wallet/CLAUDE.md)

key-wallet/src/**/*.rs: Never serialize, print, or log private keys; avoid exposing secret key material in any form
Prefer using public keys or key fingerprints for identification in logs and messages instead of private keys
Always validate network consistency; never mix mainnet and testnet operations
Use the custom Error type; propagate errors with the ? operator and provide contextual messages
Never panic in library code; return Result<T, Error> for all fallible operations

Files:

  • key-wallet/src/account/account_type.rs
  • key-wallet/src/wallet/helper.rs
  • key-wallet/src/managed_account/mod.rs
  • key-wallet/src/dip9.rs
  • key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/routing.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/identity_transactions.rs
  • key-wallet/src/managed_account/managed_account_type.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/coinbase.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/asset_unlock.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/provider.rs
  • key-wallet/src/transaction_checking/transaction_router/mod.rs
  • key-wallet/src/transaction_checking/account_checker.rs
  • key-wallet/src/transaction_checking/wallet_checker.rs
  • key-wallet/src/account/account_collection.rs
  • key-wallet/src/managed_account/managed_account_collection.rs
key-wallet/src/managed_account/**/*.rs

📄 CodeRabbit inference engine (key-wallet/CLAUDE.md)

Never attempt signing operations for watch-only accounts

Files:

  • key-wallet/src/managed_account/mod.rs
  • key-wallet/src/managed_account/managed_account_type.rs
  • key-wallet/src/managed_account/managed_account_collection.rs
key-wallet/src/{managed_account,transaction_checking}/**/*.rs

📄 CodeRabbit inference engine (key-wallet/CLAUDE.md)

Update wallet state atomically: add transaction, update UTXOs, recalculate balance, and mark addresses used in a single operation

Files:

  • key-wallet/src/managed_account/mod.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/routing.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/identity_transactions.rs
  • key-wallet/src/managed_account/managed_account_type.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/coinbase.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/asset_unlock.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/provider.rs
  • key-wallet/src/transaction_checking/transaction_router/mod.rs
  • key-wallet/src/transaction_checking/account_checker.rs
  • key-wallet/src/transaction_checking/wallet_checker.rs
  • key-wallet/src/managed_account/managed_account_collection.rs
key-wallet/src/{bip32.rs,dip9.rs}

📄 CodeRabbit inference engine (key-wallet/CLAUDE.md)

Keep Dash-specific derivation paths up to date (e.g., DIP-9) in bip32.rs and dip9.rs

Files:

  • key-wallet/src/dip9.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:

  • key-wallet/src/transaction_checking/transaction_router/tests/routing.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/identity_transactions.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/coinbase.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/asset_unlock.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/provider.rs
key-wallet/src/transaction_checking/**/*.rs

📄 CodeRabbit inference engine (key-wallet/CLAUDE.md)

Use transaction type routing to check only relevant accounts

Files:

  • key-wallet/src/transaction_checking/transaction_router/tests/routing.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/identity_transactions.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/coinbase.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/asset_unlock.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/provider.rs
  • key-wallet/src/transaction_checking/transaction_router/mod.rs
  • key-wallet/src/transaction_checking/account_checker.rs
  • key-wallet/src/transaction_checking/wallet_checker.rs
🧠 Learnings (42)
📓 Common learnings
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Maintain compatibility with Dash Core versions 0.18.0–0.21.0
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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
Learnt from: QuantumExplorer
Repo: dashpay/rust-dashcore PR: 108
File: key-wallet/src/gap_limit.rs:291-295
Timestamp: 2025-08-21T04:45:50.436Z
Learning: The rust-dashcore project uses Rust 1.89 as evidenced by rust-version = "1.89" in dash-spv/Cargo.toml. Modern Rust features like Option::is_none_or (stabilized in 1.82) can be used safely.
Learnt from: DCG-Claude
Repo: dashpay/rust-dashcore PR: 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.
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/src/transaction_checking/**/*.rs : Use transaction type routing to check only relevant accounts
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet-ffi/src/address_pool.rs
  • key-wallet/src/account/account_type.rs
  • key-wallet/src/wallet/helper.rs
  • key-wallet/src/managed_account/mod.rs
  • key-wallet/src/dip9.rs
  • key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/routing.rs
  • key-wallet-ffi/src/transaction_checking.rs
  • key-wallet/src/managed_account/managed_account_type.rs
  • key-wallet/src/transaction_checking/transaction_router/mod.rs
  • key-wallet-ffi/src/types.rs
  • key-wallet-manager/src/wallet_manager/mod.rs
  • key-wallet/src/transaction_checking/account_checker.rs
  • key-wallet/src/transaction_checking/wallet_checker.rs
  • key-wallet/src/account/account_collection.rs
  • key-wallet-ffi/src/managed_account.rs
  • key-wallet-ffi/src/wallet.rs
  • key-wallet/src/managed_account/managed_account_collection.rs
  • key-wallet-ffi/include/key_wallet_ffi.h
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet-ffi/src/address_pool.rs
  • key-wallet/src/account/account_type.rs
  • key-wallet/src/wallet/helper.rs
  • key-wallet/src/managed_account/mod.rs
  • key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/routing.rs
  • key-wallet-ffi/src/transaction_checking.rs
  • key-wallet-ffi/src/transaction.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/identity_transactions.rs
  • key-wallet/src/managed_account/managed_account_type.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/coinbase.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/asset_unlock.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/provider.rs
  • key-wallet/src/transaction_checking/transaction_router/mod.rs
  • key-wallet-ffi/src/types.rs
  • key-wallet-manager/src/wallet_manager/mod.rs
  • key-wallet/src/transaction_checking/account_checker.rs
  • key-wallet/src/transaction_checking/wallet_checker.rs
  • key-wallet/src/account/account_collection.rs
  • key-wallet-ffi/src/managed_account.rs
  • key-wallet-ffi/src/wallet.rs
  • key-wallet/src/managed_account/managed_account_collection.rs
  • key-wallet-ffi/include/key_wallet_ffi.h
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/src/transaction_checking/**/*.rs : Use transaction type routing to check only relevant accounts

Applied to files:

  • key-wallet-ffi/src/address_pool.rs
  • key-wallet/src/account/account_type.rs
  • key-wallet/src/wallet/helper.rs
  • key-wallet/src/managed_account/mod.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/routing.rs
  • key-wallet-ffi/src/transaction_checking.rs
  • key-wallet-ffi/src/transaction.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/identity_transactions.rs
  • key-wallet/src/managed_account/managed_account_type.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/coinbase.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/asset_unlock.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/provider.rs
  • key-wallet/src/transaction_checking/transaction_router/mod.rs
  • key-wallet-ffi/src/types.rs
  • key-wallet-manager/src/wallet_manager/mod.rs
  • key-wallet/src/transaction_checking/account_checker.rs
  • key-wallet/src/transaction_checking/wallet_checker.rs
  • key-wallet/src/account/account_collection.rs
  • key-wallet-ffi/src/managed_account.rs
  • key-wallet-ffi/src/wallet.rs
  • key-wallet/src/managed_account/managed_account_collection.rs
  • key-wallet-ffi/include/key_wallet_ffi.h
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/src/address_pool/**/*.rs : Do not generate unbounded addresses; enforce gap limit and staged address generation in address pools

Applied to files:

  • key-wallet-ffi/src/address_pool.rs
  • key-wallet/src/managed_account/mod.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/routing.rs
  • key-wallet/src/transaction_checking/wallet_checker.rs
  • key-wallet-ffi/src/managed_account.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/src/address_pool/**/*.rs : Pre-generate addresses in bounded batches (typically 20–100) and store them in pools

Applied to files:

  • key-wallet-ffi/src/address_pool.rs
  • key-wallet/src/managed_account/mod.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/routing.rs
  • key-wallet/src/managed_account/managed_account_type.rs
  • key-wallet/src/transaction_checking/wallet_checker.rs
  • key-wallet-ffi/src/managed_account.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/src/managed_account/**/*.rs : Never attempt signing operations for watch-only accounts

Applied to files:

  • key-wallet-ffi/src/address_pool.rs
  • key-wallet/src/wallet/helper.rs
  • key-wallet/src/managed_account/mod.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/routing.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/identity_transactions.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/coinbase.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/asset_unlock.rs
  • key-wallet/src/transaction_checking/wallet_checker.rs
  • key-wallet-ffi/src/managed_account.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet-ffi/src/address_pool.rs
  • key-wallet/src/account/account_type.rs
  • key-wallet/src/wallet/helper.rs
  • key-wallet/src/managed_account/mod.rs
  • key-wallet/src/dip9.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/routing.rs
  • key-wallet-ffi/src/transaction_checking.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/identity_transactions.rs
  • key-wallet/src/managed_account/managed_account_type.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/coinbase.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/asset_unlock.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/provider.rs
  • key-wallet/src/transaction_checking/transaction_router/mod.rs
  • key-wallet-ffi/src/types.rs
  • key-wallet-manager/src/wallet_manager/mod.rs
  • key-wallet/src/transaction_checking/account_checker.rs
  • key-wallet/src/transaction_checking/wallet_checker.rs
  • key-wallet/src/account/account_collection.rs
  • key-wallet-ffi/src/managed_account.rs
  • key-wallet-ffi/src/wallet.rs
  • key-wallet/src/managed_account/managed_account_collection.rs
  • key-wallet-ffi/include/key_wallet_ffi.h
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet-ffi/src/address_pool.rs
  • key-wallet/src/wallet/helper.rs
  • key-wallet/src/managed_account/mod.rs
  • key-wallet/src/dip9.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/routing.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/identity_transactions.rs
  • key-wallet/src/managed_account/managed_account_type.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/coinbase.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/asset_unlock.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/provider.rs
  • key-wallet/src/transaction_checking/account_checker.rs
  • key-wallet/src/transaction_checking/wallet_checker.rs
  • key-wallet/src/account/account_collection.rs
  • key-wallet-ffi/src/managed_account.rs
  • key-wallet-ffi/src/wallet.rs
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet-ffi/src/address_pool.rs
  • key-wallet/src/account/account_type.rs
  • key-wallet/src/wallet/helper.rs
  • key-wallet/src/managed_account/mod.rs
  • key-wallet-ffi/src/transaction_checking.rs
  • key-wallet/src/managed_account/managed_account_type.rs
  • key-wallet-ffi/src/types.rs
  • key-wallet/src/account/account_collection.rs
  • key-wallet-ffi/src/managed_account.rs
  • key-wallet-ffi/src/wallet.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/src/{bip32.rs,derivation/**/*.rs} : Optimize derivation: cache intermediate results, use hardened derivation only when required, and batch-derive child keys where possible

Applied to files:

  • key-wallet-ffi/src/address_pool.rs
  • key-wallet/src/account/account_type.rs
  • key-wallet/src/wallet/helper.rs
  • key-wallet/src/managed_account/mod.rs
  • key-wallet/src/dip9.rs
  • key-wallet-ffi/src/transaction_checking.rs
  • key-wallet-ffi/src/transaction.rs
  • key-wallet-manager/src/wallet_manager/mod.rs
  • key-wallet/src/transaction_checking/account_checker.rs
  • key-wallet/src/transaction_checking/wallet_checker.rs
  • key-wallet/src/account/account_collection.rs
  • key-wallet-ffi/src/managed_account.rs
  • key-wallet-ffi/src/wallet.rs
  • key-wallet/src/managed_account/managed_account_collection.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet/src/account/account_type.rs
  • key-wallet/src/dip9.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/routing.rs
  • key-wallet-ffi/src/transaction.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/identity_transactions.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/coinbase.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/asset_unlock.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/provider.rs
  • key-wallet-manager/src/wallet_manager/mod.rs
  • key-wallet-ffi/src/wallet.rs
📚 Learning: 2025-08-16T04:15:57.225Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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

Applied to files:

  • key-wallet/src/account/account_type.rs
  • key-wallet/src/managed_account/managed_account_type.rs
  • key-wallet/src/account/account_collection.rs
  • key-wallet-ffi/include/key_wallet_ffi.h
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet/src/account/account_type.rs
  • key-wallet/src/dip9.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/routing.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/identity_transactions.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/coinbase.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/asset_unlock.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/provider.rs
  • key-wallet-manager/src/wallet_manager/mod.rs
  • key-wallet/src/transaction_checking/wallet_checker.rs
  • key-wallet/src/account/account_collection.rs
📚 Learning: 2025-06-15T15:31:44.136Z
Learnt from: QuantumExplorer
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet/src/wallet/helper.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/routing.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/identity_transactions.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/coinbase.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/asset_unlock.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/provider.rs
  • key-wallet/src/transaction_checking/wallet_checker.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/src/**/*.rs : Prefer using public keys or key fingerprints for identification in logs and messages instead of private keys

Applied to files:

  • key-wallet/src/wallet/helper.rs
  • key-wallet/src/managed_account/managed_account_type.rs
  • key-wallet/src/account/account_collection.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet/src/dip9.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/routing.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/identity_transactions.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/coinbase.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/asset_unlock.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/provider.rs
  • key-wallet/src/transaction_checking/wallet_checker.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet/src/dip9.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/routing.rs
  • key-wallet-ffi/src/transaction_checking.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/identity_transactions.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/coinbase.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/asset_unlock.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/provider.rs
  • key-wallet-manager/src/wallet_manager/mod.rs
  • key-wallet/src/transaction_checking/wallet_checker.rs
📚 Learning: 2025-08-16T04:15:57.225Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet/src/dip9.rs
  • key-wallet-ffi/src/managed_account.rs
  • key-wallet-ffi/include/key_wallet_ffi.h
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet/src/transaction_checking/transaction_router/tests/routing.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/identity_transactions.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/coinbase.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/asset_unlock.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/provider.rs
  • key-wallet-manager/src/wallet_manager/mod.rs
  • key-wallet/src/transaction_checking/wallet_checker.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/tests/**/*.rs : Use property-based tests for complex invariants where suitable

Applied to files:

  • key-wallet/src/transaction_checking/transaction_router/tests/routing.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/identity_transactions.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/coinbase.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/asset_unlock.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/provider.rs
📚 Learning: 2025-08-21T05:01:58.949Z
Learnt from: QuantumExplorer
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet-ffi/src/transaction_checking.rs
  • key-wallet-ffi/src/transaction.rs
  • key-wallet-ffi/src/managed_account.rs
  • key-wallet-ffi/src/wallet.rs
  • key-wallet-ffi/include/key_wallet_ffi.h
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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/transaction_checking.rs
  • key-wallet-ffi/src/managed_account.rs
  • key-wallet-ffi/src/wallet.rs
📚 Learning: 2025-08-29T04:00:14.154Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet-ffi/src/transaction_checking.rs
  • key-wallet-ffi/src/managed_account.rs
  • key-wallet-ffi/src/wallet.rs
  • key-wallet-ffi/include/key_wallet_ffi.h
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/src/**/*.rs : Use the custom Error type; propagate errors with the ? operator and provide contextual messages

Applied to files:

  • key-wallet-ffi/src/transaction_checking.rs
  • key-wallet-ffi/src/transaction.rs
  • key-wallet-ffi/src/managed_account.rs
  • key-wallet-ffi/src/wallet.rs
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet-ffi/src/transaction_checking.rs
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet-ffi/src/transaction_checking.rs
📚 Learning: 2025-08-16T04:15:29.335Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet-ffi/src/transaction_checking.rs
📚 Learning: 2025-09-01T14:44:53.683Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-09-01T14:44:53.683Z
Learning: Applies to *-ffi/** : FFI bindings live in *-ffi crates

Applied to files:

  • key-wallet-ffi/src/transaction_checking.rs
📚 Learning: 2025-06-26T16:02:42.390Z
Learnt from: DCG-Claude
Repo: dashpay/rust-dashcore PR: 0
File: :0-0
Timestamp: 2025-06-26T16:02:42.390Z
Learning: Passing exclusive mutable references to network and storage managers into the sync manager in async Rust can lead to borrow checker issues or runtime contention if concurrent access is needed elsewhere. It's advisable to document this architectural tradeoff and consider refactoring to interior mutability or message passing for shared access as the codebase evolves.

Applied to files:

  • key-wallet-ffi/src/transaction.rs
  • key-wallet-manager/src/wallet_manager/mod.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/tests/**/*.rs : Use deterministic testing with known vectors (fixed seeds) in Rust tests

Applied to files:

  • key-wallet/src/transaction_checking/transaction_router/tests/identity_transactions.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/asset_unlock.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/provider.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet/src/transaction_checking/transaction_router/tests/coinbase.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/asset_unlock.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/provider.rs
  • key-wallet-ffi/src/wallet.rs
📚 Learning: 2025-08-29T04:00:14.154Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet/src/transaction_checking/transaction_router/tests/provider.rs
📚 Learning: 2025-09-01T14:44:53.683Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-09-01T14:44:53.683Z
Learning: Pre-PR checks: cargo fmt, cargo clippy, cargo test (workspace); update docs/CHANGELOG for user-facing changes

Applied to files:

  • key-wallet/src/transaction_checking/wallet_checker.rs
📚 Learning: 2025-06-26T16:01:37.609Z
Learnt from: DCG-Claude
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet/src/transaction_checking/wallet_checker.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/src/**/*.rs : Never panic in library code; return Result<T, Error> for all fallible operations

Applied to files:

  • key-wallet-ffi/src/managed_account.rs
  • key-wallet-ffi/src/wallet.rs
📚 Learning: 2025-08-16T04:15:29.335Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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 : At the FFI boundary, convert FFI errors to DashSDKError and use Result types; log FFI errors before converting

Applied to files:

  • key-wallet-ffi/src/managed_account.rs
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet-ffi/src/wallet.rs
📚 Learning: 2025-06-15T16:42:18.187Z
Learnt from: QuantumExplorer
Repo: dashpay/rust-dashcore PR: 74
File: key-wallet-ffi/src/lib_tests.rs:41-48
Timestamp: 2025-06-15T16:42:18.187Z
Learning: In key-wallet-ffi, the HDWallet::derive_xpriv method returns Result<String, KeyWalletError>, not an ExtPrivKey wrapper. When unwrapped, it yields a String that can have .is_empty() called on it.

Applied to files:

  • key-wallet-ffi/src/wallet.rs
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet-ffi/include/key_wallet_ffi.h
📚 Learning: 2025-06-26T15:47:37.438Z
Learnt from: DCG-Claude
Repo: dashpay/rust-dashcore PR: 0
File: :0-0
Timestamp: 2025-06-26T15:47:37.438Z
Learning: Transaction IDs (txids) and block hashes in Dash are always 32 bytes and should be passed as fixed-size byte arrays in FFI interfaces, not as C strings, to avoid inefficiency and encoding issues.

Applied to files:

  • key-wallet-ffi/include/key_wallet_ffi.h
📚 Learning: 2025-06-26T15:46:56.854Z
Learnt from: DCG-Claude
Repo: dashpay/rust-dashcore PR: 0
File: :0-0
Timestamp: 2025-06-26T15:46:56.854Z
Learning: Transaction IDs (txids) in Dash are always 32 bytes and should be passed as fixed-size byte arrays in FFI interfaces, not as C strings, to avoid inefficiency and encoding issues.

Applied to files:

  • key-wallet-ffi/include/key_wallet_ffi.h
🧬 Code graph analysis (17)
key-wallet/src/account/account_type.rs (3)
key-wallet/src/dip9.rs (1)
  • from (69-71)
key-wallet/src/transaction_checking/transaction_router/mod.rs (2)
  • from (184-231)
  • from (235-282)
key-wallet/src/bip32.rs (7)
  • from (81-83)
  • from (226-228)
  • from (776-786)
  • from (790-805)
  • from (984-989)
  • from (1201-1203)
  • from_hardened_idx (622-630)
key-wallet/src/transaction_checking/transaction_router/tests/routing.rs (1)
key-wallet/src/wallet/initialization.rs (1)
  • new_random (86-105)
key-wallet-ffi/src/transaction_checking.rs (2)
key-wallet-ffi/src/error.rs (2)
  • set_error (53-59)
  • error (44-49)
key-wallet/src/transaction_checking/account_checker.rs (1)
  • account_index (167-195)
key-wallet-ffi/src/transaction.rs (2)
dash-spv/src/client/core.rs (1)
  • wallet (161-163)
key-wallet-ffi/src/error.rs (2)
  • set_error (53-59)
  • error (44-49)
key-wallet/src/transaction_checking/transaction_router/tests/identity_transactions.rs (1)
key-wallet/src/wallet/initialization.rs (1)
  • new_random (86-105)
key-wallet/src/managed_account/managed_account_type.rs (4)
key-wallet/src/account/account_type.rs (1)
  • index (126-153)
key-wallet/src/managed_account/mod.rs (4)
  • index (138-140)
  • account_type (811-813)
  • network (819-821)
  • new (63-73)
key-wallet/src/managed_account/address_pool.rs (4)
  • network (1100-1103)
  • new (357-372)
  • new (1059-1069)
  • key_source (1118-1121)
key-wallet/src/managed_account/managed_account_collection.rs (1)
  • new (56-72)
key-wallet/src/transaction_checking/transaction_router/tests/coinbase.rs (1)
key-wallet/src/wallet/initialization.rs (1)
  • new_random (86-105)
key-wallet/src/transaction_checking/transaction_router/tests/asset_unlock.rs (1)
key-wallet/src/wallet/initialization.rs (1)
  • new_random (86-105)
key-wallet/src/transaction_checking/transaction_router/tests/provider.rs (1)
key-wallet/src/wallet/initialization.rs (1)
  • new_random (86-105)
key-wallet-ffi/src/types.rs (2)
key-wallet/src/managed_account/managed_account_type.rs (1)
  • index (112-156)
key-wallet/src/account/account_type.rs (1)
  • index (126-153)
key-wallet/src/transaction_checking/account_checker.rs (3)
key-wallet/src/managed_account/managed_account_collection.rs (1)
  • new (56-72)
key-wallet/src/managed_account/mod.rs (2)
  • new (63-73)
  • index (138-140)
key-wallet/src/managed_account/managed_account_type.rs (1)
  • index (112-156)
key-wallet/src/transaction_checking/wallet_checker.rs (7)
key-wallet/src/transaction_checking/account_checker.rs (2)
  • check_transaction (258-284)
  • account_index (167-195)
key-wallet/src/managed_account/mod.rs (5)
  • network (819-821)
  • new (63-73)
  • transactions (843-845)
  • utxos (851-853)
  • balance (835-837)
rpc-json/src/lib.rs (2)
  • is_coinbase (551-553)
  • is_coinbase (641-643)
dash/src/blockdata/transaction/mod.rs (1)
  • txid (199-214)
key-wallet/src/managed_account/managed_account_collection.rs (3)
  • new (56-72)
  • contains_key (655-677)
  • is_empty (806-820)
key-wallet/src/wallet/immature_transaction.rs (3)
  • contains (213-215)
  • is_empty (60-64)
  • is_empty (265-267)
key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs (6)
  • from_wallet_with_name (27-27)
  • from_wallet_with_name (122-124)
  • utxos (63-63)
  • utxos (179-190)
  • balance (69-69)
  • balance (198-200)
key-wallet/src/account/account_collection.rs (3)
key-wallet/src/managed_account/managed_account_collection.rs (1)
  • new (56-72)
key-wallet/src/managed_account/managed_account_type.rs (1)
  • index (112-156)
key-wallet/src/account/account_type.rs (1)
  • index (126-153)
key-wallet-ffi/src/managed_account.rs (4)
key-wallet-ffi/src/wallet_manager.rs (1)
  • wallet_manager_get_managed_wallet_info (624-663)
key-wallet/src/managed_account/managed_account_collection.rs (1)
  • new (56-72)
key-wallet/src/account/account_collection.rs (1)
  • new (68-86)
key-wallet-ffi/src/managed_wallet.rs (2)
  • new (27-31)
  • managed_wallet_info_free (743-750)
key-wallet-ffi/src/wallet.rs (5)
key-wallet/src/transaction_checking/account_checker.rs (1)
  • account_index (167-195)
key-wallet-ffi/src/types.rs (3)
  • error (204-215)
  • new (165-169)
  • success (195-201)
key-wallet/src/managed_account/managed_account_collection.rs (1)
  • new (56-72)
key-wallet-ffi/src/account.rs (3)
  • new (20-24)
  • new (41-45)
  • new (62-66)
key-wallet/src/bip32.rs (5)
  • decode (379-401)
  • decode (502-524)
  • decode (960-964)
  • decode (1581-1587)
  • decode (1873-1879)
key-wallet/src/managed_account/managed_account_collection.rs (3)
key-wallet/src/managed_account/address_pool.rs (5)
  • new (357-372)
  • new (1059-1069)
  • base_path (1072-1075)
  • network (1100-1103)
  • key_source (1118-1121)
key-wallet/src/account/account_collection.rs (1)
  • new (68-86)
key-wallet/src/managed_account/managed_account_type.rs (1)
  • index (112-156)
key-wallet-ffi/include/key_wallet_ffi.h (3)
key-wallet-ffi/src/managed_account.rs (2)
  • managed_wallet_get_dashpay_receiving_account (308-369)
  • managed_wallet_get_dashpay_external_account (376-437)
key-wallet-ffi/src/transaction_checking.rs (1)
  • managed_wallet_check_transaction (109-477)
key-wallet-ffi/src/wallet.rs (2)
  • wallet_add_dashpay_receiving_account (531-581)
  • wallet_add_dashpay_external_account_with_xpub_bytes (589-655)
⏰ 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). (19)
  • GitHub Check: Core Components Tests
  • GitHub Check: SPV Components Tests
  • GitHub Check: RPC Tests (stable, true)
  • GitHub Check: Key Wallet Components Tests
  • GitHub Check: fuzz (hashes_sha512)
  • GitHub Check: fuzz (hashes_sha1)
  • GitHub Check: fuzz (dash_deserialize_witness)
  • GitHub Check: fuzz (dash_deserialize_script)
  • GitHub Check: fuzz (hashes_sha256)
  • GitHub Check: fuzz (hashes_sha512_256)
  • GitHub Check: fuzz (hashes_ripemd160)
  • GitHub Check: fuzz (hashes_json)
  • GitHub Check: fuzz (dash_script_bytes_to_asm_fmt)
  • GitHub Check: fuzz (hashes_cbor)
  • GitHub Check: fuzz (dash_deserialize_block)
  • GitHub Check: fuzz (dash_deser_net_msg)
  • GitHub Check: fuzz (dash_outpoint_string)
  • GitHub Check: fuzz (dash_deserialize_amount)
  • GitHub Check: fuzz (dash_deserialize_address)

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between da8c2a2 and d23d16a.

📒 Files selected for processing (3)
  • key-wallet-ffi/FFI_API.md (7 hunks)
  • key-wallet-ffi/src/types.rs (3 hunks)
  • key-wallet/src/account/account_type.rs (5 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
**/*.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:

  • key-wallet/src/account/account_type.rs
  • key-wallet-ffi/src/types.rs
{key-wallet,swift-dash-core-sdk}/**/*.{rs,swift}

📄 CodeRabbit inference engine (CLAUDE.md)

Never log or expose private keys

Files:

  • key-wallet/src/account/account_type.rs
key-wallet/**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

Use secure random number generation for key material

Files:

  • key-wallet/src/account/account_type.rs
key-wallet/src/**/*.rs

📄 CodeRabbit inference engine (key-wallet/CLAUDE.md)

key-wallet/src/**/*.rs: Never serialize, print, or log private keys; avoid exposing secret key material in any form
Prefer using public keys or key fingerprints for identification in logs and messages instead of private keys
Always validate network consistency; never mix mainnet and testnet operations
Use the custom Error type; propagate errors with the ? operator and provide contextual messages
Never panic in library code; return Result<T, Error> for all fallible operations

Files:

  • key-wallet/src/account/account_type.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:

  • key-wallet/src/account/account_type.rs
  • key-wallet-ffi/src/types.rs
*-ffi/**

📄 CodeRabbit inference engine (AGENTS.md)

FFI bindings live in *-ffi crates

Files:

  • key-wallet-ffi/FFI_API.md
  • key-wallet-ffi/src/types.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:

  • key-wallet-ffi/src/types.rs
🧠 Learnings (26)
📓 Common learnings
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Maintain compatibility with Dash Core versions 0.18.0–0.21.0
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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
Learnt from: QuantumExplorer
Repo: dashpay/rust-dashcore PR: 108
File: key-wallet/src/gap_limit.rs:291-295
Timestamp: 2025-08-21T04:45:50.436Z
Learning: The rust-dashcore project uses Rust 1.89 as evidenced by rust-version = "1.89" in dash-spv/Cargo.toml. Modern Rust features like Option::is_none_or (stabilized in 1.82) can be used safely.
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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: DCG-Claude
Repo: dashpay/rust-dashcore PR: 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.
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/src/transaction_checking/**/*.rs : Use transaction type routing to check only relevant accounts
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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: DCG-Claude
Repo: dashpay/rust-dashcore PR: 0
File: :0-0
Timestamp: 2025-06-26T15:47:37.438Z
Learning: Transaction IDs (txids) and block hashes in Dash are always 32 bytes and should be passed as fixed-size byte arrays in FFI interfaces, not as C strings, to avoid inefficiency and encoding issues.
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet/src/account/account_type.rs
  • key-wallet-ffi/FFI_API.md
  • key-wallet-ffi/src/types.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/src/transaction_checking/**/*.rs : Use transaction type routing to check only relevant accounts

Applied to files:

  • key-wallet/src/account/account_type.rs
  • key-wallet-ffi/FFI_API.md
  • key-wallet-ffi/src/types.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet/src/account/account_type.rs
  • key-wallet-ffi/FFI_API.md
  • key-wallet-ffi/src/types.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet/src/account/account_type.rs
  • key-wallet-ffi/FFI_API.md
  • key-wallet-ffi/src/types.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/src/{bip32.rs,derivation/**/*.rs} : Optimize derivation: cache intermediate results, use hardened derivation only when required, and batch-derive child keys where possible

Applied to files:

  • key-wallet/src/account/account_type.rs
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet/src/account/account_type.rs
  • key-wallet-ffi/FFI_API.md
  • key-wallet-ffi/src/types.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet/src/account/account_type.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/src/**/*.rs : Prefer using public keys or key fingerprints for identification in logs and messages instead of private keys

Applied to files:

  • key-wallet/src/account/account_type.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet/src/account/account_type.rs
  • key-wallet-ffi/src/types.rs
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/src/**/*.rs : Add cbindgen annotations for complex types so headers are generated correctly

Applied to files:

  • key-wallet/src/account/account_type.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet/src/account/account_type.rs
  • key-wallet-ffi/src/types.rs
📚 Learning: 2025-08-16T04:15:57.225Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet/src/account/account_type.rs
  • key-wallet-ffi/FFI_API.md
📚 Learning: 2025-08-29T04:00:14.154Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet/src/account/account_type.rs
  • key-wallet-ffi/FFI_API.md
  • key-wallet-ffi/src/types.rs
📚 Learning: 2025-06-26T15:47:37.438Z
Learnt from: DCG-Claude
Repo: dashpay/rust-dashcore PR: 0
File: :0-0
Timestamp: 2025-06-26T15:47:37.438Z
Learning: Transaction IDs (txids) and block hashes in Dash are always 32 bytes and should be passed as fixed-size byte arrays in FFI interfaces, not as C strings, to avoid inefficiency and encoding issues.

Applied to files:

  • key-wallet/src/account/account_type.rs
  • key-wallet-ffi/FFI_API.md
  • key-wallet-ffi/src/types.rs
📚 Learning: 2025-08-21T05:01:58.949Z
Learnt from: QuantumExplorer
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet-ffi/FFI_API.md
  • key-wallet-ffi/src/types.rs
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet-ffi/FFI_API.md
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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/FFI_API.md
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet-ffi/FFI_API.md
📚 Learning: 2025-08-16T04:15:57.225Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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

Applied to files:

  • key-wallet-ffi/FFI_API.md
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet-ffi/src/types.rs
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet-ffi/src/types.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/src/**/*.rs : Use the custom Error type; propagate errors with the ? operator and provide contextual messages

Applied to files:

  • key-wallet-ffi/src/types.rs
📚 Learning: 2025-08-16T04:15:29.335Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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 : At the FFI boundary, convert FFI errors to DashSDKError and use Result types; log FFI errors before converting

Applied to files:

  • key-wallet-ffi/src/types.rs
📚 Learning: 2025-06-26T15:46:56.854Z
Learnt from: DCG-Claude
Repo: dashpay/rust-dashcore PR: 0
File: :0-0
Timestamp: 2025-06-26T15:46:56.854Z
Learning: Transaction IDs (txids) in Dash are always 32 bytes and should be passed as fixed-size byte arrays in FFI interfaces, not as C strings, to avoid inefficiency and encoding issues.

Applied to files:

  • key-wallet-ffi/src/types.rs
📚 Learning: 2025-08-16T04:15:29.335Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet-ffi/src/types.rs
🧬 Code graph analysis (2)
key-wallet/src/account/account_type.rs (3)
key-wallet/src/dip9.rs (1)
  • from (69-71)
key-wallet/src/transaction_checking/transaction_router/mod.rs (2)
  • from (184-231)
  • from (235-282)
key-wallet/src/bip32.rs (7)
  • from (81-83)
  • from (226-228)
  • from (776-786)
  • from (790-805)
  • from (984-989)
  • from (1201-1203)
  • from_hardened_idx (622-630)
key-wallet-ffi/src/types.rs (2)
key-wallet/src/account/account_type.rs (1)
  • index (126-155)
key-wallet/src/managed_account/managed_account_type.rs (2)
  • index (112-156)
  • from_account_type (408-648)

Comment on lines +304 to +329
// that are not part of the current FFI API. These types cannot be constructed via this
// conversion path. Attempting to use them is a programming error.
//
// TODO: Extend the FFI API to accept identity IDs for DashPay account creation:
// - Add new FFI functions like:
// * ffi_account_type_to_dashpay_receiving_funds(index, user_id[32], friend_id[32])
// * ffi_account_type_to_dashpay_external_account(index, user_id[32], friend_id[32])
// - Or extend to_account_type to accept optional identity ID parameters
//
// Until then, attempting to convert these variants will panic to prevent silent misrouting.
FFIAccountType::DashpayReceivingFunds => {
panic!(
"FFIAccountType::DashpayReceivingFunds cannot be converted to AccountType \
without user_identity_id and friend_identity_id. The FFI API does not yet \
support passing these 32-byte identity IDs. This is a programming error - \
DashPay account creation must use a different API path."
);
}
FFIAccountType::DashpayExternalAccount => {
panic!(
"FFIAccountType::DashpayExternalAccount cannot be converted to AccountType \
without user_identity_id and friend_identity_id. The FFI API does not yet \
support passing these 32-byte identity IDs. This is a programming error - \
DashPay account creation must use a different API path."
);
}
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

Avoid panicking in FFI conversion helpers

These new arms deliberately panic! when DashPay variants flow through to_account_type / from_account_type. Both helpers sit on hot FFI paths (e.g. wallet_add_account, managed_account_get_account_type); if a DashPay account ever reaches them, we tear down the entire host process. Please reject unsupported input via the existing FFI error machinery (e.g. return an error/result that callers can propagate) instead of panicking, so we stay within the “never panic in library/FFI code” guideline and keep the host stable. After changing the return type, update the new tests to assert the error outcome rather than expecting a panic.

Also applies to: 382-413

🤖 Prompt for AI Agents
In key-wallet-ffi/src/types.rs around lines 304-329 (and also apply the same
change to the similar blocks at 382-413), replace the panic! branches for
FFIAccountType::DashpayReceivingFunds and ::DashpayExternalAccount with
returning an FFI-style error result instead: change the conversion helper
signatures to return Result<AccountType, FFIError> (or the crate's existing FFI
error type), construct and return an appropriate error indicating missing
user_identity_id/friend_identity_id, and update all call sites and tests to
propagate/handle the Result rather than expecting a panic (adjust tests to
assert the error outcome). Ensure usage of the existing FFI error
machinery/variants and maintain ABI boundaries for FFI callers.

Comment on lines +349 to +392
Self::DashpayReceivingFunds {
user_identity_id,
friend_identity_id,
..
} => {
// Base DashPay root + account 0' + user_id/friend_id (non-hardened per DIP-14/DIP-15)
let mut path = match network {
Network::Dash => DerivationPath::from(crate::dip9::DASHPAY_ROOT_PATH_MAINNET),
Network::Testnet => {
DerivationPath::from(crate::dip9::DASHPAY_ROOT_PATH_TESTNET)
}
_ => return Err(crate::error::Error::InvalidNetwork),
};
path.push(ChildNumber::from_hardened_idx(0).map_err(crate::error::Error::Bip32)?);
path.push(ChildNumber::Normal256 {
index: *user_identity_id,
});
path.push(ChildNumber::Normal256 {
index: *friend_identity_id,
});
Ok(path)
}
Self::DashpayExternalAccount {
user_identity_id,
friend_identity_id,
..
} => {
// Base DashPay root + account 0' + friend_id/user_id (non-hardened per DIP-14/DIP-15)
let mut path = match network {
Network::Dash => DerivationPath::from(crate::dip9::DASHPAY_ROOT_PATH_MAINNET),
Network::Testnet => {
DerivationPath::from(crate::dip9::DASHPAY_ROOT_PATH_TESTNET)
}
_ => return Err(crate::error::Error::InvalidNetwork),
};
path.push(ChildNumber::from_hardened_idx(0).map_err(crate::error::Error::Bip32)?);
path.push(ChildNumber::Normal256 {
index: *friend_identity_id,
});
path.push(ChildNumber::Normal256 {
index: *user_identity_id,
});
Ok(path)
}
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

Derive DashPay paths with the requested account index

DashpayReceivingFunds / DashpayExternalAccount stash an index, yet derivation_path() still hardcodes 0'. Any caller that asks for index ≠ 0 will get the exact same path as index 0, so multiple DashPay accounts collide on identical keys/addresses. Please push the stored index into the path just like the other account types.

-            Self::DashpayReceivingFunds {
-                user_identity_id,
-                friend_identity_id,
-                ..
-            } => {
+            Self::DashpayReceivingFunds {
+                index,
+                user_identity_id,
+                friend_identity_id,
+            } => {
                 // Base DashPay root + account 0' + user_id/friend_id (non-hardened per DIP-14/DIP-15)
                 let mut path = match network {
                     Network::Dash => DerivationPath::from(crate::dip9::DASHPAY_ROOT_PATH_MAINNET),
@@
-                path.push(ChildNumber::from_hardened_idx(0).map_err(crate::error::Error::Bip32)?);
+                path.push(
+                    ChildNumber::from_hardened_idx(*index).map_err(crate::error::Error::Bip32)?,
+                );
@@
-            Self::DashpayExternalAccount {
-                user_identity_id,
-                friend_identity_id,
-                ..
-            } => {
+            Self::DashpayExternalAccount {
+                index,
+                user_identity_id,
+                friend_identity_id,
+            } => {
@@
-                path.push(ChildNumber::from_hardened_idx(0).map_err(crate::error::Error::Bip32)?);
+                path.push(
+                    ChildNumber::from_hardened_idx(*index).map_err(crate::error::Error::Bip32)?,
+                );
🤖 Prompt for AI Agents
In key-wallet/src/account/account_type.rs around lines 349 to 392, the Dashpay
variants always push a hardcoded account 0' into the derivation path, ignoring
the stored `index` field and causing different requested accounts to collide;
change both Dashpay branches to push the stored account index as a hardened
child instead of 0' (i.e., call
ChildNumber::from_hardened_idx(*index).map_err(crate::error::Error::Bip32)? ),
keeping the subsequent non-hardened user/friend indices in the same order for
each variant so the path becomes: DASHPAY_ROOT + account_index' (hardened) +
non-hardened user/friend ids.

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

🧹 Nitpick comments (1)
key-wallet/src/managed_account/managed_account_collection.rs (1)

580-677: Consider adding DashPay-specific accessor methods for consistency.

The helper methods get, get_mut, remove, and contains_key only support u32 index-based lookups and don't provide access to DashPay accounts, which require composite DashpayAccountKey keys. While direct field access works fine, dedicated accessors could improve API consistency and ergonomics.

If DashPay accounts are frequently accessed, consider adding methods like:

pub fn get_dashpay_receival(&self, key: &DashpayAccountKey) -> Option<&ManagedAccount> {
    self.dashpay_receival_accounts.get(key)
}

pub fn get_dashpay_receival_mut(&mut self, key: &DashpayAccountKey) -> Option<&mut ManagedAccount> {
    self.dashpay_receival_accounts.get_mut(key)
}

// Similar for dashpay_external_accounts

However, this is optional—the public fields already provide type-safe direct access.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 616a6e2 and be2069b.

📒 Files selected for processing (1)
  • key-wallet/src/managed_account/managed_account_collection.rs (11 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
**/*.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:

  • key-wallet/src/managed_account/managed_account_collection.rs
{key-wallet,swift-dash-core-sdk}/**/*.{rs,swift}

📄 CodeRabbit inference engine (CLAUDE.md)

Never log or expose private keys

Files:

  • key-wallet/src/managed_account/managed_account_collection.rs
key-wallet/**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

Use secure random number generation for key material

Files:

  • key-wallet/src/managed_account/managed_account_collection.rs
key-wallet/src/**/*.rs

📄 CodeRabbit inference engine (key-wallet/CLAUDE.md)

key-wallet/src/**/*.rs: Never serialize, print, or log private keys; avoid exposing secret key material in any form
Prefer using public keys or key fingerprints for identification in logs and messages instead of private keys
Always validate network consistency; never mix mainnet and testnet operations
Use the custom Error type; propagate errors with the ? operator and provide contextual messages
Never panic in library code; return Result<T, Error> for all fallible operations

Files:

  • key-wallet/src/managed_account/managed_account_collection.rs
key-wallet/src/managed_account/**/*.rs

📄 CodeRabbit inference engine (key-wallet/CLAUDE.md)

Never attempt signing operations for watch-only accounts

Files:

  • key-wallet/src/managed_account/managed_account_collection.rs
key-wallet/src/{managed_account,transaction_checking}/**/*.rs

📄 CodeRabbit inference engine (key-wallet/CLAUDE.md)

Update wallet state atomically: add transaction, update UTXOs, recalculate balance, and mark addresses used in a single operation

Files:

  • key-wallet/src/managed_account/managed_account_collection.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:

  • key-wallet/src/managed_account/managed_account_collection.rs
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Maintain compatibility with Dash Core versions 0.18.0–0.21.0
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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
Learnt from: QuantumExplorer
Repo: dashpay/rust-dashcore PR: 108
File: key-wallet/src/gap_limit.rs:291-295
Timestamp: 2025-08-21T04:45:50.436Z
Learning: The rust-dashcore project uses Rust 1.89 as evidenced by rust-version = "1.89" in dash-spv/Cargo.toml. Modern Rust features like Option::is_none_or (stabilized in 1.82) can be used safely.
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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: DCG-Claude
Repo: dashpay/rust-dashcore PR: 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.
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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: DCG-Claude
Repo: dashpay/rust-dashcore PR: 0
File: :0-0
Timestamp: 2025-06-26T15:47:37.438Z
Learning: Transaction IDs (txids) and block hashes in Dash are always 32 bytes and should be passed as fixed-size byte arrays in FFI interfaces, not as C strings, to avoid inefficiency and encoding issues.
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet/src/managed_account/managed_account_collection.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet/src/managed_account/managed_account_collection.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/src/transaction_checking/**/*.rs : Use transaction type routing to check only relevant accounts

Applied to files:

  • key-wallet/src/managed_account/managed_account_collection.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet/src/managed_account/managed_account_collection.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/src/{bip32.rs,derivation/**/*.rs} : Optimize derivation: cache intermediate results, use hardened derivation only when required, and batch-derive child keys where possible

Applied to files:

  • key-wallet/src/managed_account/managed_account_collection.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/src/managed_account/**/*.rs : Never attempt signing operations for watch-only accounts

Applied to files:

  • key-wallet/src/managed_account/managed_account_collection.rs
🧬 Code graph analysis (1)
key-wallet/src/managed_account/managed_account_collection.rs (5)
key-wallet/src/managed_account/address_pool.rs (5)
  • new (357-372)
  • new (1059-1069)
  • base_path (1072-1075)
  • network (1100-1103)
  • key_source (1118-1121)
key-wallet/src/account/account_collection.rs (1)
  • new (68-86)
key-wallet/src/managed_account/mod.rs (3)
  • new (63-73)
  • index (138-140)
  • network (819-821)
key-wallet/src/account/account_type.rs (1)
  • index (126-155)
key-wallet/src/managed_account/managed_account_type.rs (1)
  • index (112-156)
🔇 Additional comments (8)
key-wallet/src/managed_account/managed_account_collection.rs (8)

56-71: LGTM: Constructor properly initializes DashPay account maps.

The initialization of the new DashPay account maps follows the established pattern for other account type collections.


120-146: LGTM: DashPay account type checking implemented correctly.

The logic properly constructs composite keys and checks for existence in the appropriate maps, consistent with the pattern used for other indexed account types.


213-239: LGTM: DashPay account insertion logic is correct.

The insertion logic properly constructs composite keys and stores accounts in the appropriate maps, maintaining consistency with the containment checks.


321-334: LGTM: DashPay account collection conversion is properly implemented.

The conversion correctly iterates over both DashPay account maps, creates managed accounts, and preserves the composite keys during transfer from AccountCollection to ManagedAccountCollection.


723-727: LGTM: DashPay accounts properly included in all_accounts.

The DashPay account maps are correctly appended to the accounts vector, maintaining consistency with how other account types are aggregated.


774-778: LGTM: Mutable DashPay account access properly implemented.

The mutable variant correctly includes DashPay accounts using values_mut(), consistent with the immutable all_accounts method.


806-820: LGTM: Emptiness check correctly includes DashPay accounts.

The is_empty method properly checks both DashPay account maps, ensuring the collection is only considered empty when all account types are absent.


822-837: LGTM: Clear method properly resets DashPay account maps.

The clear method correctly clears both DashPay account collections, maintaining consistency with the reset of other account type fields.

Comment on lines +547 to +574
AccountType::DashpayReceivingFunds {
index,
user_identity_id,
friend_identity_id,
} => {
let addresses =
AddressPool::new(base_path, AddressPoolType::Absent, 20, network, key_source)?;
ManagedAccountType::DashpayReceivingFunds {
index,
user_identity_id,
friend_identity_id,
addresses,
}
}
AccountType::DashpayExternalAccount {
index,
user_identity_id,
friend_identity_id,
} => {
let addresses =
AddressPool::new(base_path, AddressPoolType::Absent, 20, network, key_source)?;
ManagedAccountType::DashpayExternalAccount {
index,
user_identity_id,
friend_identity_id,
addresses,
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Replace hardcoded gap limit with a named constant.

Lines 553 and 567 use a hardcoded value of 20 for the gap limit, which is inconsistent with other special-purpose accounts that use DEFAULT_SPECIAL_GAP_LIMIT (lines 452, 466, 479, 491, 503, 515, 527). This magic number reduces maintainability.

Consider one of these approaches:

Option 1 (if 20 matches the existing default): Use the existing constant.

             AccountType::DashpayReceivingFunds {
                 index,
                 user_identity_id,
                 friend_identity_id,
             } => {
-                let addresses =
-                    AddressPool::new(base_path, AddressPoolType::Absent, 20, network, key_source)?;
+                let addresses = AddressPool::new(
+                    base_path,
+                    AddressPoolType::Absent,
+                    DEFAULT_SPECIAL_GAP_LIMIT,
+                    network,
+                    key_source,
+                )?;
                 ManagedAccountType::DashpayReceivingFunds {
                     index,
                     user_identity_id,
                     friend_identity_id,
                     addresses,
                 }
             }
             AccountType::DashpayExternalAccount {
                 index,
                 user_identity_id,
                 friend_identity_id,
             } => {
-                let addresses =
-                    AddressPool::new(base_path, AddressPoolType::Absent, 20, network, key_source)?;
+                let addresses = AddressPool::new(
+                    base_path,
+                    AddressPoolType::Absent,
+                    DEFAULT_SPECIAL_GAP_LIMIT,
+                    network,
+                    key_source,
+                )?;
                 ManagedAccountType::DashpayExternalAccount {
                     index,
                     user_identity_id,
                     friend_identity_id,
                     addresses,
                 }
             }

Option 2 (if 20 is intentionally different): Define a new constant in gap_limit.rs:

pub const DEFAULT_DASHPAY_GAP_LIMIT: u32 = 20;

Then import and use it here.

🤖 Prompt for AI Agents
In key-wallet/src/managed_account/managed_account_collection.rs around lines 547
to 574, the AddressPool::new calls use a hardcoded gap limit value of 20;
replace this magic number with a named constant for consistency and
maintainability—either use the existing DEFAULT_SPECIAL_GAP_LIMIT if 20 matches
it, or add a new constant (e.g., DEFAULT_DASHPAY_GAP_LIMIT) in gap_limit.rs,
import that constant into this file, and pass it to AddressPool::new in both
DashpayReceivingFunds and DashpayExternalAccount branches.

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between be2069b and d9dd320.

📒 Files selected for processing (2)
  • dash-spv-ffi/include/dash_spv_ffi.h (2 hunks)
  • key-wallet-ffi/src/wallet.rs (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • dash-spv-ffi/include/dash_spv_ffi.h
🧰 Additional context used
📓 Path-based instructions (4)
**/*.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:

  • key-wallet-ffi/src/wallet.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:

  • key-wallet-ffi/src/wallet.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:

  • key-wallet-ffi/src/wallet.rs
*-ffi/**

📄 CodeRabbit inference engine (AGENTS.md)

FFI bindings live in *-ffi crates

Files:

  • key-wallet-ffi/src/wallet.rs
🧠 Learnings (18)
📓 Common learnings
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Maintain compatibility with Dash Core versions 0.18.0–0.21.0
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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
Learnt from: QuantumExplorer
Repo: dashpay/rust-dashcore PR: 108
File: key-wallet/src/gap_limit.rs:291-295
Timestamp: 2025-08-21T04:45:50.436Z
Learning: The rust-dashcore project uses Rust 1.89 as evidenced by rust-version = "1.89" in dash-spv/Cargo.toml. Modern Rust features like Option::is_none_or (stabilized in 1.82) can be used safely.
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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: DCG-Claude
Repo: dashpay/rust-dashcore PR: 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.
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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: DCG-Claude
Repo: dashpay/rust-dashcore PR: 0
File: :0-0
Timestamp: 2025-06-26T15:47:37.438Z
Learning: Transaction IDs (txids) and block hashes in Dash are always 32 bytes and should be passed as fixed-size byte arrays in FFI interfaces, not as C strings, to avoid inefficiency and encoding issues.
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet-ffi/src/wallet.rs
📚 Learning: 2025-08-29T04:00:14.154Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet-ffi/src/wallet.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet-ffi/src/wallet.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet-ffi/src/wallet.rs
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet-ffi/src/wallet.rs
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet-ffi/src/wallet.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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/wallet.rs
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet-ffi/src/wallet.rs
📚 Learning: 2025-08-16T04:15:57.225Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet-ffi/src/wallet.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/src/{bip32.rs,derivation/**/*.rs} : Optimize derivation: cache intermediate results, use hardened derivation only when required, and batch-derive child keys where possible

Applied to files:

  • key-wallet-ffi/src/wallet.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/src/**/*.rs : Never panic in library code; return Result<T, Error> for all fallible operations

Applied to files:

  • key-wallet-ffi/src/wallet.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/src/transaction_checking/**/*.rs : Use transaction type routing to check only relevant accounts

Applied to files:

  • key-wallet-ffi/src/wallet.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/src/**/*.rs : Use the custom Error type; propagate errors with the ? operator and provide contextual messages

Applied to files:

  • key-wallet-ffi/src/wallet.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet-ffi/src/wallet.rs
📚 Learning: 2025-06-15T16:42:18.187Z
Learnt from: QuantumExplorer
Repo: dashpay/rust-dashcore PR: 74
File: key-wallet-ffi/src/lib_tests.rs:41-48
Timestamp: 2025-06-15T16:42:18.187Z
Learning: In key-wallet-ffi, the HDWallet::derive_xpriv method returns Result<String, KeyWalletError>, not an ExtPrivKey wrapper. When unwrapped, it yields a String that can have .is_empty() called on it.

Applied to files:

  • key-wallet-ffi/src/wallet.rs
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet-ffi/src/wallet.rs
📚 Learning: 2025-08-21T05:01:58.949Z
Learnt from: QuantumExplorer
Repo: dashpay/rust-dashcore PR: 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:

  • key-wallet-ffi/src/wallet.rs
🧬 Code graph analysis (1)
key-wallet-ffi/src/wallet.rs (6)
key-wallet/src/transaction_checking/account_checker.rs (1)
  • account_index (167-195)
key-wallet-ffi/src/types.rs (3)
  • error (204-215)
  • new (165-169)
  • success (195-201)
key-wallet/src/managed_account/managed_account_collection.rs (1)
  • new (56-72)
key-wallet/src/account/account_collection.rs (1)
  • new (68-86)
key-wallet-ffi/src/account.rs (3)
  • new (20-24)
  • new (41-45)
  • new (62-66)
key-wallet/src/bip32.rs (5)
  • decode (379-401)
  • decode (502-524)
  • decode (960-964)
  • decode (1581-1587)
  • decode (1873-1879)
🔇 Additional comments (1)
key-wallet-ffi/src/wallet.rs (1)

12-12: LGTM: Import properly supports new return type.

The FFIAccountResult import is correctly placed and necessary for the new DashPay account functions.

Comment on lines +525 to +581
/// Add a DashPay receiving funds account
///
/// # Safety
/// - `wallet` must be a valid pointer
/// - `user_identity_id` and `friend_identity_id` must each point to 32 bytes
#[no_mangle]
pub unsafe extern "C" fn wallet_add_dashpay_receiving_account(
wallet: *mut FFIWallet,
network: FFINetwork,
account_index: c_uint,
user_identity_id: *const u8,
friend_identity_id: *const u8,
) -> FFIAccountResult {
use key_wallet::account::AccountType;
if wallet.is_null() || user_identity_id.is_null() || friend_identity_id.is_null() {
return FFIAccountResult::error(
crate::error::FFIErrorCode::InvalidInput,
"Null pointer provided".to_string(),
);
}
let w = &mut *wallet;
let wallet_mut = match w.inner_mut() {
Some(w) => w,
None => {
return FFIAccountResult::error(
crate::error::FFIErrorCode::InvalidInput,
"Wallet is immutable".to_string(),
)
}
};
let mut user_id = [0u8; 32];
let mut friend_id = [0u8; 32];
core::ptr::copy_nonoverlapping(user_identity_id, user_id.as_mut_ptr(), 32);
core::ptr::copy_nonoverlapping(friend_identity_id, friend_id.as_mut_ptr(), 32);

let acct = AccountType::DashpayReceivingFunds {
index: account_index,
user_identity_id: user_id,
friend_identity_id: friend_id,
};
let network_rust: key_wallet::Network = network.into();
match wallet_mut.add_account(acct, network_rust, None) {
Ok(()) => {
if let Some(coll) = wallet_mut.accounts.get(&network_rust) {
if let Some(account) = coll.account_of_type(acct) {
let ffi_account = crate::types::FFIAccount::new(account);
return FFIAccountResult::success(Box::into_raw(Box::new(ffi_account)));
}
}
FFIAccountResult::error(
crate::error::FFIErrorCode::WalletError,
"Failed to retrieve account after adding".to_string(),
)
}
Err(e) => FFIAccountResult::error(crate::error::FFIErrorCode::InvalidInput, e.to_string()),
}
}
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

Minor inconsistency: Error code mismatch at line 579.

On line 579, the function returns FFIErrorCode::InvalidInput when add_account fails. For consistency with wallet_add_account at line 512-514, this should use FFIErrorCode::WalletError.

Apply this diff to align error codes:

-        Err(e) => FFIAccountResult::error(crate::error::FFIErrorCode::InvalidInput, e.to_string()),
+        Err(e) => FFIAccountResult::error(crate::error::FFIErrorCode::WalletError, e.to_string()),
📝 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
/// Add a DashPay receiving funds account
///
/// # Safety
/// - `wallet` must be a valid pointer
/// - `user_identity_id` and `friend_identity_id` must each point to 32 bytes
#[no_mangle]
pub unsafe extern "C" fn wallet_add_dashpay_receiving_account(
wallet: *mut FFIWallet,
network: FFINetwork,
account_index: c_uint,
user_identity_id: *const u8,
friend_identity_id: *const u8,
) -> FFIAccountResult {
use key_wallet::account::AccountType;
if wallet.is_null() || user_identity_id.is_null() || friend_identity_id.is_null() {
return FFIAccountResult::error(
crate::error::FFIErrorCode::InvalidInput,
"Null pointer provided".to_string(),
);
}
let w = &mut *wallet;
let wallet_mut = match w.inner_mut() {
Some(w) => w,
None => {
return FFIAccountResult::error(
crate::error::FFIErrorCode::InvalidInput,
"Wallet is immutable".to_string(),
)
}
};
let mut user_id = [0u8; 32];
let mut friend_id = [0u8; 32];
core::ptr::copy_nonoverlapping(user_identity_id, user_id.as_mut_ptr(), 32);
core::ptr::copy_nonoverlapping(friend_identity_id, friend_id.as_mut_ptr(), 32);
let acct = AccountType::DashpayReceivingFunds {
index: account_index,
user_identity_id: user_id,
friend_identity_id: friend_id,
};
let network_rust: key_wallet::Network = network.into();
match wallet_mut.add_account(acct, network_rust, None) {
Ok(()) => {
if let Some(coll) = wallet_mut.accounts.get(&network_rust) {
if let Some(account) = coll.account_of_type(acct) {
let ffi_account = crate::types::FFIAccount::new(account);
return FFIAccountResult::success(Box::into_raw(Box::new(ffi_account)));
}
}
FFIAccountResult::error(
crate::error::FFIErrorCode::WalletError,
"Failed to retrieve account after adding".to_string(),
)
}
Err(e) => FFIAccountResult::error(crate::error::FFIErrorCode::InvalidInput, e.to_string()),
}
}
/// Add a DashPay receiving funds account
///
/// # Safety
/// - `wallet` must be a valid pointer
/// - `user_identity_id` and `friend_identity_id` must each point to 32 bytes
#[no_mangle]
pub unsafe extern "C" fn wallet_add_dashpay_receiving_account(
wallet: *mut FFIWallet,
network: FFINetwork,
account_index: c_uint,
user_identity_id: *const u8,
friend_identity_id: *const u8,
) -> FFIAccountResult {
use key_wallet::account::AccountType;
if wallet.is_null() || user_identity_id.is_null() || friend_identity_id.is_null() {
return FFIAccountResult::error(
crate::error::FFIErrorCode::InvalidInput,
"Null pointer provided".to_string(),
);
}
let w = &mut *wallet;
let wallet_mut = match w.inner_mut() {
Some(w) => w,
None => {
return FFIAccountResult::error(
crate::error::FFIErrorCode::InvalidInput,
"Wallet is immutable".to_string(),
)
}
};
let mut user_id = [0u8; 32];
let mut friend_id = [0u8; 32];
core::ptr::copy_nonoverlapping(user_identity_id, user_id.as_mut_ptr(), 32);
core::ptr::copy_nonoverlapping(friend_identity_id, friend_id.as_mut_ptr(), 32);
let acct = AccountType::DashpayReceivingFunds {
index: account_index,
user_identity_id: user_id,
friend_identity_id: friend_id,
};
let network_rust: key_wallet::Network = network.into();
match wallet_mut.add_account(acct, network_rust, None) {
Ok(()) => {
if let Some(coll) = wallet_mut.accounts.get(&network_rust) {
if let Some(account) = coll.account_of_type(acct) {
let ffi_account = crate::types::FFIAccount::new(account);
return FFIAccountResult::success(Box::into_raw(Box::new(ffi_account)));
}
}
FFIAccountResult::error(
crate::error::FFIErrorCode::WalletError,
"Failed to retrieve account after adding".to_string(),
)
}
Err(e) => FFIAccountResult::error(crate::error::FFIErrorCode::WalletError, e.to_string()),
}
}
🤖 Prompt for AI Agents
In key-wallet-ffi/src/wallet.rs around lines 525 to 581, the Err(e) branch of
wallet_add_dashpay_receiving_account currently returns
FFIErrorCode::InvalidInput; change that to FFIErrorCode::WalletError to match
wallet_add_account and maintain consistency, keeping the error message as
e.to_string().

core::ptr::copy_nonoverlapping(user_identity_id, user_id.as_mut_ptr(), 32);
core::ptr::copy_nonoverlapping(friend_identity_id, friend_id.as_mut_ptr(), 32);
let xpub_slice = core::slice::from_raw_parts(xpub_bytes, xpub_len);
let xpub = match ExtendedPubKey::decode(xpub_slice) {
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

Verify inconsistent xpub byte interpretation.

This function uses ExtendedPubKey::decode (binary deserialization via bincode), while wallet_add_account_with_xpub_bytes at lines 698-708 treats the same parameter as a UTF-8 string representation. This means callers must pass different byte formats depending on which function they use, which is error-prone.

Consider either:

  1. Documenting clearly that DashPay functions expect binary-encoded xpub while standard functions expect string-encoded xpub, or
  2. Unifying the approach by adding a wallet_add_dashpay_external_account_with_string_xpub companion function to match the pattern of the generic account functions.

🏁 Script executed:

#!/bin/bash
# Verify how ExtendedPubKey is typically encoded/decoded in the codebase
# and whether this inconsistency is intentional

# Search for other usages of ExtendedPubKey::decode
ast-grep --pattern 'ExtendedPubKey::decode($_)'

# Search for string parsing of ExtendedPubKey
rg -nP --type=rust -C3 'parse::<ExtendedPubKey>'

# Check if there's documentation distinguishing binary vs string xpub formats
rg -nP --type=rust -C3 'xpub.*byte|byte.*xpub'

Length of output: 7616


Now let me verify if there's documentation about these functions and check for the error code issue mentioned in the original review comment:

Now let me check if there's documentation about the error codes and verify the complete context around line 653:

Based on the script output and verification, I can now provide the rewritten review comment. The inconsistency has been confirmed:


Unify xpub byte format handling across FFI functions.

Extended public keys (xpub) are Base58-encoded string representations as defined in BIP 32. The current code has incompatible interpretations:

  • Line 625: ExtendedPubKey::decode(xpub_slice) expects bincode binary format
  • Line 708: xpub_str.parse::<ExtendedPubKey>() treats bytes as UTF-8 string (correct for standard xpub)

This forces callers to pass different byte formats depending on which function they use. Standardize on string-based xpub (line 708's approach), which aligns with BIP32 base58 representation starting with xpub/xprv on mainnet. Either:

  1. Modify line 625 to parse as UTF-8 string like line 708, or
  2. Add clear documentation explaining why DashPay functions use binary encoding

"Failed to retrieve account after adding".to_string(),
)
}
Err(e) => FFIAccountResult::error(crate::error::FFIErrorCode::InvalidInput, e.to_string()),
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

Minor inconsistency: Error code mismatch at line 653.

Similar to the previous function, line 653 returns FFIErrorCode::InvalidInput when add_account fails. For consistency with wallet_add_account at line 512-514, this should use FFIErrorCode::WalletError.

Apply this diff to align error codes:

-        Err(e) => FFIAccountResult::error(crate::error::FFIErrorCode::InvalidInput, e.to_string()),
+        Err(e) => FFIAccountResult::error(crate::error::FFIErrorCode::WalletError, e.to_string()),
📝 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
Err(e) => FFIAccountResult::error(crate::error::FFIErrorCode::InvalidInput, e.to_string()),
Err(e) => FFIAccountResult::error(crate::error::FFIErrorCode::WalletError, e.to_string()),
🤖 Prompt for AI Agents
In key-wallet-ffi/src/wallet.rs around line 653, the error branch currently
returns FFIErrorCode::InvalidInput when add_account fails; change it to return
FFIErrorCode::WalletError to match wallet_add_account (lines ~512-514) for
consistency—update the FFIAccountResult::error call to use
crate::error::FFIErrorCode::WalletError while keeping the same error string
(e.to_string()).

@QuantumExplorer QuantumExplorer merged commit 88c2a6e into v0.41-dev Nov 12, 2025
32 checks passed
@QuantumExplorer QuantumExplorer deleted the feat/dashpaySupport branch November 12, 2025 20:31
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