Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
updated & improved guide to installing LND, BTCD, on Ubuntu 16.04 Server on testnet

2018-03-18: Updating of this guide is taking a backseat to the mainnet version at

Intro

This guide is specific to btcd, lnd, on testnet, running on an ubuntu 16.04 server host.

It does not address mainnet, or using bitcoind, or neutrino.

Original installation guide is here:

Alternative version of this guide for bitcoind:
https://gist.github.com/bretton/1a72e9fea94405be449edbd379a1ce57

Install

The LND install guide used to refer to golang-1.8-go, and now refers to golang-1.10-go, but Ubuntu 16.04 LTS currently has golang-1.9-go. To install the latest Go using Snap:

sudo snap install --classic go

on success you will see the result:

go 1.10 from 'mwhudson' installed

Then make a 'go' directory in your home directory

mkdir go

set the go paths, this can be done in .profile (which reads .bashrc) or directly in .bashrc. You might notice some difference between ssh sessions and local terminal sessions with .profile so for the purpose of this guide we'll use .bashrc as the results are the same for both types of session:

nano .bashrc

add to the end:

export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

Important: the Snap install of Go will automatically set the GOROOT variable. It's no longer necessary to set this yourself, unless using apt-get install of older version of Go.

logout and log back in to reread variables, or you can type:

source .bashrc

then check the Go variables are set with:

go env

install dep:

go get -u github.com/golang/dep/cmd/dep

install lnd:

git clone https://github.com/lightningnetwork/lnd $GOPATH/src/github.com/lightningnetwork/lnd
cd $GOPATH/src/github.com/lightningnetwork/lnd
dep ensure
go install . ./cmd/...

(optional) run tests:

go install; go test -v -p 1 $(go list ./... | grep -v  '/vendor/')

install glide (btcd still uses glide, lnd has moved to dep)

cd
go get -u github.com/Masterminds/glide

install btcd:

git clone https://github.com/roasbeef/btcd $GOPATH/src/github.com/roasbeef/btcd
cd $GOPATH/src/github.com/roasbeef/btcd
glide install
go install . ./cmd/...

setup a $HOME/.btcd/btcd.conf file from:

https://github.com/btcsuite/btcd/blob/master/sample-btcd.conf

simplest version might be as follows:

[Application Options]
; set debug to error, warn, info, debug
; Debug logging level.
; Valid levels are {trace, debug, info, warn, error, critical}
debuglevel=warn
datadir=~/.btcd/data
testnet=1
; set to your external IP address 
externalip=YOURIP
; add a known external peer if you like
;addpeer=KNOWNPEERIP
rpcuser=REPLACEME
rpcpass=REPLACEME
txindex=1

run btcd and sync (will take a long time - ~8 hours on 1gb connection):

btcd --testnet --txindex --rpcuser=REPLACEME --rpcpass=REPLACEME

monitor progress in another terminal window with:

btcctl --testnet --rpcuser=REPLACEME --rpcpass=REPLACEME getinfo
btcctl --testnet --rpcuser=REPLACEME --rpcpass=REPLACEME getpeerinfo | more

to run in the background (and tail log file):

btcd --testnet --txindex --rpcuser=REPLACEME --rpcpass=REPLACEME 2>&1 &

view logs:

tail $HOME/.btcd/logs/testnet/btcd.log 

Please see EXTRA section at end, for supervisor configuration to run btcd automatically

create $HOME/.lnd/lnd.conf from:

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

simplest version might be as follows:

[Application Options]
debuglevel=debug
debughtlc=true
maxpendingchannels=10
; don't encrypt wallet in testing environment, but please consider it mandatory for live
noencryptwallet=true
; replace with your external IP, same as btcd.conf
externalip=YOURIP
alias=SET-YOUR-ALIAS
color=#00FF00

[Bitcoin]
bitcoin.active=1
bitcoin.testnet=1
; Use the btcd back-end if using btcd
bitcoin.node=btcd
;
; Use the bitcoind back-end if using bitcoind
; bitcoin.node=bitcoind
; Run lnd in light client mode
; bitcoin.node=neutrino

[Btcd]
; use the user/pass you setup for btcd
btcd.rpcuser=<btcd rpc username>
btcd.rpcpass=<btcd rpc password>

[Neutrino]
; Running lnd in light client mode:
; neutrino.active=1
; neutrino.connect=faucet.lightning.community

[Autopilot]
; enable these options once your wallet is funded!
; autopilot.active=1
; The maximum number of channels that should be created.
; autopilot.maxchannels=5
; The percentage of total funds that should be committed to automatic channel
; establishment
; autopilot.allocation=0.6

Once btcd has synced, run lnd using the btcd backend and lnd.conf config file we just created as follows:

