From 54b434d33f2cef9d391b561f4e98cc7723c60632 Mon Sep 17 00:00:00 2001 From: Davide Grilli Date: Fri, 28 Nov 2025 12:32:12 +0100 Subject: [PATCH] Add testnet support for palladium electrumx server Add PalladiumTestnet class with testnet-specific configurations including ports, address prefixes, and genesis hash. Update docker-compose.yml with clear network configuration comments and documentation in README.md explaining how to switch between mainnet and testnet. --- README.md | 149 ++++++++++++++++++++++++++++++++++- docker-compose.yml | 10 ++- electrumx-patch/coins_plm.py | 25 ++++++ 3 files changed, 180 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b289ff9..d9ce701 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Replace with your actual values: * `` → RPC username of the node * `` → RPC password of the node -* `` → RPC port of the node (e.g., `2332` for Palladium) +* `` → RPC port of the node (`2332` for mainnet, `12332` for testnet) **Note:** The compose uses `host.docker.internal` to connect to the Palladium node running on your host machine (outside the container). This works on both Windows/Mac and Linux thanks to the `extra_hosts` configuration. @@ -72,6 +72,150 @@ Replace with your actual values: --- +## Network Support (Mainnet & Testnet) + +This ElectrumX server supports both **Palladium mainnet** and **testnet**. You can switch between networks by modifying the `docker-compose.yml` configuration. + +### Network Comparison + +| Network | COIN Value | RPC Port | Bech32 Prefix | Address Prefix | +|---------|-----------|----------|---------------|----------------| +| **Mainnet** | `Palladium` | `2332` | `plm` | Standard (starts with `1` or `3`) | +| **Testnet** | `PalladiumTestnet` | `12332` | `tplm` | Testnet (starts with `t`) | + +--- + +### Running on Mainnet (Default) + +The default configuration is set for **mainnet**. No changes are needed if you want to run on mainnet. + +**Configuration in `docker-compose.yml`:** +```yaml +environment: + COIN: "Palladium" + DAEMON_URL: "http://:@host.docker.internal:2332/" +``` + +**Requirements:** +- Palladium Core node running on **mainnet** +- RPC port: `2332` +- RPC credentials configured in `palladium.conf` + +--- + +### Switching to Testnet + +To run ElectrumX on **testnet**, follow these steps: + +#### Step 1: Configure Palladium Core for Testnet + +Edit your Palladium Core configuration file (`palladium.conf`) and add: + +```conf +# Enable testnet +testnet=1 + +# RPC settings for testnet +rpcuser=your_rpc_username +rpcpassword=your_rpc_password +rpcport=12332 + +# Allow RPC connections +server=1 +``` + +Restart your Palladium Core node to apply testnet configuration. + +#### Step 2: Modify docker-compose.yml + +Open `docker-compose.yml` and change these two values in the `environment` section: + +**Before (Mainnet):** +```yaml +environment: + COIN: "Palladium" + DAEMON_URL: "http://:@host.docker.internal:2332/" +``` + +**After (Testnet):** +```yaml +environment: + COIN: "PalladiumTestnet" + DAEMON_URL: "http://:@host.docker.internal:12332/" +``` + +**Important changes:** +1. Change `COIN` from `"Palladium"` to `"PalladiumTestnet"` +2. Change port in `DAEMON_URL` from `2332` to `12332` +3. Replace `` and `` with your actual testnet RPC credentials + +#### Step 3: Clear Existing Database (Important!) + +When switching networks, you **must** clear the ElectrumX database to avoid conflicts: + +```bash +# Stop the container +docker compose down + +# Remove the database +rm -rf ./data/* + +# Or on Windows: +# rmdir /s /q data +# mkdir data +``` + +#### Step 4: Rebuild and Restart + +```bash +# Rebuild the image (if you modified coins_plm.py) +docker build -t electrumx-plm:local . + +# Start the container +docker compose up -d + +# Monitor the logs +docker compose logs -f +``` + +The ElectrumX server will now sync with the Palladium **testnet** blockchain. + +--- + +### Testnet-Specific Information + +**Genesis Block Hash (Testnet):** +``` +000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943 +``` + +**Address Examples:** +- Legacy (P2PKH): starts with `t` (e.g., `tPLMAddress123...`) +- SegWit (Bech32): starts with `tplm` (e.g., `tplm1q...`) + +**Network Ports:** +- Palladium Core RPC: `12332` +- Palladium Core P2P: `12333` +- ElectrumX TCP: `50001` (same as mainnet) +- ElectrumX SSL: `50002` (same as mainnet) + +--- + +### Switching Back to Mainnet + +To switch back from testnet to mainnet: + +1. Edit `palladium.conf` and remove or comment `testnet=1` +2. Change `rpcport=2332` in `palladium.conf` +3. Restart Palladium Core node +4. In `docker-compose.yml`, change: + - `COIN: "PalladiumTestnet"` → `COIN: "Palladium"` + - Port in `DAEMON_URL` from `12332` → `2332` +5. Clear database: `rm -rf ./data/*` +6. Restart ElectrumX: `docker compose down && docker compose up -d` + +--- + ## Build and Start the Project 1. Navigate to the directory containing `docker-compose.yml` and `Dockerfile`. @@ -115,7 +259,8 @@ The script will perform: ## Notes -* `coins_plm.py` defines the **Palladium (PLM)** coin, based on Bitcoin. +* `coins_plm.py` defines both **Palladium (PLM)** mainnet and **PalladiumTestnet** classes +* See "Network Support" section for switching between mainnet and testnet * Production recommendations: * Protect RPC credentials diff --git a/docker-compose.yml b/docker-compose.yml index fe21f48..ecfcdb6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,9 +10,15 @@ services: - "50002:50002" # SSL environment: - COIN: "Palladium" - NET: "mainnet" + # ===== Network Configuration ===== + # For MAINNET use: COIN: "Palladium" and DAEMON_URL port 2332 + # For TESTNET use: COIN: "PalladiumTestnet" and DAEMON_URL port 12332 + COIN: "Palladium" # Change to "PalladiumTestnet" for testnet + NET: "mainnet" # This is set automatically by the COIN parameter + + # Palladium Core RPC connection + # MAINNET: port 2332 | TESTNET: port 12332 DAEMON_URL: "http://:@host.docker.internal:2332/" # RPC credentials SERVICES: "tcp://0.0.0.0:50001,ssl://0.0.0.0:50002" diff --git a/electrumx-patch/coins_plm.py b/electrumx-patch/coins_plm.py index 6a2b3de..4d8459f 100644 --- a/electrumx-patch/coins_plm.py +++ b/electrumx-patch/coins_plm.py @@ -17,6 +17,31 @@ class Palladium(Bitcoin): # === Genesis hash (Bitcoin mainnet) === GENESIS_HASH = "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f" + # === Default ports === + RPC_PORT = 2332 + PEER_DEFAULT_PORTS = {'t': '2333', 's': '52333'} + # === Deserializer === DESERIALIZER = lib_tx.DeserializerSegWit + +class PalladiumTestnet(Palladium): + NAME = "Palladium" + SHORTNAME = "tPLM" + NET = "testnet" + + # === Testnet address prefixes === + P2PKH_VERBYTE = bytes([0x7f]) # 127 decimal - addresses start with 't' + P2SH_VERBYTE = bytes([0x73]) # 115 decimal + WIF_BYTE = bytes([0xff]) # 255 decimal + + # === Bech32 prefix for testnet === + HRP = "tplm" + + # === Genesis hash (Bitcoin testnet) === + GENESIS_HASH = "000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943" + + # === Testnet ports === + RPC_PORT = 12332 + PEER_DEFAULT_PORTS = {'t': '12333', 's': '62333'} +