Skip to content

Conversation

@kxcd
Copy link

@kxcd kxcd commented Dec 7, 2025

Summary by CodeRabbit

  • Updates
    • All denomination displays, parsing and formatting now use DASH-family terms (DASH, cDASH, mDASH, uDASH, nDASH, pDASH), updating user-facing text and outputs.
  • Tests
    • Tests and test data updated to expect DASH-based denominations in parsing, formatting, and error messages.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 7, 2025

Walkthrough

The pull request rebrands denomination string representations from BTC-family tokens ("BTC", "cBTC", "mBTC", etc.) to DASH-family tokens ("DASH", "cDASH", "mDASH", etc.) in the amount module, updating parsing, display/debug text, ambiguous-form lists, and tests.

Changes

Cohort / File(s) Summary
Denomination rebranding
dash/src/amount.rs
Replaced BTC-family denomination strings with DASH-family equivalents; updated parsing forms to accept DASH variants (case-insensitive); adjusted confusing-form listings (MDASH/PDASH); updated Display/Debug output text and test expectations referencing DASH tokens

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify all BTC string references have been replaced with DASH counterparts
  • Ensure parsing handles uppercase and lowercase DASH variants consistently
  • Confirm tests match new token strings and error messages
  • Check ambiguous-form list entries (MDASH/PDASH) for correctness

Poem

🐰🌿 I hopped through code at break of day,
Swapped "BTC" for "DASH" along the way,
cDASH, mDASH, tiny DASH in tow,
Strings now sing where numbers flow,
Thump, a patch — and off I go!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 69.23% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: Dashify the units.' directly aligns with the changeset, which replaces BTC-family denomination strings with DASH-family equivalents throughout the codebase.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@xdustinface xdustinface changed the title Dashify the units. fix: Dashify the units. Dec 7, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

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

⚠️ Outside diff range comments (2)
dash/src/amount.rs (2)

2126-2147: Fix expected error for "-42 satoshi BTC" vs "satoshi DASH"

In to_string_with_denomination_from_str_roundtrip, the second assertion still passes "-42 satoshi BTC" but expects an UnknownDenomination("satoshi DASH"). With the current parser, that call will return UnknownDenomination("satoshi BTC"), causing the test to fail.

Either adjust the input to use DASH (to mirror the previous assertion) or change the expected string. For full DASH-ification, the former seems preferable:

-        assert_eq!(
-            SignedAmount::from_str("-42 satoshi BTC"),
-            Err(ParseAmountError::UnknownDenomination("satoshi DASH".into())),
-        );
+        assert_eq!(
+            SignedAmount::from_str("-42 satoshi DASH"),
+            Err(ParseAmountError::UnknownDenomination("satoshi DASH".into())),
+        );

1960-1977: Update Dash formatting tests to expect DASH suffix instead of BTC

In the check_format_non_negative_show_denom! invocations for Dash, the suffix is still " BTC" / " BTC ":

check_format_non_negative_show_denom! {
    Dash, " BTC";}

check_format_non_negative_show_denom! {
    Dash, " BTC ";}

But fmt_satoshi_in uses Denomination::Dash::as_str() (now "DASH"), so these tests will now see "… DASH" and fail.

Adjust the suffixes to " DASH" / " DASH ":

-    Dash, " BTC";
+    Dash, " DASH";-    Dash, " BTC ";
+    Dash, " DASH ";
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b2bdf7d and d5e8907.

📒 Files selected for processing (1)
  • dash/src/amount.rs (13 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.rs: Never hardcode network parameters, addresses, or keys in Rust code
Use proper error types with thiserror crate and propagate errors appropriately in Rust code
Use tokio runtime for async operations in Rust code
Use conditional compilation with feature flags for optional features
Write unit tests for new functionality in Rust
Format Rust code with cargo fmt before committing
Ensure clippy passes with all warnings as errors on all Rust code

**/*.rs: Each crate keeps sources in src/; unit tests live alongside code with #[cfg(test)]
Maintain MSRV of 1.89 for Rust code
Format Rust code with rustfmt (see rustfmt.toml); run cargo fmt --all before commits
Lint Rust code with clippy; avoid unwrap()/expect() in library code; use error types (e.g., thiserror)
Use snake_case for function and variable names in Rust
Use UpperCamelCase for types and traits in Rust
Use SCREAMING_SNAKE_CASE for constants in Rust
Follow mixed editions (2021/2024) and crate-specific idioms; prefer async via tokio where applicable
Unit tests should be placed near code with descriptive names (e.g., test_parse_address_mainnet)
Use #[ignore] for network-dependent or long-running tests; run with -- --ignored flag
Never commit secrets or real keys; avoid logging sensitive data in Rust code
Keep test vectors deterministic in Rust test code

Files:

  • dash/src/amount.rs
🧠 Learnings (10)
📓 Common learnings
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: swift-dash-core-sdk/CLAUDE.md:0-0
Timestamp: 2025-12-01T08:00:50.618Z
Learning: Applies to swift-dash-core-sdk/**/*.rs : Implement new FFI functions in Rust with `#[no_mangle] extern "C"` annotation in dash-spv-ffi
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-01T08:00:37.919Z
Learning: Maintain Minimum Supported Rust Version (MSRV) of 1.89; ensure 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-12-01T08:00:37.919Z
Learning: Keep test vectors updated with Dash Core, monitor for new DIPs affecting wallet structure, maintain backward compatibility for serialized wallets, and update derivation paths for Platform features
📚 Learning: 2025-12-01T08:00:50.618Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: swift-dash-core-sdk/CLAUDE.md:0-0
Timestamp: 2025-12-01T08:00:50.618Z
Learning: Applies to swift-dash-core-sdk/**/*.rs : Implement new FFI functions in Rust with `#[no_mangle] extern "C"` annotation in dash-spv-ffi

Applied to files:

  • dash/src/amount.rs
📚 Learning: 2025-12-01T08:00:37.919Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-01T08:00:37.919Z
Learning: Keep test vectors updated with Dash Core, monitor for new DIPs affecting wallet structure, maintain backward compatibility for serialized wallets, and update derivation paths for Platform features

Applied to files:

  • dash/src/amount.rs
📚 Learning: 2025-12-01T08:01:18.174Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-01T08:01:18.174Z
Learning: Organize workspace with crates: `dash`, `hashes`, `internals`, `dash-network`, `dash-spv`, `key-wallet`, `rpc-*`, utilities (`fuzz`, `test-utils`), and FFI crates (`*-ffi`)

Applied to files:

  • dash/src/amount.rs
📚 Learning: 2025-12-01T07:59:58.608Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-12-01T07:59:58.608Z
Learning: Applies to dash-spv-ffi/src/**/*.rs : Rust strings must be returned as `*const c_char` with caller responsibility to free using `dash_string_free`

Applied to files:

  • dash/src/amount.rs
📚 Learning: 2025-12-01T08:00:37.919Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-01T08:00:37.919Z
Learning: Maintain Minimum Supported Rust Version (MSRV) of 1.89; ensure compatibility with Dash Core versions 0.18.0 - 0.21.0

Applied to files:

  • dash/src/amount.rs
📚 Learning: 2025-12-01T07:59:58.608Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-12-01T07:59:58.608Z
Learning: Applies to dash-spv-ffi/src/**/*.rs : Add cbindgen annotations for complex types in FFI functions

Applied to files:

  • dash/src/amount.rs
📚 Learning: 2025-12-01T08:00:37.919Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-01T08:00:37.919Z
Learning: Applies to key-wallet/**/{account,managed_account}/**/*.rs : Use strongly typed enum-based system for `AccountType` with specific variants (Standard, Identity, Masternode, etc.) to provide compile-time safety for different account purposes

Applied to files:

  • dash/src/amount.rs
📚 Learning: 2025-12-01T07:59:58.608Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-12-01T07:59:58.608Z
Learning: Applies to dash-spv-ffi/src/**/*.rs : Input strings in FFI functions are `*const c_char` (borrowed, not freed by C caller)

Applied to files:

  • dash/src/amount.rs
📚 Learning: 2025-12-04T15:51:59.632Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-04T15:51:59.632Z
Learning: Applies to dash-spv/**/*.rs : Use trait-based abstractions for core components like `NetworkManager` and `StorageManager` to enable swappable implementations

Applied to files:

  • dash/src/amount.rs
🔇 Additional comments (6)
dash/src/amount.rs (6)

693-697: Debug output rebranded to DASH – consistent with new units

Both Amount and SignedAmount now print "… DASH" in their Debug impls, matching the new denomination naming while preserving the numeric formatting. No functional issues here.

Also applies to: 1113-1116


1626-1647: Zero-amount parsing tests updated to DASH suffixes – looks correct

The from_str_zero test now iterates over ["DASH", "mDASH", "uDASH", "nDASH", "pDASH", "bits", "sats", "msats"], which matches the new recognized forms for zero and -0 handling. Behavior stays the same, just with DASH units.


1787-1807: to_string_with_denomination expectations correctly switched to DASH

The updated expectations like "1 DASH", "0.00000001 DASH", and "-0.00000042 DASH" align with Denomination::Dash’s as_str() and the formatting logic. The roundtrip behavior for these cases should remain intact.


2012-2047: From-str tests for DASH denominations are consistent

The from_str/scase tests you updated ("x DASH", "5 DASH DASH", "-1 DASH", "0.123456 mDASH", etc.) correctly exercise the new DASH forms and error conditions (InvalidCharacter, UnknownDenomination, Negative, TooPrecise, TooBig). The semantics of the checks look unchanged apart from the unit name.


2363-2393: DASH denomination string tests look good; unknown/case-variants are sensible

The updated denomination_string_acceptable_forms list now covers the main DASH strings ("DASH", "dash", "mDASH", "mdash", "uDASH", "udash", "nDASH", "pDASH") plus the sat/bit variants, matching Denomination::forms. Likewise, the unknown list ("NDASH", "UDASH", "ABC", "abc", "cBtC", "Sat", "Sats") appropriately exercises rejected/case-mismatched forms.

Once the CONFUSING_FORMS vs. "MDash" mismatch is fixed (see earlier comment), this whole block should be in good shape.


16-32: Doctest uses BTC tokens, but they are still supported—no action required

The doctest examples at lines 23–28 do use "BTC", "cBTC", etc., but these tokens are not removed; they remain valid forms. The Denomination::forms() method explicitly accepts "BTC" | "btc" and maps to Denomination::Dash, along with the other BTC-family variants. The examples will parse correctly and the assertions will pass. No doctest update is needed, and there is no breaking change to external callers.

The code maintains backward compatibility with BTC token strings while using Dash/CentiDash as enum variant names.

Likely an incorrect or invalid review comment.

Comment on lines 106 to 110
/// These form are ambiguous and could have many meanings. For example, M could denote Mega or Milli.
/// If any of these forms are used, an error type PossiblyConfusingDenomination is returned.
const CONFUSING_FORMS: [&str; 9] =
["Msat", "Msats", "MSAT", "MSATS", "MSat", "MSats", "MBTC", "Mbtc", "PBTC"];
["Msat", "Msats", "MSAT", "MSATS", "MSat", "MSats", "MDASH", "Mdash", "PDASH"];

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

Fix mismatch between CONFUSING_FORMS and disallow_confusing_forms for MDash

CONFUSING_FORMS contains "MDASH" and "Mdash", but the disallow_confusing_forms test checks for "MDASH" and "MDash". As written, "MDash" is not in CONFUSING_FORMS, so Denomination::from_str("MDash") will return UnknownDenomination rather than PossiblyConfusingDenomination, and the test will fail.

Align them by updating the constant (and, if desired, covering both variants):

-const CONFUSING_FORMS: [&str; 9] =
-    ["Msat", "Msats", "MSAT", "MSATS", "MSat", "MSats", "MDASH", "Mdash", "PDASH"];
+const CONFUSING_FORMS: [&str; 9] =
+    ["Msat", "Msats", "MSAT", "MSATS", "MSat", "MSats", "MDASH", "MDash", "PDASH"];

(The valid and unknown lists for denomination strings otherwise look good and match the new DASH-oriented behavior.)

Also applies to: 2363-2393

🤖 Prompt for AI Agents
In dash/src/amount.rs around lines 106 to 110 (and similarly at lines
~2363-2393), the CONFUSING_FORMS constant contains "MDASH" and "Mdash" but the
test disallow_confusing_forms expects "MDash"; add the missing variant "MDash"
to CONFUSING_FORMS (or replace "Mdash" with "MDash", or include both "Mdash" and
"MDash") so the constant and the test match and Denomination::from_str("MDash")
yields PossiblyConfusingDenomination.

Copy link
Member

@pauldelucia pauldelucia left a comment

Choose a reason for hiding this comment

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

Generally LGTM but I think we should take it even further and replace all Satoshi references with Duff, and probably get rid of remaining BTC references.

@kxcd
Copy link
Author

kxcd commented Dec 8, 2025

Yes, I would like that. Sat -> Duff.

QuantumExplorer
QuantumExplorer previously approved these changes Dec 9, 2025
Copy link
Collaborator

@xdustinface xdustinface left a comment

Choose a reason for hiding this comment

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

@kxcd Looks good in general but CI is failing. It needs cargo formatting run and the test are failing. There are a few more places that need adjustment for this to work.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

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

⚠️ Outside diff range comments (4)
dash/src/amount.rs (4)

3-32: Update module documentation and doc examples to use DASH denomination strings.

The module doc at line 3 still says "Bitcoin amounts" and the doc examples at lines 23-28 still use BTC-based denomination strings ("1 BTC", "1 cBTC", etc.). Since Denomination::forms was updated to only recognize DASH variants, these doc examples will fail to compile/run.

Apply this diff:

-//! Bitcoin amounts.
+//! Dash amounts.
 //!
 //! This module mainly introduces the [Amount] and [SignedAmount] types.
 //! We refer to the documentation on the types for more information.
 //!
...
-/// assert_eq!(Amount::from_str("1 BTC").unwrap(), Amount::from_sat(100_000_000));
-/// assert_eq!(Amount::from_str("1 cBTC").unwrap(), Amount::from_sat(1_000_000));
-/// assert_eq!(Amount::from_str("1 mBTC").unwrap(), Amount::from_sat(100_000));
-/// assert_eq!(Amount::from_str("1 uBTC").unwrap(), Amount::from_sat(100));
-/// assert_eq!(Amount::from_str("10 nBTC").unwrap(), Amount::from_sat(1));
-/// assert_eq!(Amount::from_str("10000 pBTC").unwrap(), Amount::from_sat(1));
+/// assert_eq!(Amount::from_str("1 DASH").unwrap(), Amount::from_sat(100_000_000));
+/// assert_eq!(Amount::from_str("1 cDASH").unwrap(), Amount::from_sat(1_000_000));
+/// assert_eq!(Amount::from_str("1 mDASH").unwrap(), Amount::from_sat(100_000));
+/// assert_eq!(Amount::from_str("1 uDASH").unwrap(), Amount::from_sat(100));
+/// assert_eq!(Amount::from_str("10 nDASH").unwrap(), Amount::from_sat(1));
+/// assert_eq!(Amount::from_str("10000 pDASH").unwrap(), Amount::from_sat(1));

120-125: Update doc comment to reflect DASH denominations.

The comment at lines 123-124 still references "BTC, mBTC, uBTC, nBTC, pBTC" but the implementation now parses DASH variants.

     /// Any combination of upper and/or lower case, excluding uppercase of SI(m, u, n, p) is considered valid.
-    /// - Singular: BTC, mBTC, uBTC, nBTC, pBTC
+    /// - Singular: DASH, mDASH, uDASH, nDASH, pDASH
     /// - Plural or singular: sat, satoshi, bit, msat

479-483: Update struct documentation to reference Dash.

The comment still says "Bitcoin amounts" but this is a Dash library.

-/// The [Amount] type can be used to express Bitcoin amounts that support
+/// The [Amount] type can be used to express Dash amounts that support

1960-1977: Fix incorrect denomination suffix in test expectations.

These tests use " BTC" as the expected denomination suffix, but Denomination::Dash.as_str() now returns "DASH". The tests will fail because the actual output will be "0.00000001 DASH" but the assertion expects "0.00000001 BTC".

 check_format_non_negative_show_denom! {
-    Dash, " BTC";
+    Dash, " DASH";
     btc_check_fmt_non_negative_show_denom_0, 1, "{:14.1}", "0.00000001";
     ...
 }

 check_format_non_negative_show_denom! {
-    Dash, " BTC ";
+    Dash, " DASH ";
     btc_check_fmt_non_negative_show_denom_align_0, 1, "{:<15}", "0.00000001";
     ...
 }
♻️ Duplicate comments (2)
dash/src/amount.rs (2)

106-109: Fix mismatch between CONFUSING_FORMS and test expectations.

The constant contains "Mdash" but the test at line 2381 expects "MDash". This will cause Denomination::from_str("MDash") to return UnknownDenomination rather than PossiblyConfusingDenomination, failing the test.


2379-2388: Test expects "MDash" but CONFUSING_FORMS contains "Mdash".

This test will fail because "MDash" is not in CONFUSING_FORMS (which has "Mdash"), so Denomination::from_str("MDash") will return UnknownDenomination instead of PossiblyConfusingDenomination.

Either update CONFUSING_FORMS at line 109 to include "MDash", or update this test to use "Mdash".

🧹 Nitpick comments (1)
dash/src/amount.rs (1)

529-532: Consider updating remaining Bitcoin/BTC references in documentation.

Multiple doc comments throughout the file still reference "Bitcoin" or "BTC" (e.g., lines 529, 565, 607, 700, 799, 860, 905, 943, 985, 1120). For consistency with the DASH rebranding, consider updating these to reference "Dash" and "DASH".

Also applies to: 565-567, 605-608, 699-701, 793-800, 858-862, 905-908, 941-948, 983-986, 1119-1121

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d5e8907 and e884215.

📒 Files selected for processing (1)
  • dash/src/amount.rs (13 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.rs: Never hardcode network parameters, addresses, or keys in Rust code
Use proper error types with thiserror crate and propagate errors appropriately in Rust code
Use tokio runtime for async operations in Rust code
Use conditional compilation with feature flags for optional features
Write unit tests for new functionality in Rust
Format Rust code with cargo fmt before committing
Ensure clippy passes with all warnings as errors on all Rust code

**/*.rs: Each crate keeps sources in src/; unit tests live alongside code with #[cfg(test)]
Maintain MSRV of 1.89 for Rust code
Format Rust code with rustfmt (see rustfmt.toml); run cargo fmt --all before commits
Lint Rust code with clippy; avoid unwrap()/expect() in library code; use error types (e.g., thiserror)
Use snake_case for function and variable names in Rust
Use UpperCamelCase for types and traits in Rust
Use SCREAMING_SNAKE_CASE for constants in Rust
Follow mixed editions (2021/2024) and crate-specific idioms; prefer async via tokio where applicable
Unit tests should be placed near code with descriptive names (e.g., test_parse_address_mainnet)
Use #[ignore] for network-dependent or long-running tests; run with -- --ignored flag
Never commit secrets or real keys; avoid logging sensitive data in Rust code
Keep test vectors deterministic in Rust test code

Files:

  • dash/src/amount.rs
🧠 Learnings (9)
📓 Common learnings
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-01T08:00:37.919Z
Learning: Keep test vectors updated with Dash Core, monitor for new DIPs affecting wallet structure, maintain backward compatibility for serialized wallets, and update derivation paths for Platform features
📚 Learning: 2025-12-01T08:00:50.618Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: swift-dash-core-sdk/CLAUDE.md:0-0
Timestamp: 2025-12-01T08:00:50.618Z
Learning: Applies to swift-dash-core-sdk/**/*.rs : Implement new FFI functions in Rust with `#[no_mangle] extern "C"` annotation in dash-spv-ffi

Applied to files:

  • dash/src/amount.rs
📚 Learning: 2025-12-01T08:00:37.919Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-01T08:00:37.919Z
Learning: Keep test vectors updated with Dash Core, monitor for new DIPs affecting wallet structure, maintain backward compatibility for serialized wallets, and update derivation paths for Platform features

Applied to files:

  • dash/src/amount.rs
📚 Learning: 2025-12-01T07:59:58.608Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-12-01T07:59:58.608Z
Learning: Applies to dash-spv-ffi/src/**/*.rs : Rust strings must be returned as `*const c_char` with caller responsibility to free using `dash_string_free`

Applied to files:

  • dash/src/amount.rs
📚 Learning: 2025-12-01T08:00:37.919Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-01T08:00:37.919Z
Learning: Maintain Minimum Supported Rust Version (MSRV) of 1.89; ensure compatibility with Dash Core versions 0.18.0 - 0.21.0

Applied to files:

  • dash/src/amount.rs
📚 Learning: 2025-12-01T08:01:18.174Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-01T08:01:18.174Z
Learning: Organize workspace with crates: `dash`, `hashes`, `internals`, `dash-network`, `dash-spv`, `key-wallet`, `rpc-*`, utilities (`fuzz`, `test-utils`), and FFI crates (`*-ffi`)

Applied to files:

  • dash/src/amount.rs
📚 Learning: 2025-12-01T07:59:58.608Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-12-01T07:59:58.608Z
Learning: Applies to dash-spv-ffi/src/**/*.rs : Input strings in FFI functions are `*const c_char` (borrowed, not freed by C caller)

Applied to files:

  • dash/src/amount.rs
📚 Learning: 2025-12-01T07:59:58.608Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-12-01T07:59:58.608Z
Learning: Applies to dash-spv-ffi/src/**/*.rs : Add cbindgen annotations for complex types in FFI functions

Applied to files:

  • dash/src/amount.rs
📚 Learning: 2025-12-01T08:01:00.652Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: swift-dash-core-sdk/Examples/DashHDWalletExample/CLAUDE.md:0-0
Timestamp: 2025-12-01T08:01:00.652Z
Learning: Applies to swift-dash-core-sdk/Examples/DashHDWalletExample/**/*.swift : Add public wrapper methods to DashSDK if needed functionality is not exposed by public API

Applied to files:

  • dash/src/amount.rs
🔇 Additional comments (8)
dash/src/amount.rs (8)

75-84: LGTM!

The denomination string representations are correctly updated to DASH variants while maintaining the SI prefix conventions.


88-103: LGTM!

The denomination parsing forms are correctly updated to recognize DASH variants with consistent uppercase/lowercase handling.


693-696: LGTM!

Debug output correctly updated to display "DASH".


1627-1648: LGTM!

Test correctly updated to use DASH denomination strings.


1797-1807: LGTM!

Test expectations correctly updated to expect "DASH" in formatted output.


2012-2050: LGTM!

Error case tests correctly updated for DASH denomination parsing.


2369-2376: LGTM!

Valid denomination forms list correctly updated to include DASH variants.


2391-2402: LGTM!

Unknown denomination test correctly includes uppercase prefix variants like "NDASH" and "UDASH" which should be rejected since only lowercase prefixes are valid.

Comment on lines 2147 to 2150
assert_eq!(
SignedAmount::from_str("-42 satoshi BTC"),
Err(ParseAmountError::UnknownDenomination("satoshi BTC".into())),
Err(ParseAmountError::UnknownDenomination("satoshi DASH".into())),
);
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

Fix incorrect test expectation.

The test parses "-42 satoshi BTC" but expects the error to contain "satoshi DASH". The error should reflect the actual parsed input: "satoshi BTC".

         assert_eq!(
             SignedAmount::from_str("-42 satoshi BTC"),
-            Err(ParseAmountError::UnknownDenomination("satoshi DASH".into())),
+            Err(ParseAmountError::UnknownDenomination("satoshi BTC".into())),
         );
📝 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
assert_eq!(
SignedAmount::from_str("-42 satoshi BTC"),
Err(ParseAmountError::UnknownDenomination("satoshi BTC".into())),
Err(ParseAmountError::UnknownDenomination("satoshi DASH".into())),
);
assert_eq!(
SignedAmount::from_str("-42 satoshi BTC"),
Err(ParseAmountError::UnknownDenomination("satoshi BTC".into())),
);
🤖 Prompt for AI Agents
In dash/src/amount.rs around lines 2147 to 2150, the unit test expects the wrong
denomination in the ParseAmountError; it parses "-42 satoshi BTC" but asserts
the error contains "satoshi DASH". Update the test expectation to assert
Err(ParseAmountError::UnknownDenomination("satoshi BTC".into())) so the error
matches the actual input string.

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.

4 participants