Lightning Node
In this section we'll install LND, the Lightning Network Daemon. We'll install the various files in accordance with the Filesystem Hierarchy Standard (FHS) discussed earlier.
These are the files and directories we'll be using for LND:
/etc/lnd.conf Configuration
/etc/systemd/system/lnd.service System service
/var/lib/lnd LND data
/usr/local/bin Symlinks to binaries
/usr/local/lib/lnd Installed LND versions
From the Terminal program on a Mac or Linux computer, or PowerShell on Windows, connect to your Bitcoin node:
ssh nelson@bitcoin-node.local
Become superuser.
su -
Create the installation directory
Create an lnd directory under /usr/local/lib. This is where the LND binaries will be installed.
cd /usr/local/lib
mkdir lnd
cd lnd
Download LND
Go to the LND GitHub repository:
https://github.com/lightningnetwork/lnd
On the right-hand side of the page you'll see the latest release. Click the release link.
Under Assets, locate the archive for your computer's architecture. For a 64-bit Intel or AMD system, the filename will be similar to:
lnd-linux-amd64-v0.21.1-beta.tar.gz
Right-click the filename and select Copy Link Address (or the equivalent option in your web browser).
At the terminal, type wget, followed by a space, paste the link you copied, and press Enter.
Repeat the same process to download the checksum file:
manifest-v0.21.1-beta.txt
and and the signature file
manifest-roasbeef-v0.21.1-beta.sig
Each time, right-click the filename, copy the link address, then paste it after wget at the terminal.
Import the release signing key
Download the LND release signing key:
wget https://raw.githubusercontent.com/lightningnetwork/lnd/master/scripts/keys/roasbeef.asc
Import the key into GnuPG:
gpg --import roasbeef.asc
Verify the release
Verify the signature on the manifest:
gpg --verify manifest-roasbeef-v0.21.1-beta.sig manifest-v0.21.1-beta.txt
The output should include a Good signature message.
Calculate the SHA-256 checksum of the downloaded archive:
sha256sum lnd-linux-amd64-v0.21.1-beta.tar.gz
Compare the checksum with the corresponding entry in the manifest:
grep lnd-linux-amd64-v0.21.1-beta.tar.gz manifest-v0.21.1-beta.txt
The two SHA-256 checksums should be identical.
Unpack the archive
Extract the downloaded package:
tar -xzf lnd-linux-amd64-v0.21.1-beta.tar.gz
The downloaded archive and verification files are no longer required:
rm lnd-linux-amd64-v0.21.1-beta.tar.gz
rm manifest-v0.21.1-beta.txt
rm manifest-roasbeef-v0.21.1-beta.sig
Enter the newly created directory:
cd lnd-linux-amd64-v0.21.1-beta
Create an LND user
Create a dedicated system user for LND:
useradd \
--system \
--home-dir /var/lib/lnd \
--create-home \
--shell /usr/sbin/nologin \
lnd
Install the binaries
Create symbolic links to the LND binaries:
ln -s /usr/local/lib/lnd/lnd-linux-amd64-v0.21.1-beta/lnd /usr/local/bin/lnd
ln -s /usr/local/lib/lnd/lnd-linux-amd64-v0.21.1-beta/lncli /usr/local/bin/lncli
Generate RPC credentials
Locate the rpcauth.py utility supplied with Bitcoin Core:
cd /usr/local/lib/bitcoin
cd bitcoin-31.0
cd share/rpcauth
Run the script:
./rpcauth.py lnd
The output will look similar to:
String to be appended to bitcoin.conf:
rpcauth=lnd:627663e423539bd3bc3ab4ce4be753dc$174a2ddf41ed9ae9abc6cd83aed3c2cd70c1c01dfc98a18ef57c059dd8d3dfdb
Your password:
wRLvJA4q8wBdej7WYxnwIfMbuzVVlO6kRoGvmf1YZBM
Do not use these example credentials. The script generates a unique username and password each time it is run.
Copy the rpcauth= line into /etc/bitcoin.conf.
Restart Bitcoin Core:
systemctl restart bitcoind
Create the LND configuration file
Create the configuration file:
nano /etc/lnd.conf
Add the following configuration:
[Application Options]
lnddir=/var/lib/lnd
[Bitcoin]
bitcoin.active=1
bitcoin.mainnet=1
bitcoin.node=bitcoind
[Bitcoind]
bitcoind.rpchost=127.0.0.1
bitcoind.rpcuser=lnd
bitcoind.rpcpass="RPC-PASSWORD-HERE"
bitcoind.zmqpubrawblock=tcp://127.0.0.1:28332
bitcoind.zmqpubrawtx=tcp://127.0.0.1:28333
Replace YOUR_GENERATED_PASSWORD with the password generated by rpcauth.py.
Create the system service
Create the systemd service:
nano /etc/systemd/system/lnd.service
Populate the file with:
[Unit]
Description=LND Lightning Network Daemon
After=network-online.target bitcoind.service
Wants=network-online.target
[Service]
User=lnd
Group=lnd
Type=notify
ExecStart=/usr/local/bin/lnd --configfile=/etc/lnd.conf
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
Save the file and exit the editor.
Reload the systemd configuration.
systemctl daemon-reload
Enable the service
Enable LND so that it starts automatically when the system boots.
systemctl enable lnd
Start the service
Start LND.
systemctl start lnd
Verify the installation
Check that the service is running.
systemctl status lnd
You should see the service listed as active (running).
View the journal
LND writes its log messages to the systemd journal.
View the current log.
journalctl -u lnd
Follow the log in real time.
journalctl -fu lnd
Create a Lightning wallet
The first time LND starts it doesn't yet have a wallet. Before you can use your Lightning node you must create one.
Run the following command:
lncli --lnddir=/var/lib/lnd create
You'll be prompted to create a wallet password. This password encrypts your Lightning wallet and will be required each time LND starts.
Next you'll be asked whether you want to use an existing seed or create a new one. For a new Lightning node, answer No.
LND will then display a 24-word recovery seed. Write these words down carefully and store them somewhere safe. This seed is the backup of your Lightning wallet. Anyone with this seed can restore your wallet and spend your funds.
After confirming the seed, the wallet will be created and LND will begin operating normally.
Verify that the wallet has been created successfully:
lncli --lnddir=/var/lib/lnd getinfo
Information about your Lightning node should be displayed, including its public key, alias and current block height.
If LND is restarted in the future, you'll need to unlock the wallet before it can operate:
lncli --lnddir=/var/lib/lnd unlock
The next section covers installing Ride The Lightning (RTL), a web-based interface for managing your Lightning node.