How to install your own bank and payment service - your bitcoin and lightning node

I’ve recently updated and re-installed some of my servers and bitcoin and lightning nodes that I am running. It’s amazing how easy it is to run and operate your own bank and payment service. And I encourage everybody to operate your own bitcoin full-node and lightning node. 

Even though there are plenty of resources out there on how to install everything you need on the various systems, here are a few notes on my setup. -  maybe it helps somebody. :) 

I am running currently: 

* Bitcoin core 0.17.0
* lnd 0.5.0-beta

My goal is to have my setup as simple and as default as possible. I am using the default packages where possible and I try to be able to update to latest versions quickly.
For parts of the setup I am using some custom ansible scripts which I will not cover here (ansible is rather sooner than later a pain anyway and you should not use it)

0. Install basic system packages

build-essential, git, unattended-upgrades, vim, zsh,...

make sure to secure your system: ufw, fail2ban, lynis, rkhunter

1. Install and configure bitcoind

The how-to run a full node on bitcoin.org has all the information you need to install bitcoind.

Basically installing bitcoind from the bitcoin ubuntu packages repository:

sudo apt-add-repository ppa:bitcoin/bitcoin
sudo apt-get update
sudo apt-get install bitcoind

I am running bitcoind as bitcoin user and have all the bitcoind data and config stored in the bitcoin’s home directory. 

useradd -m bitcoin
mkdir /home/bitcoin/bitcoind_data

Adjust your bitcoind configuration. You can use the config file generator by Jameson Lopp. You also find all the config options in the wiki.

This is my config file - pretty standard, except the bitcoin datadir and the zeromq config that we will need later for lnd.

This is the default bitcoin systemd service configuration. By default it is loading the bitcoin.conf from /etc/bitcoin/bitcoin.conf. Though I am also storing the config file in the bitcoin dir /home/bitcoin/bitcoind_data which makes it easier for lnd to find it.

Don’t forget to open the bitcoin port; typically 8333 (ufw allow 8333)

Now you should be able run bitcoind using systemctl 

sudo systemctl start bitcoind
sudo systemctl status bitcoind

When you want to see the logs in journalctl -u bitcoind you have to make sure that you are not running bitcoind as a daemon, change the Type in the of the systemd service from forking to simple and configure the printtoconsole bitcoind option. Otherwise it does print to console and the logs can not be captured. - But you can just look at the debug.log :)

Also note: when you update the bitcoind installation the systemd service and potentially your changes get overwritten.

2. Install and configure lnd

To run lnd you need go 1.10 or better 1.11. I’ve manually downloaded go and extracted it to /usr/lib/go-1.11/
Make sure to that you have the go binary in your $PATH. I’ve linked the go bin to /usr/local/bin 

sudo ln -s /usr/lib/go-1.11/bin/go /usr/local/bin/go

Also make sure that $GOPATH/bin is in your $PATH for all go installed executables.
I’ve added a /etc/profile.d/go.sh with:

export GOPATH=~/go
export PATH=$PATH:$GOPATH/bin

Once go is working install lnd as described here in the official installation notes. Make sure to run this from the bitcoin user as we have the default $GOPATH  ~/go .

Similar to bitcoind I have LND configured to use /home/bitcoin/lnd_data as main lnd directory. This is my lnd.conf.

If you want to access your LND node remotely (for example from a mobile app) you need to configure it to rpclisten on a public interface and the port 10009 (default) must be open.

LND needs uses zeromq to read data from bitcoind so make sure you configured bitcoind with the zeromq config mentioned above. 

And try your lnd setup:

lnd --configfile=/home/bitcoin/lnd_data/lnd.conf

It will tell you to create a wallet using lnci

lncli --lnddir=/home/bitcoin/lnd_data create

I use systemd to run lnd as a service. This is my service configuration which goes in /lib/systemd/system/lnd.service (don’t forget to systemctl enable it)
But please note that the wallet needs to be unlocked using the lncli on every start of lnd manually.

That should be it! Your bitcoin and lightning node should be up and running! Now it’s time for the fun part :)

3. Setup your client GUI

So far I have tried the following lighting apps connected with my LND node:

To connect those client to you wallet you will need the tls.cert and the admin.macaroon. These files can be found in the lnd directory:

/home/bitcoin/lnd_data/tls.cert and /home/bitcoin/lnd_data/data/chain/bitcoin/mainnet/admin.macaroon

For ZAP iOS there is zapconnect that generates a QR code that can be scanned to configure the mobile client. Union7 has a similar feature described in the FAQ.

Once connected you can use the client or the lncli to get a new bitcoin address and fund your lightning wallet.

lncli --lnddir=/home/bitcoin/lnd_data newaddress p2wkh

Now it is time to go shopping! Maybe checkout bitrefill, Y’alls or buy some pixels on satoshis.place
All those sites have instructions on how to open channels. Also have a look at explorers like 1ML

If you have trouble, let me know! 

if this did not help, maybe this write up has the right info for you