Electrs is a replacement for a Fulcrum, these two services cannot be run at the same time (due to the same standard ports used), remember to stop or uninstall Fulcrum by doing "sudo systemctl stop fulcrum".
Install dependencies
With user admin, update the packages and upgrade to keep up to date with the OS
$sudoaptupdate&&sudoaptfull-upgrade
Make sure that all necessary software packages are installed
Compile it. This could take time depending on your system performance, be patient
$makeshared_lib-j$(nproc)
Expected output ⬇️
$DEBUG_LEVEL is 0
$DEBUG_LEVEL is 0
CC cache/cache.o
CC cache/cache_entry_roles.o
CC cache/cache_key.o
CC cache/cache_reservation_manager.o
CC cache/charged_cache.o
CC cache/clock_cache.o
CC cache/fast_lru_cache.o
CC cache/lru_cache.o
CC cache/compressed_secondary_cache.o
CC cache/sharded_cache.o
CC db/arena_wrapped_db_iter.o
CC db/blob/blob_contents.o
CC db/blob/blob_fetcher.o
CC db/blob/blob_file_addition.o
CC db/blob/blob_file_builder.o
CC db/blob/blob_file_cache.o
CC db/blob/blob_file_garbage.o
[...]
Update the shared library cache. Wait until the prompt comes back to show
$sudoldconfig
Come back to the /tmp folder
$cd..
Delete rocksdb folder
$sudorm-rrocksdb
Check if you already have Rustc installed
$rustc--version
Expected output:
> rustc 1.71.0 (8ede3aae2 2023-07-12)
And cargo installed
$cargo-V
Expected output:
> cargo 1.71.0 (cfd3bbd8f 2023-06-08)
If you obtain "command not found" outputs, you need to follow the Rustup + Cargo bonus section to install it and then come back to continue with the guide
Reverse proxy & Firewall
In the Security section, we already set up Nginx as a reverse proxy. Now we can add the Electrs configuration.
With user admin, create the reverse proxy configuration
To avoid using bad source code, verify that the release has been properly signed by the main developer Roman Zeyde
$curlhttps://romanzey.de/pgp.txt|gpg--import
Expected output:
> % Total % Received % Xferd Average Speed Time Time Time Current
> Dload Upload Total Spent Left Speed
> 100 1255 100 1255 0 0 3562 0 --:--:-- --:--:-- --:--:-- 3555
> gpg: key 87CAE5FA46917CBB: public key "Roman Zeyde <[email protected]>" imported
> gpg: Total number processed: 1
> gpg: imported: 1
Verify the release
$gitverify-tagv$VERSION
Expected output:
> gpg: Signature made Thu 03 Nov 2022 03:37:23 PM UTC
> gpg: using ECDSA key 15C8C3574AE4F1E25F3F35C587CAE5FA46917CBB
> gpg: issuer "[email protected]"
> gpg: from "Roman Zeyde <[email protected]>" [unknown]
> gpg: aka "Roman Zeyde <[email protected]>" [unknown]
> gpg: WARNING: This key is not certified with a trusted signature!
> gpg: There is no indication that the signature belongs to the owner.
> Primary key fingerprint: 15C8 C357 4AE4 F1E2 5F3F 35C5 87CA E5FA 4691 7CBB
Now compile the source code into an executable binary
Prepare "electrs" monitoring by the systemd journal and check log logging output. You can exit monitoring at any time with Ctrl-C
$ journalctl -f -u electrs
Run
To keep an eye on the software movements, start your SSH program (eg. PuTTY) a second time, connect to the MiniBolt node, and log in as admin. Commands for the second session start with the prompt $2 (which must not be entered).
Start the service
$2 sudo systemctl start electrs
Monitor the systemd journal at the first session created to check if everything works fine
Example of expected output on the first terminal with $ journalctl -f -u electrs ⬇️
Starting electrs on x86_64 linux with Config { network: Bitcoin, db_path: "/data/electrs/db/bitcoin", daemon_dir: "/data/bitcoin", daemon_auth: CookieFile("/data/bitcoin/.cookie"), daemon_rpc_addr: 127.0.0.1:8332, daemon_p2p_addr: 127.0.0.1:8333, electrum_rpc_addr: 0.0.0.0:50001, monitoring_addr: 127.0.0.1:4224, wait_duration: 10s, jsonrpc_timeout: 15s, index_batch_size: 10, index_lookup_limit: None, reindex_last_blocks: 0, auto_reindex: true, ignore_mempool: false, sync_once: false, disable_electrum_rpc: false, server_banner: "Welcome to electrs (Electrum Rust Server) running on a MiniBolt node!", args: [] }
[2021-11-09T07:09:42.744Z INFO electrs::metrics::metrics_impl] serving Prometheus metrics on 127.0.0.1:4224
[2021-11-09T07:09:42.744Z INFO electrs::server] serving Electrum RPC on 0.0.0.0:50001
[2021-11-09T07:09:42.812Z INFO electrs::db] "/data/electrs/db/bitcoin": 0 SST files, 0 GB, 0 Grows
[2021-11-09T07:09:43.174Z INFO electrs::index] indexing 2000 blocks: [1..2000]
[2021-11-09T07:09:44.665Z INFO electrs::chain] chain updated: tip=00000000dfd5d65c9d8561b4b8f60a63018fe3933ecb131fb37f905f87da951a, height=2000
[2021-11-09T07:09:44.986Z INFO electrs::index] indexing 2000 blocks: [2001..4000]
[2021-11-09T07:09:46.191Z INFO electrs::chain] chain updated: tip=00000000922e2aa9e84a474350a3555f49f06061fd49df50a9352f156692a842, height=4000
[2021-11-09T07:09:46.481Z INFO electrs::index] indexing 2000 blocks: [4001..6000]
[2021-11-09T07:09:47.581Z INFO electrs::chain] chain updated: tip=00000000dbbb79792303bdd1c6c4d7ab9c21bba0667213c2eca955e11230c5a5, height=6000
[2021-11-09T07:09:46.481Z INFO electrs::index] indexing 2000 blocks: [6001..8000]
[2021-11-09T07:09:47.581Z INFO electrs::chain] chain updated: tip=00000000dbbb79792303bdd1c6c4d7ab9c21bba0667213c2eca955e11230c5a6, height=8000
[2021-11-09T07:09:46.481Z INFO electrs::index] indexing 2000 blocks: [8001..10000]
[2021-11-09T07:09:47.581Z INFO electrs::chain] chain updated: tip=00000000dbbb79792303bdd1c6c4d7ab9c21bba0667213c2eca955e11230c5a7, height=10000
[...]
[2021-11-09T07:09:46.481Z INFO electrs::index] indexing 65 blocks: [756001..756065]
[2021-11-09T07:09:47.581Z INFO electrs::chain] chain updated: tip=00000000dbbb79792303bdd1c6c4d7ab9c21bba0667213c2eca955e11230c510, height=756065
[2021-11-09T07:09:47.581Z INFO electrs::db] starting config compaction
[2021-11-09T07:09:47.581Z INFO electrs::db] starting headers compaction
[2021-11-09T07:09:47.581Z INFO electrs::db] starting txid compaction
[2021-11-09T07:09:47.581Z INFO electrs::db] starting funding compaction
[2021-11-09T07:09:47.581Z INFO electrs::db] starting spending compaction
[...]
Electrs will now index the whole Bitcoin blockchain so that it can provide all necessary information to wallets. With this, the wallets you use no longer need to connect to any third-party server to communicate with the Bitcoin peer-to-peer network
Ensure electrs service is working and listening at the default TCP 50001 port, the monitoring 14224 port (not used on MiniBolt) and
Electrs must first fully index the blockchain and compact its database before you can connect to it with your wallets. This can take a few hours. Only proceed with the next section once Electrs is ready
Extras (optional)
Remote access over Tor
To use your Electrum server when you're on the go, you can easily create a Tor hidden service. This way, you can connect the BitBoxApp or Electrum wallet remotely, or even share the connection details with friends and family. Note that the remote device needs to have Tor installed as well.
Ensure that you are logged in with the user admin, edit the torrc file
$ sudo nano /etc/tor/torrc
Add the following lines in the "location hidden services" section, below "## This section is just for location-hidden services ##" in the torrc file. Save and exit
You should now be able to connect to your Electrs server remotely via Tor using your hostname and port 50002 (SSL) or 50001 (TCP)
Migrate BTC RPC Explorer to Electrs API connection
To get address balances, either an Electrum server or an external service is necessary. Your local Electrs server can provide address transaction lists, balances, and more.
When you finish, restart Electrs to apply the new version
$ sudo systemctl restart electrs
Check logs and pay attention to the next log if that attends to the new version installed
$ journalctl -fu electrs
Example of expected output ⬇️
Starting electrs 0.10.0 on x86_64 linux with Config { network: Bitcoin, db_path: "/data/electrs/db/bitcoin", daemon_dir: "/data/bitcoin", daemon_auth: CookieFile("/data/bitcoin/.cookie"), daemon_rpc_addr: 127.0.0.1:8332, daemon_p2p_addr: 127.0.0.1:8333, electrum_rpc_addr: 0.0.0.0:50001, monitoring_addr: 127.0.0.1:4224, wait_duration: 10s, jsonrpc_timeout: 15s, index_batch_size: 10, index_lookup_limit: None, reindex_last_blocks: 0, auto_reindex: true, ignore_mempool: false, sync_once: false, disable_electrum_rpc: false, server_banner: "Welcome to electrs (Electrum Rust Server) running on a MiniBolt node!", args: [] }
[2021-11-09T07:09:42.744Z INFO electrs::metrics::metrics_impl] serving Prometheus metrics on 127.0.0.1:4224
[2021-11-09T07:09:42.744Z INFO electrs::server] serving Electrum RPC on 0.0.0.0:50001
[2021-11-09T07:09:42.812Z INFO electrs::db] "/data/electrs/db/bitcoin": 0 SST files, 0 GB, 0 Grows
[2021-11-09T07:09:43.174Z INFO electrs::index] indexing 2000 blocks: [1..2000]
[2021-11-09T07:09:44.665Z INFO electrs::chain] chain updated: tip=00000000dfd5d65c9d8561b4b8f60a63018fe3933ecb131fb37f905f87da951a, height=2000
[2021-11-09T07:09:44.986Z INFO electrs::index] indexing 2000 blocks: [2001..4000]
[2021-11-09T07:09:46.191Z INFO electrs::chain] chain updated: tip=00000000922e2aa9e84a474350a3555f49f06061fd49df50a9352f156692a842, height=4000
[2021-11-09T07:09:46.481Z INFO electrs::index] indexing 2000 blocks: [4001..6000]
[2021-11-09T07:09:47.581Z INFO electrs::chain] chain updated: tip=00000000dbbb79792303bdd1c6c4d7ab9c21bba0667213c2eca955e11230c5a5, height=6000
[2021-11-09T07:09:46.481Z INFO electrs::index] indexing 2000 blocks: [6001..8000]
[2021-11-09T07:09:47.581Z INFO electrs::chain] chain updated: tip=00000000dbbb79792303bdd1c6c4d7ab9c21bba0667213c2eca955e11230c5a6, height=8000
[2021-11-09T07:09:46.481Z INFO electrs::index] indexing 2000 blocks: [8001..10000]
[2021-11-09T07:09:47.581Z INFO electrs::chain] chain updated: tip=00000000dbbb79792303bdd1c6c4d7ab9c21bba0667213c2eca955e11230c5a7, height=10000
[...]
[2021-11-09T07:09:46.481Z INFO electrs::index] indexing 65 blocks: [756001..756065]
[2021-11-09T07:09:47.581Z INFO electrs::chain] chain updated: tip=00000000dbbb79792303bdd1c6c4d7ab9c21bba0667213c2eca955e11230c510, height=756065
[2021-11-09T07:09:47.581Z INFO electrs::db] starting config compaction
[2021-11-09T07:09:47.581Z INFO electrs::db] starting headers compaction
[2021-11-09T07:09:47.581Z INFO electrs::db] starting txid compaction
[2021-11-09T07:09:47.581Z INFO electrs::db] starting funding compaction
[2021-11-09T07:09:47.581Z INFO electrs::db] starting spending compaction
[...]
Uninstall
Uninstall service & user
Ensure you are logged in with the user admin, stop, disable, and delete the service
$ sudo systemctl stop electrs
$ sudo systemctl disable electrs
$ sudo rm /etc/systemd/system/electrs.service
Ensure you are logged in with the user admin. Delete the electrs user.
Don't worry about userdel: electrs mail spool (/var/mail/electrs) not found output, the uninstall has been successful
$ sudo userdel -rf electrs
Delete electrs directory
$ sudo rm -rf /data/electrs/
Uninstall Tor hidden service
Ensure that you are logged in with the user admin , edit the torrc config file
$ sudo nano /etc/tor/torrc
Delete or comment on the following lines in the "location hidden services" section, below "## This section is just for location-hidden services ##" in the torrc file. Save and exit