BitLab is an interactive command-line tool for exploring and interacting with the Bitcoin P2P network and blockchain. Inspired by SockLab, BitLab provides a user-friendly interface for learning and working with Bitcoin's peer-to-peer networking protocols without needing to write low-level C code. The tool allows users to perform a wide range of operations on the Bitcoin network, such as peer discovery, connecting to peers, sending messages, and retrieving blockchain data.
BitLab acts as a powerful educational resource and debugging tool for understanding how Bitcoin nodes communicate, synchronize blocks, and process transactions by interacting with the Bitcoin network in real-time. The tool is designed to be user-friendly, intuitive, and informative, providing users with a comprehensive view of the Bitcoin network's inner workings using the Bitcoin protocol.
Please run following:
sudo apt-get update
sudo apt-get install -y gcc libreadline-dev libssl-dev
Note
Default installation directory is /usr/local/bin
To install BitLab, simply run the following command in your terminal:
curl -s https://raw.githubusercontent.com/milosz275/bitlab/main/install.sh | sudo bash
To uninstall BitLab, simply run the following command in your terminal:
curl -s https://raw.githubusercontent.com/milosz275/bitlab/main/uninstall.sh | sudo bash -s -- -y
To build BitLab from source, follow these steps:
-
Clone the repository:
git clone https://github.com/milosz275/bitlab.git
-
Change to the project directory:
cd bitlab
-
Build the project:
make
-
Use the
main
executable:bitlab/build/bin/main
Run help
to display available commands and help [command]
to view detailed information about specific one.
The default configuration directory is ~/.bitlab
. The configuration directory contains
the following files:
logs/bitlab.log
: BitLab main log filehistory/cli_history.txt
: BitLab CLI command history file
Please feel free to link logs and history to your current working directory:
ln -s ~/.bitlab/logs ./logs
ln -s ~/.bitlab/history ./history
Note
Running as root will create the configuration directory in /root/.bitlab
.
Easily find and connect with peers using various methods:
-
Discovery Options: - Via Command Line Parameters - Predefined Seeds - DNS Lookup
-
Bootstrapping with Peer Data: - Use the
getaddr
message to request anaddr
message containing active peers. -addr
messages will provide a list of IP addresses and ports. -
Peer Information: - Print out IP addresses of discovered peers. - Perform recursive discovery to find given amounts of peers.
Seamlessly establish and maintain connections with peers:
- Initial Connection:
- Exchange
version
messages to introduce versions. - Follow up withverack
messages to confirm the connection is successful.
Stay connected with active peers and monitor peer availability:
-
Peer Availability Checks: - Use
ping
messages to check peer responsiveness and connection health. -
Network Alerts: - Send
alert
messages to notify peers of important network events. -alert
has been deprecated because of security risks so it won't be implemented in this app. documentation thread
Handle errors gracefully and communicate network events transparently:
-
Error Reporting: - Use
reject
messages to report any client-side errors. - Deprecated in Bitcoin Core 0.18.0. source: documentation thread -
Diagnostics: - Use
message
messages to log diagnostics and troubleshooting information.
Efficiently share and request blocks and transactions with peers:
-
Inventory Announcements: - Use
inv
messages to announce available blocks or transactions. -
Requesting Data: -
getdata
message: Request specific blocks or transactions by their hash. -getblocks
message: Request an inventory list for blocks within a specified range. -getheaders
message: Request headers of blocks in a specific range for easy synchronization. -
Transaction and Block Sharing: -
tx
message: Announce new transactions. -block
message: Send or advertise a specific block. -headers
message: Share up to 2,000 block headers for faster synchronization.
This project is licensed under the MIT License - see the LICENSE file for details.