AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Moderate 51 Bitcoin

Fix RoundToSignificant for negative amounts (#7782)

Public commit record

What the developer wrote

Authored by Amartya Vikram Singh

81/100 · Strong
Fix RoundToSignificant for negative amounts (#7782)

The relative error was divided by the signed value, so for a negative
amount it was never positive and the first rounding was always accepted.
Small negative amounts were rounded to zero (-0.0004 with divisibility 2
became -0.00) instead of keeping their significant digits like positive
ones (0.0004 stays 0.0004).
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This commit fixes a math bug in how BTCPay Server rounds very small negative amounts. Previously, a helper called RoundToSignificant divided by the signed value instead of its absolute value, so negative numbers behaved differently from positive ones. Tiny negative amounts could be rounded to zero (for example, -0.0004 became -0.00) while the equivalent positive amount kept its precision. The same patch also makes sure transaction fee bumps are never rounded down below the Bitcoin network's minimum relay-fee increase, preventing a fee-bump transaction from being rejected for paying too little.

Recommended action

Review other callers of RoundToSignificant to confirm no other negative-amount logic depends on the old behavior, and verify that the new fee-bump floor is applied consistently across wallet implementations. Consider adding explicit integration tests for RBF replacement transactions near the minimum incremental relay fee boundary.

Security signals we found

01

Rounding/truncation bug in financial amount handling

02

Negative-amount handling asymmetry that could alter displayed or computed balances

03

Fee-bump calculation could fall below Bitcoin incremental relay fee requirement

04

Replacement transaction could be rejected by the network due to underpayment

Risk score

Why this scored 51/100

Our methodology →
Potential impact 12/30
Exploitability 8/25
Stealth signal 10/15
Affected reach 10/15
Confidence 7/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.