This article is no longer maintained. Please see the latest instructions on my github page:
https://github.com/seth586/guides/tree/master/FreeNAS
This article is part of a series:
Previous: Compile Bitcoin Core on FreeNAS
Goal:
In a previous post, we discussed how to compile bitcoind in a FreeNAS jail. Today we will discuss setting up electrum-personal-server inside that same jail.
One advantage of using electrum-personal-server instead of bitcoin core’s UI is the additional security of key signing with an external hardware wallet, such as the Trezor or Ledger Nano. As cypherpunks, we don’t trust, we verify! So ditch Ledger Live, and lets sign our bitcoin transactions in a safe hardware wallet environment, and broadcast / verify receipt of transactions with our own node!
Lets begin
Download & Configuration
SSH into your freenas box, and switch to your bitcoin_node console:
# iocage console bitcoin_node
Electrum-personal-server is on github, check for the latest release at https://github.com/chris-belcher/electrum-personal-server/releases .
# cd /usr/local
# wget https://github.com/chris-belcher/electrum-personal-server/archive/eps-v0.1.6.tar.gz
# tar xzvf eps-v0.1.6.tar.gz
# rm eps-v0.1.6.tar.gz
Lets make sure that we have the dependencies already installed.
# pkg install py36-pip python3
Lets edit our configuration file:
# cd electrum-personal-server-eps-v0.1.6
# cp config.cfg_sample config.cfg
# nano config.cfg
Now we need to add our hardware wallet’s master public keys xpub /ypub/zpub).
xpub is for P2PKH (legacy) addresses, which start with a 1
ypub is for P2SH-P2WPKH (segwit), which start with a 3
zpub is for P2WPKH, (bech32 native segwit), which start with bc1
You can find it under Electrum’s menu Wallet>Information.
You 24 word seed can generate all 3, so it might be best to put all 3 in your config.cfg file under [master-public-keys]
[master-public-keys]
wallet_legacy = xpub.....
wallet_segwit = ypub....
wallet_bech32 = zpub...
Under [bitcoin-rpc]
, change datadir = /var/db/bitcoin
Under [electrum-serever]
, change host to 0.0.0.0
to allow any incoming connections. Change ip_whitelist
to your home network subnet, for example, my router assigns IP adresses as 192.168.84.XXX, so I typed in 192.168.84.0/24
to allow connections from this range. Save and exit nano.
Install
# pip-3.6 install .
First start
# /usr/local/bin/electrum-personal-server /usr/local/electrum-personal-server-eps-v0.1.6/config.cfg
It will import addresses from each master public key. When complete, electrum-personal-server will exit. Next, if you have transaction history, look up the block height of your oldest transaction. Then, lets scan the blockchain for those historical transactions:
# /usr/local/bin/electrum-personal-server-rescan /usr/local/electrum-personal-server-eps-v0.1.6/config.cfg
Lets run it!
# /usr/local/bin/electrum-personal-server /usr/local/electrum-personal-server-eps-v0.1.6/config.cfg
Startup Script
Terminating your SSH will also terminate electrum-personal-server, so lets close it with Ctrl+C, then daemon-zie the process with a rc.d startup script:
# nano /etc/rc.d/electrumpersonalserver
Copy the following startup script to nano, (follow link to pastebin) then save and exit.
https://pastebin.com/HSFXAbLd
Lets enable our startup script:
# nano /etc/rc.conf
Add the following line, then save and exit.
electrumpersonalserver_enable=YES
You should now be able to start and stop electrumpersonalserver as a service.
# service electrumpersonalserver start
You can run ps auxww
in the command line to verify that it is running.
# service electrumpersonalserver stop
Again, verify that it sucessfully stops with ps auxww
. Go ahead and reboot your jail, and check that it is running!
Logging
The startup script uses daemon(8) to run the process in the background and forward all console messages to a log file. We don’t want that log file to grow too large, thankfully FreeBSD has a utility called newsyslog(8), configured by newsyslog.conf
# nano /etc/newsyslog.conf
Add the following line, then save and exit:
/var/log/electrumpersonalserver.log 600 1 100 * JN
Electrum Client
Now boot up your electrum client, goto Tools>Network>Server, point it at your jail’s ip:50002, it should work!