Skip to content

Commit 521f814

Browse files
committed
Add support for bitcoin core 29.0
1 parent 1aabd27 commit 521f814

File tree

32 files changed

+2380
-18
lines changed

32 files changed

+2380
-18
lines changed

.github/workflows/rust.yaml

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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};
Lines changed: 33 additions & 0 deletions
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

Lines changed: 171 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 11 additions & 0 deletions
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

Lines changed: 15 additions & 5 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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.

0 commit comments

Comments
 (0)