Skip to content

Finish off support for Bitcoin Core v31.0#615

Open
satsfy wants to merge 12 commits into
rust-bitcoin:masterfrom
satsfy:v31
Open

Finish off support for Bitcoin Core v31.0#615
satsfy wants to merge 12 commits into
rust-bitcoin:masterfrom
satsfy:v31

Conversation

@satsfy
Copy link
Copy Markdown
Contributor

@satsfy satsfy commented May 29, 2026

Closes #599

Completes v31 support across the client, types, and integration tests. Makes v31 the default version.

  • set v31 as the latest version and re-export the v31 types.
  • enabled the v31 integration tests.
  • Dropped the incorrect "fields changed" doc notes on several v31 types.

Fixed:

  • getpeerinfo (network): added inv_to_send and last_inv_sequence, and made startingheight optional now that it is only returned under -deprecatedrpc=startingheight.
  • logging (control): added the new kernel and privatebroadcast categories.
  • getwalletinfo (wallet): no longer returns paytxfee.
  • getdeploymentinfo (blockchain): added the script_flags field.
  • gettxspendingprevout (blockchain): fixed the result type to carry the new spendingtx and blockhash fields, plus added support for the new mempool_only and return_spending_tx arguments.
  • getblock (blockchain): added the coinbase_tx object returned at verbosity 1, 2 and 3.

Added:

  • cluster mempool (blockchain): new getmempoolcluster and getmempoolfeeratediagram RPCs, the chunk_weight and chunk_fee fields on getmempoolentry, getrawmempool, getmempoolancestors and getmempooldescendants, and the cluster_limit and optimal fields on getmempoolinfo.
  • private broadcast (raw transactions): new getprivatebroadcastinfo and abortprivatebroadcast RPCs.

LLM usage: Claude helped on generating tests for new RPCs, verifying things over and over again, attempting to call every RPC, spotting additional unfixed things, and reviewing every change the PR.

When appropriate, comments have been checked to match v31 documentation exactly.

@satsfy
Copy link
Copy Markdown
Contributor Author

satsfy commented Jun 1, 2026

Latest force push uses enums for getpeerinfo types, maintaining full v31 docs in corepc (before, it simply discarded relevant messages from Bitcoin Core documentation).

EDIT: below i retriggered CI

Comment thread types/src/model/blockchain.rs Outdated
Comment thread types/src/v19/blockchain/into.rs Outdated
Comment thread types/src/v31/blockchain/into.rs Outdated
Comment thread types/src/v31/blockchain/into.rs Outdated
Comment thread types/src/v31/blockchain/into.rs Outdated
Comment on lines -38 to +46
/// Transactions in this chunk in mining order (txids).
/// Transactions in this chunk in mining order.
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.

Why this change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In Bitcoin Core, it looks like this

