Skip to content

fix: trim trailing zeros in proposal amounts - #7644

Merged
PastaPastaPasta merged 1 commit into
dashpay:developfrom
PastaPastaPasta:t3code/trim-proposal-amount-decimals
Aug 29, 2026
Merged

fix: trim trailing zeros in proposal amounts#7644
PastaPastaPasta merged 1 commit into
dashpay:developfrom
PastaPastaPasta:t3code/trim-proposal-amount-decimals

Conversation

@PastaPastaPasta

@PastaPastaPasta PastaPastaPasta commented Aug 28, 2026

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

Governance proposal amounts were displayed with fixed-width trailing zeros (for example, 1.00000000 DASH). This adds unnecessary visual noise to the proposal list and makes scanning amounts harder.

What was done?

The Governance payment-amount column now formats the amount at the user's configured decimal precision (the digits display option, default 2 — the same precision the column used before), then removes only insignificant trailing zeros and any bare trailing decimal point.

  • 1.00000000 DASH renders as 1 DASH
  • 1.10 DASH renders as 1.1 DASH
  • 15.27 DASH is unchanged

No amount value is rounded beyond what the display-precision setting already did, and the model's sort/underlying values still use the integer amount.

How Has This Been Tested?

  • Built dash-qt successfully on macOS ARM64.
  • Ran a disposable regtest governance fixture with five masternodes and three proposals.
  • Verified the GUI dropped the padded zero fractions from the amount column while honoring the configured decimal precision.
  • Ran git diff --check.

Breaking Changes

None. This is a GUI display-only change; sorting and model values continue to use the integer amount.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

This pull request was created by Codex.

@thepastaclaw

thepastaclaw commented Aug 28, 2026

Copy link
Copy Markdown

