- Notifications
You must be signed in to change notification settings - Fork293
rust-bitcoin/rust-bitcoincore-rpc
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This repository has been archived as of 2025-11-25, and this crate is no longer mantained. We recommend users switch tocorepc-client, which provides a blocking API. Users interested in an async RPC client may want to check therust-bitcoin discussion thread about this issue.
This 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 interface
This 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.
Given below is an example of how to connect to the Bitcoin Core JSON-RPC for a Bitcoin Core node running onlocalhostand print out the hash of the latest block.
It assumes that the node has password authentication setup, the RPC interface is enabled at port8332 and the nodeis set up to accept RPC connections.
externcrate bitcoincore_rpc;use bitcoincore_rpc::{Auth,Client,RpcApi};fnmain(){let rpc =Client::new("http://localhost:8332",Auth::UserPass("<FILL RPC USERNAME>".to_string(),"<FILL RPC PASSWORD>".to_string())).unwrap();let best_block_hash = rpc.get_best_block_hash().unwrap();println!("best block hash: {}", best_block_hash);}
Seeclient/examples/ for more usage examples.
The following versions are officially supported and automatically tested:
- 0.18.0
- 0.18.1
- 0.19.0.1
- 0.19.1
- 0.20.0
- 0.20.1
- 0.21.0
This library should always compile with any combination of features onRust 1.56.1.
About
Rust RPC client library for the Bitcoin Core JSON-RPC API.
Resources
Uh oh!
There was an error while loading.Please reload this page.
