Use coins_plm.py as single source of truth for ElectrumX patch
- Remove inline Palladium coin definition from Dockerfile.electrumx and COPY coins_plm.py instead, reducing duplication - Add TX_COUNT/TX_COUNT_HEIGHT/TX_PER_BLOCK to coins_plm.py with real chain data (457478 txs at height 382404) - Update entrypoint.sh to fetch live TX stats from palladiumd at container startup, keeping sync estimates accurate automatically
This commit is contained in:
@@ -1,88 +1,29 @@
|
||||
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')
|
||||
# Copy Palladium coin definition and patch ElectrumX
|
||||
COPY electrumx-patch/coins_plm.py /tmp/coins_plm.py
|
||||
|
||||
# Define Palladium coin classes directly in coins.py to avoid circular imports
|
||||
palladium_classes = '''
|
||||
RUN python3 - <<'PATCH'
|
||||
import pathlib, re
|
||||
|
||||
# Palladium (PLM) - Bitcoin-based cryptocurrency
|
||||
class Palladium(Bitcoin):
|
||||
NAME = "Palladium"
|
||||
SHORTNAME = "PLM"
|
||||
NET = "mainnet"
|
||||
patch = pathlib.Path('/tmp/coins_plm.py').read_text()
|
||||
# Extract only class definitions (skip import lines)
|
||||
classes = re.split(r'^(?=class )', patch, flags=re.MULTILINE)
|
||||
classes = [c for c in classes if c.strip().startswith('class ')]
|
||||
body = '\n' + '\n'.join(classes)
|
||||
|
||||
# Address prefixes (same as Bitcoin mainnet)
|
||||
P2PKH_VERBYTE = bytes([0x00])
|
||||
P2SH_VERBYTE = bytes([0x05])
|
||||
WIF_BYTE = bytes([0x80])
|
||||
for target in [
|
||||
'/usr/local/lib/python3.13/dist-packages/electrumx/lib/coins.py',
|
||||
'/electrumx/src/electrumx/lib/coins.py',
|
||||
]:
|
||||
p = pathlib.Path(target)
|
||||
if p.exists():
|
||||
s = p.read_text()
|
||||
if 'class Palladium(Bitcoin):' not in s:
|
||||
p.write_text(s + body)
|
||||
|
||||
# Bech32 prefix
|
||||
HRP = "plm"
|
||||
|
||||
# Genesis hash (Bitcoin mainnet)
|
||||
GENESIS_HASH = "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"
|
||||
|
||||
# Clear inherited checkpoints
|
||||
CHECKPOINTS = []
|
||||
|
||||
# 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
|
||||
print('>> Patched ElectrumX with Palladium coin classes')
|
||||
PATCH
|
||||
|
||||
RUN mkdir -p /certs && \
|
||||
cat >/certs/openssl.cnf <<'EOF' && \
|
||||
|
||||
Reference in New Issue
Block a user