Skip to content

Commit 5438355

Browse files
committed
Add support for bitcoin core 29.0
1 parent f0586c0 commit 5438355

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+3129
-236
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_0",
214215
"27_1",
215216
"27_0",

client/src/client_sync/error.rs

+27-9
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,51 @@ pub enum Error {
2727
}
2828

2929
impl From<jsonrpc::error::Error> for Error {
30-
fn from(e: jsonrpc::error::Error) -> Error { Error::JsonRpc(e) }
30+
fn from(e: jsonrpc::error::Error) -> Error {
31+
Error::JsonRpc(e)
32+
}
3133
}
3234

3335
impl From<hex::HexToArrayError> for Error {
34-
fn from(e: hex::HexToArrayError) -> Self { Self::HexToArray(e) }
36+
fn from(e: hex::HexToArrayError) -> Self {
37+
Self::HexToArray(e)
38+
}
3539
}
3640

3741
impl From<hex::HexToBytesError> for Error {
38-
fn from(e: hex::HexToBytesError) -> Self { Self::HexToBytes(e) }
42+
fn from(e: hex::HexToBytesError) -> Self {
43+
Self::HexToBytes(e)
44+
}
3945
}
4046

4147
impl From<serde_json::error::Error> for Error {
42-
fn from(e: serde_json::error::Error) -> Error { Error::Json(e) }
48+
fn from(e: serde_json::error::Error) -> Error {
49+
Error::Json(e)
50+
}
4351
}
4452

4553
impl From<bitcoin::consensus::encode::FromHexError> for Error {
46-
fn from(e: bitcoin::consensus::encode::FromHexError) -> Error { Error::BitcoinSerialization(e) }
54+
fn from(e: bitcoin::consensus::encode::FromHexError) -> Error {
55+
Error::BitcoinSerialization(e)
56+
}
4757
}
4858

4959
impl From<secp256k1::Error> for Error {
50-
fn from(e: secp256k1::Error) -> Error { Error::Secp256k1(e) }
60+
fn from(e: secp256k1::Error) -> Error {
61+
Error::Secp256k1(e)
62+
}
5163
}
5264

5365
impl From<io::Error> for Error {
54-
fn from(e: io::Error) -> Error { Error::Io(e) }
66+
fn from(e: io::Error) -> Error {
67+
Error::Io(e)
68+
}
5569
}
5670

5771
impl From<bitcoin::amount::ParseAmountError> for Error {
58-
fn from(e: bitcoin::amount::ParseAmountError) -> Error { Error::InvalidAmount(e) }
72+
fn from(e: bitcoin::amount::ParseAmountError) -> Error {
73+
Error::InvalidAmount(e)
74+
}
5975
}
6076

