Pages:
Author

Topic: [Questions] Running my own electrum server (Read 532 times)

legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
Was there such configuration file for electrumx? In the docs you linked it says that there should be different files for each environment variable. For example, it says that you'll have to create the COIN, DB_DIRECTORY and DAEMON_URL necessarily and some others optionally.

Different setup (systemd, docker and svscan) use different way to configure the environment variable.

Anyway, yes, if I understood your question correctly, docker does allow you to do that. You just need to add parameters on your script. Three posts above, @ETFbitcoin included the DONATION_ADDRESS param. You can do the same for the banner:

Code:
-e BANNER_FILE=LOCATION_OF_YOUR_BANNER_FILE

Note that the location starts from the electrumx data directory which means that if you enter BANNER_FILE=banner.txt, it'll search for /home/user/electrumx:/data/banner.txt

Yeah, that was my question.  I guess it does simplify the installation by using the docker image.  I'm just so used to systemd, and I find it simple to enable a process to run at machine startup.

Using docker is simpler (even if you barely know how to use docker), but you also need to trust lukechilds who made the docker image (unless you inspect the docker image).

But i also prefer systemd for elecrrumx, since it's easier to manage the service (enable/start/stop) and environment variable.
legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
Please share some more informations, I also wanted to start with electrum, but failed to install and run. Lets help us each other if you are also at the beginning.

1. Be more specific, what did you try and what's the problem?
2. OP already mention what he did to run electrum server

I then watched a video on YouTube which was much more simpler than with electrumx's tutorial. Thus, I discovered electrum personal server which seems a great implementation under some serious development.
legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
Honestly if the VPS use linux, you can use easy installer/docker (which i mentioned above), which is very easy to use.

I saw the docker, but I haven't ever used docker in the past for setups. Would you mind guiding me a hand? There's no steps, just a “docker run /” script.

I rarely use Docker, but here's short guide (i've tested it on my device, but don't know whether it runs on WSL)

1. Install docker

Code:
sudo apt install docker.io

2. Test whether docker run correctly

Code:
sudo docker run hello-world

If you see message "Hello from Docker!", then Docker run correctly.

3. Create directory which used to store electrumx data

Code:
cd /home/user
mkdir electrumx

4. Run this command

Code:
sudo docker run \
-v /home/user/electrumx:/data \
--net="host" \
-e DAEMON_URL=username:password@localhost \
-e COIN=Bitcoin \
-e NET=testnet \
-p 50002:50002 \
lukechilds/electrumx

Here's short explanation

1. --net="host", this command is used to ensure the container can access host port.
2. -e used to configure environment for electrumx.
3. -p HOST_PORT:CONTAINER_PORT is used to expose and link port between host and container.
4. -v HOST_DIRECTORY:CONTAINER_DIRECTORY is used to link host directory on the container.
5. lukechilds/electrumx means container we're going to use

P.S. If you want ElectrumX container to automatically start after boot, add --restart=always when you run docker.
copper member
Activity: 2338
Merit: 4543
Join the world-leading crypto sportsbook NOW!
Was there such configuration file for electrumx?

Yes, you'll find it in .../contrib/systemd/

https://github.com/spesmilo/electrumx/tree/master/contrib/systemd


In the docs you linked it says that there should be different files for each environment variable. For example, it says that you'll have to create the COIN, DB_DIRECTORY and DAEMON_URL necessarily and some others optionally.

No, all you need is one .conf file, all the environment variables can go there.  For example:

Code:
COIN = Bitcoin
DAEMON_URL = myrpcusername:myrpcpassword@localhost:port
SERVICES = tcp://my.domain.name:50001,ssl://my.domain.name:50002,rpc://
REPORT_SERVICES = tcp://myaddress.onion:50001,ssl://myaddress.onion:50002
SSL_CERTFILE = /path/to/sslcertfile.crt
SSL_KEYFILE = /path/to/sslkeyfile.key
DONATION_ADDRESS = 157v67atJjnx7Fdi2wmcBBpChugHNmDWup
BANNER_FILE = /path/to/file.banner



