Skip to content

fix(types): use f64 for GetChainTxStats tx_rate field - #430

Merged
tcharding merged 2 commits into
rust-bitcoin:masterfrom
deadmanoz:fix-tx-rate-type
Dec 29, 2025
Merged

tcharding merged 2 commits into
rust-bitcoin:masterfrom
deadmanoz:fix-tx-rate-type

Conversation

@deadmanoz

Copy link
Copy Markdown
Contributor

Bitcoin Core has always returned txrate as a double since the RPC was added in v0.15 (PR #9733).

The previous type (i64) causes deserialisation to fail. Here's a minimal example:

use corepc_client::client_sync::v28::Client;
use corepc_client::client_sync::Auth;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let auth = Auth::UserPass("bitcoin".to_string(), "bitcoin".to_string());
    let client = Client::new_with_auth("http://127.0.0.1:8332", auth)?;
    let stats = client.get_chain_tx_stats()?;
    println!("tx_rate: {:?}", stats.tx_rate);
    Ok(())
}
Error: JsonRpc(Json(Error("invalid type: floating point `5.086614477523837`, expected i64", line: 1, column: 273)))

Bitcoin Core has always returned txrate as a double since the RPC was
added in v0.15 (PR #9733).
jamillambert
jamillambert previously approved these changes Dec 16, 2025

@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 687119b

Thanks for the fix.

@jamillambert

Copy link
Copy Markdown
Collaborator

This should also be tested. It can be added to this PR or as a follow up.

Change to a Default wallet and fund/mine so we get transactions for `GetChainTxStats` to report meaningful data.
@deadmanoz

Copy link
Copy Markdown
Contributor Author

Updated existing test.

Switced to a Default wallet, and fund/mine so we get transactions to report meaningful data for assertion, e.g.

GetChainTxStats { 
  time: 1766036241,
  tx_count: 104,
  window_final_block_hash: 5d1f1967e8c133164a25a51f9bb125e79c8d2395baaabde8c3767b0220442a66,
  window_final_block_height: Some(102), 
  window_block_count: 101, 
  window_tx_count: Some(102), 
  window_interval: Some(17), 
  tx_rate: Some(6.0)
}

@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 7ba4142

@tcharding tcharding left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ACK 7ba4142

@tcharding
tcharding merged commit 9a0763f into rust-bitcoin:master Dec 29, 2025
@deadmanoz
deadmanoz deleted the fix-tx-rate-type branch December 30, 2025 01:50
0xB10C added a commit to peer-observer/peer-observer that referenced this pull request Dec 30, 2025
This makes corepc support:

- cpu_load and inv_to_send in getpeerinfo (as before)
- addconnection
- getorphantxs

and includes rust-bitcoin/corepc#430 for #312
as well as other improvements in corepc master.

Also upgrading the node version feature to v30 from v29.
0xB10C added a commit to peer-observer/peer-observer that referenced this pull request Dec 30, 2025
This makes corepc support:

- cpu_load and inv_to_send in getpeerinfo (as before)
- addconnection
- getorphantxs

and includes rust-bitcoin/corepc#430 for #312
as well as other improvements in corepc master.

Also upgrading the node version feature to v30 from v29.
deadmanoz added a commit to deadmanoz/peer-observer that referenced this pull request Dec 31, 2025
corepc now correctly returns tx_rate as f64, matching Bitcoin Core.
Upstream fix: rust-bitcoin/corepc#430
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants