Crate bitcoin_explorer[][src]

Expand description

Introduction

This library is designed for efficient and massive deserialization of the binary Bitcoin Core block files.

It decodes all transactions, addresses, script types, connects outpoints of inputs to outputs, to figure out input addresses.

This library allows efficient and versatile reading of all bitcoin transaction records. This is good for analysis and research on bitcoin trading behaviour.

Features

By default, when iterating through blocks with inputs addresses attached (db.iter_connected_block()), the unspent transaction outputs (UTXO) are stored on disk using rocksdb. Feature on-disk-utxo is enabled by default. Disabling on-disk-utxo feature automatically enables in-memory UTXO cache, which is very fast but requires 32GB memory or more.

By default, UTXO is stored on disk, which usually requires less than 1GB memory.

[dependencies.explorer]
version = "1.2"

To enable in-memory UTXO. Set the default features to false:

Notice that with in-memory-utxo, db.iter_connected_block() currently uses 32GB RAM.

[dependencies.explorer]
version = "1.2"
default-features = false

Caveat

Currently it only decode addresses from standard script types.

Example

use bitcoin_explorer::BitcoinDB;
use std::path::Path;

let path = Path::new("/Users/me/bitcoin");

// launch without reading txindex
let db = BitcoinDB::new(path, false).unwrap();

// launch attempting to read txindex
let db = BitcoinDB::new(path, true).unwrap();

Re-exports

pub use crate::parser::block_index::BlockIndex;
pub use crate::parser::block_index::BlockIndexRecord;
pub use crate::parser::proto::connected_proto::BlockConnectable;
pub use crate::parser::proto::connected_proto::FConnectedBlock;
pub use crate::parser::proto::connected_proto::FConnectedTransaction;
pub use crate::parser::proto::connected_proto::SConnectedBlock;
pub use crate::parser::proto::connected_proto::SConnectedTransaction;
pub use crate::parser::proto::connected_proto::TxConnectable;
pub use crate::parser::proto::full_proto::FBlock;
pub use crate::parser::proto::full_proto::FBlockHeader;
pub use crate::parser::proto::full_proto::FTransaction;
pub use crate::parser::proto::full_proto::FTxOut;
pub use crate::parser::proto::simple_proto::SBlock;
pub use crate::parser::proto::simple_proto::SBlockHeader;
pub use crate::parser::proto::simple_proto::STransaction;
pub use crate::parser::proto::simple_proto::STxOut;

Modules

This module defines the infrastructure for efficient iteration over blocks

Structs

A Bitcoin address

This is the main struct of this crate!! Click and read the doc.

A Bitcoin block, which is a collection of transactions with an attached proof of work.

A bitcoin block hash.

A block header, which contains all the block’s information except the actual transactions

iterate through blocks according to array index.

iterate through blocks, and connecting outpoints.

A Bitcoin script

A Bitcoin transaction, which describes an authenticated movement of coins.

A bitcoin transaction hash/transaction ID.

Enums

The cryptocurrency to act on

Traits

Trait for objects that can be deserialized from hex strings

Trait for objects that can be serialized as hex strings

Functions

Extract addresses from a script public key.