Rust REST client for Bitcoin Core REST API
A Rust REST client library for calling the Bitcoin Core REST API. It makes it easy to talk to the Bitcoin Core REST interface.
The REST interface is useful for quickly iterating over the blockchain, because it can request blocks and transactions in binary form without having to serialize/deserialize into JSON. It is unauthenticated so there's no need to worry about storing credentials.
It also has API for quickly retrieving large amounts of block headers and BIP157 compact block filter headers. There is also support for getting block chain info, mempool info, the raw mempool, querying the utxo set, and soft fork deployment statuses.
See https://github.com/bitcoin/bitcoin/blob/master/doc/REST-interface.md for more details.
Installation
Run the following Cargo command in your project directory:
Or add the following line to your Cargo.toml:
= "4.0.2"
Usage
The Bitcoin Core bitcoind instance must be started with -rest on the command
line or rest=1 in the bitcoin.conf file.
use *;
async
API
Unfortunately, async_trait trait functions are expanded in docsrs, so here are
the unexpanded functions for RestApi, which RestClient implements:
async ;
async ;
async ;
async ;
async ;
async ;
async ;
async ;
async ;
async ;
async ;
async ;
async ;
async ;
/// Only available on Bitcoin Core v25.1 and later
///
/// WARNING: CALLING THIS CONNECTED TO BITCOIN CORE V25.0 WILL CRASH BITCOIND
///
/// IT IS MARKED UNSAFE TO ENSURE YOU ARE NOT USING BITCOIN CORE V25.0
async unsafe ;
Features
By default, this library includes a struct RestClient which implements
RestApi by using the reqwest library. To not use reqwest as a dependency
and implement your own version of RestApi, set default-features = false in
your Cargo.toml:
= { = "4.0.2", = false }
You will have to implement the get_json and get_bin methods on RestApi
with your own http functionality. All methods are GET requests. For example,
using the surf http library and
thiserror:
use ;
;