Skip to main content

corepc_client/client_sync/v17/
hidden.rs

1// SPDX-License-Identifier: CC0-1.0
2
3//! Macros for implementing JSON-RPC methods on a client.
4//!
5//! Specifically this is `== Hidden ==` methods that are not listed in the
6//! API docs of Bitcoin Core `v0.17`.
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 `estimaterawfee`.
13#[macro_export]
14macro_rules! impl_client_v17__estimate_raw_fee {
15    () => {
16        impl Client {
17            /// # Panics
18            ///
19            /// * Panics if `conf_target` is outside the range [1, 1008].
20            pub fn estimate_raw_fee(&self, conf_target: u32) -> Result<EstimateRawFee> {
21                assert!(
22                    (1..=1008).contains(&conf_target),
23                    "invalid conf_target, must be between 1 and 1008 inclusive"
24                );
25
26                self.call("estimaterawfee", &[conf_target.into()])
27            }
28        }
29    };
30}
31
32/// Implements Bitcoin Core JSON-RPC API method `waitforblock`.
33#[macro_export]
34macro_rules! impl_client_v17__wait_for_block {
35    () => {
36        impl Client {
37            pub fn wait_for_block(&self, hash: &bitcoin::BlockHash) -> Result<WaitForBlock> {
38                self.call("waitforblock", &[into_json(hash)?])
39            }
40        }
41    };
42}
43
44/// Implements Bitcoin Core JSON-RPC API method `waitforblockheight`.
45#[macro_export]
46macro_rules! impl_client_v17__wait_for_block_height {
47    () => {
48        impl Client {
49            pub fn wait_for_block_height(&self, height: u64) -> Result<WaitForBlockHeight> {
50                self.call("waitforblockheight", &[into_json(height)?])
51            }
52        }
53    };
54}
55
56/// Implements Bitcoin Core JSON-RPC API method `waitfornewblock`.
57#[macro_export]
58macro_rules! impl_client_v17__wait_for_new_block {
59    () => {
60        impl Client {
61            pub fn wait_for_new_block(&self) -> Result<WaitForNewBlock> {
62                self.call("waitfornewblock", &[])
63            }
64        }
65    };
66}
67
68/// Implements Bitcoin Core JSON-RPC API method `syncwithvalidationinterfacequeue`.
69#[macro_export]
70macro_rules! impl_client_v17__sync_with_validation_interface_queue {
71    () => {
72        impl Client {
73            pub fn sync_with_validation_interface_queue(&self) -> Result<()> {
74                self.call("syncwithvalidationinterfacequeue", &[])
75            }
76        }
77    };
78}
79
80/// Implements Bitcoin Core JSON-RPC API method `reconsiderblock`.
81#[macro_export]
82macro_rules! impl_client_v17__reconsider_block {
83    () => {
84        impl Client {
85            pub fn reconsider_block(&self, blockhash: bitcoin::BlockHash) -> Result<()> {
86                self.call("reconsiderblock", &[into_json(blockhash)?])
87            }
88        }
89    };
90}