RPCResult{RPCResult::Type::ARR, "txs", "transactions in this chunk in mining order",
    {RPCResult{RPCResult::Type::STR_HEX, "txid", "transaction 

And in the docs

"txs" : [             (json array) transactions in this chunk in mining order
  "hex",              (string) transaction id
  ...
]

There is no (txids). Whenever this kind of conflict happens (knowing that our existing docs have errors sometimes) I took no chances and copied exactly what core said to prevent drift. I thought this would be the way to go because we will have codegen types which effortlessly copy precisely the same docs as core.

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.

Yep nice, spot on. Thanks

@tcharding
Copy link
Copy Markdown
Member

Looks pretty good man. To create all the new types you just copied the one from the latest version and added the fields, right? I.e for MempoolEntry you copied the one from v24, right?

@tcharding
Copy link
Copy Markdown
Member

Reviewed: 1d584d8

@satsfy
Copy link
Copy Markdown
Contributor Author

satsfy commented Jun 2, 2026

Looks pretty good man. To create all the new types you just copied the one from the latest version and added the fields, right? I.e for MempoolEntry you copied the one from v24, right?

Yes. Everything that didn't need to change hasn't changed. Diffs only in new/modified fields or the corresponding docs. All "institutional memory" is kept.

Copy link
Copy Markdown
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.

I've had a look through and it all looks good so far. There is a lot here at so will need to have another look tomorrow.

@tcharding
Copy link
Copy Markdown
Member

tcharding commented Jun 2, 2026

The first commit doesn't build. Can you get the PR into a state where I can review patch by patch and on each I can run test30 and test31 cleanly (in integration_test/) please? See the README for these commands if you haven't already.

@satsfy satsfy force-pushed the v31 branch 2 times, most recently from 508d5cf to aad9a24 Compare June 4, 2026 03:17
@satsfy
Copy link
Copy Markdown
Contributor Author

satsfy commented Jun 4, 2026

Force push fixed the bissectability of every commit.

EDIT: no, a90eb31 is broken.

@satsfy satsfy force-pushed the v31 branch 2 times, most recently from 508d5cf to 150016f Compare June 4, 2026 04:14
@apoelstra
Copy link
Copy Markdown
Member

150016f needs rebase

@satsfy satsfy force-pushed the v31 branch 2 times, most recently from bc23b4d to a58753a Compare June 4, 2026 04:31
@satsfy
Copy link
Copy Markdown
Contributor Author

satsfy commented Jun 4, 2026

Force push fixes the other bad force pushes I made. Should be good to go.

}
}

impl GetBlockVerboseThree {
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.

This doesn't seem right. It should do the parsing of each field in the into_model function like is done for VerboseTwo.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes my mistake. Has been fixed.

Comment thread types/src/v31/blockchain/into.rs Outdated
pub fn into_model(
self,
) -> Result<model::GetDeploymentInfo, crate::v23::GetDeploymentInfoError> {
use crate::v23::GetDeploymentInfoError as E;
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
use crate::v23::GetDeploymentInfoError as E;
use GetDeploymentInfoError as E;

Errors from previous versions should be reexported from the module, i.e. in this case types/src/v30/blockchain/mod.rs and then added to the use super at the top of the into.rs file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Everything used from previous versions is now exported from the module.

Comment thread types/src/v31/mod.rs Outdated
//! | dumptxoutset | version + model | |
//! | getbestblockhash | version + model | |
//! | getblock | version + model | TODO: Fields have changed since v30 |
//! | getblock | version + model | Includes 'coinbase_tx' object |
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
//! | getblock | version + model | Includes 'coinbase_tx' object |
//! | getblock | version + model | Includes additional 'verbose' type |

These comments in the table are saying there are additional types, i.e. more than just the GetBlock type, not what fields were changed in the version. I didn't check the rest of the RPCs in this table but any that have a verbose type should have this comment and all the other comments about what changed removed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

satsfy added 11 commits June 5, 2026 18:24
Converted to enum the type of fields "connection_type" and
"transport_protocol_type" to match Bitcoin Core docs.
New fields kernel and privatebroadcast.
RPC getwalletinfo no longer returns paytxfee
Add getmempoolcluster and getmempoolfeeratediagram RPCs.

Update getmempoolentry, getrawmempool, getmempoolancestors,
getmempooldescendants and getmempoolinfo with new field chunk_weight,
chunk_fee and cluster_limit fields.

Back-fill optional fields as None for earlier versions.
RPC getdeploymentinfo gets script_flags field.
This commit adds an Enum with the possible flags.
RPC gettxspendingprevout adds spending_tx and block_hash fields when
return_spending_tx is set.
RPC getblock gets new field coinbase_tx.
Commit backfills None for earlier versions.
Deny unknown fields.
Use i64 for peer timestamps because time can be emmited as a negative.
getblockfrompeer, disconnectnode, getnetworkinfo, getblocktemplate and
waitfornewblock each carried a a note that said the fields since v30,
but their modelled return types match v30.
Despite getmempoolfeeratediagram being a new RPC, it is hidden. It is
not included in the rustdoc method table.

Remove SetTxFee import because the RPC has been deleted but the
re-export had been kept.
@satsfy
Copy link
Copy Markdown
Contributor Author

satsfy commented Jun 5, 2026

Latest force push:

  • Made GetRawTransactionVerboseWithPrevout::into_model_with_prevouts public in v29 so v31 can call it.
  • Refactored the into_model conversions to follow corepc pattern.
  • Routed any call that reach back into older version though mod.rs.
  • GetBlockVerboseThree::into_model now builds correctly.
  • Cleaned up the notes column in the v31 method table.

Drop the v30_and_below gates from tests covering RPCs unchanged in v31.
@satsfy
Copy link
Copy Markdown
Contributor Author

satsfy commented Jun 5, 2026

Clean up accidental garbage file

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.

Finish off support for Core v31

4 participants