Setup Electrs
Install an Electrum server with Electrs.
An Electrum server is an indexing layer built on top of Bitcoin Core. It enables more efficient blockchain queries and easier wallet connections. Most wallets support Electrum.
We're going to use Electrs, a Rust implementation of an Electrum Server.
Make sure Rust and Cargo are installed.
Make sure your node is 100% synchronized before proceeding.
Install Electrs
Clone the repo:
cd ~
git clone https://github.com/romanz/electrs.git
Source the env file to update your $PATH with Rust & Cargo binaries:
. "$HOME/.cargo/env"
Now you can compile electrs:
cd electrs
cargo build --locked --release
Once it's done, test the compilation was successful by checking the version:
~/electrs/target/release/electrs --version
Configure Electrs
Create the configuration file:
mkdir ~/.electrs && mkdir ~/.electrs/db && touch ~/.electrs/config.toml
Add the following configuration to the config.toml file we just created:
With the configuration below the Electrum server will be accessible only on localhost and on the Tor network. Refer to the configuration file on this page if you wish to also expose your node via IPv4/IPv6.
cookie_file = "/home/alex/.bitcoin/.cookie"
daemon_rpc_addr = "127.0.0.1:8332"
daemon_p2p_addr = "127.0.0.1:8333"
db_dir = "/home/alex/.electrs/db"
network = "bitcoin"
electrum_rpc_addr = "127.0.0.1:50001"
log_filters = "INFO"
cookie_file: Electrs can use the Bitcoin JSON-RPC API with cookie authentication.
daemon_rpc_addr: Bitcoin JSON-RPC API address and port.
daemon_p2p_addr: Bitcoin P2P address and port.
db_dir: Directory where Electrs store its index file.
electrum_rpc_addr: Electrum will run only on localhost, on port 50001.
Create Tor hidden service
We need to create a Tor hidden service to connect our wallets to the Electrum server. Edit the conf file:
sudo vim /etc/tor/torrc
Add the following:
HiddenServiceDir /var/lib/tor/electrs_hidden_service/
HiddenServicePort 50001 127.0.0.1:50001
Save it then restart tor:
sudo systemctl restart tor
Configure systemd service
Create the service file:
sudo vim /etc/systemd/system/electrs.service
Add the following:
[Unit]
Description=electrs
Requires=bitcoind.service
After=bitcoind.service
[Service]
WorkingDirectory=/home/your_user/electrs
ExecStart=/home/your_user/electrs/target/release/electrs
User=your_user
Group=your_user
Type=simple
Restart=on-failure
TimeoutSec=120
RestartSec=30
[Install]
WantedBy=multi-user.target
Line 6,7,8 and 9 make sure to replace your_user by your own user. Finally, reload systemd:
sudo systemctl daemon-reload
Startup
Configure Electrs to automatically start at boot:
sudo systemctl enable electrs.service
Start Electrs:
sudo systemctl start electrs.service
Electrum will now connect to Bitcoin Core to build its own index of the blockchain.
Indexing is in progress. This operation may take 12 to 24 hours to complete.
Monitoring
Check the logs and monitor progress in real time:
journalctl -u electrs.service -f
Last updated
Was this helpful?