Skip to content

Commit 3e54aff

Browse files
committed
Add support for bitcoin core 29.0
1 parent 1aabd27 commit 3e54aff

File tree

32 files changed

+2428
-18
lines changed

32 files changed

+2428
-18
lines changed

.github/workflows/rust.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ jobs:
210210
matrix:
211211
feature:
212212
[
213+
"29_0",
213214
"28_1",
214215
"28_0",
215216
"27_2",

client/src/client_sync/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub mod v25;
1515
pub mod v26;
1616
pub mod v27;
1717
pub mod v28;
18+
pub mod v29;
1819

1920
use std::fs::File;
2021
use std::io::{BufRead, BufReader};
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// SPDX-License-Identifier: CC0-1.0
2+
3+
//! Macros for implementing JSON-RPC methods on a client.
4+
//!
5+
//! Specifically this is methods found under the `== Blockchain ==` section of the
6+
//! API docs of Bitcoin Core `v29`.
7+
//!
8+
//! All macros require `Client` to be in scope.
9+
//!
10+
//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`.
11+
12+
/// Implements Bitcoin Core JSON-RPC API method `getdescriptoractivity`
13+
#[macro_export]
14+
macro_rules! impl_client_v29__getdescriptoractivity {
15+
() => {
16+
impl Client {
17+
pub fn get_descriptor_activity(
18+
&self,
19+
blockhashes: &[BlockHash],
20+
scan_objects: &[&str],
21+
include_mempool: bool,
22+
) -> Result<GetDescriptorActivity> {
23+
let blockhashes_val = json!(blockhashes);
24+
let scan_objects_val = json!(scan_objects);
25+
let include_mempool_val = json!(include_mempool);
26+
27+
let params = vec![blockhashes_val, scan_objects_val, include_mempool_val];
28+
29+
self.call("getdescriptoractivity", &params)
30+
}
31+
}
32+
};
33+
}

client/src/client_sync/v29/mod.rs

+171
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
// SPDX-License-Identifier: CC0-1.0
2+
3+
//! A JSON-RPC client for testing against Bitcoin Core `v29`.
4+
//!
5+
//! We ignore option arguments unless they effect the shape of the returned JSON data.
6+
pub mod blockchain;
7+
8+
use std::collections::BTreeMap;
9+
use std::path::Path;
10+
11+
use bitcoin::address::{Address, NetworkChecked};
12+
use bitcoin::{sign_message, Amount, Block, BlockHash, PublicKey, Txid};
13+
use serde::{Deserialize, Serialize};
14+
use serde_json::json;
15+
16+
use crate::client_sync::into_json;
17+
use crate::types::v29::*;
18+
19+
#[rustfmt::skip] // Keep public re-exports separate.
20+
pub use crate::client_sync::{
21+
v17::{Input, Output, WalletCreateFundedPsbtInput},
22+
v23::AddressType,
23+
};
24+
25+
crate::define_jsonrpc_minreq_client!("v29");
26+
crate::impl_client_check_expected_server_version!({ [290000] });
27+
28+
// == Blockchain ==
29+
crate::impl_client_v17__getbestblockhash!();
30+
crate::impl_client_v17__getblock!();
31+
crate::impl_client_v17__getblockchaininfo!();
32+
crate::impl_client_v17__getblockcount!();
33+
crate::impl_client_v19__getblockfilter!();
34+
crate::impl_client_v17__getblockhash!();
35+
crate::impl_client_v17__getblockheader!();
36+
crate::impl_client_v17__getblockstats!();
37+
crate::impl_client_v17__getchaintips!();
38+
crate::impl_client_v17__getchaintxstats!();
39+
crate::impl_client_v29__getdescriptoractivity!();
40+
crate::impl_client_v17__getdifficulty!();
41+
crate::impl_client_v17__getmempoolancestors!();
42+
crate::impl_client_v17__getmempooldescendants!();
43+
crate::impl_client_v17__getmempoolentry!();
44+
crate::impl_client_v17__getmempoolinfo!();
45+
crate::impl_client_v17__getrawmempool!();
46+
crate::impl_client_v17__gettxout!();
47+
crate::impl_client_v17__gettxoutproof!();
48+
crate::impl_client_v26__gettxoutsetinfo!();
49+
crate::impl_client_v17__preciousblock!();
50+
crate::impl_client_v17__pruneblockchain!();
51+
crate::impl_client_v23__savemempool!();
52+
crate::impl_client_v17__verifychain!();
53+
crate::impl_client_v17__verifytxoutproof!();
54+
55+
// == Control ==
56+
crate::impl_client_v17__getmemoryinfo!();
57+
crate::impl_client_v18__getrpcinfo!();
58+
crate::impl_client_v17__help!();
59+
crate::impl_client_v17__logging!();
60+
crate::impl_client_v17__stop!();
61+
crate::impl_client_v17__uptime!();
62+
63+
// == Generating ==
64+
crate::impl_client_v17__generatetoaddress!();
65+
crate::impl_client_v17__invalidateblock!();
66+
67+
// == Mining ==
68+
crate::impl_client_v17__getblocktemplate!();
69+
crate::impl_client_v17__getmininginfo!();
70+
crate::impl_client_v17__getnetworkhashps!();
71+
crate::impl_client_v26__get_prioritised_transactions!();
72+
crate::impl_client_v17__prioritisetransaction!();
73+
crate::impl_client_v17__submitblock!();
74+
75+
// == Network ==
76+
crate::impl_client_v17__getaddednodeinfo!();
77+
crate::impl_client_v17__getnettotals!();
78+
crate::impl_client_v17__getnetworkinfo!();
79+
crate::impl_client_v18__getnodeaddresses!();
80+
crate::impl_client_v17__getpeerinfo!();
81+
82+
// == Rawtransactions ==
83+
crate::impl_client_v18__analyzepsbt!();
84+
crate::impl_client_v17__combinepsbt!();
85+
crate::impl_client_v17__combinerawtransaction!();
86+
crate::impl_client_v17__converttopsbt!();
87+
crate::impl_client_v17__createpsbt!();
88+
crate::impl_client_v17__createrawtransaction!();
89+
crate::impl_client_v17__decodepsbt!();
90+
crate::impl_client_v17__decoderawtransaction!();
91+
crate::impl_client_v17__decodescript!();
92+
crate::impl_client_v17__finalizepsbt!();
93+
crate::impl_client_v17__fundrawtransaction!();
94+
crate::impl_client_v17__getrawtransaction!();
95+
crate::impl_client_v18__joinpsbts!();
96+
crate::impl_client_v17__sendrawtransaction!();
97+
crate::impl_client_v17__signrawtransaction!();
98+
crate::impl_client_v17__signrawtransactionwithkey!();
99+
crate::impl_client_v28__submitpackage!();
100+
crate::impl_client_v17__testmempoolaccept!();
101+
crate::impl_client_v18__utxoupdatepsbt!();
102+
103+
// == Util ==
104+
crate::impl_client_v17__createmultisig!();
105+
crate::impl_client_v17__estimatesmartfee!();
106+
crate::impl_client_v17__signmessagewithprivkey!();
107+
crate::impl_client_v17__validateaddress!();
108+
crate::impl_client_v17__verifymessage!();
109+
110+
// == Wallet ==
111+
crate::impl_client_v17__addmultisigaddress!();
112+
crate::impl_client_v17__bumpfee!();
113+
crate::impl_client_v23__createwallet!();
114+
crate::impl_client_v17__dumpprivkey!();
115+
crate::impl_client_v17__dumpwallet!();
116+
crate::impl_client_v17__getaddressesbylabel!();
117+
crate::impl_client_v17__getaddressinfo!();
118+
crate::impl_client_v17__getbalance!();
119+
crate::impl_client_v19__getbalances!();
120+
crate::impl_client_v17__getnewaddress!();
121+
crate::impl_client_v17__getrawchangeaddress!();
122+
crate::impl_client_v17__getreceivedbyaddress!();
123+
crate::impl_client_v17__gettransaction!();
124+
crate::impl_client_v17__getunconfirmedbalance!();
125+
crate::impl_client_v17__getwalletinfo!();
126+
crate::impl_client_v17__listaddressgroupings!();
127+
crate::impl_client_v17__listlabels!();
128+
crate::impl_client_v17__listlockunspent!();
129+
crate::impl_client_v17__listreceivedbyaddress!();
130+
crate::impl_client_v17__listsinceblock!();
131+
crate::impl_client_v17__listtransactions!();
132+
crate::impl_client_v17__listunspent!();
133+
crate::impl_client_v17__listwallets!();
134+
crate::impl_client_v22__loadwallet!();
135+
crate::impl_client_v17__rescanblockchain!();
136+
crate::impl_client_v17__sendmany!();
137+
crate::impl_client_v17__sendtoaddress!();
138+
crate::impl_client_v17__signmessage!();
139+
crate::impl_client_v17__signrawtransactionwithwallet!();
140+
crate::impl_client_v21__unloadwallet!();
141+
crate::impl_client_v17__walletcreatefundedpsbt!();
142+
crate::impl_client_v17__walletprocesspsbt!();
143+
144+
/// Client side supported softfork deployment.
145+
#[derive(Copy, Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
146+
#[serde(rename_all = "lowercase")]
147+
pub enum TemplateRules {
148+
/// SegWit v0 supported.
149+
Segwit,
150+
/// Signet supported.
151+
Signet,
152+
/// CSV supported.
153+
Csv,
154+
/// Taproot supported.
155+
Taproot,
156+
}
157+
158+
/// Arg for the `getblocktemplate` method. (v29+).
159+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
160+
pub struct TemplateRequest {
161+
#[serde(skip_serializing_if = "Option::is_none")]
162+
pub mode: Option<String>,
163+
#[serde(default, skip_serializing_if = "Vec::is_empty")]
164+
pub capabilities: Vec<String>,
165+
#[serde(default, skip_serializing_if = "Vec::is_empty")]
166+
pub rules: Vec<TemplateRules>,
167+
#[serde(skip_serializing_if = "Option::is_none")]
168+
pub longpollid: Option<String>,
169+
#[serde(skip_serializing_if = "Option::is_none")]
170+
pub data: Option<String>,
171+
}

contrib/run-bitcoind.sh

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ CONFIGURATION
4242
4343
- Examples
4444
45+
v29 29.0 290 /opt/bitcoin-29.0/bin/bitcoind
4546
v28 28.1 281 /opt/bitcoin-28.1/bin/bitcoind
4647
v24 24.2 242 /opt/bitcoin-24.2/bin/bitcoind
4748
v21 0.21.2 212 /opt/bitcoin-0.21.2/bin/bitcoind

integration_test/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ edition = "2021"
1313
[features]
1414
# Enable the same feature in `node` and the version feature here.
1515
# All minor releases of the latest three versions.
16+
29_0 = ["v29", "node/29_0"]
1617
28_1 = ["v28", "node/28_1"]
1718
28_0 = ["v28", "node/28_0"]
1819
27_2 = ["v27", "node/27_2"]
@@ -34,6 +35,7 @@ edition = "2021"
3435

3536
# These features are just for internal use (feature gating).
3637
# Each major version is tested with the same client.
38+
v29 = []
3739
v28 = []
3840
v27 = []
3941
v26 = []

integration_test/tests/blockchain.rs

+11
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ fn blockchain__get_block__modelled() {
3636
// assert!(json.into_model().is_ok());
3737
}
3838

39+
#[cfg(not(feature = "v29"))]
3940
#[test]
4041
fn blockchain__get_blockchain_info__modelled() {
4142
let node = Node::with_wallet(Wallet::None, &[]);
@@ -148,6 +149,16 @@ fn blockchain__get_chain_tx_stats__modelled() {
148149
model.unwrap();
149150
}
150151

152+
#[test]
153+
#[cfg(feature = "v29")]
154+
fn blockchain__get_descriptor_activity__modelled() {
155+
let node = Node::with_wallet(Wallet::None, &["-coinstatsindex=1", "-txindex=1"]);
156+
157+
let json: GetDescriptorActivity = node.client.get_descriptor_activity(&[], &[], false).expect("getdescriptoractivity");
158+
let model: Result<mtype::GetDescriptorActivity, GetDescriptorActivityError> = json.into_model();
159+
model.unwrap();
160+
}
161+
151162
#[test]
152163
fn blockchain__get_difficulty__modelled() {
153164
let node = Node::with_wallet(Wallet::None, &[]);

integration_test/tests/mining.rs

+15-5
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,22 @@ fn mining__get_block_template__modelled() {
1818
node1.mine_a_block();
1919
node2.mine_a_block();
2020
node3.mine_a_block();
21+
std::thread::sleep(std::time::Duration::from_millis(500));
22+
23+
let options = match () {
24+
#[cfg(not(feature = "v29"))]
25+
() => TemplateRequest { rules: vec![TemplateRules::Segwit] },
26+
#[cfg(feature = "v29")]
27+
() => TemplateRequest {
28+
rules: vec![TemplateRules::Segwit],
29+
mode: Some("template".to_string()),
30+
..Default::default()
31+
}
32+
};
2133

22-
let options = TemplateRequest { rules: vec![TemplateRules::Segwit] };
23-
24-
let json: GetBlockTemplate = node1.client.get_block_template(&options).expect("rpc");
25-
let model: Result<mtype::GetBlockTemplate, GetBlockTemplateError> = json.into_model();
26-
model.unwrap();
34+
let json: GetBlockTemplate = node1.client.get_block_template(&options)
35+
.expect("get_block_template RPC failed");
36+
let _: Result<mtype::GetBlockTemplate, GetBlockTemplateError> = json.into_model();
2737
}
2838

2939
#[test]

node/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ default = ["0_17_2"]
4545
download = ["anyhow", "bitcoin_hashes", "flate2", "tar", "minreq", "zip"]
4646

4747
# We support all minor releases of the latest three versions.
48+
29_0 = ["28_1"]
4849
28_1 = ["28_0"]
4950
28_0 = ["27_2"]
5051
27_2 = ["27_1"]

node/contrib/extra_tests.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
set -euox pipefail
1616

17-
FEATURES=("28_1" "28_0" "27_1" "27_0" "26_2" "26_1" "26_0" "25_2" "24_2" \
17+
FEATURES=("29_0" "28_1" "28_0" "27_1" "27_0" "26_2" "26_1" "26_0" "25_2" "24_2" \
1818
"23_2" "22_1" "0_21_2" "0_20_2" "0_19_1" "0_18_1" "0_17_2")
1919

2020
# Use the current `Cargo.lock` file without updating it.
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
95da3fb840044bddcde761394597da5e2f7d7030d371c94a6b51b15db9ea6a92 bitcoin-29.0-aarch64-linux-gnu-debug.tar.gz
2+
7922ac99363dd28f79e57ef7098581fd48ebd1119b412b07e73b1fd19fd0443f bitcoin-29.0-aarch64-linux-gnu.tar.gz
3+
f7f5c47d5e7674b325473e8d6834ba842e280794f6d9079f3e3cc26d031b755b bitcoin-29.0-arm-linux-gnueabihf-debug.tar.gz
4+
ea8ca24ab56d486a55289c43cb4256f9f0e66224899cc43482c9498a3f2614d1 bitcoin-29.0-arm-linux-gnueabihf.tar.gz
5+
34431c582a0399dd42e1276d87d25306cbdde0217f6744bd55a2945986645dda bitcoin-29.0-arm64-apple-darwin.tar.gz
6+
f660d4a968f5dabcee4d72cd31b4a50ab0d646386a9fc78c6208a9a101f8878d bitcoin-29.0-arm64-apple-darwin.zip
7+
fc7dee914326fc734f3fd982be3e58a163c4838f056593707ff0e68123fded5c bitcoin-29.0-arm64-apple-darwin-codesigning.tar.gz
8+
9e828fee8562c1748337182a723f5f574cec19196a36bff184d0ea346dde335d bitcoin-29.0-arm64-apple-darwin-unsigned.tar.gz
9+
d948735aa17f01af243ee621af80b0c4073587868d6a71309b2531b9b429fed4 bitcoin-29.0-arm64-apple-darwin-unsigned.zip
10+
bc69f1351ea6c5e88e54ad4ce93ee322066e7ec868b2b289f1544e432a799363 bitcoin-29.0-codesignatures-29.0.tar.gz
11+
882c782c34a3bf2eacd1fae5cdc58b35b869883512f197f7d6dc8f195decfdaa bitcoin-29.0.tar.gz
12+
9407abc574ddd52fe4ebfae4bed6c782d7701142e4096d29f08e5fb747f4a218 bitcoin-29.0-powerpc64-linux-gnu-debug.tar.gz
13+
6cbf1056b48799f366374c12b3cdc2cc0dcd5b37dc8058433ae35bb7764d3f17 bitcoin-29.0-powerpc64-linux-gnu.tar.gz
14+
a3e35a74e1647aec5425c5434acc28c3508c6e796382e7024b44f4c3c63c9607 bitcoin-29.0-riscv64-linux-gnu-debug.tar.gz
15+
4b3cb5e6490354778a289cf808c0d1adb29e6a251570942b5f25c143c47fbdd0 bitcoin-29.0-riscv64-linux-gnu.tar.gz
16+
5bb824fc86a15318d6a83a1b821ff4cd4b3d3d0e1ec3d162b805ccf7cae6fca8 bitcoin-29.0-x86_64-apple-darwin.tar.gz
17+
3bbee3e1f006365542d5c84beb632c90a6d206fa610c1fe415f52e69febe9b0c bitcoin-29.0-x86_64-apple-darwin.zip
18+
0ce7617e8207490fe186bef3c8dc61f6a2cd1ae192ddf1cb864ef2a58e1367d3 bitcoin-29.0-x86_64-apple-darwin-codesigning.tar.gz
19+
783334643eca7f3e9e9d6d34a6d04f9bbeb0a8036ff9b90a990a5255370c8a62 bitcoin-29.0-x86_64-apple-darwin-unsigned.tar.gz
20+
a15b65890537f4dc73b4af0c9b9a30e735f45dd0ae53ff45dfac9c67f05080b6 bitcoin-29.0-x86_64-apple-darwin-unsigned.zip
21+
50d320dcea299c8ff5bd42be877b4f61a0fce290d945fe0b0b431b9c26ea1b06 bitcoin-29.0-x86_64-linux-gnu-debug.tar.gz
22+
a681e4f6ce524c338a105f214613605bac6c33d58c31dc5135bbc02bc458bb6c bitcoin-29.0-x86_64-linux-gnu.tar.gz
23+
f68589b8f81c670fe4850ba7c388a5da9ec9db6bfc715db2b381a17e37cc1ba4 bitcoin-29.0-win64-setup.exe
24+
4c1780532031129fcacfc0e393c8430b3cea414c9f8c5e0c0c87ebe59a5ada1b bitcoin-29.0-win64.zip
25+
f3a20b09dfab33b4f8ae64a55c2669520c397b5eba5fb9a5b5a4afac75337d91 bitcoin-29.0-win64-codesigning.tar.gz
26+
d1c07f87a6d7ec3be84fb3071cbf79a0f2c1a610d0c71998e54d3d0ff543b5c3 bitcoin-29.0-win64-debug.zip
27+
4e161b0fbe72f41124d94019e014c6e5aa87761253373fcba3926f419f861f76 bitcoin-29.0-win64-setup-unsigned.exe
28+
8adb995aae3ff69922b4d6ab5d8fb4093bdc5984d80121a62684a37f483dccc1 bitcoin-29.0-win64-unsigned.zip

node/src/client_versions.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66

77
#![allow(unused_imports)] // Not all users need the json types.
88

9-
#[cfg(feature = "28_1")]
9+
#[cfg(feature = "29_0")]
10+
pub use corepc_client::{client_sync::v29::*, types::v29 as vtype};
11+
12+
#[cfg(all(feature = "28_1", not(feature = "29_0")))]
1013
pub use corepc_client::{client_sync::v28::*, types::v28 as vtype};
1114

1215
#[cfg(all(feature = "28_0", not(feature = "28_1")))]
@@ -60,6 +63,7 @@ pub use corepc_client::{client_sync::v17::*, types::v17 as vtype};
6063
/// This is meaningless but we need it otherwise we can't get far enough into
6164
/// the build process to trigger the `compile_error!` in `./versions.rs`.
6265
#[cfg(all(
66+
not(feature = "29_0"),
6367
not(feature = "28_1"),
6468
not(feature = "28_0"),
6569
not(feature = "27_2"),

node/src/versions.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// An explicit version of Bitcoin Core must be selected by enabling some feature.
22
// We check this here instead of in `lib.rs` because this file is included in `build.rs`.
33
#[cfg(all(
4+
not(feature = "29_0"),
45
not(feature = "28_1"),
56
not(feature = "28_0"),
67
not(feature = "27_2"),
@@ -21,8 +22,11 @@
2122
))]
2223
compile_error!("enable a feature in order to select the version of Bitcoin Core to use");
2324

24-
#[cfg(feature = "28_1")]
25+
#[cfg(feature = "29_0")]
2526
#[allow(dead_code)] // Triggers in --all-features builds.
27+
pub const VERSION: &str = "29.0";
28+
29+
#[cfg(all(feature = "28_1", not(feature = "29_0")))]
2630
pub const VERSION: &str = "28.1";
2731

2832
#[cfg(all(feature = "28_0", not(feature = "28_1")))]
@@ -76,6 +80,7 @@ pub const VERSION: &str = "0.17.2";
7680
/// This is meaningless but we need it otherwise we can't get far enough into
7781
/// the build process to trigger the `compile_error!` in `./versions.rs`.
7882
#[cfg(all(
83+
not(feature = "29_0"),
7984
not(feature = "28_1"),
8085
not(feature = "28_0"),
8186
not(feature = "27_2"),

0 commit comments

Comments
 (0)