BTC Mesh Relay is a project designed to enable the broadcasting of Bitcoin raw transactions by sending them as chunked hexadecimal strings via LoRa Meshtastic direct messages. A dedicated client script (btcmesh_cli.py) will be used for sending, and a relay device running btcmesh_server.py will reassemble these chunks, decode, validate, and then relay the complete transaction to a configured Bitcoin RPC node. This system is intended for scenarios with limited or censored internet access but where LoRa Meshtastic network availability exists.
This project is currently under development.
- Meshtastic Communication: Initializes and manages communication with a Meshtastic device.
- Transaction Chunking & Reassembly: Allows large Bitcoin transactions to be sent in smaller chunks over LoRa by
btcmesh_cli.pyand reassembled bybtcmesh_server.py. - Payload Handling: Relay server reassembles hexadecimal chunks. The connected Bitcoin Core node performs full transaction validation upon broadcast attempt. (Advanced pre-broadcast decoding and validation capabilities on the relay server via
core/transaction_parser.pyare planned for future enhancements). - Basic Transaction Validation: Currently, the relay server relies on the connected Bitcoin Core node for most transaction validation. (More extensive pre-broadcast sanity checks on the relay are planned).
- Bitcoin RPC Integration: Connects to a Bitcoin Core RPC node to broadcast the validated raw transaction.
- Logging: Comprehensive logging for both server and client operations.
- Client Script (
btcmesh_cli.py): Implemented command-line tool (btcmesh_cli.py) for users to send raw transactions. - Tor Support: Optionally connect to a Bitcoin RPC node via its
.onionaddress (requires Tor to be installed and running on your system).
btcmesh/
βββ btcmesh_cli.py # Command-line client script
βββ btcmesh_gui.py # Graphical user interface client
βββ btcmesh_server.py # Server/Relay script
βββ btcmesh_server_gui.py # Server GUI for relay operators
βββ core/ # Core logic for the server/relay
β βββ __init__.py
β βββ config_loader.py # For loading .env and other configurations
β βββ gui_common.py # Shared GUI components and styling
β βββ logger_setup.py # For setting up consistent logging
β βββ meshtastic_utils.py # Meshtastic device utilities
β βββ transaction_parser.py # For decoding raw Bitcoin transactions (Planned)
β βββ rpc_client.py # For interacting with Bitcoin RPC
β βββ reassembler.py # For reassembling chunked messages
βββ project/ # Project planning documents
β βββ tasks.txt
β βββ protocol_spec.md
β βββ reference_materials.md
βββ logs/ # Directory for log files (created at runtime)
βββ tests/ # Unit and integration tests
βββ .env.example # Example environment variable configuration file
βββ requirements.txt # Python dependencies
βββ README.md # This file
(Refer to project/tasks.txt for detailed ongoing tasks and user stories.)
-
Clone the Repository:
git clone https://github.com/eddieoz/btcmesh.git cd btcmesh -
Create and Activate Conda Environment: It's recommended to use a Conda environment. If you don't have Conda, please install it first.
conda create -n btcmesh python=3.11 conda activate btcmesh
Or use venv
python -m venv env source env/bin/activate -
Install Dependencies:
pip install -r requirements.txt
-
Configure Environment (.env): The application is configured using a
.envfile in the project root. Copy the example file to create your own configuration:cp .env.example .env
Then, edit the
.envfile to set your specific configurations. For example:MESHTASTIC_SERIAL_PORT: Specifies the serial port for your Meshtastic device (e.g.,/dev/ttyUSB0,/dev/ttyACM0on Linux, orCOM3on Windows). If this is not set or is commented out, the application will attempt to auto-detect the Meshtastic device.# MESHTASTIC_SERIAL_PORT=/dev/your/meshtastic_port- Bitcoin RPC Node Details: Required for the relay server (
btcmesh_server.py).BITCOIN_RPC_HOST=your_bitcoin_node_host BITCOIN_RPC_PORT=your_bitcoin_node_port # e.g., 8332 for mainnet BITCOIN_RPC_USER=your_rpc_username BITCOIN_RPC_PASSWORD=your_rpc_password # Optional: For transaction reassembly timeout # REASSEMBLY_TIMEOUT_SECONDS=120
- Connecting via Tor: If you wish to connect to your Bitcoin RPC node via Tor, set the
BITCOIN_RPC_HOSTto your node's.onionaddress. You must have Tor installed and running on your system (see Tor Setup below).# Example for Tor connection: BITCOIN_RPC_HOST=yourbitcoinrpcnode.onion
-
Meshtastic Device Setup:
- Ensure you have a Meshtastic device connected to the machine where
btcmesh_server.pywill run (and another for the client whenbtcmesh_cli.pyis used). - The Meshtastic Python library, by default, attempts to auto-detect your device. You can specify the serial port explicitly by setting
MESHTASTIC_SERIAL_PORTin your.envfile. - Ensure your Bitcoin Core node is configured to accept RPC connections.
- Configure the RPC host, port, user, and password in your
.envfile (see step 4). - Tor Connectivity: If
BITCOIN_RPC_HOSTis a.onionaddress, you must have Tor installed and running on your system. See Tor Setup for installation instructions.
- Ensure you have a Meshtastic device connected to the machine where
The primary method for configuration is via a .env file in the project root (see "Configure Environment (.env)" in Setup Instructions).
Key settings configurable in .env:
- Meshtastic device serial port (
MESHTASTIC_SERIAL_PORT). - Bitcoin RPC connection details (
BITCOIN_RPC_HOST,BITCOIN_RPC_PORT,BITCOIN_RPC_USER,BITCOIN_RPC_PASSWORD). Use a.onionaddress forBITCOIN_RPC_HOSTto route traffic through Tor (requires Tor to be installed and running). - Transaction reassembly timeout (
REASSEMBLY_TIMEOUT_SECONDS).
Once set up and configured, you can run the BTC Mesh Relay server:
python btcmesh_server.pyThe server will initialize the Meshtastic interface, connect to the Bitcoin RPC node (if configured), and start listening for incoming messages.
The client script is used to send a raw Bitcoin transaction to a relay server.
python btcmesh_cli.py --destination <SERVER_NODE_ID> --tx <RAW_TRANSACTION_HEX>Replace <SERVER_NODE_ID> with the Meshtastic node ID of the machine running btcmesh_server.py (e.g., !abcdef12) and <RAW_TRANSACTION_HEX> with the full raw transaction hex string you intend to broadcast.
Use python btcmesh_cli.py --help for more options, such as --dry-run to simulate sending without actually transmitting over LoRa.
The GUI provides a user-friendly graphical interface for sending Bitcoin transactions over the Meshtastic LoRa mesh network. It wraps the CLI with visual feedback and easy-to-use controls.
python btcmesh_gui.py- Device Selection: Dropdown to select from multiple connected Meshtastic devices with scan/refresh capability
- Connection Status: Displays connected device name and node ID with color-coded indicators
- Known Nodes Dropdown: Select destination from previously seen mesh nodes
- Transaction Input: Text fields for destination node ID and raw transaction hex
- Dry Run Toggle: Test your transaction without actually broadcasting (ON/OFF indicator)
- Real-time Status Log: Color-coded scrollable log showing transaction progress
- Success Popup: Styled confirmation popup with TXID and copy-to-clipboard button
- Abort Button: Cancel a transaction in progress
- Load Example: Quick-fill example data for testing
- Disabled Controls During Send: Input fields are locked while transaction is in progress
Main window showing device selection, connection status, destination dropdown, and input fields
Main window in action sending a transaction in chunks to the relay server
-
Select your Meshtastic device - Use the device dropdown to select from available devices. Click "Scan" to refresh the list.
-
Select or enter destination - Choose a known node from the dropdown or manually type the relay server's Meshtastic node ID (e.g.,
!abcdef12). -
Enter transaction hex - Paste your raw Bitcoin transaction hex string or use the "Paste" button to paste from clipboard.
-
Toggle Dry Run (optional) - Enable dry run mode to test without actually transmitting over LoRa.
-
Click Send - The transaction will be chunked and sent to the relay. Progress appears in the status log.
-
Monitor progress - Watch the status log for:
- Green messages: Success/ACK confirmations
- Orange messages: Warnings
- Red messages: Errors
-
Receive confirmation - On successful broadcast, a styled popup displays the transaction ID (TXID) with a copy button.
The Server GUI provides a graphical interface for relay operators to run and monitor the BTCMesh relay server.
python btcmesh_server_gui.py- Start/Stop Controls: One-click buttons to start and stop the relay server
- Network Badge: Displays the connected Bitcoin network (MAINNET/TESTNET3/TESTNET4/SIGNET) with color-coded badge
- Bitcoin RPC Status: Shows connection status to Bitcoin Core node with host information and Tor indicator
- Meshtastic Status: Shows device connection status with node ID and device path
- Activity Log: Real-time color-coded log of all server events
- Clear Log: Button to clear the activity log
Server GUI showing status indicators for Network, Bitcoin RPC, and Meshtastic connections
The Server GUI displays:
- Network: Current Bitcoin network (orange for mainnet, blue for testnet, purple for signet)
- Bitcoin RPC: Connection status with host:port (or
*.onion [Tor]for Tor connections) - Meshtastic: Device connection status with node ID and device path
-
Configure your
.envfile - Ensure Bitcoin RPC credentials and Meshtastic settings are configured. -
Click Start Server - The server will initialize connections to Meshtastic and Bitcoin RPC.
-
Monitor status indicators:
- Network badge shows which Bitcoin network you're connected to
- Green indicators show successful connections
- Red indicators show connection failures
-
Watch the activity log - All server events appear with color-coded messages.
-
Click Stop Server - Gracefully shuts down the relay server.
To connect to a Bitcoin RPC node via its .onion address, you must have Tor installed and running on your system. The application will automatically route traffic through Tor's SOCKS proxy (default: 127.0.0.1:9050).
macOS (using Homebrew):
brew install tor
brew services start torUbuntu/Debian:
sudo apt update
sudo apt install tor
sudo systemctl start tor
sudo systemctl enable tor # Optional: start on bootWindows:
- Download the Tor Expert Bundle from torproject.org/download/tor/
- Extract and run
tor.exe - Or install via Chocolatey:
choco install tor
Check that Tor is listening on the SOCKS port:
# macOS/Linux
nc -zv 127.0.0.1 9050
# Or check the service status
# macOS
brew services list | grep tor
# Linux
sudo systemctl status torOnce Tor is running, simply set your .onion address in the .env file:
BITCOIN_RPC_HOST=yourbitcoinnode.onion
BITCOIN_RPC_PORT=8332
BITCOIN_RPC_USER=your_rpc_user
BITCOIN_RPC_PASSWORD=your_rpc_passwordThe application automatically detects .onion addresses and routes the connection through Tor.
- Connection refused: Ensure Tor service is running (
brew services start tororsudo systemctl start tor) - Timeout errors: Check that your
.onionaddress is correct and the remote node is accessible - SOCKS proxy errors: Verify Tor is using the default port 9050, or check your Tor configuration
To run the automated tests:
python -m unittest discover -s tests -p 'test_*.py'Contributions are welcome! Please refer to the project's issue tracker and development plan in project/tasks.txt. Follow TDD/BDD principles when adding new features or fixing bugs.
This project is licensed under the MIT License.
Did you like it? Buy me a coffee
Or drop me a tip through Lightning Network: β‘ getalby.com/p/eddieoz



