I'm writing a code in RUST to query data from bitcoin-core using JSON-RPC. I'm using this curl-rust, but no output is being shown on running cargo run
.
extern crate curl;
use std::io::Read;
use curl::easy::{Easy, List};
fn main() {
let mut data = r#"{"jsonrpc":"1.0","id":"curltext","method":"getrawtransaction","params":["f8ae07a1292136def6d79d5aef15aacfa1aefa2db153037b878b06f00e2cd051", 2]}"#.as_bytes();
let mut easy = Easy::new();
easy.url("http://192.168.X.X:8332").unwrap();
easy.post(true).unwrap();
easy.post_field_size(data.len() as u64).unwrap();
let mut list = List::new();
list.append("Authorization: Basic some_user:some_password").unwrap();
easy.http_headers(list).unwrap();
let mut transfer = easy.transfer();
transfer.read_function(|buf| {
Ok(data.read(buf).unwrap_or(0))
}).unwrap();
transfer.perform().unwrap();
}
I would expect the code to give some output, why this isn't the case?