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

Merge rust-bitcoin/rust-bitcoin#6921: units: fix div_by_fee_rate_ceil precision

Public commit record

What the developer wrote

Authored by Andrew Poelstra

91/100 · Strong
Merge rust-bitcoin/rust-bitcoin#6921: units: fix div_by_fee_rate_ceil precision

75e087f15d314b892c1d80a961e989a91615acd2 units: fix div_by_fee_rate_ceil precision (Nick Johnson)

Pull request description:

div_by_fee_rate_ceil used to_sat_per_kwu_ceil() as the divisor, collapsing FeeRate from sat/MvB precision down to sat/kwu before dividing. This rounds the divisor up, which potentially produces a weight too small to cover the fee budget.

Switch to to_sat_per_mvb() at full precision in u128, matching the recent fix applied to div_by_fee_rate_floor in #6884.


ACKs for top commit:
tcharding:
ACK 75e087f15d314b892c1d80a961e989a91615acd2
apoelstra:
ACK 75e087f15d314b892c1d80a961e989a91615acd2; successfully ran local tests


Tree-SHA512: 1bd8a5079d62afa40c4ccd5da847ee9bf297f3e400da3609c03148441220da137511205ba991b150bc7cc2f3818751e7635e4ed7fa43572c7bfdf8db70b5b790
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This commit fixes a rounding bug in how the rust-bitcoin library calculates the minimum transaction weight needed to pay a given fee at a given fee rate. The old code rounded the fee rate up too early, which could produce a weight slightly smaller than actually required. In practice, that means a wallet relying on this function might think a transaction meets its fee target when it actually falls a tiny bit short. The fix performs the division at full precision, matching a similar recent fix for the floor-division variant.

Recommended action

Review any code that calls div_by_fee_rate_ceil to confirm it now produces weights large enough to meet fee targets; update to this patch release. No immediate incident response is indicated, but fee-calculation correctness is safety-critical for wallet software.

Security signals we found

01

Incorrect fee-weight calculation due to premature integer rounding

02

Potential transaction fee shortfall when using div_by_fee_rate_ceil

03

Overflow protection added for Amount::MAX * 4_000_000 intermediate value

04

Matches analogous precision fix in div_by_fee_rate_floor (#6884)

Risk score

Why this scored 48/100

Our methodology →
Potential impact 12/30
Exploitability 8/25
Stealth signal 7/15
Affected reach 9/15
Confidence 8/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.