A Bitcoin full node written in Go.
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.
- 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
make build
./blockbrew --network regtest --datadir ~/.blockbrew
./blockbrew wallet createcmd/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
make test # unit tests
make test-race # with race detector
make bench # benchmarks
make profile-cpu # CPU profilingEnable pprof at runtime:
./blockbrew --pprof localhost:6060
# then: go tool pprof http://localhost:6060/debug/pprof/profile?seconds=30