✅ Final review complete — no blockers (commit dd7fba2)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 25da1b5b5c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/qt/proposalmodel.cpp Outdated
namespace {
QString formatProposalAmount(const BitcoinUnit& unit, const CAmount& amount)
{
QString result = BitcoinUnits::format(unit, amount, false, BitcoinUnits::SeparatorStyle::ALWAYS);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the configured decimal precision

When a user selects 2–7 “Decimal digits” in the display settings, this call bypasses floorWithUnit, which reads that setting, and always emits the unit's full precision before removing zeros. For example, a proposal for 15.2714286 DASH now displays all seven fractional digits even when the user configured two; apply the configured precision first and then trim its insignificant trailing zeros so this focused change does not also disable the existing preference.

AGENTS.md reference: AGENTS.md:L13-L14

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Confirmed and fixed in dd7fba2. formatProposalAmount() now starts from BitcoinUnits::floorWithUnit() (which reads the QSettings digits preference, default 2), strips the appended unit suffix, trims the insignificant trailing zeros and any bare trailing ., then re-appends the suffix. With the default setting 15.2714286 DASH renders as 15.27 DASH again, while 1.00000000 DASH still collapses to 1 DASH.


🤖 Posted autonomously by Claude on behalf of pasta.

@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 78a4bf46-6137-47ff-9ac9-2543d95b164a

📥 Commits

Reviewing files that changed from the base of the PR and between 25da1b5 and dd7fba2.

📒 Files selected for processing (1)
  • src/qt/proposalmodel.cpp

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


Walkthrough

The proposal model adds formatProposalAmount to format CAmount values with separators, remove trailing zeros and a trailing decimal point, and append the unit name. The PAYMENT_AMOUNT display column now uses this helper instead of BitcoinUnits::floorWithUnit.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to dd7fb

This change only trims insignificant trailing zeros from displayed proposal amounts while preserving configured precision and underlying integer values; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: trimming insignificant trailing zeros in proposal amounts.
Description check ✅ Passed The description directly explains the display-only formatting change, its behavior, testing, and lack of breaking changes.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Preliminary review — Codex only

The trailing-zero cleanup preserves the underlying integer model values and sorting, but the new formatter bypasses the configured decimal-digit setting. Because the Governance amount column previously honored that user preference, this introduces an in-scope display regression that should be fixed before merge.
Source: reviewer backend gpt-5.6-sol (general and dash-core-commit-history); final verifier backend gpt-5.6-sol(high); orchestration-only openclaw-agent/cliproxy/gpt-5.6-sol (not reviewer evidence).

Validated blockers were found in the Codex precheck. Opus is deferred until a fresh Codex revalidation clears the blocker gate.

Review provenance

  • Codex reviewers: gpt-5.6-sol — general (completed), gpt-5.6-sol — dash-core-commit-history (completed)
  • Verifier: gpt-5.6-sol — verifier
  • Sonnet: not run (deferred by blocker gate)

🔴 1 blocking

🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `src/qt/proposalmodel.cpp`:
- [BLOCKING] src/qt/proposalmodel.cpp:25: Preserve the configured decimal precision
  `BitcoinUnits::format()` always emits the unit's full precision, while the replaced `floorWithUnit()` call reads the QSettings `digits` preference, whose default is two. Consequently, an amount such as `15.2714286 DASH` now displays all seven fractional digits even when the user selected two, changing the established behavior of the Governance amount column. Start with the configured-precision representation, remove its unit suffix, and then let the existing code trim insignificant zeros.

Comment thread src/qt/proposalmodel.cpp Outdated
namespace {
QString formatProposalAmount(const BitcoinUnit& unit, const CAmount& amount)
{
QString result = BitcoinUnits::format(unit, amount, false, BitcoinUnits::SeparatorStyle::ALWAYS);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 Blocking: Preserve the configured decimal precision

BitcoinUnits::format() always emits the unit's full precision, while the replaced floorWithUnit() call reads the QSettings digits preference, whose default is two. Consequently, an amount such as 15.2714286 DASH now displays all seven fractional digits even when the user selected two, changing the established behavior of the Governance amount column. Start with the configured-precision representation, remove its unit suffix, and then let the existing code trim insignificant zeros.

Suggested change
QString result = BitcoinUnits::format(unit, amount, false, BitcoinUnits::SeparatorStyle::ALWAYS);
QString result = BitcoinUnits::floorWithUnit(unit, amount, false, BitcoinUnits::SeparatorStyle::ALWAYS);
result.chop(BitcoinUnits::name(unit).size() + 1);

source: ['codex']

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Confirmed and fixed in dd7fba2. formatProposalAmount() now starts from BitcoinUnits::floorWithUnit() (which reads the QSettings digits preference, default 2), strips the appended unit suffix, trims the insignificant trailing zeros and any bare trailing ., then re-appends the suffix. With the default setting 15.2714286 DASH renders as 15.27 DASH again, while 1.00000000 DASH still collapses to 1 DASH.


🤖 Posted autonomously by Claude on behalf of pasta.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Resolved in this update — Preserve the configured decimal precision no longer present.

Auto-resolved by the review system based on the latest commit diff. If you believe this was closed in error, reopen the thread.

Governance proposal amounts were padded to the display unit's full precision ("1.00000000 DASH"), which adds noise without conveying information.

Format at the user's configured decimal precision, as before, then drop only insignificant trailing zeros and a bare trailing decimal point.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@PastaPastaPasta
PastaPastaPasta force-pushed the t3code/trim-proposal-amount-decimals branch from 25da1b5 to dd7fba2 Compare August 29, 2026 00:07
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-29T00:08:47.267985Z dd7fba2 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Final validation — GLM Flash + Sol

The exact-head implementation fixes the prior precision regression by formatting through the QSettings-backed floorWithUnit() before removing insignificant zeros, while the edit role continues to expose the raw integer amount for sorting. No correctness defect remains, but the newly introduced formatting behavior still lacks automated regression coverage despite the earlier precision bug demonstrating its value.
Source: reviewer backends glm-5.3-flash, gpt-5.6-sol, and Claude Opus 5 (1M context); final verifier backend Claude Opus 5 (1M context).

Review provenance

  • Phase 1 reviewers (GLM Flash): glm-5.3-flash — general (completed), glm-5.3-flash — dash-core-commit-history (completed)
  • Fresh verifier (Sol): gpt-5.6-sol — final-verifier
  • Phase 2 reviewers (Sol): gpt-5.6-sol — general (completed), gpt-5.6-sol — dash-core-commit-history (completed)

🟡 1 suggestion(s)

🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `src/qt/proposalmodel.cpp`:
- [SUGGESTION] src/qt/proposalmodel.cpp:24-40: Add automated coverage for proposal amount formatting
  The new helper implements the PR's complete behavior—configured precision, suffix removal, trailing-zero trimming, and bare-decimal-point removal—but no automated test exercises those invariants. The initial revision already bypassed the configured `digits` preference and required a correction, so a regression test would protect behavior that has demonstrably been easy to break. Add focused Qt coverage that sets the `digits` preference and verifies whole and partially fractional amounts, retained nonzero digits, negative and grouped amounts, and a unit whose native precision is lower than the configured value.

Comment thread src/qt/proposalmodel.cpp
Comment on lines +24 to +40
//! insignificant trailing zeros ("1.00 DASH" -> "1 DASH").
QString formatProposalAmount(const BitcoinUnit& unit, const CAmount& amount)
{
const QString suffix{QLatin1Char(' ') + BitcoinUnits::name(unit)};
QString result{BitcoinUnits::floorWithUnit(unit, amount, /*plussign=*/false, BitcoinUnits::SeparatorStyle::ALWAYS)};
result.chop(suffix.size());

if (result.contains('.')) {
while (result.endsWith('0')) {
result.chop(1);
}

if (result.endsWith('.')) {
result.chop(1);
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Suggestion: Add automated coverage for proposal amount formatting

The new helper implements the PR's complete behavior—configured precision, suffix removal, trailing-zero trimming, and bare-decimal-point removal—but no automated test exercises those invariants. The initial revision already bypassed the configured digits preference and required a correction, so a regression test would protect behavior that has demonstrably been easy to break. Add focused Qt coverage that sets the digits preference and verifies whole and partially fractional amounts, retained nonzero digits, negative and grouped amounts, and a unit whose native precision is lower than the configured value.

source: ['claude', 'codex']

@PastaPastaPasta
PastaPastaPasta merged commit 4876cab into dashpay:develop Aug 29, 2026
50 of 51 checks passed
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