The Bitcoin Lightning network is a second layer network that allows for cheaper and faster transactions. This second layer network enables Bitcoin to scale to millions of transactions per second at a fraction of the cost. In order to interact with the Lightning network one needs to connect to a Lightning network node. Wallets, point of sale systems, applications, etc. all connect to a node in order to transact on the network.
In order to run a Bitcoin Lightning node one needs to run a Bitcoin blockchain full node. The Lightning network needs to transact with the Bitcoin blockchain network to confirm final settlement of transactions. So in this tutorial we will detail how to setup a full Bitcoin blockchain node and a Bitcoin Lightning network node.
Why setup a Bitcoin network node?
One would host a Bitcoin blockchain node and Lightning network node for the following reasons:
- Contribute to the growth of the Bitcoin network
- Maintain full custody of your Bitcoin
- Direct access to the blockchain to self verify transaction data
- Enable Bitcoin transaction privacy
- Prevent nefarious parties from changing Bitcoin code by not accepting software updates
- Earn SATS by routing payments on the Lightning network
- Allows one to be their own central bank
The Bitcoin blockchain & Bitcoin Lightning network
The Bitcoin blockchain is typically referred to as layer 1 or the base layer. Miners process transactions on the base layer and can process approximately 10 transactions per second. The Lightning network is referred to as layer 2 and can theoretically process millions of transactions per second. Transacting on the Lightning network are sent to the Bitcoin blockchain to complete final settlement.
Bitcoin Lightning Network High Level Process Flow
- Wallets, point of sale systems, applications, etc. connect to a Bitcoin Lightning network node
- Wallets, point of sale systems, applications, etc. can also connect directly to the Bitcoin network
- Wallet addresses are created on the Lightning network and can store Bitcoin
- The Lightning network nodes connect to each other using payment channels
- When a transaction occurs on the Lightning network Bitcoin is routed from node to node
- When a payment channel is closed or not needed anymore final settlement can occur on the Bitcoin blockchain
For a detailed explanation of how the Bitcoin Lightning network functions review this article buy Bitcoin Magazine Understanding the Lightning Network. The article goes into sufficient detail and provides examples of how they system works.
Software needed to setup a Bitcoin node and Lightning network node
There are multiple software options that will help you run a Bitcoin node and Lightning network node. For this tutorial we will use the Umbrel software as it is free and all source code is available for review on GitHub. All Umbrel services use TOR (The Onion Router) by default to help preserve your anonymity at all times. The software allows you to access your node from anywhere in the world using a TOR enabled browser. In addition to all of these features we found positive reviews on Reddit, good documentation on their website, and a solid support community online.
The options that we researched were:
|Software Options to run a node|
|Bitcoin full node (Github) and Lightning (Github)|
The options listed above all had good reviews and their own pros and cons. It was a tough choice but we chose to test Umbrel for the reasons listed above.
Hardware needed to setup a Bitcoin node and a Lightning network node
For this project we will build a small discreet node using a Raspberry Pi. You can use a laptop or desktop but we want a smaller form factor so it can be stored out of sight. In order to create the node we will need the following components:
|Raspberry Pi 4 – You can use 4gb or 8gb|
|Charging cord for Raspberry Pi|
|Raspberry Pi Heatsink for cooling|
|1 or 2 TB SSD or HDD|
|SSD or HDD external enclosure Take note to where the charging port is on the shell to make sure it aligns with you node case|
|16gb or 32gb flash drive micro SD card|
|Case for your node – This can be printed using a 3D printer|
For this project you do not need a display because you will be able to access Umbrel on any device connected to the same network at http://umbrel.local in a web browser.
Download software to run your node
Download the following software onto your computer:
- Umbrel OS for the Raspberry Pi
- Balena Etcher to flash the Umbrel OS on the microSD card
After you download the software listed above plug your microSD card into your computer. Open Balena Etcher and flash the Umbrel OS onto the microSD card.
- Balena Etcher will detect the MicroSD card by default
- Select the Umbrel OS software that you downloaded onto your PC
- Select Flash! on the Balena Etcher screen
When Balena Etcher is done flashing the Umbrel OS software onto the microSD card you will see the screen change indicating that the flash is complete.
Assemble your node hardware
Now assemble the hardware required to build a node.
- Insert the microSD card into the Raspberry Pi
- Apply the heat sinks to your Raspberry Pi to dissipate heat
- Fit your Raspberry Pi into your node case
- Inset the SSD into the external enclosure
- Insert your external enclosure containing your SSD into your node case (if there is room)
- Make sure you have a opening in your node case for the external enclosure power cable
- Connect the SSD to the Raspberry Pi
- Connect one end of the ethernet cable to the Raspberry Pi and the other end to a port on your router
Finally connect your Raspberry Pi to a power source. The Umbrel OS will boot and run as soon as you plug in your Pi. After 10 minutes the Umbrel software will be accessible for you to configure. You do not need to wait for the complete Bitcoin blockchain to copy to your node to use the software. You can use Umbrel before the Bitcoin blockchain synchronization is complete.
Configure Umbrel node
To configure your node visit http://umbrel.local on any device that’s connected to the same network as the Raspberry Pi. Follow the on screen tutorial to get started.
- Set a password
- Write down your seed phrase and store it in a safe location
- This seed phase is used to recover your private keys for the wallets that are created with your node
- Continue following the on screen tutorial
Once your basic setup is complete you will have the following components on your Raspberry Pi:
- Lightning node
- Lightning wallet
- Bitcoin blockchain full node
- Bitcoin blockchain wallet
- Ability to run all transactions (Lightning and blockchain) through TOR
The Umbrel home screen is simple and intuitive. It details basic information about your wallets and the Bitcoin blockchain.
The Bitcoin menu on the left will allow you to:
- Send and receive transactions on the Bitcoin blockchain
- Connect a Bitcoin wallet
- View Bitcoin blockchain network statistics
The Lightning menu on the left will allow you to:
- Send and receive transactions on the Lightning network
- Connect a Bitcoin Lightning wallet
- View Bitcoin Lightning network statistics
- Open payment channels and connect to other nodes
How to open a Lightning payment channel
Make sure you fund your Lightning wallet with Bitcoin. Then use the resources below to search the Lightning network for Payment channels to connect to.
|Explorer Acinq||Lightning network explorer|
|1ML||Lightning network Search and Analysis Engine|
|LnRouter||Visualization of nodes and channels on the Lightning network|
|Amboss||The “anvil” search the network for nodes|
After you identify a Lightning network node that you would like to connect to copy their node information in notepad or your favorite text editor. Navigate to the Umbrel Lightning page and click on the open channel button.
Paste the node information that you copied into the Lightning address field. In the Amount field indicate how much Bitcoin you want to keep in this channel. Finally click on the green open channel button to complete the process.
Overall Umbrel is user friendly software that will help you get started running a Bitcoin blockchain full node and a Lightning network node quickly.