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 thebdkwallet 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
Clientfor 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.
- Address
Info - Information about the transactional activity of an address.
- Address
Info Basic - Information about the funds moved from or to an address.
- Address
Info Paging - Paging information.
- Amount
- Amount
- Backend
- Information about the full node backing the Blockbook server.
- Balance
History - A balance history entry.
- Bitcoin
Transaction - Bitcoin transaction.
- Block
- Information about a block.
- Block
Hash - A bitcoin block hash.
- Block
Transaction - Information about a transaction.
- Block
Vin - Information about a transaction input.
- Block
Vout - Information about a transaction output.
- Client
- A REST client that can query a Blockbook server.
- Derivation
Path - A BIP-32 derivation path.
- Height
- An absolute block height, guaranteed to always contain a valid height value.
- OpReturn
- An
OP_RETURNoutput. - Reqwest
Error - The Errors that may occur when processing a
Request. - Script
Buf - An owned, growable script.
- Script
PubKey - A script specifying spending conditions.
- Script
Sig - A script fulfilling spending conditions.
- Sequence
- Bitcoin transaction input sequence number.
- Status
- Status and backend information of the Blockbook server.
- Status
Blockbook - Status information of the Blockbook server.
- Ticker
- A timestamp and a set of exchange rates for multiple currencies.
- Tickers
List - 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.
- Transaction
Specific - Detailed information about a transaction input.
- TxMerkle
Node - 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.
- Vout
Specific - 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.
- XPub
Info - Detailed information about funds held in addresses derivable from an
extended public key, - XPub
Info Basic - Aggregated information about funds held in addresses derivable from an
extended public key.
Enums§
- Address
Block Vout - Either an address or an
OP_RETURN output. - Address
Filter - 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.
- Lock
Time - An absolute lock time value, representing either a block height or a UNIX timestamp (seconds since epoch).
- Network
Unchecked - Marker that address’s network has not yet been validated. See section Parsing addresses
on
Addressfor details. - Parse
Error - Errors that can occur during parsing.
- Script
PubKey Type - 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 infotransactions.