Skip to content

Commit 47caf92

Browse files
committed
Merge #234: Add missing v18 util methods
b6dbf1a Run the formatter (Jamil Lambert, PhD) eb50e30 Add missing v18 util methods (Jamil Lambert, PhD) Pull request description: Add `deriveaddresses` and `getdescriptorinfo` methods and tests. Include `getdescriptorinfo` return shape changes in v19 and v29. `deriveaddresses` return shape change in v29 TODO ACKs for top commit: tcharding: ACK b6dbf1a Tree-SHA512: 789ff7fe0d3f9f4ce5a2e70298c041d69084896208f0ce90ff9235f201fb40d5128dc15c86f579548269b1e7fd1289cd606c2595b32758a9edfcea087d6247f7
2 parents 0d91b5f + b6dbf1a commit 47caf92

File tree

32 files changed

+278
-55
lines changed

32 files changed

+278
-55
lines changed

client/src/client_sync/v18/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
pub mod control;
88
pub mod network;
99
pub mod raw_transactions;
10+
pub mod util;
1011

1112
use std::collections::BTreeMap;
1213
use std::path::Path;
@@ -110,7 +111,9 @@ crate::impl_client_v18__utxo_update_psbt!();
110111

111112
// == Util ==
112113
crate::impl_client_v17__create_multisig!();
114+
crate::impl_client_v18__derive_addresses!();
113115
crate::impl_client_v17__estimate_smart_fee!();
116+
crate::impl_client_v18__get_descriptor_info!();
114117
crate::impl_client_v17__sign_message_with_priv_key!();
115118
crate::impl_client_v17__validate_address!();
116119
crate::impl_client_v17__verify_message!();

client/src/client_sync/v18/util.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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 `== Util ==` section of the
6+
//! API docs of Bitcoin Core `v0.18`.
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 `deriveaddresses`
13+
#[macro_export]
14+
macro_rules! impl_client_v18__derive_addresses {
15+
() => {
16+
impl Client {
17+
pub fn derive_addresses(&self, descriptor: &str) -> Result<DeriveAddresses> {
18+
self.call("deriveaddresses", &[descriptor.into()])
19+
}
20+
}
21+
};
22+
}
23+
24+
/// Implements Bitcoin Core JSON-RPC API method `getdescriptorinfo`
25+
#[macro_export]
26+
macro_rules! impl_client_v18__get_descriptor_info {
27+
() => {
28+
impl Client {
29+
pub fn get_descriptor_info(&self, descriptor: &str) -> Result<GetDescriptorInfo> {
30+
self.call("getdescriptorinfo", &[descriptor.into()])
31+
}
32+
}
33+
};
34+
}

client/src/client_sync/v19/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ crate::impl_client_v18__utxo_update_psbt!();
108108

109109
// == Util ==
110110
crate::impl_client_v17__create_multisig!();
111+
crate::impl_client_v18__derive_addresses!();
111112
crate::impl_client_v17__estimate_smart_fee!();
113+
crate::impl_client_v18__get_descriptor_info!();
112114
crate::impl_client_v17__sign_message_with_priv_key!();
113115
crate::impl_client_v17__validate_address!();
114116
crate::impl_client_v17__verify_message!();

client/src/client_sync/v20/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ crate::impl_client_v18__utxo_update_psbt!();
105105

106106
// == Util ==
107107
crate::impl_client_v17__create_multisig!();
108+
crate::impl_client_v18__derive_addresses!();
108109
crate::impl_client_v17__estimate_smart_fee!();
110+
crate::impl_client_v18__get_descriptor_info!();
109111
crate::impl_client_v17__sign_message_with_priv_key!();
110112
crate::impl_client_v17__validate_address!();
111113
crate::impl_client_v17__verify_message!();

client/src/client_sync/v21/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ crate::impl_client_v18__utxo_update_psbt!();
107107

108108
// == Util ==
109109
crate::impl_client_v17__create_multisig!();
110+
crate::impl_client_v18__derive_addresses!();
110111
crate::impl_client_v17__estimate_smart_fee!();
112+
crate::impl_client_v18__get_descriptor_info!();
111113
crate::impl_client_v17__sign_message_with_priv_key!();
112114
crate::impl_client_v17__validate_address!();
113115
crate::impl_client_v17__verify_message!();

client/src/client_sync/v22/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ crate::impl_client_v18__utxo_update_psbt!();
107107

108108
// == Util ==
109109
crate::impl_client_v17__create_multisig!();
110+
crate::impl_client_v18__derive_addresses!();
110111
crate::impl_client_v17__estimate_smart_fee!();
112+
crate::impl_client_v18__get_descriptor_info!();
111113
crate::impl_client_v17__sign_message_with_priv_key!();
112114
crate::impl_client_v17__validate_address!();
113115
crate::impl_client_v17__verify_message!();

client/src/client_sync/v23/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ crate::impl_client_v18__utxo_update_psbt!();
109109

110110
// == Util ==
111111
crate::impl_client_v17__create_multisig!();
112+
crate::impl_client_v18__derive_addresses!();
112113
crate::impl_client_v17__estimate_smart_fee!();
114+
crate::impl_client_v18__get_descriptor_info!();
113115
crate::impl_client_v17__sign_message_with_priv_key!();
114116
crate::impl_client_v17__validate_address!();
115117
crate::impl_client_v17__verify_message!();

client/src/client_sync/v24/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ crate::impl_client_v18__utxo_update_psbt!();
106106

107107
// == Util ==
108108
crate::impl_client_v17__create_multisig!();
109+
crate::impl_client_v18__derive_addresses!();
109110
crate::impl_client_v17__estimate_smart_fee!();
111+
crate::impl_client_v18__get_descriptor_info!();
110112
crate::impl_client_v17__sign_message_with_priv_key!();
111113
crate::impl_client_v17__validate_address!();
112114
crate::impl_client_v17__verify_message!();

client/src/client_sync/v25/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ crate::impl_client_v18__utxo_update_psbt!();
106106

107107
// == Util ==
108108
crate::impl_client_v17__create_multisig!();
109+
crate::impl_client_v18__derive_addresses!();
109110
crate::impl_client_v17__estimate_smart_fee!();
111+
crate::impl_client_v18__get_descriptor_info!();
110112
crate::impl_client_v17__sign_message_with_priv_key!();
111113
crate::impl_client_v17__validate_address!();
112114
crate::impl_client_v17__verify_message!();

client/src/client_sync/v26/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ crate::impl_client_v18__utxo_update_psbt!();
112112

113113
// == Util ==
114114
crate::impl_client_v17__create_multisig!();
115+
crate::impl_client_v18__derive_addresses!();
115116
crate::impl_client_v17__estimate_smart_fee!();
117+
crate::impl_client_v18__get_descriptor_info!();
116118
crate::impl_client_v17__sign_message_with_priv_key!();
117119
crate::impl_client_v17__validate_address!();
118120
crate::impl_client_v17__verify_message!();

0 commit comments

Comments
 (0)