corepc_client/client_sync/v17/generating.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 `== Generating ==` section of 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_minreq_client!` macro to define a `Client`.
11
12/// Implements Bitcoin Core JSON-RPC API method `generatetoaddress`
13#[macro_export]
14macro_rules! impl_client_v17__generatetoaddress {
15 () => {
16 impl Client {
17 pub fn generate_to_address(
18 &self,
19 nblocks: usize,
20 address: &bitcoin::Address,
21 ) -> Result<GenerateToAddress> {
22 self.call("generatetoaddress", &[nblocks.into(), into_json(address)?])
23 }
24 }
25 };
26}
27
28/// Implements Bitcoin Core JSON-RPC API method `generate`
29#[macro_export]
30macro_rules! impl_client_v17__generate {
31 () => {
32 impl Client {
33 pub fn generate(&self, nblocks: usize) -> Result<Generate> {
34 self.call("generate", &[nblocks.into()])
35 }
36 }
37 };
38}
39
40/// Implements Bitcoin Core JSON-RPC API method `invalidateblock`
41#[macro_export]
42macro_rules! impl_client_v17__invalidateblock {
43 () => {
44 impl Client {
45 pub fn invalidate_block(&self, hash: BlockHash) -> Result<()> {
46 self.call("invalidateblock", &[into_json(hash)?])
47 }
48 }
49 };
50}