Add initial support for Bitcoin Core v31#598
Conversation
|
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? |
1eaa872 to
d10ec71
Compare
|
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 |
d10ec71 to
bc93a1e
Compare
|
If this is good can you push up a release tracking PR @jamillambert for |
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.
bc93a1e to
1fdcf93
Compare
|
Rebaesed on master after merge of #591 |
| macro_rules! impl_client_v31__get_private_broadcast_info { | ||
| () => { | ||
| impl Client { | ||
| pub fn get_private_broadcast_info(&self) -> Result<GetPrivateBroadcastInfor> { |
There was a problem hiding this comment.
| pub fn get_private_broadcast_info(&self) -> Result<GetPrivateBroadcastInfor> { | |
| pub fn get_private_broadcast_info(&self) -> Result<GetPrivateBroadcastInfo> { |
There was a problem hiding this comment.
Solid reviewing, thanks mate! verify should have caught these mistakes, let me investigate that.
There was a problem hiding this comment.
Gee wiz, the v31 module was not being built in. Missing pub mod v31 ...
| ), | ||
| Method::new_modelled("getdifficulty", "GetDifficulty", "get_difficulty"), | ||
| Method::new_modelled("getmempoolancestors", "GetMempoolAncestors", "get_mempool_ancestors"), | ||
| Method::new_modelled("getmempoolcluster", "GetMempoolClusted", "get_mempool_cluster"), |
There was a problem hiding this comment.
| Method::new_modelled("getmempoolcluster", "GetMempoolClusted", "get_mempool_cluster"), | |
| Method::new_modelled("getmempoolcluster", "GetMempoolCluster", "get_mempool_cluster"), |
There was a problem hiding this comment.
This is definitely a bug in verify. Added #602. Thanks man.
There was a problem hiding this comment.
The RPC is marked at TODO so isn't checked by verify
| @@ -0,0 +1,35 @@ | |||
| // SPDX-License-Identifier: CC0-1.0 | |||
|
|
|||
| //! The JSON-RPC API for Bitcoin Core `v31` - blockchain.b | |||
There was a problem hiding this comment.
| //! 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, |
There was a problem hiding this comment.
| pub cluster_weight: u64, | |
| #[serde(rename = "clusterweight")] | |
| pub cluster_weight: u64, |
| /// Total sigops-adjusted weight (as defined in BIP 141 and modified by `-bytespersigop`). | ||
| pub cluster_weight: u64, | ||
| /// Number of transactions. | ||
| pub tx_count: u64, |
There was a problem hiding this comment.
| pub tx_count: u64, | |
| #[serde(rename = "txcount")] | |
| pub tx_count: u64, |
| #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] | ||
| pub struct Chunk { | ||
| /// Fees of the transactions in this chunk. | ||
| pub chunk_fee: u64, |
There was a problem hiding this comment.
Its a float.
| 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, |
There was a problem hiding this comment.
| 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; | ||
|
|
There was a problem hiding this comment.
| pub mod raw_transactions; | |
| 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), |
There was a problem hiding this comment.
| chunk_fee: Amount::from_sat(chunk.chunk_fee), | |
| chunk_fee: Amount::from_btc(chunk.chunk_fee), |
There was a problem hiding this comment.
I"ll take your word for it. Thanks.
There was a problem hiding this comment.
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.
1fdcf93 to
da3e0f3
Compare
| #![allow(unused_imports)] // Not all users need the json types. | ||
|
|
||
| #[cfg(feature = "30_0")] | ||
| #[cfg(feature = "30_2")] |
There was a problem hiding this comment.
| #[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, |
There was a problem hiding this comment.
| pub chunk_fee: u64, | |
| pub chunk_fee: u64, |
Cause of the fmt CI job failure.
| Method::new_numeric("getnetworkhashps", "get_network_hashes_per_second"), | ||
| Method::new_modelled( | ||
| "getprioritisedtransactions", | ||
| "GetPrioritisedTransactionsREMOVEME", |
There was a problem hiding this comment.
| "GetPrioritisedTransactionsREMOVEME", | |
| "GetPrioritisedTransactions", |
Not sure what REMOVEME was for, but doing what it says fixes verify.
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