#[macro_use] extern crate jsonrpc_v1; extern crate strason; extern crate serde; use jsonrpc_v1::client::Client as RpcClient; use strason::Json; struct MiningInfo { pub blocks: i64, pub currentblocksize: i64, pub currentblocktx: i64, pub difficulty: f64, pub errors: Option, pub genproclimit: i64, pub networkhashps: f64, pub pooledtx: i64, pub testnet: bool, pub chain: String, pub generate: bool, } serde_struct_impl!(MiningInfo, blocks, currentblocksize, currentblocktx, difficulty, errors, genproclimit, networkhashps, pooledtx, testnet, chain, generate); fn main() { let conn = (String::from("http://localhost:8332"), String::from("user"), String::from("pass")); let client = RpcClient::new(conn.0, Some(conn.1), Some(conn.2)); let method_name = String::from("getmininginfo"); let request = client.build_request(method_name, vec![]); match client.send_request(&request).and_then(|res| res.into_result::()) { Ok(mining_info) => { println!("blocks: {}", mining_info.blocks); return; } Err(e) => panic!("error: {}", e), } }