edilmedeiros / rust-bcli

Bitcoin CLI in Rust
GNU General Public License v3.0
6 stars 2 forks source link

Build a minimal example of an RPC call in Rust #3

Closed edilmedeiros closed 5 months ago

edilmedeiros commented 6 months ago

Build a minimal example of an RPC call in Rust to understand how to use the bitcoincore-rpc crate.

itornaza commented 6 months ago

There is a nice example in rust-bitcoincore-rpc/client/examples/test_against_node.rs

itornaza commented 6 months ago

We can start with creating an rpc client that will be further used to call all API functions like so:

// Creates an rpc client used as a base to communicate with the API methods
fn rpc(url: &str, user: &str, passwd: &str) -> Result<(), Error> {
    let url = url.to_string()
    let auth = Auth::UserPass(user.to_string(), passwd.to_string());
    Client::new(url, auth)
}
edilmedeiros commented 6 months ago

Done with 946a4ec, but waiting for more input from nasser.