-
Notifications
You must be signed in to change notification settings - Fork 9
refactor: consolidate balance calculations #338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughManagedAccount::update_balance now computes spendable, unconfirmed, and locked balances by aggregating its UTXOs internally. Wallet-level update_balance delegates to each account's parameterless update and accumulates account balances using a new WalletBalance AddAssign implementation. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
bad5230 to
2860407
Compare
|
This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them. |
6ea5b3f to
508f2b3
Compare
There was a problem hiding this 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
🤖 Fix all issues with AI Agents
In @key-wallet/src/wallet/balance.rs:
- Line 8: Replace the import of std::ops::AddAssign with core::ops::AddAssign so
the crate remains no_std compatible; update the use statement that currently
references AddAssign to import from core::ops::AddAssign (the symbol: AddAssign)
to match the existing core::fmt usage and the crate's no_std cfg in lib.rs.
🧹 Nitpick comments (1)
key-wallet/src/managed_account/mod.rs (1)
268-284: Good refactor consolidating balance computation from UTXOs.The logic correctly prioritizes locked status, then confirmed, then unconfirmed. A few observations:
Potential overflow: The
+=operations on lines 275, 277, 279 could overflow if an account accumulates an extremely large number of UTXOs. Consider usingsaturating_addorchecked_addfor defensive coding.Semantic concern with
last_used: Updatinglast_usedon everyupdate_balance()call (line 283) may not be semantically accurate—a balance recalculation doesn't mean the account was actively used. This was present before, but the refactor amplifies it sinceupdate_balance()is now called more frequently (from wallet-level aggregation).🔎 Consider using saturating arithmetic
pub fn update_balance(&mut self) { let mut spendable = 0; let mut unconfirmed = 0; let mut locked = 0; for utxo in self.utxos.values() { let value = utxo.txout.value; if utxo.is_locked { - locked += value; + locked = locked.saturating_add(value); } else if utxo.is_confirmed { - spendable += value; + spendable = spendable.saturating_add(value); } else { - unconfirmed += value; + unconfirmed = unconfirmed.saturating_add(value); } } self.balance = WalletBalance::new(spendable, unconfirmed, locked); - self.metadata.last_used = Some(Self::current_timestamp()); + // Consider: only update last_used when account is actively used (e.g., mark_address_used) }
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
key-wallet/src/managed_account/mod.rskey-wallet/src/transaction_checking/wallet_checker.rskey-wallet/src/wallet/balance.rskey-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs
💤 Files with no reviewable changes (1)
- key-wallet/src/transaction_checking/wallet_checker.rs
🧰 Additional context used
📓 Path-based instructions (3)
key-wallet/**/*.rs
📄 CodeRabbit inference engine (key-wallet/CLAUDE.md)
key-wallet/**/*.rs: Separate immutable structures (Account,Wallet) containing only identity information from mutable wrappers (ManagedAccount,ManagedWalletInfo) with state management
Never serialize or log private keys in production; use public keys or key fingerprints for identification instead
Always validate network consistency when deriving or validating addresses; never mix mainnet and testnet operations
UseBTreeMapfor ordered data (accounts, transactions) andHashMapfor lookups (address mappings); apply memory management strategies for old transaction data
Apply atomic state updates when managing watch-only wallets: validate that external signatures match expected pubkeys and never attempt signing operations
Use the?operator for error propagation, provide context in error messages, never panic in library code, and returnResult<T>for all fallible operations
Files:
key-wallet/src/managed_account/mod.rskey-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rskey-wallet/src/wallet/balance.rs
key-wallet/**/managed_account/**/*.rs
📄 CodeRabbit inference engine (key-wallet/CLAUDE.md)
Implement atomic state updates when processing transactions: update transactions, UTXOs, balances, and address usage state together
Files:
key-wallet/src/managed_account/mod.rs
**/*.rs
📄 CodeRabbit inference engine (AGENTS.md)
**/*.rs: MSRV (Minimum Supported Rust Version) is 1.89; ensure compatibility with this version for all builds
Unit tests should live alongside code with#[cfg(test)]annotation; integration tests use thetests/directory
Usesnake_casefor function and variable names
UseUpperCamelCasefor types and traits
UseSCREAMING_SNAKE_CASEfor constants
Format code withrustfmtbefore commits; ensurecargo fmt --allis run
Runcargo clippy --workspace --all-targets -- -D warningsfor linting; avoid warnings in CI
Preferasync/awaitviatokiofor asynchronous operations
**/*.rs: Never hardcode network parameters, addresses, or keys in Rust code
Use proper error types (thiserror) and propagate errors appropriately in Rust
Use tokio runtime for async operations in Rust
Use conditional compilation with feature flags for optional features
Write unit tests for new functionality in Rust
Format code using cargo fmt
Run clippy with all features and all targets, treating warnings as errors
Never log or expose private keys in any code
Always validate inputs from untrusted sources in Rust
Use secure random number generation for keys
Files:
key-wallet/src/managed_account/mod.rskey-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rskey-wallet/src/wallet/balance.rs
🧠 Learnings (9)
📓 Common learnings
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/managed_account/**/*.rs : Implement atomic state updates when processing transactions: update transactions, UTXOs, balances, and address usage state together
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/*.rs : Separate immutable structures (`Account`, `Wallet`) containing only identity information from mutable wrappers (`ManagedAccount`, `ManagedWalletInfo`) with state management
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/*.rs : Use `BTreeMap` for ordered data (accounts, transactions) and `HashMap` for lookups (address mappings); apply memory management strategies for old transaction data
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/managed_account/**/*.rs : Implement atomic state updates when processing transactions: update transactions, UTXOs, balances, and address usage state together
Applied to files:
key-wallet/src/managed_account/mod.rskey-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rskey-wallet/src/wallet/balance.rs
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/*.rs : Separate immutable structures (`Account`, `Wallet`) containing only identity information from mutable wrappers (`ManagedAccount`, `ManagedWalletInfo`) with state management
Applied to files:
key-wallet/src/managed_account/mod.rskey-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rskey-wallet/src/wallet/balance.rs
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/*.rs : Apply atomic state updates when managing watch-only wallets: validate that external signatures match expected pubkeys and never attempt signing operations
Applied to files:
key-wallet/src/managed_account/mod.rskey-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rskey-wallet/src/wallet/balance.rs
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/*.rs : Use `BTreeMap` for ordered data (accounts, transactions) and `HashMap` for lookups (address mappings); apply memory management strategies for old transaction data
Applied to files:
key-wallet/src/managed_account/mod.rskey-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rskey-wallet/src/wallet/balance.rs
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/account/**/*.rs : Use enum-based type system for `AccountType` with specific variants (Standard, IdentityAuthentication, IdentityEncryption, MasternodeOperator, etc.) to provide compile-time safety and clear semantics
Applied to files:
key-wallet/src/managed_account/mod.rskey-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rskey-wallet/src/wallet/balance.rs
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/transaction_checking/**/*.rs : Implement transaction classification and routing through `TransactionRouter` to avoid checking all accounts for every transaction
Applied to files:
key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/address_pool/**/*.rs : Support multiple `KeySource` variants (Private, Public, NoKeySource) to enable both full wallets and watch-only wallets with the same interface
Applied to files:
key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rskey-wallet/src/wallet/balance.rs
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/*.rs : Use the `?` operator for error propagation, provide context in error messages, never panic in library code, and return `Result<T>` for all fallible operations
Applied to files:
key-wallet/src/wallet/balance.rs
🧬 Code graph analysis (3)
key-wallet/src/managed_account/mod.rs (2)
key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs (2)
update_balance(81-81)update_balance(205-212)key-wallet/src/wallet/balance.rs (3)
spendable(33-35)unconfirmed(38-40)locked(43-45)
key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs (1)
key-wallet/src/managed_account/mod.rs (1)
balance(858-860)
key-wallet/src/wallet/balance.rs (1)
key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs (2)
balance(78-78)balance(201-203)
🔇 Additional comments (4)
key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs (2)
6-6: Import added to support per-account balance method access.The
ManagedAccountTraitimport is necessary to callaccount.balance()on the mutable account references. This aligns with the trait-based architecture separating immutable identity from mutable state management.
205-211: Clean delegation of balance computation to per-account updates.This refactor properly centralizes balance calculation: each account computes its own balance from its UTXOs, then the wallet aggregates. The use of
AddAssignmakes the accumulation idiomatic.One minor note: the dereference
*account.balance()is required sincebalance()returns&WalletBalance. This works correctly with theCopyderive onWalletBalance.key-wallet/src/wallet/balance.rs (2)
66-72: AddAssign implementation is correct but inherits overflow behavior.The implementation correctly adds only the stored fields (
spendable,unconfirmed,locked), relying ontotal()being computed on-the-fly.Note: The existing
test_balance_overflowtest (line 88-92) documents that overflow panics are expected fortotal(). TheAddAssignoperations on lines 68-70 have the same overflow behavior. This is consistent but worth documenting—if accounts with massive balances are aggregated, overflow could occur during+=.
104-118: Good test coverage for AddAssign.The test validates both:
- Adding non-zero balances correctly sums all fields
- Adding a default (zero) balance leaves the original unchanged
Consider adding an overflow test case for
AddAssignto match the existingtest_balance_overflowpattern if overflow behavior should be documented/enforced.
| } | ||
| } | ||
|
|
||
| let _ = account.update_balance(confirmed, unconfirmed, locked); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure you can remove this update call??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it's just moved into ManagedWalletInfo::update_balance which now calls ManagedAccount::update_balance. Before it only updated its own balance.
Move the account balance updates happening within `check_transaction` into `ManagedAccount::update_balance` and reuse it in `ManagedWalletInfo::update_balance` which also already gets called in `check_transaction`.
508f2b3 to
7f66b40
Compare
There was a problem hiding this 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
🤖 Fix all issues with AI Agents
In @key-wallet/src/managed_account/mod.rs:
- Around line 268-284: The update_balance method misclassifies
InstantSend-locked UTXOs as unconfirmed; modify ManagedAccount::update_balance
to treat utxo.is_instantlocked as spendable (i.e., include utxo in the spendable
branch when utxo.is_confirmed || utxo.is_instantlocked) so its behavior matches
get_spendable_utxos; update the conditional around spendable/unconfirmed/locked
accumulation in update_balance accordingly and leave
WalletBalance::new(spendable, unconfirmed, locked) and metadata updates as-is.
🧹 Nitpick comments (1)
key-wallet/src/managed_account/mod.rs (1)
283-283: Consider semantics of timestamp update during balance recalculation.Updating
last_usedon every balance recalculation may not accurately reflect actual account usage, as balance updates can occur passively through transaction confirmations or maturation without user interaction. Consider whether this timestamp should only be updated when addresses are explicitly marked as used (line 260).
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
key-wallet/src/managed_account/mod.rskey-wallet/src/transaction_checking/wallet_checker.rskey-wallet/src/wallet/balance.rskey-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs
💤 Files with no reviewable changes (1)
- key-wallet/src/transaction_checking/wallet_checker.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- key-wallet/src/wallet/balance.rs
🧰 Additional context used
📓 Path-based instructions (3)
key-wallet/**/*.rs
📄 CodeRabbit inference engine (key-wallet/CLAUDE.md)
key-wallet/**/*.rs: Separate immutable structures (Account,Wallet) containing only identity information from mutable wrappers (ManagedAccount,ManagedWalletInfo) with state management
Never serialize or log private keys in production; use public keys or key fingerprints for identification instead
Always validate network consistency when deriving or validating addresses; never mix mainnet and testnet operations
UseBTreeMapfor ordered data (accounts, transactions) andHashMapfor lookups (address mappings); apply memory management strategies for old transaction data
Apply atomic state updates when managing watch-only wallets: validate that external signatures match expected pubkeys and never attempt signing operations
Use the?operator for error propagation, provide context in error messages, never panic in library code, and returnResult<T>for all fallible operations
Files:
key-wallet/src/managed_account/mod.rskey-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs
key-wallet/**/managed_account/**/*.rs
📄 CodeRabbit inference engine (key-wallet/CLAUDE.md)
Implement atomic state updates when processing transactions: update transactions, UTXOs, balances, and address usage state together
Files:
key-wallet/src/managed_account/mod.rs
**/*.rs
📄 CodeRabbit inference engine (AGENTS.md)
**/*.rs: MSRV (Minimum Supported Rust Version) is 1.89; ensure compatibility with this version for all builds
Unit tests should live alongside code with#[cfg(test)]annotation; integration tests use thetests/directory
Usesnake_casefor function and variable names
UseUpperCamelCasefor types and traits
UseSCREAMING_SNAKE_CASEfor constants
Format code withrustfmtbefore commits; ensurecargo fmt --allis run
Runcargo clippy --workspace --all-targets -- -D warningsfor linting; avoid warnings in CI
Preferasync/awaitviatokiofor asynchronous operations
**/*.rs: Never hardcode network parameters, addresses, or keys in Rust code
Use proper error types (thiserror) and propagate errors appropriately in Rust
Use tokio runtime for async operations in Rust
Use conditional compilation with feature flags for optional features
Write unit tests for new functionality in Rust
Format code using cargo fmt
Run clippy with all features and all targets, treating warnings as errors
Never log or expose private keys in any code
Always validate inputs from untrusted sources in Rust
Use secure random number generation for keys
Files:
key-wallet/src/managed_account/mod.rskey-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs
🧠 Learnings (8)
📓 Common learnings
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/managed_account/**/*.rs : Implement atomic state updates when processing transactions: update transactions, UTXOs, balances, and address usage state together
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/managed_account/**/*.rs : Implement atomic state updates when processing transactions: update transactions, UTXOs, balances, and address usage state together
Applied to files:
key-wallet/src/managed_account/mod.rskey-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/*.rs : Separate immutable structures (`Account`, `Wallet`) containing only identity information from mutable wrappers (`ManagedAccount`, `ManagedWalletInfo`) with state management
Applied to files:
key-wallet/src/managed_account/mod.rskey-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/*.rs : Apply atomic state updates when managing watch-only wallets: validate that external signatures match expected pubkeys and never attempt signing operations
Applied to files:
key-wallet/src/managed_account/mod.rskey-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/*.rs : Use `BTreeMap` for ordered data (accounts, transactions) and `HashMap` for lookups (address mappings); apply memory management strategies for old transaction data
Applied to files:
key-wallet/src/managed_account/mod.rskey-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/account/**/*.rs : Use enum-based type system for `AccountType` with specific variants (Standard, IdentityAuthentication, IdentityEncryption, MasternodeOperator, etc.) to provide compile-time safety and clear semantics
Applied to files:
key-wallet/src/managed_account/mod.rskey-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/address_pool/**/*.rs : Support multiple `KeySource` variants (Private, Public, NoKeySource) to enable both full wallets and watch-only wallets with the same interface
Applied to files:
key-wallet/src/managed_account/mod.rskey-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/transaction_checking/**/*.rs : Implement transaction classification and routing through `TransactionRouter` to avoid checking all accounts for every transaction
Applied to files:
key-wallet/src/managed_account/mod.rskey-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs
🧬 Code graph analysis (2)
key-wallet/src/managed_account/mod.rs (2)
key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs (2)
update_balance(81-81)update_balance(205-212)key-wallet/src/wallet/balance.rs (3)
spendable(33-35)unconfirmed(38-40)locked(43-45)
key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs (2)
key-wallet/src/managed_account/mod.rs (1)
balance(858-860)key-wallet/src/managed_account/managed_account_trait.rs (1)
balance(36-36)
⏰ 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). (20)
- GitHub Check: macOS / wallet
- GitHub Check: fuzz (hashes_sha512)
- GitHub Check: fuzz (dash_deserialize_address)
- GitHub Check: fuzz (dash_deserialize_amount)
- GitHub Check: fuzz (hashes_cbor)
- GitHub Check: fuzz (dash_deserialize_script)
- GitHub Check: fuzz (dash_deserialize_block)
- GitHub Check: fuzz (hashes_sha256)
- GitHub Check: fuzz (hashes_sha1)
- GitHub Check: fuzz (dash_deserialize_witness)
- GitHub Check: fuzz (hashes_json)
- GitHub Check: fuzz (dash_script_bytes_to_asm_fmt)
- GitHub Check: fuzz (hashes_sha512_256)
- GitHub Check: fuzz (hashes_ripemd160)
- GitHub Check: fuzz (dash_deser_net_msg)
- GitHub Check: Pre-commit (windows-latest)
- GitHub Check: Pre-commit (macos-latest)
- GitHub Check: Pre-commit (ubuntu-latest)
- GitHub Check: Thread Sanitizer
- GitHub Check: Address Sanitizer
🔇 Additional comments (2)
key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs (2)
6-6: LGTM!The import enables trait-based access to account balance methods, supporting the refactored balance calculation flow.
205-212: LGTM! Centralized balance logic is well-structured.The refactored implementation correctly delegates balance computation to individual accounts and aggregates the results. The use of
AddAssign(implemented inbalance.rsas noted in the summary) provides clean accumulation semantics.
Move the account balance updates happening within
check_transactionintoManagedAccount::update_balanceand reuse it inManagedWalletInfo::update_balancewhich also already gets called incheck_transaction.Summary by CodeRabbit
Refactor
Tests
✏️ Tip: You can customize this high-level summary in your review settings.