Skip to main content

Codebase Structure

The Bitcoin Knots codebase follows the same structure as Bitcoin Core.

Top-Level Directories

bitcoin/
├── src/ # Main source code
├── doc/ # Documentation
├── test/ # Test framework
├── contrib/ # Contributed scripts and configs
├── depends/ # Dependency builder
├── share/ # Shared resources
└── ci/ # Continuous integration

Source Code (src/)

src/
├── consensus/ # Consensus-critical code
├── crypto/ # Cryptographic primitives
├── index/ # Block and tx indexes
├── interfaces/ # Interface definitions
├── kernel/ # Libbitcoinkernel
├── net/ # Networking code
├── node/ # Node-specific code
├── policy/ # Mempool policy
├── primitives/ # Basic data structures
├── rpc/ # RPC handlers
├── script/ # Script interpreter
├── secp256k1/ # ECDSA library
├── support/ # Support utilities
├── univalue/ # JSON library
├── util/ # Utility functions
├── wallet/ # Wallet implementation
├── qt/ # Qt GUI
├── bench/ # Benchmarks
└── test/ # Unit tests

Key Files

FilePurpose
src/bitcoind.cppDaemon entry point
src/init.cppInitialization logic
src/validation.cppBlock/tx validation
src/net.cppNetwork connections
src/txmempool.cppMempool management
src/rpc/server.cppRPC server

Knots-Specific Changes

Knots patches are distributed throughout the codebase. To find Knots-specific code:

# Search for Knots-related changes
git log --oneline --grep="knots" | head -20

# Find files modified in a patch
git show --stat <commit-hash>

Configuration Files

~/.bitcoin/
├── bitcoin.conf # Main configuration
├── debug.log # Debug output
├── wallet.dat # Legacy wallet (if used)
├── wallets/ # Wallet directory
├── blocks/ # Block data
├── chainstate/ # UTXO set
└── peers.dat # Known peers

See Also