Skip to content

Fix BTC/kB conversion logic - #483

Merged
tcharding merged 2 commits into
rust-bitcoin:masterfrom
tcharding:push-vzmpmotrqmys
Jan 27, 2026
Merged

tcharding merged 2 commits into
rust-bitcoin:masterfrom
tcharding:push-vzmpmotrqmys

Conversation

@tcharding

@tcharding tcharding commented Jan 27, 2026 •

Copy link
Copy Markdown
Member

Old RPC calls use BTC/kB, we need a FeeRate but v0.32 cannot elegantly handle the conversion so we do it manually - and surprise surprise its buggy.

This bug is why we spent so much time on the FeeRate API in rust-bitcoin.

The original code was written by me, was untested, and was buggy (even after I worked on the API in rust-bitcoin) - bad Tobin no biscuit.

Patch 2 adds a unit test and can be put before patch 1 to see the bug.

Fix: #482

We divided by 1000 _before_ converting to a fee rate which means for
sats less than 100 the value gets truncated to zero - woops.

Convert to fee rate first then div by 100 afterwards.

Props to 0xB10C for finding the bug.
Add a test to check that we can convert 0.000001 BTC/kB to sats i.e.,
100 sats per kB (note naive div / 1000 truncates to zero).
@tcharding tcharding changed the title Push vzmpmotrqmys Fix BTC/kB conversion logic Jan 27, 2026

@jamillambert jamillambert left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ACK 2bb341b

@tcharding
tcharding merged commit d31fc06 into rust-bitcoin:master Jan 27, 2026
0xB10C added a commit to peer-observer/peer-observer that referenced this pull request Feb 6, 2026
This includes the bug fix rust-bitcoin/corepc#483
required for the following commit.
0xB10C added a commit to peer-observer/peer-observer that referenced this pull request Feb 6, 2026
This includes the bug fix rust-bitcoin/corepc#483
required for the following commit.
0xB10C added a commit to peer-observer/peer-observer that referenced this pull request Feb 6, 2026
This includes the bug fix rust-bitcoin/corepc#483
required for the following commit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: GetMempoolInfo model FeeRate conversion broken

2 participants