Skip to content

Instantly share code, notes, and snippets.

@Engelberg
Last active October 5, 2022 18:26
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Engelberg/aac9da2f27b723683982d187bd4d5ea4 to your computer and use it in GitHub Desktop.
Save Engelberg/aac9da2f27b723683982d187bd4d5ea4 to your computer and use it in GitHub Desktop.
Installing local electrum server that relies on the bitcoin daemon inside of Samourai Dojo for its data
I am successfully running a local electrum server, getting its data from dojo. This is useful for private use of hardware wallets.
Step 1: As Laurent MT suggested in the Samourai telegram group, you need to edit the docker-compose.yaml file, adding to the bitcoind section the following two lines
ports:
- "127.0.0.1:28256:28256"
Step 2: Follow install directions for electrs, an electrum server written in rust.
electrs install directions can be found here: https://github.com/romanz/electrs/blob/master/doc/usage.md
Step 3: Change directory so you are in the electrs directory. Then, run with the following flags:
cargo run --release -- -vvv --timestamp --db-dir ./db --electrum-rpc-addr="127.0.0.1:50001" --cookie="dojorpcuser:dojorpcpassword" --daemon-rpc-addr="127.0.0.1:28256" --jsonrpc-import
Use whatever rpc user and password you configured in your own config file when setting up dojo.
It took about 12 hours on my computer for electrum to build its index.
Also on that page are instructions on how to configure your electrum client to connect only to your sever. From the command line, you'll type:
$ electrum setconfig oneserver true
$ electrum setconfig server 127.0.0.1:50001:t
The "t" in the server configuration is important, specifying a protocol between client and server that is different from the default, and I don't see a way to do it through the client UI, only through command line.
On windows, I had difficulty accomplishing this from the command line, but you can do the same thing from the console window of the client:
setconfig("oneserver", True)
setconfig("server", "127.0.0.1:50001:t")
If you want to be able to access Electrum server from a client running on another computer in your local network, you can accomplish this by changing the runtime flag --electrum-rpc-addr to use your actual private ip address rather than 127.0.0.1.
Then, when configuring the server to use in the client, you refer to the private ip address of the computer running the server.
Your private ip address likely starts with 192 or 10, and you can find it on linux with the terminal command "ip address".
@05nelsonm
Copy link

05nelsonm commented Jun 8, 2019

Step 3 has some typos:

  1. -vvv not --vvv
  2. --db-dir not --dib-dir

Also running cargo run --release -- ..... wasn't able to pickup my ~/electrs/Cargo.toml file

Might be better to run for startup:
cargo run --release --manifest-path /home/***user***/electrs/Cargo.toml -- -vvv --timestamp --db-dir ./db --electrum-rpc-addr="127.0.0.1:50001" --cookie="dojo_rpc_username:dojo_rpc_password" --daemon-rpc-addr="127.0.0.1:28256" --jsonrpc-import

But yeah, everything works! Thanks!

EDIT: figured out why cargo run --release ... was not working. I created a desktop file that didn't bash -c 'cd ~/electrus; cargo run --release ...

@Engelberg
Copy link
Author

Thanks, I have corrected the typos and made a note that you have to be in your electrs directory for the cargo run command to work.

@05nelsonm
Copy link

How large was your db/mainnet/ directory, might I ask? Mine is 50+ G...

@Engelberg
Copy link
Author

About 48g

@rider0211
Copy link

please let me know how to install electrum wallet as a daemon on windows server. please help me!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment