Skip to content

Testing environment for Bitcoin Mainnet. Designed to facilitate experimentation and development in a controlled and isolated setting.

Notifications You must be signed in to change notification settings

Dmenec/BTC-Labnet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BTC Labnet: Creating a Parallel Bitcoin Mainnet for Controlled Testing

Introduction

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.

Table of Contents

Features

  • 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.

Getting Started

To get started, you'll need to have Docker installed on your machine.

Prerequisites

  • Docker (v20.10 or higher recommended)
  • Basic knowledge of Bitcoin Core and Docker

Installation

Method 1: Download the Image from GitHub Container Registry

You can directly pull the pre-built Docker image and run the setup script without building the image from source. Follow these steps:

  1. Pull the image from the GitHub Container Registry:

    docker pull ghcr.io/niktowcode/mainnet_testbed:1.0
  2. Clone the repository:

    git clone https://github.com/NiktowCode/BTC-Labnet.git
    cd BTC-Labnet
  3. Run the script to set up Docker containers (commenting out the build step):

./start.sh

Method 2: Build from Source

Follow these steps to build the image from source:

  1. Clone the repository:
git clone https://github.com/NiktowCode/BTC-Labnet.git
cd BTC-Labnet
  1. Run the script to set up Docker containers:
./start.sh

After execution, three interconnected Bitcoin nodes (bc-node1, bc-node2, and bc-node3) will be created.

Setup Process

Building a Customized Docker Image for Bitcoin-Core

  1. Modify Bitcoin-Core: Adjust the Bitcoin-Core code to enable SegWit and Taproot.

  2. Create a Dockerfile: Use your own Dockerfile to build your custom Bitcoin-Core image.

  3. Build the Docker Image: Run the following command:

    docker build -t bitcoin .

Setting Up the Docker Network

Create a Docker bridge network:

docker network create -d bridge bitcoin_network

Running Bitcoin Nodes

Start your Bitcoin node:

docker run -it -d --network bitcoin_network --name bc-node1 -p 8333:8333 -p 8332:8332 bitcoin -printtoconsole -txindex=1 -reindex

Configuring Node Connectivity

Ensure all nodes can connect properly by updating the bitcoin.conf file of each node with the IP address of the router node.

Configuration

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> and rpcpassword=<password>: Set up RPC authentication.
  • server=1: Enable RPC commands.

Mining Blocks

To mine blocks, you can use this command inside one of the nodes.

cd home/bitcoin/.bitcoin
./start_mining.sh

For a more efficient mining process, integrate with a Stratum mining pool using the Bitaxe miner.

Contributing

Contributions are more than welcome! :) Please open an issue or submit a pull request for any enhancements or bug fixes.

About

Testing environment for Bitcoin Mainnet. Designed to facilitate experimentation and development in a controlled and isolated setting.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages