ElectrumX server as a Tor hidden service

0

I am trying to run an ElectrumX server on my PC. I run it on a docker container with the following Dockerfile configuration:

FROM python:3.7-alpine3.11
LABEL maintainer="Luke Childs <lukechilds123@gmail.com>"

COPY ./bin /usr/local/bin
COPY ./VERSION /tmp

RUN VERSION=$(cat /tmp/VERSION) && \
    chmod a+x /usr/local/bin/* && \
    apk add --no-cache git build-base openssl && \
    apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.11/main leveldb-dev && \
    apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing rocksdb-dev && \
    pip install aiohttp pylru plyvel websockets python-rocksdb && \
    git clone -b $VERSION https://github.com/kyuupichan/electrumx.git && \
    cd electrumx && \
    python setup.py install && \
    apk del git build-base && \
    rm -rf /tmp/*

VOLUME ["/data"]
ENV HOME /data
ENV ALLOW_ROOT 1
ENV DB_DIRECTORY /data
ENV SERVICES=tcp://:50001,ssl://:50002,wss://:50004,rpc://0.0.0.0:8000
ENV SSL_CERTFILE ${DB_DIRECTORY}/electrumx.crt
ENV SSL_KEYFILE ${DB_DIRECTORY}/electrumx.key
ENV HOST ""
WORKDIR /data

EXPOSE 50001 50002 50004 8000

CMD ["init"]

I want to advertise the ElectrumX server as a Tor hidden server. My bitcoin-core is also reachable by an .onion address: j3zla562edof65jn.onion. How can I configure the ElectrumX hidden server? What will be the .onion address of the server? I cannot access the ElectrumX from my electrum client using j3zla562edof65jn.onion address. Also, the status of the server is Closed in the Servers list.

Many Thanks.

Taghi

Posted 2020-07-20T14:01:50.870

Reputation: 11

Answers

0

I found the answer. It was not too hard. You should make a separate Tor hidden service for the ElectrumX server. The following two links helped me:

To create a hidden service, you should take the following steps:

  1. You must have tor (at least version 0.2.7.1) installed on your host. You don't need to install it on the docker container.
  2. To establish a hidden service, open torcc file (probably you can find it at /etc/tor/torrc). Add these lines to the file:
HiddenServiceDir /var/lib/tor/electrumX_service/
HiddenServiceVersion 2
HiddenServicePort 50001 127.0.0.1:50001
HiddenServicePort 50002 127.0.0.1:50002
  1. Restart tor by running this command: sudo service tor restart
  2. To see the hostname of the new hidden service (electrumX_service), run sudo cat /var/lib/tor/electrumX_service/hostname. you will see the hostname. For example, my hostname is dpojvtzgm5dcg5ds.onion.
  3. Now, you should set the REPORT_SERVICES environment variable in the ElectrumX container. To do this, you can set it at the beginning, when you want to run the container. I use the following command to run the container: (use the recently created hostname address for the REPORT_SERVICES environment variable.)
docker run --name=electrumx --rm --network=host -v /home/taghi/Taghi/docker-electrumx/electrumx:/data \
-e DAEMON_URL=http://MY_BITCOIN_CORE_USERNAME:MY_BITCOIN_CORE_PASSWORD@127.0.0.1:8332 \
-e COIN=BitcoinSegwit \
-e REPORT_SERVICES=tcp://dpojvtzgm5dcg5ds.onion:50001,ssl://dpojvtzgm5dcg5ds.onion:50002 \
lukechilds/electrumx
  1. you can connect to the ElectrumX server by an Electrum client to check if it is working correctly. Furthermore, you can add it to this Server list .

Remember: I have exposed 50001, 50002, 50004, and 8000 ports in the above Dockerfile.

Taghi

Posted 2020-07-20T14:01:50.870

Reputation: 11