Crate blockbook

Source
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 the bdk wallet library

§Supported Blockbook Version

The currently supported version of Blockbook is commit 95ee9b5b.

Re-exports§

pub use bitcoin::hashes;

Modules§

websocket
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§

Address
A Bitcoin address.
AddressInfo
Information about the transactional activity of an address.
AddressInfoBasic
Information about the funds moved from or to an address.
AddressInfoPaging
Paging information.
Amount
Amount
Backend
Information about the full node backing the Blockbook server.
BalanceHistory
A balance history entry.
BitcoinTransaction
Bitcoin transaction.
Block
Information about a block.
BlockHash
A bitcoin block hash.
BlockTransaction
Information about a transaction.
BlockVin
Information about a transaction input.
BlockVout
Information about a transaction output.
Client
A REST client that can query a Blockbook server.
DerivationPath
A BIP-32 derivation path.
Height
An absolute block height, guaranteed to always contain a valid height value.
OpReturn
An OP_RETURN output.
ReqwestError
The Errors that may occur when processing a Request.
ScriptBuf
An owned, growable script.
ScriptPubKey
A script specifying spending conditions.
ScriptSig
A script fulfilling spending conditions.
Sequence
Bitcoin transaction input sequence number.
Status
Status and backend information of the Blockbook server.
StatusBlockbook
Status information of the Blockbook server.
Ticker
A timestamp and a set of exchange rates for multiple currencies.
TickersList
Information about the available exchange rates at a given timestamp.
Time
A UNIX timestamp, seconds since epoch, guaranteed to always contain a valid time value.
Token
Information about funds at a Bitcoin address derived from an extended public key.
Transaction
Information about a transaction.
TransactionSpecific
Detailed information about a transaction input.
TxMerkleNode
A hash of the Merkle tree branch or root for transactions
Txid
A bitcoin transaction hash/transaction ID.
Utxo
Information about an unspent transaction outputs.
Version
Version information about the full node.
Vin
Information about a transaction input.
VinSpecific
Bitcoin-specific information about a transaction input.
Vout
Information about a transaction output.
VoutSpecific
Bitcoin-specific information about a transaction output.
Witness
The Witness is the data used to unlock bitcoin since the segwit upgrade.
Wtxid
A bitcoin witness transaction ID.
XPubInfo
Detailed information about funds held in addresses derivable from an extended public key,
XPubInfoBasic
Aggregated information about funds held in addresses derivable from an extended public key.

Enums§

AddressBlockVout
Either an address or an OP_RETURN output.
AddressFilter
Used to select which addresses to consider when deriving from extended public keys.
Asset
A cryptocurrency asset.
Chain
The specific chain (mainnet, testnet, …).
Currency
The supported currencies.
Error
The errors emitted by the REST client.
LockTime
An absolute lock time value, representing either a block height or a UNIX timestamp (seconds since epoch).
NetworkUnchecked
Marker that address’s network has not yet been validated. See section Parsing addresses on Address for details.
ParseError
Errors that can occur during parsing.
ScriptPubKeyType
The type of spending condition.
Tx
The variants for the transactions contained in AddressInfo::transactions.
TxDetail
Used to select the level of detail for address info transactions.