Skip to content

Conversation

@deadmanoz
Copy link

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

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.

2 participants