Skip to content

Instantly share code, notes, and snippets.

@npodonnell
Last active January 31, 2021 11:55
Show Gist options
  • Save npodonnell/69c994700a50646c9ff1e3d410aa924f to your computer and use it in GitHub Desktop.
Save npodonnell/69c994700a50646c9ff1e3d410aa924f to your computer and use it in GitHub Desktop.
Electrs Litecoin Setup

Electrs Litecoin Setup

N. P. O'Donnell, 2021

Ubuntu instructions. More info can be found here

Install Dependencies

sudo apt update
sudo apt install clang cmake build-essential rustc cargo librocksdb-dev

Cloning / Building

Clone and select version:

git clone https://github.com/romanz/electrs.git
git tag
git checkout <latest tag> # eg. git checkout v0.8.6

Build:

cargo build --locked --release

Installing Locally

Assume the Litecoin daemon runs under a user called litecoin:

ELECTRS_DATA_DIR=/electrs-ltc # perhaps change to a directory on a faster disk
sudo mkdir -p $ELECTRS_DATA_DIR
sudo mkdir -p $ELECTRS_DATA_DIR/db
sudo chown litecoin $ELECTRS_DATA_DIR
sudo chgrp litecoin $ELECTRS_DATA_DIR
sudo -u litecoin chmod 700 $ELECTRS_DATA_DIR

Copy binary:

sudo cp target/release/electrs /usr/local/bin

Preparing Litecoin Node

Modify litecoind.conf file to set at least rpccokiefile and rpcport:

# Example litecoind.conf

rpccookiefile=/litecoin/.cookie
rpcport=9332

# Does not need to be set to 1 but it's no harm.
txindex=1

Configuring Electrs

Create a file called /electrs-ltc/electrs.toml:

# electrs.toml

network = "bitcoin" # Not a mistake. Set network to "bitcoin".
db_dir = "/electrs-ltc/db"
cookie_file = "/litecoin/.cookie"
#daemon_dir = "/litecoin" # DO NOT INCLUDE daemon_dir. Electrs doesn't like litecoind's data files.
jsonrpc_import = true
daemon_rpc_addr = "127.0.0.1:9332"
electrum_rpc_addr = "0.0.0.0:50001"
verbosity = 3

Running Electrs

Make a test run in a terminal (will cause initial sync, so perhaps run with screen or tmux):

sudo su litecoin # Switch to user litecoin first. su -u ... won't work!
cd /electrs-ltc # also required.
RUST_BACKTRACE=full electrs --conf electrs.toml -vvvv 

Running as a Systemd Service

Example Unit file:

# electrs-ltc.unit
[Unit]
Description=Electrs Litecoin
After=network.target

[Service]
ExecStart=/usr/local/bin/electrs --conf /electrs-ltc/electrs.toml
WorkingDirectory=/electrs-ltc
User=litecoin
Group=litecoin
Restart=on-failure

[Install]
WantedBy=multi-user.target

Then enable and start the service:

sudo systemctl daemon-reload
sudo systemctl enable electrs-ltc
sudo systemctl start electrs-ltc

Ensure service is running:

systemctl status electrs-ltc

Tail logs:

journalctl --follow _SYSTEMD_UNIT=electrs-ltc.service

Running Electrum-LTC

On client machine, run Electrum-LTC with only your personal server and will not allow any other server to be used:

electrum-ltc-3.3.8.1-x86_64.AppImage --oneserver --server=<hostname>:50001:t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment