Skip to content

feat: format wallet event amounts as DASH#530

Open
xdustinface wants to merge 1 commit intov0.42-devfrom
feat/format-wallet-event-amounts
Open

feat: format wallet event amounts as DASH#530
xdustinface wants to merge 1 commit intov0.42-devfrom
feat/format-wallet-event-amounts

Conversation

@xdustinface
Copy link
Collaborator

@xdustinface xdustinface commented Mar 13, 2026

Use Amount and SignedAmount for better readable logging output in wallet event descriptions.

Summary by CodeRabbit

  • New Features
    • Wallet balance tracking now includes a separate locked amount field, providing clearer visibility into spendable versus locked funds.
    • Transaction amount formatting has been improved for better readability.

Use `Amount` and `SignedAmount` for better readable
logging output in wallet event descriptions.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 13, 2026

📝 Walkthrough

Walkthrough

The changes extend imports to include Amount and SignedAmount from dashcore, add a new locked: u64 field to the WalletEvent::BalanceUpdated variant, and update event formatting to use proper Amount type conversions instead of raw values.

Changes

Cohort / File(s) Summary
Event Structure Enhancement
key-wallet-manager/src/events.rs
Added locked: u64 field to BalanceUpdated variant; updated display formatting for TransactionReceived and BalanceUpdated to use SignedAmount and Amount conversions from dashcore instead of raw numeric values.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A wallet that knows what's locked away,
With amounts displayed in proper way,
From dashes raw to amounts so bright,
Our events now show the true insight! 💰

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: format wallet event amounts as DASH' directly and clearly describes the main change—converting raw numeric amounts to formatted DASH representations using Amount and SignedAmount types.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/format-wallet-event-amounts
📝 Coding Plan
  • Generate coding plan for human review comments

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.

@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

❌ Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.88%. Comparing base (33eb7b8) to head (573a301).

Files with missing lines Patch % Lines
key-wallet-manager/src/events.rs 0.00% 9 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##           v0.42-dev     #530      +/-   ##
=============================================
- Coverage      66.91%   66.88%   -0.04%     
=============================================
  Files            313      313              
  Lines          64741    64748       +7     
=============================================
- Hits           43321    43305      -16     
- Misses         21420    21443      +23     
Flag Coverage Δ *Carryforward flag
core 75.02% <ø> (ø)
dash-network 75.00% <ø> (ø) Carriedforward from 33eb7b8
dash-network-ffi 34.76% <ø> (ø) Carriedforward from 33eb7b8
dash-spv 68.26% <ø> (ø) Carriedforward from 33eb7b8
dash-spv-ffi 34.76% <ø> (ø) Carriedforward from 33eb7b8
dashcore 75.00% <ø> (ø) Carriedforward from 33eb7b8
dashcore-private 75.00% <ø> (ø) Carriedforward from 33eb7b8
dashcore-rpc 19.92% <ø> (ø) Carriedforward from 33eb7b8
dashcore-rpc-json 19.92% <ø> (ø) Carriedforward from 33eb7b8
dashcore_hashes 75.00% <ø> (ø) Carriedforward from 33eb7b8
ffi 36.51% <ø> (+0.01%) ⬆️
key-wallet 65.65% <ø> (+<0.01%) ⬆️ Carriedforward from 33eb7b8
key-wallet-ffi 34.76% <ø> (ø) Carriedforward from 33eb7b8
key-wallet-manager 65.65% <ø> (+<0.01%) ⬆️ Carriedforward from 33eb7b8
rpc 19.92% <ø> (ø)
spv 81.04% <ø> (-0.15%) ⬇️
wallet 65.66% <0.00%> (-0.03%) ⬇️

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

Files with missing lines Coverage Δ
key-wallet-manager/src/events.rs 0.00% <0.00%> (ø)

... and 5 files with indirect coverage changes

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

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.

Caution

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

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

47-75: 🛠️ Refactor suggestion | 🟠 Major

Please add regression tests for description().