6177
impl fmt::Display for Error {
@@ -122,5 +138,7 @@ impl fmt::Display for UnexpectedServerVersionError {
122138
impl error::Error for UnexpectedServerVersionError {}
123139

124140
impl From<UnexpectedServerVersionError> for Error {
125-
fn from(e: UnexpectedServerVersionError) -> Self { Self::ServerVersion(e) }
141+
fn from(e: UnexpectedServerVersionError) -> Self {
142+
Self::ServerVersion(e)
143+
}
126144
}

client/src/client_sync/mod.rs

+31-7
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};
@@ -177,15 +178,21 @@ where
177178

178179
/// Shorthand for `serde_json::Value::Null`.
179180
#[allow(dead_code)] // TODO: Remove this if unused still when we are done.
180-
fn null() -> serde_json::Value { serde_json::Value::Null }
181+
fn null() -> serde_json::Value {
182+
serde_json::Value::Null
183+
}
181184

182185
/// Shorthand for an empty `serde_json::Value` array.
183186
#[allow(dead_code)] // TODO: Remove this if unused still when we are done.
184-
fn empty_arr() -> serde_json::Value { serde_json::Value::Array(vec![]) }
187+
fn empty_arr() -> serde_json::Value {
188+
serde_json::Value::Array(vec![])
189+
}
185190

186191
/// Shorthand for an empty `serde_json` object.
187192
#[allow(dead_code)] // TODO: Remove this if unused still when we are done.
188-
fn empty_obj() -> serde_json::Value { serde_json::Value::Object(Default::default()) }
193+
fn empty_obj() -> serde_json::Value {
194+
serde_json::Value::Object(Default::default())
195+
}
189196

190197
/// Convert a possible-null result into an `Option`.
191198
#[allow(dead_code)] // TODO: Remove this if unused still when we are done.
@@ -205,11 +212,12 @@ fn log_response(method: &str, resp: &Result<jsonrpc::Response>) {
205212

206213
if log::log_enabled!(Warn) || log::log_enabled!(Debug) || log::log_enabled!(Trace) {
207214
match resp {
208-
Err(ref e) =>
215+
Err(ref e) => {
209216
if log::log_enabled!(Debug) {
210217
log::debug!(target: "corepc", "error: {}: {:?}", method, e);
211-
},
212-
Ok(ref resp) =>
218+
}
219+
}
220+
Ok(ref resp) => {
213221
if let Some(ref e) = resp.error {
214222
if log::log_enabled!(Debug) {
215223
log::debug!(target: "corepc", "response error for {}: {:?}", method, e);
@@ -219,7 +227,8 @@ fn log_response(method: &str, resp: &Result<jsonrpc::Response>) {
219227
serde_json::value::to_raw_value(&serde_json::value::Value::Null).unwrap();
220228
let result = resp.result.as_ref().unwrap_or(&def);
221229
log::trace!(target: "corepc", "response for {}: {}", method, result);
222-
},
230+
}
231+
}
223232
}
224233
}
225234
}
@@ -262,3 +271,18 @@ pub enum TemplateRules {
262271
/// Taproot supported.
263272
Taproot,
264273
}
274+
275+
/// Arg for the `getblocktemplate` method. (v29+).
276+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
277+
pub struct TemplateRequestV29 {
278+
#[serde(skip_serializing_if = "Option::is_none")]
279+
pub mode: Option<String>,
280+
#[serde(default, skip_serializing_if = "Vec::is_empty")]
281+
pub capabilities: Vec<String>,
282+
#[serde(default, skip_serializing_if = "Vec::is_empty")]
283+
pub rules: Vec<String>,
284+
#[serde(skip_serializing_if = "Option::is_none")]
285+
pub longpollid: Option<String>,
286+
#[serde(skip_serializing_if = "Option::is_none")]
287+
pub data: Option<String>,
288+
}

client/src/client_sync/v17/blockchain.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ macro_rules! impl_client_v17__getblockstats {
128128
macro_rules! impl_client_v17__getchaintips {
129129
() => {
130130
impl Client {
131-
pub fn get_chain_tips(&self) -> Result<GetChainTips> { self.call("getchaintips", &[]) }
131+
pub fn get_chain_tips(&self) -> Result<GetChainTips> {
132+
self.call("getchaintips", &[])
133+
}
132134
}
133135
};
134136
}

client/src/client_sync/v17/control.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ macro_rules! impl_client_v17__getmemoryinfo {
2626
macro_rules! impl_client_v17__help {
2727
() => {
2828
impl Client {
29-
pub fn help(&self) -> Result<String> { self.call("help", &[]) }
29+
pub fn help(&self) -> Result<String> {
30+
self.call("help", &[])
31+
}
3032
}
3133
};
3234
}
@@ -36,7 +38,9 @@ macro_rules! impl_client_v17__help {
3638
macro_rules! impl_client_v17__logging {
3739
() => {
3840
impl Client {
39-
pub fn logging(&self) -> Result<Logging> { self.call("logging", &[]) }
41+
pub fn logging(&self) -> Result<Logging> {
42+
self.call("logging", &[])
43+
}
4044
}
4145
};
4246
}
@@ -46,7 +50,9 @@ macro_rules! impl_client_v17__logging {
4650
macro_rules! impl_client_v17__stop {
4751
() => {
4852
impl Client {
49-
pub fn stop(&self) -> Result<String> { self.call("stop", &[]) }
53+
pub fn stop(&self) -> Result<String> {
54+
self.call("stop", &[])
55+
}
5056
}
5157
};
5258
}
@@ -56,7 +62,9 @@ macro_rules! impl_client_v17__stop {
5662
macro_rules! impl_client_v17__uptime {
5763
() => {
5864
impl Client {
59-
pub fn uptime(&self) -> Result<u32> { self.call("uptime", &[]) }
65+
pub fn uptime(&self) -> Result<u32> {
66+
self.call("uptime", &[])
67+
}
6068
}
6169
};
6270
}

client/src/client_sync/v17/mining.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ macro_rules! impl_client_v17__getmininginfo {
4141
macro_rules! impl_client_v17__getnetworkhashps {
4242
() => {
4343
impl Client {
44-
pub fn get_network_hash_ps(&self) -> Result<f64> { self.call("getnetworkhashps", &[]) }
44+
pub fn get_network_hash_ps(&self) -> Result<f64> {
45+
self.call("getnetworkhashps", &[])
46+
}
4547
}
4648
};
4749
}

client/src/client_sync/v17/network.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ macro_rules! impl_client_v17__getaddednodeinfo {
2626
macro_rules! impl_client_v17__getnettotals {
2727
() => {
2828
impl Client {
29-
pub fn get_net_totals(&self) -> Result<GetNetTotals> { self.call("getnettotals", &[]) }
29+
pub fn get_net_totals(&self) -> Result<GetNetTotals> {
30+
self.call("getnettotals", &[])
31+
}
3032
}
3133
};
3234
}
@@ -54,7 +56,9 @@ macro_rules! impl_client_v17__getnetworkinfo {
5456
macro_rules! impl_client_v17__getpeerinfo {
5557
() => {
5658
impl Client {
57-
pub fn get_peer_info(&self) -> Result<GetPeerInfo> { self.call("getpeerinfo", &[]) }
59+
pub fn get_peer_info(&self) -> Result<GetPeerInfo> {
60+
self.call("getpeerinfo", &[])
61+
}
5862
}
5963
};
6064
}

client/src/client_sync/v17/wallet.rs

+15-6
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ macro_rules! impl_client_v17__getaddressinfo {
111111
macro_rules! impl_client_v17__getbalance {
112112
() => {
113113
impl Client {
114-
pub fn get_balance(&self) -> Result<GetBalance> { self.call("getbalance", &[]) }
114+
pub fn get_balance(&self) -> Result<GetBalance> {
115+
self.call("getbalance", &[])
116+
}
115117
}
116118
};
117119
}
@@ -153,8 +155,9 @@ macro_rules! impl_client_v17__getnewaddress {
153155
ty: Option<AddressType>,
154156
) -> Result<GetNewAddress> {
155157
match (label, ty) {
156-
(Some(label), Some(ty)) =>
157-
self.call("getnewaddress", &[into_json(label)?, into_json(ty)?]),
158+
(Some(label), Some(ty)) => {
159+
self.call("getnewaddress", &[into_json(label)?, into_json(ty)?])
160+
}
158161
(Some(label), None) => self.call("getnewaddress", &[into_json(label)?]),
159162
(None, Some(ty)) => self.call("getnewaddress", &["".into(), into_json(ty)?]),
160163
(None, None) => self.call("getnewaddress", &[]),
@@ -244,7 +247,9 @@ macro_rules! impl_client_v17__listaddressgroupings {
244247
macro_rules! impl_client_v17__listlabels {
245248
() => {
246249
impl Client {
247-
pub fn list_labels(&self) -> Result<ListLabels> { self.call("listlabels", &[]) }
250+
pub fn list_labels(&self) -> Result<ListLabels> {
251+
self.call("listlabels", &[])
252+
}
248253
}
249254
};
250255
}
@@ -302,7 +307,9 @@ macro_rules! impl_client_v17__listtransactions {
302307
macro_rules! impl_client_v17__listunspent {
303308
() => {
304309
impl Client {
305-
pub fn list_unspent(&self) -> Result<ListUnspent> { self.call("listunspent", &[]) }
310+
pub fn list_unspent(&self) -> Result<ListUnspent> {
311+
self.call("listunspent", &[])
312+
}
306313
}
307314
};
308315
}
@@ -312,7 +319,9 @@ macro_rules! impl_client_v17__listunspent {
312319
macro_rules! impl_client_v17__listwallets {
313320
() => {
314321
impl Client {
315-
pub fn list_wallets(&self) -> Result<ListWallets> { self.call("listwallets", &[]) }
322+
pub fn list_wallets(&self) -> Result<ListWallets> {
323+
self.call("listwallets", &[])
324+
}
316325
}
317326
};
318327
}

client/src/client_sync/v18/control.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
macro_rules! impl_client_v18__getrpcinfo {
1313
() => {
1414
impl Client {
15-
pub fn get_rpc_info(&self) -> Result<GetRpcInfo> { self.call("getrpcinfo", &[]) }
15+
pub fn get_rpc_info(&self) -> Result<GetRpcInfo> {
16+
self.call("getrpcinfo", &[])
17+
}
1618
}
1719
};
1820
}

client/src/client_sync/v19/wallet.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
macro_rules! impl_client_v19__getbalances {
1515
() => {
1616
impl Client {
17-
pub fn get_balances(&self) -> Result<GetBalances> { self.call("getbalances", &[]) }
17+
pub fn get_balances(&self) -> Result<GetBalances> {
18+
self.call("getbalances", &[])
19+
}
1820
}
1921
};
2022
}

0 commit comments

Comments
 (0)