How bitcoinj/bitcoinj works
Project Type and Purpose
• This is a multi-module Java library and toolset (“bitcoinj”) implementing the Bitcoin protocol.
• It provides two core libraries (base + core), plus CLI tools (wallettool, tools), a JavaFX template app (wallettemplate), example applications (Java + Kotlin), and comprehensive tests.
High-Level Module Structure
• build system (Gradle + settings.gradle + Docker/Containerfile)
• base module: low-level data types (Address, Base58, Bech32, Monetary, VarInt, Hash, Utils)
• core module: protocol+networking (Message, Serializer, PeerGroup, Peer, NetworkParameters), blockchain (Block, BlockChain, SPV or full-pruned stores), wallet (KeyChain, Wallet, Transaction, CoinSelector), script interpreter, crypto primitives
• tools module: batch/block importers, checkpoint builders
• wallettool module: CLI wallet creation, sync, dump (uses core + base + Protobuf)
• wallettemplate module: JavaFX GUI application skeleton (UI layer + controller + model)
• examples / examples-kotlin: sample apps demonstrating library usage
• integration-test & test-support modules: external-facing integration tests and support code
External Dependencies
• Java 8+ (base, core) and Java 17+ (tools, wallettool, wallettemplate, examples)
• Gradle (build orchestration)
• Google Protobuf (core RPC/serialization)
• Bitcoin P2P network (peers, block data)
Architectural Layers & Patterns
• Layered architecture:
• Data Model & Utilities (base)
• Protocol & Networking + Blockchain + Wallet + Crypto (core)
• Application/Tooling (tools, wallettool, wallettemplate, examples)
• Test layers (unit, integration)
• Modular design: each Gradle subproject builds independently and depends on lower layers
• Event-driven in core’s networking (listeners for block download, transactions)
• Strategy pattern in wallet (CoinSelector, TransactionSigner)