the following guide is an updated install process based on the following, which needs some improvement still
This guide here is specific to getting lnd and bitcoind running on ubuntu 16.04 LTS for testnet.
It does not address mainnet, or using btcd, or neutrino.
btcd guide here
https://gist.github.com/bretton/266b5a3902cd8e1a2b9776b878e5652d
Following the guide from https://bitcoin.org/en/full-node#linux-instructions
if you'd prefer to compile bitcoind yourself, please refer to
https://gist.github.com/itoonx/95aec9a3b4da01fd1fd724dffc056963
First add the repository
sudo apt-add-repository ppa:bitcoin/bitcoin
You will be prompted for your user password. Provide it to continue, and press enter when prompted.
Run the update process
sudo apt-get update
Then proceed with installing bitcoind as follows
sudo apt-get install bitcoind
Setup your .bitcin/bitcoin.conf file, there is a sample here
https://github.com/bitcoin/bitcoin/blob/master/contrib/debian/examples/bitcoin.conf
simplest version might be as follows:
server=1
testnet=1
txindex=1
daemon=1
externalip=X.X.X.X
maxconnections=10
rpcuser=REPLACEME
rpcpassword=REPLACEME
zmqpubrawblock=tcp://127.0.0.1:28332
zmqpubrawtx=tcp://127.0.0.1:28332
Start bitcoin to initiate sync, and be sure to take a look at https://en.bitcoin.it/wiki/Running_Bitcoin
bitcoind
You can monitor the progress in the logs
tail $HOME/.bitcoin/testnet3/debug.log
This process will take a couple of hours on testnet to complete. You can confirm you are up to date as follows:
- get the current testnet block count
curl -s https://testnet-api.smartbit.com.au/v1/blockchain/blocks |jq -r -c .blocks[0].height
- compare the result to the output of
bitcoin-cli getblockcount
- alternatively, do both as a one-liner expression:
echo `bitcoin-cli getblockcount 2>&1`/`curl -s https://testnet-api.smartbit.com.au/v1/blockchain/blocks |jq -r -c .blocks[0].height 2>/dev/null`
If the output values are the same, then your bitcoind node is fully synced and you can proceed with lnd installation.
Please see Supervisor section at end, for configuration to run automatically
install golang
sudo apt-get install golang-1.9-go
Setup your go directory. It can be ".go" or "go" depending on what works for you.
mkdir go
set your go paths so go will work properly
nano .profile
add to the end
export GOROOT=/usr/lib/go-1.9/
export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
logout, log back in
check variables with
go env
install glide
go get -u github.com/Masterminds/glide
install lnd
git clone https://github.com/lightningnetwork/lnd $GOPATH/src/github.com/lightningnetwork/lnd
cd $GOPATH/src/github.com/lightningnetwork/lnd
glide install
go install . ./cmd/...
run tests and check for any errors
go install; go test -v -p 1 $(go list ./... | grep -v '/vendor/')
Now you need to wait for bitcoind to finish syncing before continuing.
Once bitcoind has synced, run lnd for first run as follows, it will take a while to catch up and sync properly. Let it finish.
lnd --bitcoin.active --bitcoin.testnet --debuglevel=debug --bitcoin.node=bitcoind --bitcoind.rpcuser=REPLACEME --bitcoind.rpcpass=REPLACEME --externalip=X.X.X.X --noencryptwallet --bitcoind.zmqpath=tcp://127.0.0.1:28332
Once sync is complete, proceed with editing config file so as to start lnd with fewer flags:
create/edit $HOME/.lnd/lnd.conf from
https://github.com/lightningnetwork/lnd/blob/master/sample-lnd.conf
simple version might be as follows:
[Application Options]
datadir=/home/YOURUSERNAME/.lnd/data
logdir=/home/YOURUSERNAME/.lnd/logs
debuglevel=warn
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
externalip=YOURIP
alias=SET-YOUR-ALIAS
color=#00FF00
[Bitcoin]
bitcoin.active=1
bitcoin.testnet=1
bitcoin.node=bitcoind
[Bitcoind]
bitcoind.rpcuser=REPLACE
bitcoind.rpcpass=REPLACE
bitcoind.zmqpath=tcp://127.0.0.1:28332
[Neutrino]
; neutrino.active=1
; neutrino.connect=faucet.lightning.community
[Autopilot]
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
thereafter you can start lnd without flags
lnd
to run in the background (and tail log file)
lnd &
tail the log file
tail $HOME/.lnd/logs/testnet3/bitcoin/lnd.log
Please see Supervisor section at end, for configuration to run automatically
To verify things are operational
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 https://testnet.manu.backend.hamburg/faucet and paste in the address you created and click 'give me some coins' multiple times
After a few minutes your coins should have arrived. You can verify with
lncli walletbalance
With autopilot enabled connections should start happening automatically, however if you'd like to include manual channels then 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 is NOT an authoritative source. Please also note these pubkeys are changing with iterations in the software itself, often requiring things be setup from scratch.
Yall.org: 033a743ab6e0a464ef5ee187d4fde82af01b737cc8e06a4a1beaa09144c445b87a@45.77.115.33
Htlc.me: 02d28c3aac4b4f36746052a735831afbe65bc5698a7be5bd41b42fd1ddf2a1a358@45.63.87.131:9735
Bitrefill: 0298d0c6987e2e64451c7f723e15aff4dfca92f0e3973d214e206257abb0d1dd55@lnd.bitrefill.com:9735
lnd.fun: 02f057867392ba8e9fe2b62b8a21ee36be00a3338d5d34cb1a2ffab3d57d8a2aea@lnd.fun:9735
Eclair: 03933884aaf1d6b108397e5efe5c86bcf2d8ca8d2f700eda99db9214fc2712b134@endurance.acinq.co:9735
LND Faucet: 02c39955c1579afe4824dc0ef4493fdf7f3660b158cf6d367d8570b9f19683afb5@159.203.125.125:9735
lncast.com: 02139a5bc1f1c929c04530a99160f2072e2a731f14c666abf87479510912279c11@lncast.com:9735
Slack Tipbot: 03ba998c7cfc9e48d59bf5350ebb54356b75ba9cce6a6284628eda6bf389ce452c@194.135.83.49:9735
ctrlbreak_1: 03b0d54ece3b31934a96b8c425aa33759ee9acb876cc9b92bbfe8e1c19af6c11a2@47.55.95.227:9735
Elaine store: 02c8ebb98a0f133b19fb7bc982ec233d2db32b59d1f1ec178c9bb091a4e2c8d72c@45.76.235.75:9735
Open a channel by first connection, then opening a channel as follows
lncli connect pubkey@ip:port
lncli openchannel --node_key=<pubkey> --local_amt=100000
verify pending & open channels using
lncli pendingchannels
lncli listchannels
THIS SECTION STILL WIP
The are multiple ways to start things automatically.
Running bitcoind automatically can be done with
crontab -e
and adding
@reboot /usr/bin/bitcoind -conf=/home/USERNAME/.bitcoin/bitcoin.conf
Then lnd can be autostarted from supervisor.
First install supervisor
sudo apt-get install supervisor
Then add a configuration files as follows:
cd /etc/supervisor/conf.d
edit lnd.conf and add the following
[program:lnd]
user=REPLACE-WITH-YOUR-USERNAME
command=/home/USERNAME/go/bin/lnd --configfile=/home/USERNAME/.lnd/lnd.conf
startretries=999999999999999999999999999
autostart = true
autorestart=true
reload supervisor
sudo supervisorctl reload
You can monitor the log files by tailing them in the relevant directories in your home directory, or in /var/log/supervisor
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>