Skip to main content

corepc_client/client_sync/v29/
util.rs

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 `v29`.
7//!
8//! All macros require `Client` to be in scope.
9//!
10//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`.
11
12/// Implements Bitcoin Core JSON-RPC API method `deriveaddresses`.
13#[macro_export]
14macro_rules! impl_client_v29__derive_addresses {
15    () => {
16        impl Client {
17            // For single derivation descriptors.
18            pub fn derive_addresses(&self, descriptor: &str) -> Result<DeriveAddresses> {
19                self.call("deriveaddresses", &[descriptor.into()])
20            }
21
22            // For multipath descriptors.
23            pub fn derive_addresses_multipath(
24                &self,
25                descriptor: &str,
26                range: (u32, u32),
27            ) -> Result<DeriveAddressesMultipath> {
28                let range = json!([range.0, range.1]);
29                self.call("deriveaddresses", &[descriptor.into(), range.into()])
30            }
31        }
32    };
33}