const GET_TX_OUT_SET_INFO_COMMAND: &str = "gettxoutsetinfo";
const DEFAULT_HASH_TYPE_ARG: &str = "hash_serialized_2";
use crate::client::Client;
use crate::command::request::request;
use crate::command::CallableCommand;
use serde::Deserialize;
use serde::Serialize;
use serde_json::value::{to_raw_value, RawValue};
pub struct GetTxOutSetInfoCommand {
hash_type: String, }
impl GetTxOutSetInfoCommand {
pub fn new() -> Self {
GetTxOutSetInfoCommand {
hash_type: DEFAULT_HASH_TYPE_ARG.to_string(),
}
}
pub fn hash_type(&mut self, hash_type: String) -> &Self {
self.hash_type = hash_type;
self
}
}
#[derive(Serialize, Deserialize, Debug)]
pub struct GetTxOutSetInfoCommandResponse {
pub height: u64, pub bestblock: String, pub transactions: u64, pub txouts: u64, pub bogosize: u64, pub hash_serialized_2: String, pub disk_size: u64, pub total_amount: u64, }
impl CallableCommand for GetTxOutSetInfoCommand {
type Response = GetTxOutSetInfoCommandResponse;
fn call(&self, client: &Client) -> Self::Response {
let command = GET_TX_OUT_SET_INFO_COMMAND;
let hash_type_arg = &self.hash_type;
let hash_type_arg_raw_value = to_raw_value(&hash_type_arg).unwrap();
let params: Vec<Box<RawValue>> = vec![hash_type_arg_raw_value];
let r = request(client, command, params);
let response: GetTxOutSetInfoCommandResponse = r.result().unwrap();
response
}
}