Skip to content

Conversation

@deadmanoz
Copy link
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
Copy link
Collaborator

@jamillambert jamillambert left a comment

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
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
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)
}

Copy link
Collaborator

@jamillambert jamillambert left a comment

Choose a reason for hiding this comment

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

ACK 7ba4142

Copy link
Member

@tcharding tcharding left a comment

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
30 checks passed
@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