diff --git a/doc/quickstart.md b/doc/quickstart.md new file mode 100644 index 000000000..13cba9ca8 --- /dev/null +++ b/doc/quickstart.md @@ -0,0 +1,138 @@ +# 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`