lnd --bitcoin.active --bitcoin.testnet 

Please see EXTRA section at end, for supervisor configuration to run lnd automatically

To verify things are operational, in another terminal window or session run:

lncli getinfo
lncli getnetworkinfo
lncli describegraph

Setup a wallet to get testnet coins from faucet (needs a np2wkh segwit format address):

lncli newaddress np2wkh

open a testnet3 faucet:

and paste in the address you created.

After a few minutes your coins should have arrived. You can verify with:

lncli walletbalance

Open a channel to one or more of the following nodes (via @moli), or another peer you know, or find one from https://explorer.acinq.co/#/ (which should NOT be considered an authoritative source, just a useful one)

Yalls.org:      039cc950286a8fa99218283d1adc2456e0d5e81be558da77dd6e85ba9a1fff5ad3@34.200.252.146:9735
Htlc.me:        02eba4a726c20c4fcc5a7291181f65dd389951b944dc48a0aec07b13d7c772de57@54.236.31.248:9735
Bitrefill:      02ca1f8792292fd2ad4001b578e962861cc1120f0140d050e87ce1d143f7179031@52.18.61.50:9735
lnd.fun:        03172377a939b21aadab64943ac82fc54a6600db48812dec9046c78abd78f5a0a2@lnd.fun:9735  
Eclair:         03933884aaf1d6b108397e5efe5c86bcf2d8ca8d2f700eda99db9214fc2712b134@endurance.acinq.co:9735
LND Faucet:     02fa77e0f4ca666f7d158c4bb6675d1436e339903a9feeeaacbd6e55021b98e7ee@159.203.125.125   
lncast.com:     027c4d2f938f5ee5184fbf0c1b3152a806243b5ec1e53cff814f439d3c18ceceec@lncast.com:9735
Slack Tipbot:   03ba998c7cfc9e48d59bf5350ebb54356b75ba9cce6a6284628eda6bf389ce452c@194.135.83.49:9735
Internet Cafe:  032d0e1611c0b8aff507703fefc3ad48f722c45a190c81de7a07141f6c92a5c9cc@86.24.91.84:9735

Open a channel by first connecting to the node, then issuing the openchannel command as follows:

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

verify pending & open channels using:

lncli pendingchannels
lncli listchannels

Extra - Supervisor configuration

start btcd and lnd automatically by using supervisor. First install supervisor:

sudo apt-get install supervisor

Then add two configuration files as follows:

cd /etc/supervisor/conf.d
nano btcd.conf (or lnd.conf)

add the following text to /etc/supervisor/conf.d/btcd.conf

[program:btcd]
user=REPLACE-WITH-YOUR-USERNAME
command=/home/YOUR-HOME-DIR/go/bin/btcd --configfile=/home/YOUR-HOME-DIR/.btcd/btcd.conf
startretries=999999999999999999999999999
autostart=true
autorestart=true

add the following text to /etc/supervisor/conf.d/lnd.conf

[program:lnd]
user=REPLACE-WITH-YOUR-USERNAME
command=/home/YOUR-HOME-DIR/go/bin/lnd --configfile=/home/YOUR-HOME-DIR/.lnd/lnd.conf
startretries=999999999999999999999999999
autostart=true
autorestart=true

start the processes:

sudo supervisorctl start btcd
sudo supervisorctl start lnd

or simply:

sudo supervisorctl reload

monitor the log files by tailing them in the logs directory under $HOME/.btcd/logs/testnet/btcd.log and $HOME/.lnd/logs/bitcoin/testnet/lnd.log

Updating

It is NOT advised to update yet as per the original install instructions for updating. It's better to wipe your install and start over, until such time as there is compatibility between updates.

However, if you do follow the updating process in the original install guide, you might need to rollback and close channels when problems.

you can use git reflog to find your prior commit, close out your channels, then roll forward and start from there.

Something like:

cd $GOPATH/src/github.com/lightningnetwork/lnd
git reflog
  4559438 HEAD@{0}: pull: Fast-forward
  dd08662 HEAD@{1}: clone: from https://github.com/lightningnetwork/lnd
git revert <id>

Then once it's working again, close your channels using the help available here:

https://github.com/lightningnetwork/lnd/issues/641

once confirmations done for closure, THEN proceed with upgrade process.

@Matt-Jensen

This comment has been minimized.

Copy link

Matt-Jensen commented Mar 16, 2018

IDK if this is a common issue, but I was running into this error installing dep:

exec: "gcc": executable file not found in $PATH

I was able to install it successfully by running: sudo apt-get install build-essential before installing dep.

@gopye

This comment has been minimized.

Copy link

gopye commented Nov 15, 2019

Running dep ensure raised this error could not find project Gopkg.toml, use dep init to initiate a manifest. Running dep init solved it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.