Bitcoin rpc

Comment

Author: Admin | 2025-04-28

Rust RPC client for Bitcoin Core JSON-RPCThis is a Rust RPC client library for calling the Bitcoin Core JSON-RPC API. It provides a layer of abstraction overrust-jsonrpc and makes it easier to talk to the Bitcoin JSON-RPC interfaceThis git package compiles into two crates.bitcoincore-rpc - contains an implementation of an rpc client that exposesthe Bitcoin Core JSON-RPC APIs as rust functions.bitcoincore-rpc-json - contains rust data structures that representthe json responses from the Bitcoin Core JSON-RPC APIs. bitcoincore-rpc depends on this.UsageGiven below is an example of how to connect to the Bitcoin Core JSON-RPC for a Bitcoin Core node running on localhostand print out the hash of the latest block.It assumes that the node has password authentication setup, the RPC interface is enabled at port 8332 and the nodeis set up to accept RPC connections.".to_string(), "".to_string())).unwrap(); let best_block_hash = rpc.get_best_block_hash().unwrap(); println!("best block hash: {}", best_block_hash);}">extern crate bitcoincore_rpc;use bitcoincore_rpc::{Auth, Client, RpcApi};fn main() { let rpc = Client::new("http://localhost:8332", Auth::UserPass("".to_string(), "".to_string())).unwrap(); let best_block_hash = rpc.get_best_block_hash().unwrap(); println!("best block hash: {}", best_block_hash);}See client/examples/ for more usage examples.Supported Bitcoin Core VersionsThe following versions are officially supported and automatically tested:0.18.00.18.10.19.0.10.19.10.20.00.20.10.21.0Minimum Supported Rust Version (MSRV)This library should always compile with any combination of features on Rust 1.56.1.

Add Comment