Anyway, yes, if I understood your question correctly, docker does allow you to do that. You just need to add parameters on your script. Three posts above, @ETFbitcoin included the DONATION_ADDRESS param. You can do the same for the banner:

Code:
-e BANNER_FILE=LOCATION_OF_YOUR_BANNER_FILE

Note that the location starts from the electrumx data directory which means that if you enter BANNER_FILE=banner.txt, it'll search for /home/user/electrumx:/data/banner.txt

Yeah, that was my question.  I guess it does simplify the installation by using the docker image.  I'm just so used to systemd, and I find it simple to enable a process to run at machine startup.
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
Does the docker method allow one to use all the same environment variables that one might enable in electumx.conf?

Was there such configuration file for electrumx? In the docs you linked it says that there should be different files for each environment variable. For example, it says that you'll have to create the COIN, DB_DIRECTORY and DAEMON_URL necessarily and some others optionally.

Anyway, yes, if I understood your question correctly, docker does allow you to do that. You just need to add parameters on your script. Three posts above, @ETFbitcoin included the DONATION_ADDRESS param. You can do the same for the banner:

Code:
-e BANNER_FILE=LOCATION_OF_YOUR_BANNER_FILE

Note that the location starts from the electrumx data directory which means that if you enter BANNER_FILE=banner.txt, it'll search for /home/user/electrumx:/data/banner.txt
copper member
Activity: 2338
Merit: 4543
Join the world-leading crypto sportsbook NOW!

I've read about the installer, but this is the first I've heard about people using docker to run electrumx.  I'm not familiar with docker, so seems like a rabbit hole of it's own.  I just use systemd to run bitcoind and electrumx.  Old dog, new tricks, and all that.

Does the docker method allow one to use all the same environment variables that one might enable in electumx.conf?
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
Thank you @ETFbitcoin. It now works like a charm.
legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
Sorry, but I hadn't noticed that the DAEMON_URL was expecting two input fields (username and password). Once I entered it correctly, it started the server.

I'd like to mention that you can change value of other parameter (such as where do you store electrumx file) or add additional environment parameter.

  • Before exposing it to the internet, I'd like to firstly try it on LAN. It seems that with the way you've described me, it works only on localhost. Do I simply change the DAEMON_URL from localhost to 192.168.x.x?
  • Can you explain a little further the last one you mentioned (container)? I don't have the electrumx files on my computer. Where does it execute the commands and from what files? Github?
  • How do I change the banner/donation address? I've created a file called "DONATION_ADDRESS" containing a legacy address as being said on electrumx's documentation, but it doesn't seem to read it.

1. AFAIK yes.
2. You should search what is docker and how docker works. Here's an article i found https://devopscube.com/what-is-docker/.
3. You need to add another parameter when run electrumx

Code:
-e DONATION_ADDRESS=YOUR_BITCOIN_ADDRESS

P.S. Those are good question, but unfortunately i'm still newbie when using Docker.
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
Update.

It works!  Cheesy


Sorry, but I hadn't noticed that the DAEMON_URL was expecting two input fields (username and password). Once I entered it correctly, it started the server. That actually happened yesterday, couple hours after my last post, but I went offline, so I couldn't inform about it.

Alright, so I have some questions to make regarding electrumx:
  • Before exposing it to the internet, I'd like to firstly try it on LAN. It seems that with the way you've described me, it works only on localhost. Do I simply change the DAEMON_URL from localhost to 192.168.x.x?
  • Can you explain a little further the last one you mentioned (container)? I don't have the electrumx files on my computer. Where does it execute the commands and from what files? Github?
  • How do I change the banner/donation address? I've created a file called "DONATION_ADDRESS" containing a legacy address as being said on electrumx's documentation, but it doesn't seem to read it.



legendary
Activity: 1512
Merit: 7340
Farewell, Leo
If you see message "Hello from Docker!", then Docker run correctly.
On the WSL I don't get it. I returns me an error instead. But don't worry, I'll setup it on my Ubuntu machine. On my Ubuntu 18.04 the hello-world works properly, but not the script you've given:


Please share some more informations, I also wanted to start with electrum, but failed to install and run. Lets help us each other if you are also at the beginning.
If you read the entire thread, you'll find the information you're searching. In a few words, I'm fumbled with the whole server thing...  Cheesy.  I feel better now that I see that I am not the only one with these issues.  Tongue

And the VPS is hardware or software or rented?
I think it's software, but I ain't completely sure. It's really cheap so I doubt if it'd be a hardware one.
newbie
Activity: 16
Merit: 0
I have been experimenting with electrum as a wallet since I learnt about bitcoin, a year ago, and I can admit that it's the simplest and most useful one. I'd like to run my own electrum server, but not for privacy reasons, just for exercise. I also have bought a Windows VPS that isn't being used at the moment, so why not providing it to the electrum community?

I picked electrumx, because it's the most popular implementation. It seems that I can't install it on windows, only on unix. The thing is that I don't have an Ubuntu installed right now. Could this work with Windows 10 on an Ubuntu LTS?

Other questions too:
  • Is the same procedure if I want to run a testnet server? I don't have the storage for downloading the entire blockchain.
  • How does it return the balance of address(es) instantly? On Bitcoin Core it has to rescan the blockchain (which will take a lot of time).
  • Will I be shown on others' network servers? If no, how can I be shown?

Hello,

Please share some more informations, I also wanted to start with electrum, but failed to install and run. Lets help us each other if you are also at the beginning.
And the VPS is hardware or software or rented? Because I heard that is possible, personally I didnt saw such a witchcraft Smiley))
Thanks!
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
Honestly if the VPS use linux, you can use easy installer/docker (which i mentioned above), which is very easy to use.

I saw the docker, but I haven't ever used docker in the past for setups. Would you mind guiding me a hand? There's no steps, just a “docker run /” script.
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
oh man... if I had known you just wanted a little local Electrum server... I would have recommended electrs Tongue I thought you were trying to get your own public facing Electrum server up and running.  Roll Eyes
I do. I just wanted to firstly setup a personal server. Running a server publicly is secondary.

The problem with electrumx is that I still haven't understood how it works. For example, on electrum-personal-server, you're starting the server with electrum-personal-server config.ini. With what file do you start electrumx? service/electrumx?

The tutorial doesn't tell you much. It just says "run that command, then another command etc.". Where's the explanation? How am I supposed to know what does that do and from what directory should I run it?:
Code:
systemctl start electrumx

This is what it returns me when I execute the above command:
Code:
angelo@angelopc:~/Desktop/electrumx$ systemctl start electrumx
Warning: The unit file, source configuration file or drop-ins of electrumx.service changed on disk. Run 'systemctl daemon-reload' to reload units.
Job for electrumx.service failed because of unavailable resources or another system error.
See "systemctl status electrumx.service" and "journalctl -xe" for details.

And then with systemctl status electrumx.service (as it's been said in the error):
Code:
angelo@angelopc:~/Desktop$ systemctl status electrumx.service
● electrumx.service - Electrumx
   Loaded: loaded (/etc/systemd/system/electrumx.service; disabled; vendor prese
   Active: failed (Result: resources)

Aπρ 30 15:21:48 angelopc systemd[1]: electrumx.service: Failed with result 'reso
Aπρ 30 15:21:48 angelopc systemd[1]: Failed to start Electrumx.
Aπρ 30 15:21:53 angelopc systemd[1]: electrumx.service: Failed to load environme
Aπρ 30 15:21:53 angelopc systemd[1]: electrumx.service: Failed to run 'start' ta
Aπρ 30 15:21:53 angelopc systemd[1]: electrumx.service: Failed with result 'reso
Aπρ 30 15:21:53 angelopc systemd[1]: Failed to start Electrumx.
Aπρ 30 15:22:14 angelopc systemd[1]: electrumx.service: Failed to load environme
Aπρ 30 15:22:14 angelopc systemd[1]: electrumx.service: Failed to run 'start' ta
Aπρ 30 15:22:14 angelopc systemd[1]: electrumx.service: Failed with result 'reso
Aπρ 30 15:22:14 angelopc systemd[1]: Failed to start Electrumx.

(Aπρ is Apr on my lang)



As I said, I have a VPS left over and I'd like to "donate" its operation to the electrum community instead of having it shut down. I also like practicing in this field. I'd have probably given up with this setup, but it seems that I'm a stubborn...
legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
So, I just switched to EPS. I didn't fix electrumx. I may formulated it wrongly, but "fixed" goes to my main purpose, which is running electrum without trusting anyone. I achieved it, thank you for your help.  Smiley

As long as you accomplish your goal Roll Eyes

But if you want to use electrumx to make Electrum server which is publicly accessible, you can consider,
1. Easy installer, https://github.com/bauerj/electrumx-installer. Although i don't know how well it works.
2. Docker, https://github.com/lukechilds/docker-electrumx
3. Setup with systemd, https://electrumx-spesmilo.readthedocs.io/en/latest/HOWTO.html#using-systemd
HCP
legendary
Activity: 2086
Merit: 4361
oh man... if I had known you just wanted a little local Electrum server... I would have recommended electrs Tongue I thought you were trying to get your own public facing Electrum server up and running.  Roll Eyes

I have successfully had electrs running under WSL+Ubuntu (reading a Windows based Bitcoin data directory and connecting to it from Windows based Electrum)... it works a treat and has a relatively small footprint. It "syncs" relatively quickly if it's been offline for a few days, although the initial build+initial sync process can take a while.
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
I didn't fix it. I don't know why it didn't work, but I was feeling a little alienated after all those tries. I then watched a video on YouTube which was much more simpler than with electrumx's tutorial. Thus, I discovered electrum personal server which seems a great implementation under some serious development.

So, I just switched to EPS. I didn't fix electrumx. I may formulated it wrongly, but "fixed" goes to my main purpose, which is running electrum without trusting anyone. I achieved it, thank you for your help.  Smiley
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
Thank you for your time!

9.  Start svscan

If you can't have multiple terminal run this instead

Code:
cd /home/user/Desktop/electrumx
svscan ./service & disown

I have an issue with svscan Fixed. I'm now running electrum-personal-server.
legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
In the end, i decided to try setup electrumx from scratch and i think successfully setup it based on the log file.

Code:
Launching ElectrumX server...
INFO:electrumx:ElectrumX server starting
INFO:electrumx:logging level: INFO
INFO:Controller:Python version: 3.8.7 (default, Jan 31 2021, 21:48:01)  [GCC 10.2.1 20201224]
INFO:Controller:software version: ElectrumX 1.16.0
INFO:Controller:aiorpcX version: 0.18.7
INFO:Controller:supported protocol versions: 1.4-1.4.2
INFO:Controller:event loop policy: None
INFO:Controller:reorg limit is 8,000 blocks
INFO:Daemon:daemon #1 at localhost:18332/ (current)
INFO:DB:switching current directory to /home/user/Desktop/electrumx/DB
INFO:DB:using leveldb for DB backend
INFO:DB:created new database
INFO:DB:creating metadata directory
INFO:DB:UTXO DB version: 8
INFO:DB:coin: Bitcoin
INFO:DB:network: testnet
INFO:DB:height: -1
INFO:DB:tip: 0000000000000000000000000000000000000000000000000000000000000000
INFO:DB:tx count: 0
INFO:DB:flushing DB cache at 1,200 MB
INFO:DB:sync time so far: 00s
INFO:History:history DB version: 1
INFO:History:flush count: 0
INFO:Prefetcher:catching up to daemon height 1,973,091 (1,973,092 blocks behind)
INFO:Prefetcher:verified genesis block with hash 000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943
INFO:BlockProcessor:our height: 9 daemon: 1,973,091 UTXOs 0MB hist 0MB
INFO:BlockProcessor:our height: 104,142 daemon: 1,973,091 UTXOs 58MB hist 111MB



This is how i do it. Hopefully i don't forget any step or copy wrong command

1. Install daemontools

Code:
sudo apt install daemontools

2. Move to proper path

Code:
cd ~/Desktop
git clone https://github.com/kyuupichan/electrumx.git
cd electrumx

3. Configure Python virtual environment (optional)

Code:
python3.8 -m venv .venv
source .venv/bin/activate
mkdir ./DB

4. Install electrumx (i think it's optional)

Code:
pip install .

5. Create directory service

Code:
mkdir ./service

6. Copy the daemontools script

Code:
mkdir -p ./scripts/electrumx
cp -R ./contrib/daemontools ./scripts/electrumx

7. Configure ENV. Make sure to read this guide https://electrumx.readthedocs.io/en/latest/environment.html#environment

Code:
cd ./scripts/electrumx/daemontools/env
nano DB_DIRECTORY

Here's value i used

Code:
FILENAME=VALUE

COIN=BITCOIN
DAEMON_URL=USERNAME:PASSWORD@LOCALHOST
DB_DIRECTORY=/home/user/Desktop/electrum/DB
NET=TESTNET
ELECTRUMX=/home/user/Desktop/electrumx/.venv/bin/electrumx_server
USERNAME=user

8. Configure log path. Change /path/to/log/dir to /home/user/Desktop/electrumx/scripts/electrumx/daemontools/log

Code:
cd /home/user/Desktop/electrumx/scripts/electrumx/daemontools
nano run

9.  Start svscan

Code:
cd /home/user/Desktop/electrumx
svscan ./service

If you can't have multiple terminal run this instead

Code:
cd /home/user/Desktop/electrumx
svscan ./service & disown

10. Add the service

Code:
cd /home/user/Desktop/electrumx/service
ln -s /home/user/Desktop/electrumx/scripts/electrumx/daemontools electrumx

11. To see output from Electrum

Code:
cd /home/user/Desktop/electrumx/scripts/electrumx/daemontools/log
tail current

P.S. It's very complicated compared with setup for systemd system or using docker (https://github.com/lukechilds/docker-electrumx).
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
Sorry, i made a mistake, it's been some time since i tried electrumx and not familiar with daemontools (usually i use systemd).
If you're using an implementation of the server that has a simpler tutorial, feel free to give me a link please! The problem with systemd is that I get this:
Code:
angelo@DESKTOP-5QOEJVC:~/electrumx$ systemctl start electrumx
System has not been booted with systemd as init system (PID 1). Can't operate.

sudo affect how you run Electrum with daemontools, not where environment file is locate
I meant that I'm running the commands from “angelo”, which is the main user probably.

How do run electrumx? Simply by typing electrumx_server? If yes, i think that's the problem since you're following guide to configure/run electrum with daemontools.
I don't understand. Should there be a command for daemontools that will start the electrumx server? The only thing that is mentioned about those tools is this:  https://github.com/spesmilo/electrumx/blob/master/docs/HOWTO.rst#using-daemontools
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
Code:
/mnt/e/p2p/BTC/AppData/testnet

Thanks for that, but it seems that something else goes wrong, because I still get the same error. I reads that I haven't set a DB_DIRECTORY while I do have on scripts\electrumx\daemontools\env.
Pages:
Jump to: