From fe75ab0d0e7c44a9c8971a9f491f0696446c47bb Mon Sep 17 00:00:00 2001 From: k3tan172 <44537874+k3tan172@users.noreply.github.com> Date: Mon, 1 Nov 2021 19:20:25 +1100 Subject: [PATCH 1/2] Creating the quickstart guide Electrs is an incredibly critical piece of software and requires a quick and easy way to get up and running. I have written this guide for beginners hoping others can use it. Feedback welcome. --- doc/quickstart.md | 139 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 doc/quickstart.md diff --git a/doc/quickstart.md b/doc/quickstart.md new file mode 100644 index 000000000..16b7be2f8 --- /dev/null +++ b/doc/quickstart.md @@ -0,0 +1,139 @@ +# The Quick Start Guide to Electrum Rust Server + +### Prepare bitcoind + +In your bitcoin.conf (usually sitting in /home/username/.bitcoin) ensure you have the following: +``` +rpcallowip=127.0.0.1 +rpcallowip=10.0.0.0/8 +rpcallowip=172.0.0.0/8 +rpcallowip=192.0.0.0/8 +rpcuser=bitcoin +rpcpassword=bitcoin +whitelist=127.0.0.1 +whitelist=download@127.0.0.1 +``` +Note: Be sure to restart your bitcoind instance for changes to take effect. +Your rpcuser and rpcpassword can be set to whatever you want, I've used bitcoin/bitcoin here. + + +### Prepare system to build electrs + +``` +sudo apt update +sudo apt install clang cmake build-essential +``` + +### Install latest version of Rust + +`curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh` + +### Download electrs + +In your home directory, download the electrs github repository and change directory into it. + +`cd ~` +`git clone https://github.com/romanz/electrs` +`cd electrs` + +### Build electrs + +`cargo build --locked --release` + +Wait a while, can take some time. + +### Configure electrs + +In the ~/electrs/doc folder, there is a config_example.toml file. We need to copy that into the electrs folder and rename it to electrs.toml. This can be done by: + +`cp ~/electrs/doc/config_example.toml ~/electrs/electrs.toml` + +Now we need to edit the electrs.toml file in the ~electrs directory. + +`nano ~/electrs/electrs.toml` + +Take a look at the one below, make the necessary adjustments to username/password/db directory/electrum_rpc_address. Notice I've changed `cookie_file` it to `auth = bitcoin:bitcoin` + +``` +# DO NOT EDIT THIS FILE DIRECTLY - COPY IT FIRST! +# If you edit this, you will cry a lot during update and will not want to live anymore! + +# This is an EXAMPLE of how configuration file should look like. +# Do NOT blindly copy this and expect it to work for you! +# If you don't know what you're doing consider using automated setup or ask an experienced friend. + +# This example contains only the most important settings. +# See docs or electrs man page for advanced settings. + +# File where bitcoind stores the cookie, usually file .cookie in its datadir +auth = "bitcoin:bitcoin" + +# The listening RPC address of bitcoind, port is usually 8332 +daemon_rpc_addr = "127.0.0.1:8332" + +# The listening P2P address of bitcoind, port is usually 8333 +daemon_p2p_addr = "127.0.0.1:8333" + +# Directory where the index should be stored. It should have at least 70GB of free space. +db_dir = "/home/username/electrs/db" + +# bitcoin means mainnet. Don't set to anything else unless you're a developer. +network = "bitcoin" + +# The address on which electrs should listen. Warning: 0.0.0.0 is probably a bad idea! +# Tunneling is the recommended way to access electrs remotely. +electrum_rpc_addr = "0.0.0.0:50001" + +# How much information about internal workings should electrs print. Increase before reporting a bug. +verbose = 2 +``` + +### Run electrs for the first time + +`cd ~/electrs` +`./target/release/electrs` + +Electrs should connect successfully to your bitcoind and start creating an index of all transactions in the db_dir you nominated in the electrs.toml file. It will take a while. Let it run. There will be lots of logs being created in your terminal. + +You can stop at any time by pressing CTRL+C. + +### Autostart on boot + +First create the service file +`sudo nano /etc/systemd/system/electrs.service` + +Copy and paste the below. Edit the 'username' accordingly. + +``` + +[Unit] +Description=Electrs +After=bitcoind.service + +[Service] +WorkingDirectory=/home/username/electrs +ExecStart=/home/username/electrs/target/release/electrs +User=username +Group=username +Type=simple +KillMode=process +TimeoutSec=60 +Restart=always +RestartSec=60 + +[Install] +WantedBy=multi-user.target +``` +CTRL+X then Y then ENTER to save and exit. + +`sudo systemctl enable electrs` +`sudo systemctl start electrs` + + +### Upgrading + +`cd ~/electrs` +`git pull origin master` +`sudo systemctl stop electrs` +`cargo build --locked --release` +`sudo systemctl start electrs` From 69454cc569f4f76c8cbd96b5425b700d2ecb5667 Mon Sep 17 00:00:00 2001 From: k3tan172 <44537874+k3tan172@users.noreply.github.com> Date: Mon, 1 Nov 2021 12:29:15 +0000 Subject: [PATCH 2/2] Update doc/quickstart.md Co-authored-by: Roman Zeyde --- doc/quickstart.md | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/quickstart.md b/doc/quickstart.md index 16b7be2f8..13cba9ca8 100644 --- a/doc/quickstart.md +++ b/doc/quickstart.md @@ -105,7 +105,6 @@ First create the service file Copy and paste the below. Edit the 'username' accordingly. ``` - [Unit] Description=Electrs After=bitcoind.service