qtumcore_rpc/
lib.rs

1// To the extent possible under law, the author(s) have dedicated all
2// copyright and related and neighboring rights to this software to
3// the public domain worldwide. This software is distributed without
4// any warranty.
5//
6// You should have received a copy of the CC0 Public Domain Dedication
7// along with this software.
8// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
9//
10
11//! # Rust Client for Bitcoin Core API
12//!
13//! This is a client library for the Bitcoin Core JSON-RPC API.
14//!
15
16#![crate_name = "qtumcore_rpc"]
17#![crate_type = "rlib"]
18
19#[macro_use]
20extern crate log;
21#[allow(unused)]
22#[macro_use] // `macro_use` is needed for v1.24.0 compilation.
23extern crate serde;
24
25pub extern crate jsonrpc;
26
27pub extern crate qtumcore_rpc_json;
28pub use crate::json::qtum;
29pub use qtumcore_rpc_json as json;
30use json::qtum::consensus::{Decodable, ReadExt};
31use qtum_hashes::hex::HexIterator;
32// use json::qtum::hashes::hex::HexIterator;
33
34mod client;
35mod error;
36mod queryable;
37
38pub use crate::client::*;
39pub use crate::error::Error;
40pub use crate::queryable::*;
41
42fn deserialize_hex<T: Decodable>(hex: &str) -> Result<T> {
43    let mut reader = HexIterator::new(&hex)?;
44    let object = Decodable::consensus_decode(&mut reader)?;
45    if reader.read_u8().is_ok() {
46        Err(Error::BitcoinSerialization(qtum::consensus::encode::Error::ParseFailed(
47            "data not consumed entirely when explicitly deserializing",
48        )))
49    } else {
50        Ok(object)
51    }
52}