Expand description
Rust Blockbook Library
This crate provides REST and WebSocket clients to query various information from a Blockbook server, which is a block explorer backend created and maintained by SatoshiLabs.
Note that this crate currently only exposes a Bitcoin-specific API, even though Blockbook provides a unified API that supports multiple cryptocurrencies.
The methods exposed in this crate make extensive use of types from the
bitcoin
crate to provide strongly typed APIs.
An example of how to use the REST client
:
ⓘ
let client = blockbook::Client::new(url).await?;
// query the Genesis block hash
let genesis_hash = client
.block_hash(&blockbook::Height::from_consensus(0).unwrap())
.await?;
assert_eq!(
genesis_hash.to_string(),
"000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"
);
// query the full block
let genesis = client.block_by_hash(&genesis_hash).await?;
assert_eq!(genesis.previous_block_hash, None);
// inspect the first coinbase transaction
let tx = genesis.txs.get(0).unwrap();
assert!((tx.vout.get(0).unwrap().value.to_btc() - 50.0).abs() < f64::EPSILON);
For an example of how to use the WebSocket client, see its documentation
.
Available feature flags
bdk
- adds functions for integration with thebdk
wallet library
Supported Blockbook Version
The currently supported version of Blockbook is commit 95ee9b5b
.
Re-exports
pub use bitcoin::hashes;
Modules
- The WebSocket client. This module contains the WebSocket
Client
for interacting with a Blockbook server via a WebSocket connection. The client provides numerous query-response methods, as well as a few subscription methods.
Structs
- A Bitcoin address.
- Information about the transactional activity of an address.
- Information about the funds moved from or to an address.
- Paging information.
- Amount
- Information about the full node backing the Blockbook server.
- A balance history entry.
- Bitcoin transaction.
- Information about a block.
- A bitcoin block hash.
- Information about a transaction.
- Information about a transaction input.
- Information about a transaction output.
- A REST client that can query a Blockbook server.
- A BIP-32 derivation path.
- An absolute block height, guaranteed to always contain a valid height value.
- An
OP_RETURN
output. - The Errors that may occur when processing a
Request
. - An owned, growable script.
- A script specifying spending conditions.
- A script fulfilling spending conditions.
- Bitcoin transaction input sequence number.
- Status and backend information of the Blockbook server.
- Status information of the Blockbook server.
- A timestamp and a set of exchange rates for multiple currencies.
- Information about the available exchange rates at a given timestamp.
- A UNIX timestamp, seconds since epoch, guaranteed to always contain a valid time value.
- Information about funds at a Bitcoin address derived from an
extended public key
. - Information about a transaction.
- Detailed information about a transaction input.
- A hash of the Merkle tree branch or root for transactions
- A bitcoin transaction hash/transaction ID.
- Information about an unspent transaction outputs.
- Version information about the full node.
- Information about a transaction input.
- Bitcoin-specific information about a transaction input.
- Information about a transaction output.
- Bitcoin-specific information about a transaction output.
- The Witness is the data used to unlock bitcoin since the segwit upgrade.
- A bitcoin witness transaction ID.
- Detailed information about funds held in addresses derivable from an
extended public key
, - Aggregated information about funds held in addresses derivable from an
extended public key
.
Enums
- Either an address or an
OP_RETURN output
. - Used to select which addresses to consider when deriving from
extended public keys
. - A cryptocurrency asset.
- The specific chain (mainnet, testnet, …).
- The supported currencies.
- The errors emitted by the REST client.
- An absolute lock time value, representing either a block height or a UNIX timestamp (seconds since epoch).
- Marker that address’s network has not yet been validated. See section Parsing addresses on
Address
for details. - Errors that can occur during parsing.
- The type of spending condition.
- The variants for the transactions contained in
AddressInfo::transactions
. - Used to select the level of detail for
address info
transactions.