Files
palladium-stack/Dockerfile
Davide Grilli 9000278f17 feat: add complete Palladium testnet support to ElectrumX
This commit implements full support for both Palladium mainnet and testnet
networks in ElectrumX, allowing users to switch between them via configuration.

Changes:
- Dockerfile: Fixed coin class registration by adding Palladium classes
  directly to coins.py instead of using external imports (avoids circular
  dependency). Both /usr/local/lib and /electrumx/src files are patched.
  Added required TX_COUNT, TX_COUNT_HEIGHT, TX_PER_BLOCK attributes.

- README.md: Updated with comprehensive network support documentation
  including network comparison table, step-by-step switching instructions,
  testnet-specific information, and corrected COIN/NET usage.

- docker-compose.yml: Configured for testnet with proper COIN and NET
  environment variables. Added clear comments for mainnet/testnet switching.

Network Configuration:
- Mainnet: COIN="Palladium" NET="mainnet" port 2332
- Testnet: COIN="Palladium" NET="testnet" port 12332
  (Note: COIN value is always "Palladium" for both networks)

Tested successfully with Palladium testnet node - synced 6,576 blocks
and serving on TCP:50001 and SSL:50002.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 13:24:42 +01:00

114 lines
2.8 KiB
Docker

FROM lukechilds/electrumx
RUN python3 - <<'PY'
import pathlib
p = pathlib.Path('/usr/local/lib/python3.13/dist-packages/electrumx/lib/coins.py')
s = p.read_text(encoding='utf-8')
# Define Palladium coin classes directly in coins.py to avoid circular imports
palladium_classes = '''
# Palladium (PLM) - Bitcoin-based cryptocurrency
class Palladium(Bitcoin):
NAME = "Palladium"
SHORTNAME = "PLM"
NET = "mainnet"
# Address prefixes (same as Bitcoin mainnet)
P2PKH_VERBYTE = bytes([0x00])
P2SH_VERBYTE = bytes([0x05])
WIF_BYTE = bytes([0x80])
# Bech32 prefix
HRP = "plm"
# Genesis hash (Bitcoin mainnet)
GENESIS_HASH = "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"
# Network statistics (required by ElectrumX)
TX_COUNT = 1000
TX_COUNT_HEIGHT = 1
TX_PER_BLOCK = 4
# 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"
# Network statistics (required by ElectrumX)
TX_COUNT = 500
TX_COUNT_HEIGHT = 1
TX_PER_BLOCK = 2
# Testnet ports
RPC_PORT = 12332
PEER_DEFAULT_PORTS = {'t': '12333', 's': '62333'}
'''
# Add Palladium classes if not already present
if 'class Palladium(Bitcoin):' not in s:
s += palladium_classes
p.write_text(s, encoding='utf-8')
# Also patch the source file used by the container
p_src = pathlib.Path('/electrumx/src/electrumx/lib/coins.py')
if p_src.exists():
s_src = p_src.read_text(encoding='utf-8')
if 'class Palladium(Bitcoin):' not in s_src:
s_src += palladium_classes
p_src.write_text(s_src, encoding='utf-8')
print('>> Patched ElectrumX with Palladium and PalladiumTestnet coins')
PY
RUN mkdir -p /certs && \
cat >/certs/openssl.cnf <<'EOF' && \
openssl req -x509 -nodes -newkey rsa:4096 -days 3650 \
-keyout /certs/server.key -out /certs/server.crt \
-config /certs/openssl.cnf && \
chmod 600 /certs/server.key && chmod 644 /certs/server.crt
[req]
distinguished_name = dn
x509_extensions = v3_req
prompt = no
[dn]
C = IT
ST = -
L = -
O = ElectrumX
CN = plm.local
[v3_req]
keyUsage = keyEncipherment, dataEncipherment, digitalSignature
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
[alt_names]
DNS.1 = plm.local
IP.1 = 127.0.0.1
EOF
ENV SSL_CERTFILE=/certs/server.crt
ENV SSL_KEYFILE=/certs/server.key