corepc_client/client_sync/v24/
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 `v24`.
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 `gettxspendingprevout`
13#[macro_export]
14macro_rules! impl_client_v24__get_tx_spending_prevout {
15    () => {
16        impl Client {
17            pub fn get_tx_spending_prevout(
18                &self,
19                outputs: &[bitcoin::OutPoint],
20            ) -> Result<GetTxSpendingPrevout> {
21                let json_outputs: Vec<_> = outputs.iter().map(|out| {
22                    serde_json::json!({
23                        "txid": out.txid.to_string(),
24                        "vout": out.vout,
25                    })
26                }).collect();
27                self.call("gettxspendingprevout", &[json_outputs.into()])
28            }
29        }
30    };
31}