Skip to content

hashhog/blockbrew

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

168 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

blockbrew

A Bitcoin full node written in Go.

What is it?

Maybe you've wondered what it takes to validate a Bitcoin transaction from scratch. blockbrew is a from-scratch Bitcoin full node implementation that does exactly that — syncs the blockchain, validates blocks, and participates in the peer-to-peer network.

Current status

  • Binary serialization (varint, compact size, tx, block)
  • Cryptographic primitives (SHA256, RIPEMD160, secp256k1, ECDSA, Schnorr)
  • Address encoding (Base58Check, Bech32, Bech32m)
  • Script interpreter (P2PKH, P2SH, P2WPKH, P2WSH, P2TR)
  • Consensus rules (difficulty, BIP34/65/66/68, segwit, taproot)
  • Database layer (Pebble backend, tuned for Bitcoin workloads)
  • Block and transaction validation (merkle tree, sigops, witness)
  • P2P networking (message serialization, peer discovery, sync)
  • Chain manager (block connection, reorg handling, undo data)
  • UTXO set (L1 cache, script compression, batched flushes)
  • Mempool (fee tracking, CPFP, orphan pool, eviction)
  • Block template construction (tx selection, witness commitment)
  • JSON-RPC server (Bitcoin Core compatible API)
  • HD Wallet (BIP32/BIP39/BIP84, P2WPKH addresses)
  • Performance optimizations (parallel script validation, IBD tuning)
  • Checkpoint verification (fork rejection during header sync)
  • Regtest mode with generate RPCs (instant block mining)
  • Signature verification cache (avoids redundant script checks)
  • Full mainnet IBD completion

Quick start

make build
./blockbrew --network regtest --datadir ~/.blockbrew
./blockbrew wallet create

Project structure

cmd/blockbrew/     main entrypoint, CLI, configuration
internal/
  consensus/       validation, chain manager, UTXO set, profiling
  script/          script interpreter
  p2p/             peer-to-peer networking, sync
  storage/         database layer (pebble)
  mempool/         transaction pool, fee estimation
  rpc/             JSON-RPC server
  wallet/          hd wallet (bip32/39/84)
  mining/          block template and PoW
  crypto/          hashing, keys, ecdsa, schnorr
  wire/            protocol serialization
  address/         address encoding

Running tests

make test              # unit tests
make test-race         # with race detector
make bench             # benchmarks
make profile-cpu       # CPU profiling

Enable pprof at runtime:

./blockbrew --pprof localhost:6060
# then: go tool pprof http://localhost:6060/debug/pprof/profile?seconds=30

About

Bitcoin full node in Go

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages