Electrs
Time: 30 minutes of work, then 12 hours to index.
The Road to Node gives you a choice between three different implementations of Electrum Server. With all three implementations you achieve the same thing, which is that you host an Electrum Server. They differ in development language, performance, and how public the servers are. Electrs differs from the rest because it is written in Rust. Performance-wise you should look up the differences between Electrum Personal Server, Electrum X and Electrs.
Electrs waits for Bitcoin Core to finish synchronizing. So you can't use Electrs until the synchronization is done.
Installation
Start by installing the dependencies.
sudo apt install -y clang cmakeInstall Rust and Cargo
curl https://sh.rustup.rs -sSf | shSource the corresponding env file
. "$HOME/.cargo/env"Make sure you are in the home directory and get Electrs in via Git.
git clone https://github.com/romanz/electrsGo into the Electrs directory.
cd electrsFinally, install Electrs with Cargo.
cargo build --locked --releaseTest if it works. The expected output is v0.10.4.
./target/release/electrs --versionConfiguration
Electrs can be configured through a configuration file. Create it with mkdir ~/.electrs && mkdir ~/.electrs/db && nano ~/.electrs/config.toml. Then paste the following into the file.
cookie_file = "/home/ubuntu/.bitcoin/.cookie"daemon_rpc_addr = "127.0.0.1:8332"daemon_p2p_addr = "127.0.0.1:8333"db_dir = "/home/ubuntu/.electrs/db"network = "bitcoin"electrum_rpc_addr = "0.0.0.0:50001"log_filters = "INFO"Save it with Ctrl + X and confirm with Y. You can check if it works with the same command as before: ./target/release/electrs. You should now see an output on your screen showing that Electrs has started indexing.
Firewall
The Electrum protocol communicates over a fixed set of ports. You can open 50001 if you want to talk to your Electrum Server using, for example, Sparrow wallet on your laptop.
sudo ufw allow 50001 comment "Port for Electrum Server"If you want to monitor Electrs remotely you also need to open 4224. This is optional.
sudo ufw allow 4224 comment "Port for monitoring Electrs"Automation
Electrs can also be automated so that it runs in the background and you don't have to start it manually. First create a service.
sudo nano /etc/systemd/system/electrs.servicePut the following text in there.
[Unit]Description=electrsRequires=bitcoind.serviceAfter=bitcoind.service[Service]WorkingDirectory=/home/ubuntu/electrsExecStart=/home/ubuntu/electrs/target/release/electrsUser=ubuntuGroup=ubuntuType=simpleRestart=on-failureTimeoutSec=120RestartSec=30[Install]WantedBy=multi-user.targetSave it with Ctrl + X and confirm with Y.
Enable and start the service with these two commands:
sudo systemctl enable electrssudo systemctl start electrsWith systemctl status electrs you can see if everything is running properly and get an output similar to the one below.
- electrs.service - electrs     Loaded: loaded (/etc/systemd/system/electrs.service; enabled; vendor preset: enabled)     Active: active (running) since Fri 2022-01-14 20:36:59 UTC; 35s ago   Main PID: 67163 (electrs)      Tasks: 20 (limit: 4203)     CGroup: /system.slice/electrs.service             67163 /home/ubuntu/electrs/target/release/electrsUpdating
Go to the application directory.
cd ~/electrsUpdate the repository with the latest changes via Git.
git fetch --allShow the latest version/tag/release.
git describe --tags `git rev-list --tags --max-count=1`Retrieve the changes from the latest release.
git checkout -f <OUTPUT FROM PREVIOUS STEP> # for example 0.10.4Install the software.
cargo build --locked --releaseRestart the Electrs service.
sudo systemctl restart electrsElectrs is now updated! You may find that during the restart - something that can take several minutes - your node can't do anything else.