BTC Labnet is a project developed by the Blockchain and Cryptocurrency Research Group at the Autonomous University of Barcelona. This project allows for controlled testing of the Bitcoin network by creating a parallel mainnet using Docker containers.
The main goal is to provide a safe environment for testing without connecting to the real Bitcoin network.
- Run multiple Bitcoin nodes in an isolated Docker network.
- Custom consensus rules, including SegWit and Taproot support from block 0.
- Easy setup and management using shell scripts.
- Integration with a Stratum mining pool for efficient mining.
To get started, you'll need to have Docker installed on your machine.
- Docker (v20.10 or higher recommended)
- Basic knowledge of Bitcoin Core and Docker
You can directly pull the pre-built Docker image and run the setup script without building the image from source. Follow these steps:
-
Pull the image from the GitHub Container Registry:
docker pull ghcr.io/niktowcode/mainnet_testbed:1.0
-
Clone the repository:
git clone https://github.com/NiktowCode/BTC-Labnet.git cd BTC-Labnet -
Run the script to set up Docker containers (commenting out the build step):
./start.shFollow these steps to build the image from source:
- Clone the repository:
git clone https://github.com/NiktowCode/BTC-Labnet.git
cd BTC-Labnet- Run the script to set up Docker containers:
./start.shAfter execution, three interconnected Bitcoin nodes (bc-node1, bc-node2, and bc-node3) will be created.
-
Modify Bitcoin-Core: Adjust the Bitcoin-Core code to enable SegWit and Taproot.
-
Create a Dockerfile: Use your own
Dockerfileto build your custom Bitcoin-Core image. -
Build the Docker Image: Run the following command:
docker build -t bitcoin .
Create a Docker bridge network:
docker network create -d bridge bitcoin_networkStart your Bitcoin node:
docker run -it -d --network bitcoin_network --name bc-node1 -p 8333:8333 -p 8332:8332 bitcoin -printtoconsole -txindex=1 -reindexEnsure all nodes can connect properly by updating the bitcoin.conf file of each node with the IP address of the router node.
The bitcoin.conf file is crucial for customizing your node properties. Key settings include:
addnode=<IP_ADDRESS>: Add the router node's IP.rpcbind=0.0.0.0: Listen on all available network interfaces.rpcport=8332: Default RPC port.rpcuser=<username>andrpcpassword=<password>: Set up RPC authentication.server=1: Enable RPC commands.
To mine blocks, you can use this command inside one of the nodes.
cd home/bitcoin/.bitcoin
./start_mining.shFor a more efficient mining process, integrate with a Stratum mining pool using the Bitaxe miner.
Contributions are more than welcome! :) Please open an issue or submit a pull request for any enhancements or bug fixes.