| Crates.io | brk_types |
| lib.rs | brk_types |
| version | 0.1.0-beta.0 |
| created_at | 2025-12-18 22:16:44.018252+00 |
| updated_at | 2026-01-25 13:21:18.772076+00 |
| description | Structs used throughout BRK |
| homepage | https://bitcoinresearchkit.org |
| repository | https://github.com/bitcoinresearchkit/brk |
| max_upload_size | |
| id | 1993653 |
| size | 469,712 |
Domain types for Bitcoin data analysis with serialization and indexing support.
Work with Bitcoin primitives (heights, satoshis, addresses, transactions) through purpose-built types that handle encoding, arithmetic, time conversions, and database storage automatically.
Height, Sats, Txid, BlockHash, Outpoint with full arithmetic and conversion supportDateIndex, WeekIndex, MonthIndex, QuarterIndex, SemesterIndex, YearIndex, DecadeIndex with cross-index conversionDifficultyEpoch, HalvingEpoch, TxVersion, RawLocktimeDollars, Cents, OHLC (Open/High/Low/Close)| Category | Examples |
|---|---|
| Block metadata | Height, BlockHash, BlockTimestamp, BlkPosition |
| Transaction | Txid, TxIndex, TxIn, TxOut, Vsize, Weight |
| Address | P2PKHAddressIndex, P2TRBytes, AnyAddressIndex, AddressStats |
| Value | Sats, Dollars, Cents, Bitcoin |
| Time | Date, DateIndex, WeekIndex, MonthIndex, ... |
| Metric | Metric, MetricData, MetricSelection |
| API | Pagination, Health, RecommendedFees, MempoolInfo |
All types implement standard traits: Debug, Clone, Serialize, Deserialize, plus domain-specific operations like CheckedSub, Formattable, and PrintableIndex.
use brk_types::{Height, Sats, DateIndex, Date};
let height = Height::new(840_000);
let reward = Sats::FIFTY_BTC / 16; // Post-4th-halving reward
let date_idx = DateIndex::try_from(Date::new(2024, 4, 20))?;
brk_error for error handling