use bitcoin::BlockHash;
use corepc_types::{
bitcoin,
model::{GetBlockHeaderVerbose, GetBlockVerboseOne, GetBlockchainInfo},
v28,
};
use jsonrpc::serde_json::json;
use super::Client;
use crate::{Error, Rpc};
impl Client {
pub fn get_block_header_verbose(
&self,
block_hash: &BlockHash,
) -> Result<GetBlockHeaderVerbose, Error> {
let header_info: v28::GetBlockHeaderVerbose =
self.call(Rpc::GetBlockHeader, &[json!(block_hash)])?;
header_info.into_model().map_err(Error::model)
}
pub fn get_block_verbose(&self, block_hash: &BlockHash) -> Result<GetBlockVerboseOne, Error> {
let block_info: v28::GetBlockVerboseOne =
self.call(Rpc::GetBlock, &[json!(block_hash), json!(1)])?;
block_info.into_model().map_err(Error::model)
}
pub fn get_blockchain_info(&self) -> Result<GetBlockchainInfo, Error> {
let info: v28::GetBlockchainInfo = self.call(Rpc::GetBlockchainInfo, &[])?;
info.into_model().map_err(Error::model)
}
}