42 releases

Uses new Rust 2024

0.3.0-beta.9 May 8, 2026
0.3.0-beta.8 May 7, 2026
0.3.0-beta.7 Apr 27, 2026
0.2.5 Mar 29, 2026
0.1.0-alpha.1 Dec 21, 2025

#914 in Magic Beans

Download history 20/week @ 2026-01-18 1/week @ 2026-01-25 26/week @ 2026-02-01 15/week @ 2026-02-08 29/week @ 2026-02-15 47/week @ 2026-02-22 25/week @ 2026-03-01 36/week @ 2026-03-08 45/week @ 2026-03-15 37/week @ 2026-03-22 23/week @ 2026-03-29 14/week @ 2026-04-05 15/week @ 2026-04-12 10/week @ 2026-04-19 3/week @ 2026-04-26 47/week @ 2026-05-03

75 downloads per month
Used in 18 crates

MIT license

600KB
19K SLoC

brk_types

Domain types for Bitcoin data analysis with serialization and indexing support.

What It Enables

Work with Bitcoin primitives (heights, satoshis, addresses, transactions) through purpose-built types that handle encoding, arithmetic, time conversions, and database storage automatically.

Key Features

  • Bitcoin primitives: Height, Sats, Txid, BlockHash, Outpoint with full arithmetic and conversion support
  • Address types: All output types (P2PK33, P2PK65, P2PKH, P2MS, P2SH, P2WPKH, P2WSH, P2TR, P2A, OP_RETURN) with address index variants
  • Time indexes: DateIndex, WeekIndex, MonthIndex, QuarterIndex, SemesterIndex, YearIndex, DecadeIndex with cross-index conversion
  • Protocol types: Epoch, Halving, TxVersion, RawLocktime
  • Financial types: Dollars, Cents, OHLC (Open/High/Low/Close)
  • Serialization: Serde + JSON Schema generation via schemars
  • Compression: PCO (Pco) derive for columnar compression in vecdb

Type Categories

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

Core API

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))?;

Built On

  • brk_error for error handling

Dependencies

~19MB
~299K SLoC