corepc_client/client_sync/v19/
blockchain.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 `== Blockchain ==` section of the
6//! API docs of Bitcoin Core `v0.19`.
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 `getmempoolancestors`
13#[macro_export]
14macro_rules! impl_client_v19__getmempoolancestors {
15    () => {
16        impl Client {
17            pub fn get_mempool_ancestors(&self, txid: Txid) -> Result<GetMempoolAncestors> {
18                // Equivalent to self.call("getmempoolancestors", &[into_json(txid)?, into_json(false)?])
19                self.call("getmempoolancestors", &[into_json(txid)?])
20            }
21
22            pub fn get_mempool_ancestors_verbose(
23                &self,
24                txid: Txid,
25            ) -> Result<GetMempoolAncestorsVerbose> {
26                self.call("getmempoolancestors", &[into_json(txid)?, into_json(true)?])
27            }
28        }
29    };
30}
31
32/// Implements Bitcoin Core JSON-RPC API method `getmempooldescendants`
33#[macro_export]
34macro_rules! impl_client_v19__getmempooldescendants {
35    () => {
36        impl Client {
37            pub fn get_mempool_descendants(&self, txid: Txid) -> Result<GetMempoolDescendants> {
38                // Equivalent to self.call("getmempooldescendants", &[into_json(txid)?, into_json(false)?])
39                self.call("getmempooldescendants", &[into_json(txid)?])
40            }
41
42            pub fn get_mempool_descendants_verbose(
43                &self,
44                txid: Txid,
45            ) -> Result<GetMempoolDescendantsVerbose> {
46                self.call("getmempooldescendants", &[into_json(txid)?, into_json(true)?])
47            }
48        }
49    };
50}
51
52/// Implements Bitcoin Core JSON-RPC API method `getmempoolentry`
53#[macro_export]
54macro_rules! impl_client_v19__getmempoolentry {
55    () => {
56        impl Client {
57            pub fn get_mempool_entry(&self, txid: Txid) -> Result<GetMempoolEntry> {
58                self.call("getmempoolentry", &[into_json(txid)?])
59            }
60        }
61    };
62}