Crates.io | blockbook |
lib.rs | blockbook |
version | 0.2.0 |
source | src |
created_at | 2023-05-16 08:03:43.236539 |
updated_at | 2023-11-28 10:47:50.864118 |
description | A robust and blazing fast blockbook blockexporer client |
homepage | https://21analytics.ch |
repository | https://gitlab.com/21analytics/blockbook |
max_upload_size | |
id | 865878 |
size | 228,353 |
blockbook
is a Rust client for the Blockbook block explorer.
It provides both REST and WebSocket clients to access Blockbook APIs in a type-safe manner.
#[tokio::main]
async fn main() {
let client = blockbook::Client::new("https://myblockbook.com".parse().unwrap());
// 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);
}
See the crate documentation for more examples.
The currently supported version of Blockbook is commit 95ee9b5b
.
Currently, blockbook
only provides Bitcoin-specific APIs.
All tests need a BLOCKBOOK_SERVER
environment variable set:
BLOCKBOOK_SERVER=myblockbook.com cargo test -- --include-ignored
This crate is developed and maintained by 21 Analytics.
This project is licensed under the MIT license.