1#![crate_name = "bitcoincore_rpc"]
17#![crate_type = "rlib"]
18
19#[macro_use]
20extern crate log;
21#[allow(unused)]
22#[macro_use] extern crate serde;
24
25pub extern crate jsonrpc;
26
27pub extern crate bitcoincore_rpc_json;
28pub use crate::json::bitcoin;
29pub use bitcoincore_rpc_json as json;
30use json::bitcoin::consensus::{Decodable, ReadExt};
31use json::bitcoin::hashes::hex::HexIterator;
32
33mod client;
34mod error;
35mod queryable;
36mod rpc_json;
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(
47 bitcoin::consensus::encode::Error::ParseFailed(
48 "data not consumed entirely when explicitly deserializing",
49 ),
50 ))
51 } else {
52 Ok(object)
53 }
54}