Installing Electrs ontop of Dojo
A guide on how to utilize your Dojo backend with Electrs Private Server to connect hardware devices (i.e Trezor, Cold Card, Ledger) to your own Full Dojo node completely over Tor.
Prep Dojo
In order to connect to External Apps via RPC (like Electrs, Explorer, and LND) you'll need to modify the default settings of your Dojo.
You must be on Dojo v1.2 to not produce errors.
You Dojo is now ready to connect to external apps.
Getting Started
Electrs is a unique build of ElectrumX server as it is written in Rust language and much more efficient on your resources. So first let's install Rust:
If you'd like to few this script and verify its source. Go to https://doc.rust-lang.org/1.0.0/book/installing-rust.html
Now, lets set up the environment so we can properly install:
Next we need to get clang in order for rust to build the rust-rocksdb
Now we have the required tools to build electrs. Let's pull the code:
Now this is going to take some time. If you get an error at the end, re-enter the environment comment from above ($ source $HOME/.cargo/env) and run again.
Now in a new window we can start prepping the database
Note: This recommended to be on your external device your dojo is set up on. You can expect the full index to be around 40-50GB.
Once the install of Electrs is complete, before we run it. Let's go ahead and create our config.toml file.
Lock down the port 50001 via UFW (even tho we will be connecting thru Tor, best to lock it down)
Start Electrs
Important to note that you must enable external apps in your Dojo bitcoin.conf file. Unless you are utilizing your Dojo's RPC via Local LAN, ie from Pi to Laptop, you can keep the IP address as 127.0.0.1 . However, if you are using other apps on your Local LAN, you'll need to substitute the above IP with the IP of your RPi4.
If you get errors, enter Ctrl+C and enter the following:
Now that is going to take awhile to sync. So lets setup tor as a service outside the docker. (Guide credit: https://github.com/s2l1/Headless-Samourai-Dojo/blob/master/README.md#8-tor)
In order to verify the integrity of the Tor files, download and add the signing keys of the torproject using the network certificate management service (dirmngr).
Create a new user for Tor
The latest version of Tor can now be installed. While not required, tor-arm provides a dashboard that you might find useful.
edit the torrc
Check the onion address of your new hidden service
Install Electrum on Host device by following the steps at: https://electrum.org/#download
Now that Electrum is downloaded on your host device we are going to set it up to connect thru Tor (so if you don't have tor or tor browser set up do that now) Note: If you use tor browser the Port is 9051, tor service is 9050.
Once Electrum is downloaded it is important to make sure you are in the right env and PATH so the commands work properly:
Start electrum with the Tor Browser open (proxy on port 9150)
With Tor installed and running (proxy on port 9050):
"If you try to connect to Electrs before the index is complete, it will not appear to be connecting. You MUST wait for index to be complete before Electrs will allow for Electrum to connect. This took me about 8ish hours on my Pi4."
Credits
Heavily utilized the guides provided by:
openoms @ https://github.com/openoms/bitcoin-tutorials/tree/master/electrs
Romanz @ https://github.com/romanz/electrs
And bit shout out to the Dojo Telegram who helped along the way. Join the group at https://t.me/samourai_dojo
DM me on Twitter: @BTCxZelko or Telegram @BTCxZelko if you have any questions.
Last updated