corepc-client 0.8.0

Bitcoin Core JSON-RPC client
Documentation
// SPDX-License-Identifier: CC0-1.0

//! Macros for implementing JSON-RPC methods on a client.
//!
//! Specifically this is methods found under the `== Rawtransactions ==` section of the
//! API docs of Bitcoin Core `v0.18`.
//!
//! All macros require `Client` to be in scope.
//!
//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`.

/// Implements Bitcoin Core JSON-RPC API method `analyzepsbt`
#[macro_export]
macro_rules! impl_client_v18__analyzepsbt {
    () => {
        impl Client {
            pub fn analyze_psbt(&self, psbt: &bitcoin::Psbt) -> Result<AnalyzePsbt> {
                let psbt = format!("{}", psbt);
                self.call("analyzepsbt", &[psbt.into()])
            }
        }
    };
}

/// Implements Bitcoin Core JSON-RPC API method `joinpsbts`
#[macro_export]
macro_rules! impl_client_v18__joinpsbts {
    () => {
        impl Client {
            pub fn join_psbts(&self, psbts: &[bitcoin::Psbt]) -> Result<JoinPsbts> {
                let psbts = psbts.iter().map(|psbt| format!("{}", psbt)).collect::<Vec<String>>();
                self.call("joinpsbts", &[psbts.into()])
            }
        }
    };
}

/// Implements Bitcoin Core JSON-RPC API method `uxtoupdatepsbt`
#[macro_export]
macro_rules! impl_client_v18__utxoupdatepsbt {
    () => {
        impl Client {
            pub fn utxo_update_psbt(&self, psbt: &bitcoin::Psbt) -> Result<JoinPsbts> {
                let psbt = format!("{}", psbt);
                self.call("uxtoupdatepsbt", &[psbt.into()])
            }
        }
    };
}