Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save stonedbear/a2fbdc1cff107446fa3128a47f02d3b0 to your computer and use it in GitHub Desktop.
Save stonedbear/a2fbdc1cff107446fa3128a47f02d3b0 to your computer and use it in GitHub Desktop.
Guide to installing LND with bitcoin-qt on Arch Linux for Mainnet

Intro

This guide is specific to getting LND 0.4.2-beta and bitcoin-qt running on Arch Linux for mainnet.

Original installation guide:

This guide is broken into the following sections:

  • Install bitcoin-qt and set to start automatically
  • Install lnd, setup a config file, fund and open channels

Advance warnings:

  • The bitcoin-qt portion of this guide can take several days to sync
  • The lnd portion of this guide can take several hours to sync

Install bitcoin-qt

Published instructions

https://bitcoin.org/en/full-node#linux-instructions

Installation

Install from offical repository (https://www.archlinux.org/packages/community/x86_64/bitcoin-qt/):

sudo pacman -S bitcoin-qt

You will be prompted for your user password. Provide it to continue, and press enter when prompted.

Start bitcoin-qt, go to settings -> options -> open configuration file:
(conf file examples https://github.com/bitcoin/bitcoin/blob/master/contrib/debian/examples/bitcoin.conf)

Simplest version might be as follows:

server=1
txindex=1
daemon=1
externalip=X.X.X.X (your external ip or address)
maxconnections=10
rpcuser=REPLACEME
rpcpassword=REPLACEME (try using letters and numbers as there is a bug preventing from connecting when password contains special characterts such as ! or @)
minrelaytxfee=0.00000000
incrementalrelayfee=0.00000010
zmqpubrawblock=tcp://127.0.0.1:28332
zmqpubrawtx=tcp://127.0.0.1:28333

Note: as of github master from 2018-08-10 onwards you need different ports for each zmq config option, setup in bitcoin.conf

Wait for bitcoin-qt to sync, and be sure to take a look at https://en.bitcoin.it/wiki/Running_Bitcoin

You can monitor the progress in the gui or in the logs:

tail $HOME/.bitcoin/debug.log -f

Important: The bitcoin-qt sync process can take 3 to 5 days to complete on slow machine! On a powerhorse computer it should take couple of hours.

Setting up bitcoin-qt to start automatically

To setup bitcoin-qt to start automatically, go to settings -> options -> start bitcoin core on system login Next we need to install lnd.

Install LND from AUR

Install lnd from AUR user repository https://aur.archlinux.org/packages/lnd/:

Prerequisite build tools

sudo pacman -S base-devel

Acquire the build files, including the PKGBUILD and possibly other required files, like systemd units and patches (often not the actual code).

mkdir lnd
cd lnd
wget https://aur.archlinux.org/cgit/aur.git/snapshot/lnd.tar.gz

Verify that the PKGBUILD and accompanying files are not malicious or untrustworthy.

Run 'makepkg -si' in the directory where the files are saved. This will download the code, resolve the dependencies with pacman, compile it, package it, and install the package.

sudo makepkg -si

Important: this next step requires bitcoin-qt be fully synced!

Create and edit $HOME/.lnd/lnd.conf from

https://github.com/lightningnetwork/lnd/blob/master/sample-lnd.conf

nano $HOME/.lnd/lnd.conf

A very simple version might be as follows, you can add more from the info in the sample config later:

[Application Options]
; set external IP if not using NAT
externalip=YOURIP
; set node alias (seen in explorers)
alias=SET-YOUR-ALIAS

[Bitcoin]
bitcoin.active=1
bitcoin.mainnet=1
bitcoin.node=bitcoind

[Bitcoind]
bitcoind.rpcuser=REPLACE
bitcoind.rpcpass=REPLACE
bitcoind.zmqpubrawblock=tcp://127.0.0.1:28332
bitcoind.zmqpubrawtx=tcp://127.0.0.1:28333

Note: as of github master from 2018-08-10 onwards you need different ports for each zmq config option, and no longer use bitcoind.zmqpath option.

Run lnd for first run as follows, it will take a while to catch up and perform its own sync:

lnd

But before the sync actually starts, in another terminal window you will need to create a wallet, store the recovery key, and then issue the unlock command.

To create a wallet run:

lncli create

An example of the output is as follows. Please ensure you have a strong password with minimum 8 characters, and mix of uppercase and lowercase:

Input wallet password: ********
Confirm wallet password: ********

Do you have an existing cipher seed mnemonic you want to use? (Enter y/n): n

Your cipher seed can optionally be encrypted.
Input your passphrase you wish to encrypt it (or press enter to proceed without a cipher seed passphrase): ********
Confirm cipher seed passphrase: ********

Generating fresh cipher seed...

!!!YOU MUST WRITE DOWN THIS SEED TO BE ABLE TO RESTORE THE WALLET!!!

------------------BEGIN LND CIPHER SEED------------------
 1. one        2. two        3. three        4. four 
 5. five       6. six        7. seven        8. eight
 9. nine      10. ten       11. eleven      12. twelve 
13. thirteen  14. fourteen  15. fifteen     16. sixteen
17. seventeen 18. eighteen  19. nineteen    20. twenty
21. twentyone 22. twentytwo 23. twentythree 24. twentfour
------------------END LND CIPHER SEED--------------------

Copy and paste the cipher seed and store it securely somehow, such a secure note in a password manager, or printed to paper and locked in a safe, or similar.

You will now have to unlock the wallet you just created so lnd can proceed with the initial sync:

lncli unlock

Once sync is complete, you can <ctrl-c> the lnd process, and proceed with editing a config file so you can start lnd with fewer flags on next launch.

You can monitor the log file in the logs directory under $HOME/.lnd/logs/bitcoin/mainnet/lnd.log

tail $HOME/.lnd/logs/bitcoin/mainnet/lnd.log -f

To verify lnd is operational, open another terminal window or session and try the following:

lncli getinfo
lncli getnetworkinfo
lncli describegraph

Setup a wallet to deposit some bitcoin (create address and then deposit bitcoin onto it):

lncli newaddress p2wkh or lncli newaddress np2wkh

Make the deposit and check progress with:

lncli walletbalance 

A confirmed a balance means the deposit is complete and ready for opening channels.

To open your first channel(s) it may be useful to find active nodes. You can do this by browsing the node directory at various explorers such as https://www.robtex.com/lightning/node/ or https://1ml.com/ or you can open channels with the following:

* bitrefill: 024a2e265cd66066b78a788ae615acdc84b5b0dec9efac36d7ac87513015eaf6ed@lnd.bitrefill.com:9735
* yalls: 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56@mainnet-lnd.yalls.org:9735
* original guide author: 02262bbc21c171bc91a1d6bbf89571c95873849b9a60d3ea9671b777d852d39ecd@197.155.6.118:9735
* arch linux guide author: 02d558babbb875e3b4d2e43ef02ea6bf713722523ab52d77f6604ba9183013aae4@orbiter.dyndns-ip.com:9735

Open a channel by first connecting, then opening a channel as follows:

lncli connect pubkey@ip:port
lncli openchannel --node_key=<pubkey> --local_amt=<amount>

Helpful hint:

if mSATs, satoshis, bits, mBTC are confusing, consider installing this useful calculator https://github.com/jb55/bcalc

Verify pending & open channels using:

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