Bitcoin full node and Lightning network node

What is a Bitcoin full node?

Why setup a full node?

How to setup a full node?

What is a Lightning Network node?

Why setup LN node?

How to setup a Lightning Network node on testnet?

Install Ubuntu 16.04.3 LTS. Download from https://www.ubuntu.com/download/desktop.

If you are just looking to test, start with a fresh install from a virtual machine.
You can use https://www.virtualbox.org/wiki/Downloads and the ISO above.

Install go
$ sudo add-apt-repository ppa:longsleep/golang-backports
$ sudo apt-get update
$ sudo apt-get install golang-go

Open file manager. Click View -> Show hidden files. Browse to /home/ and open .bashrc. Add the following lines to the bottom and save.
export GOPATH=~/gocode
export PATH=$PATH:$GOPATH/bin

Restart terminal (close then open new one)

Install glide
$ sudo add-apt-repository ppa:masterminds/glide && sudo apt-get update
$ sudo apt-get install glide

Install git
$ sudo apt-get install git

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/…

Updating (not required after fresh install):

$ cd $GOPATH/src/github.com/lightningnetwork/lnd
$ git pull && glide install
$ go install . ./cmd/…

Start btcd
$ btcd — testnet — txindex — rpcuser=kek — rpcpass=kek

Wait for it to sync.

Commands
Create new address (this will be the onchain address you fund channels from)
$ lncli newaddress np2wkh
{
“address”: <MY_DEPOSIT_ADDRESS>
}

Send some testnet BTC to this address using a faucet such as https://testnet.manu.backend.hamburg/faucet

$ lncli getinfo
{
— — ->”identity_pubkey”: <MY_PUBKEY>,
“alias”: “”,
“num_pending_channels”: 0,
“num_active_channels”: 0,
“num_peers”: 0,
“block_height”: 450,
“block_hash”: “2a84b7a2c3be81536ef92cf382e37ab77f7cfbcf229f7d553bb2abff3e86231c”,
“synced_to_chain”: true,
“testnet”: false,
“chains”: [
“bitcoin”
]
}

$ lncli connect <TARGET_PUBKEY>@<IP:PORT>
{
“peer_id”: 0
}

If you don’t include port, it will just use the default one. With LND you have to connect to the target before opening a channel with them.

$ lncli listpeers
{
“peers”: [
{
“pub_key”: <TARGET_PUBKEY>,
“peer_id”: 1,
“address”: “127.0.0.1:10012”,
“bytes_sent”: “292”,
“bytes_recv”: “292”,
“sat_sent”: “0”,
“sat_recv”: “0”,
“inbound”: true,
“ping_time”: “0”
}
]
}

$ lncli openchannel — node_key=<TARGET_PUBKEY> — local_amt=<SATOSHIS_TO_COMMIT_TO_CHANNEL>
full options see:
$ lncli openchannel — help

$ lncli listchannels
{
“channels”: [
{
“active”: true,
“remote_pubkey”: <BOB_PUBKEY>,
“channel_point”: “2622b779a8acca471a738b0796cd62e4457b79b33265cbfa687aadccc329023a:0”,
“chan_id”: “495879744192512”,
“capacity”: “1000000”,
“local_balance”: “991312”,
“remote_balance”: “0”,
“commit_fee”: “8688”,
“commit_weight”: “600”,
“fee_per_kw”: “12000”,
“unsettled_balance”: “0”,
“total_satoshis_sent”: “0”,
“total_satoshis_received”: “0”,
“num_updates”: “0”
}
]
}

$ lncli addinvoice — value=<REQUESTED_SATOSHIS>
{
“r_hash”: “<a_random_rhash_value>”,
“pay_req”: “<ENCODED_INVOICE>”,
}
Copy the <ENCODED_INVOICE> and give to whoever you want to receive payment from.

$ lncli sendpayment — pay_req=<ENCODED_INVOICE>
{
“payment_preimage”: “baf6929fc95b3824fb774a4b75f6c8a1ad3aaef04efbf26cc064904729a21e28”,
“payment_route”: {
“total_time_lock”: 1,
“total_amt”: 10000,
“hops”: [
{
“chan_id”: 495879744192512,
“chan_capacity”: 1000000,
“amt_to_forward”: 10000
}
]
}
}

$ = copy following text to paste into terminal
{ blah blah } = terminal output from a command

Replace outputs with an example output to a testnet address.