Skip to content

Add initial support for Bitcoin Core v31#598

Open
tcharding wants to merge 7 commits into
rust-bitcoin:masterfrom
tcharding:push-xxtnqtoqxumu
Open

Add initial support for Bitcoin Core v31#598
tcharding wants to merge 7 commits into
rust-bitcoin:masterfrom
tcharding:push-xxtnqtoqxumu

Conversation

@tcharding
Copy link
Copy Markdown
Member

@tcharding tcharding commented May 21, 2026

First do a bunch of cleanups. Then add initial support.

We include types for the three new methods but they are untested. All failing tests, typically caused by changed fields, are feature gated out and marked as TODO. These can be tackled at a later date because downstream is waiting for this and don't need full support immediately.

ref: #599

@tcharding
Copy link
Copy Markdown
Member Author

Props to @xyzconstant and @0xB10C for pushing me to do this.

I believe we can release this and then chip away at fixing the methods that were changed. Would that fix your use case lads?

@tcharding
Copy link
Copy Markdown
Member Author

Supersedes #586 and #596

@tcharding tcharding force-pushed the push-xxtnqtoqxumu branch 2 times, most recently from 1eaa872 to d10ec71 Compare May 21, 2026 02:38
@tcharding
Copy link
Copy Markdown
Member Author

I reset the author of final patch to remove you @xyzconstant, I did use the shasums from you PR but that is all. Is that ok or do you want Co-authored-by?

@tcharding tcharding force-pushed the push-xxtnqtoqxumu branch from d10ec71 to bc93a1e Compare May 21, 2026 02:45
@tcharding
Copy link
Copy Markdown
Member Author

If this is good can you push up a release tracking PR @jamillambert for corepc-types, corepc-client, and bitcoind. In the changelog of types we should explicitly point out that the support is limited.

tcharding added 6 commits May 21, 2026 13:30
The version features are weird in this crate, later Core versions
enable earlier ones. So we can simplify the 'all-features' feature
gating to just check for the earlies `0_17_2` with no change of
functionality.
The features on this crate are non-typical. Improve the docs and put
the `latest` feature right below `default`.
This is buggy, I couldn't come up with a way to catch this in case we
do it again another time when we add a later Core version.
A few problems being fixed here:

- We once committed to supporting all point releases for the latest 3
  versions of Core. During 88ddaf1 it looks like this was changed to
  4 and I missed this in review (or I don't remember it).
- We want to add support for the latest version of Core (v31)

Cut back early point releases to only be for the latest 2 versions,
then when we add support for v31 it will be back to 3. Leave
docs/comments saying 'three'.
The wallet migration bug was present in both v30.0 and v30.1 but we
continue to have a `30_0` feature - this is wrong, remove it.
`v30_and_below` is currently all versions, this feature gate is
incorrect - remove it.
@tcharding tcharding force-pushed the push-xxtnqtoqxumu branch from bc93a1e to 1fdcf93 Compare May 21, 2026 03:30
@tcharding
Copy link
Copy Markdown
Member Author

Rebaesed on master after merge of #591

Copy link
Copy Markdown
Contributor

@satsfy satsfy left a comment

Choose a reason for hiding this comment

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

Reviewed 1fdcf93

Let's do v31!

  • In contrib/templates/bitcoind_aliases there is an alias mentioned 30_0 and Cargo.toml mentioned 30_0 still.

macro_rules! impl_client_v31__get_private_broadcast_info {
() => {
impl Client {
pub fn get_private_broadcast_info(&self) -> Result<GetPrivateBroadcastInfor> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
pub fn get_private_broadcast_info(&self) -> Result<GetPrivateBroadcastInfor> {
pub fn get_private_broadcast_info(&self) -> Result<GetPrivateBroadcastInfo> {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Solid reviewing, thanks mate! verify should have caught these mistakes, let me investigate that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Gee wiz, the v31 module was not being built in. Missing pub mod v31 ...

Comment thread verify/src/method/v31.rs Outdated
),
Method::new_modelled("getdifficulty", "GetDifficulty", "get_difficulty"),
Method::new_modelled("getmempoolancestors", "GetMempoolAncestors", "get_mempool_ancestors"),
Method::new_modelled("getmempoolcluster", "GetMempoolClusted", "get_mempool_cluster"),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Method::new_modelled("getmempoolcluster", "GetMempoolClusted", "get_mempool_cluster"),
Method::new_modelled("getmempoolcluster", "GetMempoolCluster", "get_mempool_cluster"),

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is definitely a bug in verify. Added #602. Thanks man.

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.

The RPC is marked at TODO so isn't checked by verify

Comment thread types/src/v31/blockchain/mod.rs Outdated
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: CC0-1.0

//! The JSON-RPC API for Bitcoin Core `v31` - blockchain.b
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
//! The JSON-RPC API for Bitcoin Core `v31` - blockchain.b
//! The JSON-RPC API for Bitcoin Core `v31` - blockchain.

#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))]
pub struct GetMempoolCluster {
/// Total sigops-adjusted weight (as defined in BIP 141 and modified by `-bytespersigop`).
pub cluster_weight: u64,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
pub cluster_weight: u64,
#[serde(rename = "clusterweight")]
pub cluster_weight: u64,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good eye bro!

/// Total sigops-adjusted weight (as defined in BIP 141 and modified by `-bytespersigop`).
pub cluster_weight: u64,
/// Number of transactions.
pub tx_count: u64,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
pub tx_count: u64,
#[serde(rename = "txcount")]
pub tx_count: u64,

Comment thread types/src/v31/blockchain/mod.rs Outdated
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
pub struct Chunk {
/// Fees of the transactions in this chunk.
pub chunk_fee: u64,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Its a float.

Suggested change
pub chunk_fee: u64,
#[serde(rename = "chunkfee")]
pub chunk_fee: f64,

/// Fees of the transactions in this chunk.
pub chunk_fee: u64,
/// Sigops-adjusted weight of all transactions in this chunk.
pub chunk_weight: u64,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
pub chunk_weight: u64,
#[serde(rename = "chunkweight")]
pub chunk_weight: u64,

//! We ignore option arguments unless they effect the shape of the returned JSON data.

pub mod blockchain;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
pub mod raw_transactions;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ha, nice one.

let txs =
chunk.txs.iter().map(|txid| txid.parse::<Txid>()).collect::<Result<Vec<_>, _>>()?;
chunks.push(model::Chunk {
chunk_fee: Amount::from_sat(chunk.chunk_fee),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
chunk_fee: Amount::from_sat(chunk.chunk_fee),
chunk_fee: Amount::from_btc(chunk.chunk_fee),

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I"ll take your word for it. Thanks.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm going to leave it as is for now because from_btc is infallible and that means adding an error type. I'm too lazy to do all that for code that is not tested in this PR. The dev who does that can add the error type as part of testing.

I did add a TODO and linked to this discussion. Thanks man, good reviewing.

Props to xyzconstant and 0xB10C for pushing me to do this.

Add initial support for Bitcoin Core v31

We include types for the three new methods but they are untested. All
failing tests, typically caused by changed fields, are feature gated
out and marked as `TODO`. These can be tackled at a later date because
downstream is waiting for this and don't need full support immediately.
@tcharding tcharding force-pushed the push-xxtnqtoqxumu branch from 1fdcf93 to da3e0f3 Compare May 22, 2026 03:38
#![allow(unused_imports)] // Not all users need the json types.

#[cfg(feature = "30_0")]
#[cfg(feature = "30_2")]
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.

Suggested change
#[cfg(feature = "30_2")]
#[cfg(feature = "31_0")]
pub use corepc_client::{client_sync::v31::*, types::v31 as vtype};
#[cfg(all(feature = "30_2", not(feature = "31_0")))]

/// Fees of the transactions in this chunk.
#[serde(rename = "chunkfee")]
// FIXME: This is probably a float. https://github.com/rust-bitcoin/corepc/pull/598#discussion_r3283795812
pub chunk_fee: u64,
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.

Suggested change
pub chunk_fee: u64,
pub chunk_fee: u64,

Cause of the fmt CI job failure.

Comment thread verify/src/method/v31.rs
Method::new_numeric("getnetworkhashps", "get_network_hashes_per_second"),
Method::new_modelled(
"getprioritisedtransactions",
"GetPrioritisedTransactionsREMOVEME",
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.

Suggested change
"GetPrioritisedTransactionsREMOVEME",
"GetPrioritisedTransactions",

Not sure what REMOVEME was for, but doing what it says fixes verify.

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