Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BCA testnet support #232

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions contrib/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 .`
Expand Down
21 changes: 20 additions & 1 deletion electrumx/lib/coins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions electrumx/lib/tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down