From e9062824e70d51c8e19c7c6a498388d02e71d37e Mon Sep 17 00:00:00 2001 From: sdcwen Date: Wed, 4 Oct 2023 14:29:44 +0400 Subject: [PATCH 1/2] Add BCA testnet support --- electrumx/lib/coins.py | 21 ++++++++++++++++++++- electrumx/lib/tx.py | 4 ++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/electrumx/lib/coins.py b/electrumx/lib/coins.py index ce49f4c6f..629dcf849 100644 --- a/electrumx/lib/coins.py +++ b/electrumx/lib/coins.py @@ -2314,6 +2314,9 @@ class BitcoinAtom(Coin): NET = "mainnet" P2PKH_VERBYTE = bytes.fromhex("17") P2SH_VERBYTES = (bytes.fromhex("0a"),) + WIF_BYTE = bytes.fromhex("80") + GENESIS_HASH = ('000000000019d6689c085ae165831e93' + '4ff763ae46a2a6c172b3f1b60a8ce26f') STATIC_BLOCK_HEADERS = False DESERIALIZER = lib_tx.DeserializerBitcoinAtom HEADER_SIZE_POST_FORK = 84 @@ -2322,7 +2325,7 @@ class BitcoinAtom(Coin): TX_COUNT = 295158744 TX_COUNT_HEIGHT = 589197 TX_PER_BLOCK = 10 - RPC_PORT = 9136 + RPC_PORT = 7332 REORG_LIMIT = 5000 @classmethod @@ -2345,6 +2348,22 @@ def block_header(cls, block, height): return deserializer.read_header(height, cls.BASIC_HEADER_SIZE) +class BitcoinAtomTestnet(BitcoinAtom): + SHORTNAME = "tBCA" + NET = "testnet" + P2PKH_VERBYTE = bytes.fromhex("6f") + P2SH_VERBYTES = [bytes.fromhex("c4")] + WIF_BYTE = bytes.fromhex("ef") + GENESIS_HASH = ('000000000933ea01ad0ee984209779ba' + 'aec3ced90fa3f408719526f8d77f4943') + DESERIALIZER = lib_tx.DeserializerBitcoinAtomTestnet + TX_COUNT = 17128321 + TX_COUNT_HEIGHT = 1334108 + TX_PER_BLOCK = 3 + RPC_PORT = 17332 + PEER_DEFAULT_PORTS = {'t': '51001', 's': '51002'} + + class Decred(Coin): NAME = "Decred" SHORTNAME = "DCR" diff --git a/electrumx/lib/tx.py b/electrumx/lib/tx.py index a753e7030..e2afe49c7 100644 --- a/electrumx/lib/tx.py +++ b/electrumx/lib/tx.py @@ -908,6 +908,10 @@ def read_header(self, height, static_header_size): return self._read_nbytes(header_len) +class DeserializerBitcoinAtomTestnet(DeserializerBitcoinAtom): + FORK_BLOCK_HEIGHT = 1260000 + + class DeserializerGroestlcoin(DeserializerSegWit): TX_HASH_FN = staticmethod(sha256) From 25ad69d86348985d8bb7573325efaca304d0f9a7 Mon Sep 17 00:00:00 2001 From: sdcwen Date: Wed, 4 Oct 2023 17:43:48 +0400 Subject: [PATCH 2/2] Fix Dockerfile --- contrib/Dockerfile | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/contrib/Dockerfile b/contrib/Dockerfile index f30849504..481941414 100644 --- a/contrib/Dockerfile +++ b/contrib/Dockerfile @@ -7,27 +7,27 @@ WORKDIR /usr/src/app # Install the libs needed by rocksdb (including development headers) RUN apt-get update \ - && apt-get -y --no-install-recommends install \ - librocksdb-dev libsnappy-dev libbz2-dev libz-dev liblz4-dev \ + && apt-get -y --no-install-recommends install librocksdb-dev libsnappy-dev libbz2-dev libz-dev liblz4-dev \ && rm -rf /var/lib/apt/lists/* RUN python -m venv venv \ - && venv/bin/pip install --no-cache-dir e-x[rapidjson,rocksdb]==1.16.0 - + && venv/bin/pip install --no-cache-dir Cython==0.29.21 \ + && venv/bin/pip install --no-cache-dir e-x==1.16.0 \ + && venv/bin/pip install --no-cache-dir python-rapidjson==1.11 \ + && venv/bin/pip install --no-cache-dir python-rocksdb==0.7.0 FROM python:3.9.16-slim-bullseye # Install the libs needed by rocksdb (no development headers or statics) RUN apt-get update \ - && apt-get -y --no-install-recommends install \ - librocksdb6.11 libsnappy1v5 libbz2-1.0 zlib1g liblz4-1 \ + && apt-get -y --no-install-recommends install librocksdb6.11 libsnappy1v5 libbz2-1.0 zlib1g liblz4-1 \ && rm -rf /var/lib/apt/lists/* -ENV SERVICES="tcp://:50001" -ENV COIN=Bitcoin -ENV DB_DIRECTORY=/var/lib/electrumx -ENV DAEMON_URL="http://username:password@hostname:port/" -ENV ALLOW_ROOT=true +ENV HOME /data +ENV DB_DIRECTORY=/data +ENV SSL_CERTFILE ${DB_DIRECTORY}/electrumx.crt +ENV SSL_KEYFILE ${DB_DIRECTORY}/electrumx.key +ENV ALLOW_ROOT=1 ENV DB_ENGINE=rocksdb ENV MAX_SEND=10000000 ENV BANDWIDTH_UNIT_COST=50000 @@ -36,10 +36,13 @@ ENV CACHE_MB=2000 WORKDIR /usr/src/app COPY --from=builder /usr/src/app . -VOLUME /var/lib/electrumx - RUN mkdir -p "$DB_DIRECTORY" && ulimit -n 1048576 +VOLUME ["/data"] + +WORKDIR /data +RUN openssl req -newkey rsa:2048 -sha256 -nodes -x509 -days 365 -subj "/O=ElectrumX" -keyout electrumx.key -out electrumx.crt + CMD ["/usr/src/app/venv/bin/python", "/usr/src/app/venv/bin/electrumx_server"] # build it with eg.: `docker build -t electrumx .`