A lightweight Bitcoin block mining simulator and transaction validation engine built from scratch
BitMiner is an educational implementation of Bitcoin's core mining and transaction validation mechanisms. Built without relying on Bitcoin-specific libraries, this project demonstrates the fundamental cryptographic and algorithmic principles that power Bitcoin's proof-of-work consensus.
- Transaction Validation: Validates Bitcoin transactions from scratch using cryptographic primitives
- Block Mining Simulation: Implements proof-of-work mining algorithm with configurable difficulty targets
- Mempool Processing: Efficiently processes and prioritizes transactions based on fee rates
- Block Construction: Constructs valid Bitcoin blocks including coinbase transactions
- Zero External Bitcoin Libraries: Built using only standard cryptographic libraries (secp256k1, SHA-256)
- Rust 1.70+ (or your language runtime)
- Standard cryptographic libraries
git clone https://github.com/benodiwal/BitMiner.git
cd BitMiner- Place transaction JSON files in the
mempool/directory - Run the mining simulation:
bash run.sh- The mined block will be output to
output.txtwith the following structure:- Line 1: Block header
- Line 2: Serialized coinbase transaction
- Line 3+: Transaction IDs included in the block
- Transaction Parsing: Reads and parses transactions from the mempool
- Validation: Validates each transaction using cryptographic signatures and script verification
- Fee Optimization: Selects transactions to maximize fee collection while respecting block size limits
- Coinbase Creation: Generates coinbase transaction with block reward and collected fees
- Mining: Iterates through nonce values to find a block hash below the difficulty target
The default difficulty target is:
0000ffff00000000000000000000000000000000000000000000000000000000
This can be configured to simulate different mining difficulties.
Customize mining parameters by modifying the configuration:
- Difficulty target
- Block size limits
- Fee calculation methods
- Validation rules
Note: This is an educational implementation for learning purposes. It is not intended for production use or actual Bitcoin mining.
For questions or feedback, please open an issue on GitHub.