This changes user-visible log strings and adds the new locked component, but there is no adjacent #[cfg(test)] coverage pinning the new formatted output. A couple of focused tests here would prevent silent format regressions.

As per coding guidelines, "**/*.rs: Write unit tests for new functionality in Rust code" and "Place unit tests alongside code with #[cfg(test)] attribute."

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

In `@key-wallet-manager/src/events.rs` around lines 47 - 75, Add unit tests for
WalletEvent::description() under a #[cfg(test)] mod in the same file: create
tests that construct a TransactionReceived and a BalanceUpdated (including the
new locked field) and assert the returned String matches the expected formatted
output (checking txid and SignedAmount::from_sat formatting for
TransactionReceived and Amount::from_sat formatting for each field in
BalanceUpdated). Ensure tests cover both positive and zero/edge values for
locked to prevent regressions in the new component and use the exact variant
constructors (WalletEvent::TransactionReceived and WalletEvent::BalanceUpdated)
so the assertions will fail on any formatting changes.

31-41: ⚠️ Potential issue | 🟠 Major

Add unit tests for WalletEvent::description() and document breaking API change.

Adding locked to WalletEvent::BalanceUpdated is a breaking API change—downstream exhaustive pattern matches and direct constructors without all four balance fields will no longer compile. Confirm this change is acceptable in your versioning strategy, or document migration guidance in release notes.

Additionally, per coding guidelines, add #[cfg(test)] tests alongside the description() method to validate the formatted output includes the locked field:

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_balance_updated_description_includes_all_fields() {
        // Verify spendable, unconfirmed, immature, and locked appear in output
    }

    #[test]
    fn test_transaction_received_description_format() {
        // Verify SignedAmount formatting
    }
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@key-wallet-manager/src/events.rs` around lines 31 - 41, Update docs and add
unit tests to account for the breaking API change from adding the locked field
to WalletEvent::BalanceUpdated: update release notes or migration guidance to
call out that exhaustive pattern matches and constructors must now include the
new locked: u64 field. Also add #[cfg(test)] tests next to the description()
impl: create tests verifying WalletEvent::BalanceUpdated::description() output
contains spendable, unconfirmed, immature and locked values, and a test
verifying WalletEvent::TransactionReceived (or the type using SignedAmount)
description formats SignedAmount correctly; reference
WalletEvent::BalanceUpdated, WalletEvent::description, and the SignedAmount
formatting in the test names so future readers can find them.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@key-wallet-manager/src/events.rs`:
- Around line 47-75: Add unit tests for WalletEvent::description() under a
#[cfg(test)] mod in the same file: create tests that construct a
TransactionReceived and a BalanceUpdated (including the new locked field) and
assert the returned String matches the expected formatted output (checking txid
and SignedAmount::from_sat formatting for TransactionReceived and
Amount::from_sat formatting for each field in BalanceUpdated). Ensure tests
cover both positive and zero/edge values for locked to prevent regressions in
the new component and use the exact variant constructors
(WalletEvent::TransactionReceived and WalletEvent::BalanceUpdated) so the
assertions will fail on any formatting changes.
- Around line 31-41: Update docs and add unit tests to account for the breaking
API change from adding the locked field to WalletEvent::BalanceUpdated: update
release notes or migration guidance to call out that exhaustive pattern matches
and constructors must now include the new locked: u64 field. Also add
#[cfg(test)] tests next to the description() impl: create tests verifying
WalletEvent::BalanceUpdated::description() output contains spendable,
unconfirmed, immature and locked values, and a test verifying
WalletEvent::TransactionReceived (or the type using SignedAmount) description
formats SignedAmount correctly; reference WalletEvent::BalanceUpdated,
WalletEvent::description, and the SignedAmount formatting in the test names so
future readers can find them.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a19e78d8-9fdd-4d5f-acbb-284e5e80535f

📥 Commits

Reviewing files that changed from the base of the PR and between 33eb7b8 and 573a301.

📒 Files selected for processing (1)
  • key-wallet-manager/src/events.rs

@xdustinface xdustinface requested a review from ZocoLini March 15, 2026 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant