#[macro_export]
macro_rules! impl_client_v17__getblockchaininfo {
() => {
impl Client {
pub fn get_blockchain_info(&self) -> Result<GetBlockchainInfo> {
self.call("getblockchaininfo", &[])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__getbestblockhash {
() => {
impl Client {
pub fn best_block_hash(&self) -> Result<bitcoin::BlockHash> {
let json = self.get_best_block_hash()?;
Ok(json.block_hash()?)
}
pub fn get_best_block_hash(&self) -> Result<GetBestBlockHash> {
self.call("getbestblockhash", &[])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__getblock {
() => {
impl Client {
pub fn get_block(&self, hash: BlockHash) -> Result<Block> {
let json = self.get_block_verbose_zero(hash)?;
Ok(json.block()?)
}
pub fn get_block_verbose_zero(&self, hash: BlockHash) -> Result<GetBlockVerboseZero> {
self.call("getblock", &[into_json(hash)?, 0.into()])
}
pub fn get_block_verbose_one(&self, hash: BlockHash) -> Result<GetBlockVerboseOne> {
self.call("getblock", &[into_json(hash)?, 1.into()])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__getblockcount {
() => {
impl Client {
pub fn get_block_count(&self) -> Result<GetBlockCount> {
self.call("getblockcount", &[])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__getblockhash {
() => {
impl Client {
pub fn get_block_hash(&self, height: u64) -> Result<GetBlockHash> {
self.call("getblockhash", &[into_json(height)?])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__getblockheader {
() => {
impl Client {
pub fn get_block_header(&self, hash: &BlockHash) -> Result<GetBlockHeader> {
self.call("getblockheader", &[into_json(hash)?, into_json(false)?])
}
pub fn get_block_header_verbose(
&self,
hash: &BlockHash,
) -> Result<GetBlockHeaderVerbose> {
self.call("getblockheader", &[into_json(hash)?])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__getblockstats {
() => {
impl Client {
pub fn get_block_stats_by_height(&self, height: u32) -> Result<GetBlockStats> {
self.call("getblockstats", &[into_json(height)?])
}
pub fn get_block_stats_by_block_hash(&self, hash: &BlockHash) -> Result<GetBlockStats> {
self.call("getblockstats", &[into_json(hash)?])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__getchaintips {
() => {
impl Client {
pub fn get_chain_tips(&self) -> Result<GetChainTips> { self.call("getchaintips", &[]) }
}
};
}
#[macro_export]
macro_rules! impl_client_v17__getchaintxstats {
() => {
impl Client {
pub fn get_chain_tx_stats(&self) -> Result<GetChainTxStats> {
self.call("getchaintxstats", &[])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__getdifficulty {
() => {
impl Client {
pub fn get_difficulty(&self) -> Result<GetDifficulty> {
self.call("getdifficulty", &[])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__getmempoolancestors {
() => {
impl Client {
pub fn get_mempool_ancestors(&self, txid: Txid) -> Result<GetMempoolAncestors> {
self.call("getmempoolancestors", &[into_json(txid)?])
}
pub fn get_mempool_ancestors_verbose(
&self,
txid: Txid,
) -> Result<GetMempoolAncestorsVerbose> {
self.call("getmempoolancestors", &[into_json(txid)?, into_json(true)?])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__getmempooldescendants {
() => {
impl Client {
pub fn get_mempool_descendants(&self, txid: Txid) -> Result<GetMempoolDescendants> {
self.call("getmempooldescendants", &[into_json(txid)?])
}
pub fn get_mempool_descendants_verbose(
&self,
txid: Txid,
) -> Result<GetMempoolDescendantsVerbose> {
self.call("getmempooldescendants", &[into_json(txid)?, into_json(true)?])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__getmempoolentry {
() => {
impl Client {
pub fn get_mempool_entry(&self, txid: Txid) -> Result<GetMempoolEntry> {
self.call("getmempoolentry", &[into_json(txid)?])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__getmempoolinfo {
() => {
impl Client {
pub fn get_mempool_info(&self) -> Result<GetMempoolInfo> {
self.call("getmempoolinfo", &[])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__getrawmempool {
() => {
impl Client {
pub fn get_raw_mempool(&self) -> Result<GetRawMempool> {
self.call("getrawmempool", &[])
}
pub fn get_raw_mempool_verbose(&self) -> Result<GetRawMempool> {
self.call("getrawmempool", &[into_json(true)?])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__gettxout {
() => {
impl Client {
pub fn get_tx_out(&self, txid: Txid, vout: u64) -> Result<GetTxOut> {
self.call("gettxout", &[into_json(txid)?, into_json(vout)?])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__gettxoutproof {
() => {
impl Client {
pub fn get_tx_out_proof(&self, txids: &[Txid]) -> Result<String> {
self.call("gettxoutproof", &[into_json(txids)?])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__gettxoutsetinfo {
() => {
impl Client {
pub fn get_tx_out_set_info(&self) -> Result<GetTxOutSetInfo> {
self.call("gettxoutsetinfo", &[])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__preciousblock {
() => {
impl Client {
pub fn precious_block(&self, hash: BlockHash) -> Result<()> {
match self.call("preciousblock", &[into_json(hash)?]) {
Ok(serde_json::Value::Null) => Ok(()),
Ok(res) => Err(Error::Returned(res.to_string())),
Err(err) => Err(err.into()),
}
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__pruneblockchain {
() => {
impl Client {
pub fn prune_blockchain(&self, target: u64) -> Result<PruneBlockchain> {
self.call("pruneblockchain", &[target.into()])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__savemempool {
() => {
impl Client {
pub fn save_mempool(&self) -> Result<()> {
match self.call("savemempool", &[]) {
Ok(serde_json::Value::Null) => Ok(()),
Ok(res) => Err(Error::Returned(res.to_string())),
Err(err) => Err(err.into()),
}
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__verifychain {
() => {
impl Client {
pub fn verify_chain(&self) -> Result<VerifyChain> { self.call("verifychain", &[]) }
}
};
}
#[macro_export]
macro_rules! impl_client_v17__verifytxoutproof {
() => {
impl Client {
pub fn verify_tx_out_proof(&self, proof: &str) -> Result<VerifyTxOutProof> {
self.call("verifytxoutproof", &[into_json(proof)?])
}
}
};
}