bitcoind-request

Crates.iobitcoind-request
lib.rsbitcoind-request
version0.1.17
sourcesrc
created_at2022-08-09 17:37:35.141926
updated_at2022-11-04 19:14:06.299833
descriptionQuery bitcoind
homepage
repository
max_upload_size
id641940
size184,180
Joe Gesualdo (joegesualdo)

documentation

README

Bitcoind Request

Send RPC commands to a bitcoind server.


⚠️ This is experimental. Please use at your own risk.⚠️


This library provides typesafe functions over raw RPC bitcoind commands to easily and safely retrieve information from a bitcoin node.

As this library only provides typesafety over raw RPC commands, functions will be mapped 1:1 to RPC commands. See bitcoin core docs for a list of all commands and what they return.

If you're looking for additional information about the Bitcoin Network (i.e. time since last block, etc) , take a look at bitcoin-node-query, which provides additional functions to query bitcoin network data.

Install

Add package to Cargo.toml file

[dependencies]
bitcoind-request = "0.1.17"

Usage:

use bitcoind_request::{
    client::Client,
    command::{
        get_blockchain_info::GetBlockchainInfoCommand,
        CallableCommand,
    },
};

// Create a Client.
let bitcoind_password: &str = ...
let bitcoind_username: &str = ...
let bitcoind_url = "127.0.0.1:8332"
let client = Client::new(
        &bitcoind_url,
        &bitcoind_username,
        &bitcoind_password
    ).expect("failed to create client");

// Get the estimated size of the block and undo files on disk.
// Note: this calls "getblockchaininfo" bitcoin core rpc command under the hood.
let blockchain_info = GetBlockchainInfoCommand::new().call(client);
println!("{}", blockchain_info.size_on_disk);

// Compute statistics about the total number and rate of transactions in the chain.
// Note: this calls "getchaintxstats" bitcoin core rpc command under the hood.
let maybe_chain_tx_stats = GetChainTxStatsCommand::new()
	.set_n_blocks(2016)
	.call(client);
println!("{:#?}", maybe_chain_tx_stats.unwrap());

Commands

List of all bitcoind commands can be found at bitcoin.org

They can also be found in the bitcoin-cli docs:

$ bitcoin-cli help

Related

License

MIT © Joe Gesualdo

Commit count: 0

cargo fmt