Lightning Node Setup Guide (With Docker)

0

This guide will get you started setting up a Lightning node to send and receive Bitcoin on the lightning network. The node will be always online – you’ll be able to send and receive lightning transactions at any time. We’ll be using a Docker container allow for faster deployment and updating. Remote Lightning nodes are great for anyone who wants to make some extra money routing lightning network transactions for passive income.

  • Difficulty: Intermediate
  • Time required: 1h
  • Setup type: LND with Docker
  • Prerequisites: Ability Deploy nodes on AWS or DigitalOcean

This guide has been adapted from ZAP-tutorials – including a few updated commands.

Note: For this guide we’re going to be using the Bitcoin Testnet – a test environment where we can make mistakes without serious consequences. Once you’re comfortable with deploying the node, you can switch over to the bitcoin mainnet by replacing “testnet” with “mainnet” in the code.

Remote Node Setup with Docker

For this setup, you’ll need to setup your own remote node on a cloud hosting service such as AWS or DigitalOcean. In this example, I deployed a t2.micro instance on AWS running Ubuntu Server 18.04. You can deploy any type of server, so long as it supports Docker you’re good to go.
Note: must have 1GB or more of RAM on the VPS. Anything less will result in frequent crashes.

To get Docker, install it with these commands

sudo apt update
sudo apt install docker.io

Installing the Lightning node

For the container, we’ll be using an image built by Zap – it’s already pre-configured with everything you need to get started (lnd, lndconnect). The first step is to create a “volume” which allows our data to be preserved in case the container is destroyed in the future. The volume we are creating is called “lnd-data”.

Note: some installations docker don’t require “sudo”, if you run into problems, run docker without elevated “sudo” privileges.

sudo docker volume create lnd-data

Next step we’re going to run the latest image from “lnzap/lnd:latest”. We’re going to connect to the Bitcoin Testnet – this way if we make any mistakes we won’t be losing real Bitcoin.

We are also connecting to public neutrino clients – this greatly lowers the hard disk requirements for this node.

Before executing, make sure you fill in your IP in the YOUR_EXTERNAL_IP section.

sudo docker run -v lnd-data:/lnd --name=lnd-node -d \
  -p 9735:9735 \
  -p 10009:10009 \
  lnzap/lnd:latest \
  --bitcoin.active \
  --bitcoin.testnet \
  --debuglevel=info \
  --bitcoin.node=neutrino \
  --neutrino.connect=testnet1-btcd.zaphq.io \
  --neutrino.connect=testnet2-btcd.zaphq.io \
  --autopilot.active \
  --tlsextraip=YOUR_EXTERNAL_IP \
  --externalip=YOUR_EXTERNAL_IP:10009 \
  --rpclisten=0.0.0.0:10009

Congrats! You got your Lightning Node up and running.

Create a Bitcoin Wallet

Now its time to create a Bitcoin Wallet. You can do this directly by interacting with the lnd-node via Docker.

  sudo docker exec -u lnd -it lnd-node lncli --network=testnet create
Successfully created a Bitcoin Wallet. Make sure you keep the seed phrase safe (written down on paper)

You can create a new address with the following command

  sudo docker exec -u lnd -it lnd-node lncli --network=testnet newaddress np2wkh

This will give you a Bitcoin address where you can send Bitcoin to to fund the account. Since we’re on the Bitcoin Testnet, you can use https://coinfaucet.eu/en/btc-testnet/ to fund the account for free.

PRO TIP: You can check if your node is working by scanning port 10009 and 9735 using https://www.yougetsignal.com/tools/open-ports/. This is a great way to check if there are any firewalls blocking your node from communicating and if the overall setup is successful. Running nodes will always have an “OPEN” status for the 2 ports.

Connecting the Remote node with ZAP iOS app

The ZAP app on iOS allows you to easily access the node remote node, send transactions, manage channels and more. The ZAP app is free and downloadable from https://zap.jackmallers.com/

To connect ZAP with the remote node, run this command:

 sudo docker exec -u lnd -it lnd-node lndconnect --bitcoin.active 

This gives you a QR code you can scan with your wallet (“Connect to a Remote Node”) to complete the binding. (Note: Older guides ask you to use zapconnect which no longer works and will give you an error).

Creating Channels with other nodes

To start making payments, you’ll need to create Lightning Channels with other nodes on the network. A great place to start finding other nodes is via https://1ml.com/testnet/. This is a list of all the testnet nodes.

You can scan the QR code for various servers via “Settings” -> “Manage Channels” -> “+”

Helpful Debugging tools and commands

Now you’re all done – the remote node is running and funded. To test out the configuration you can use these following tests:

Check LND status

This command checks for status of lnd and if you’re fully synchronized with the Bitcoin Network.

sudo docker exec -u lnd -it lnd-node lncli --network=testnet getinfo

Checking LND Logs

If there any problems and issues, it’ll usually show up in the logs. Access the latest 100 log messages using this command

 sudo docker logs --tail 100 -f lnd-node  

Restarting the container

When you restart the node, you’ll need to restart the container. For this you’ll need to know the container ID, then starting it.

sudo docker ps -a 

sudo docker start CONTAINER_ID

Unlocking the Wallet

Every time you restart the container, you’ll need to unlock the wallet:

 sudo docker exec -u lnd -it lnd-node lncli unlock

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.