Skip to content

Instantly share code, notes, and snippets.

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


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:


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

install lnd:

git clone $GOPATH/src/
cd $GOPATH/src/
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)

go get -u

install btcd:

git clone $GOPATH/src/
cd $GOPATH/src/
glide install
go install . ./cmd/...

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

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}
; set to your external IP address 
; add a known external peer if you like

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:

simplest version might be as follows:

[Application Options]
; don't encrypt wallet in testing environment, but please consider it mandatory for live
; replace with your external IP, same as btcd.conf

; Use the btcd back-end if using btcd
; Use the bitcoind back-end if using bitcoind
; bitcoin.node=bitcoind
; Run lnd in light client mode
; bitcoin.node=neutrino

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

; Running lnd in light client mode:

; enable these options once your wallet is funded!
; 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.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 (which should NOT be considered an authoritative source, just a useful one)      039cc950286a8fa99218283d1adc2456e0d5e81be558da77dd6e85ba9a1fff5ad3@        02eba4a726c20c4fcc5a7291181f65dd389951b944dc48a0aec07b13d7c772de57@
Bitrefill:      02ca1f8792292fd2ad4001b578e962861cc1120f0140d050e87ce1d143f7179031@  
LND Faucet:     02fa77e0f4ca666f7d158c4bb6675d1436e339903a9feeeaacbd6e55021b98e7ee@
Slack Tipbot:   03ba998c7cfc9e48d59bf5350ebb54356b75ba9cce6a6284628eda6bf389ce452c@
Internet Cafe:  032d0e1611c0b8aff507703fefc3ad48f722c45a190c81de7a07141f6c92a5c9cc@

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

command=/home/YOUR-HOME-DIR/go/bin/btcd --configfile=/home/YOUR-HOME-DIR/.btcd/btcd.conf

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

command=/home/YOUR-HOME-DIR/go/bin/lnd --configfile=/home/YOUR-HOME-DIR/.lnd/lnd.conf

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


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/
git reflog
  4559438 HEAD@{0}: pull: Fast-forward
  dd08662 HEAD@{1}: clone: from
git revert <id>

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

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


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.


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.