Bitcoin for Beginners: Lightning Network Explained
In this post, I break down the Lightning Network into simple terms, with easy to follow illustrations so that someone new to bitcoin can have a strong understanding of the basics of the Lightning Network.
We'll first go over the concept of layers and how you might be familiar with them, then we'll get into how this relates to bitcoin. Finally, we'll finish off with some simple examples demonstrating how transactions work in the Lightning Network. Let's go!
What are "Layers"?
If you take the time to think about how your financial institutions work, you'll come to notice that they work in layers. Your bank would be known as the first layer, or Layer 1, since what's on their books is what we consider to be the final score. But as you know, this first layer can be clunky and slow. After all, banks are closed on the weekends and on the weekdays after 5pm. They close so they can have time to make sure the balances they have recorded from the day's transactions are accurately reflected across the banking sector.
For that reason, most of our transactions do not occur on the first layer, but instead, on Layer 2.
Some examples of what would be considered "Layer 2" in traditional finance would be your credit and debit cards. These transactions happen much quicker and more efficiently, but they're not final since they can be reversed for a period of time after the transaction takes place.
The Layers of Bitcoin
The layers of Bitcoin are very similar to those in traditional finance in that Layer 1 is quite slow and clunky, yet it is final. In Bitcoin, the "gold standard" of finality is when a transaction has 6 confirmations, meaning the transaction has embedded itself "deep enough" into the blockchain, making the odds of the transaction being reversed slim to none.
Six blocks take about 1 hour, so it's not fast enough for quick, snappy transactions. However, compared to the time it takes for a transaction to become final in traditional finance, the difference is stark. In traditional finance, it's a matter of days, whereas in Bitcoin, it's a matter of minutes.
Moreover, Bitcoin's Layer 1 isn't just slow; it can also become expensive, particularly for micro-transactions.
The chart below illustrates the average transaction fee over time required to get a transaction confirmed. Imagine trying to buy a $5 coffee when the transaction fees alone cost $15. You can view the full chart at bitinfocharts.com
Introducing the Lightning Network
The Lightning Network is one of several projects designed to enhance Bitcoin by making micro-transactions economically feasible. We'll focus on the Lightning Network here because it's the most widely recognized layer 2 project on Bitcoin.
In the Lightning Network, transactions occur within "channels", and only the opening and closing of these channels involve Layer 1 transactions, dramatically reducing transaction fees associated with moving bitcoin between parties.
How the Lightning Network Works
The Lightning Network is a distributed Layer 2 network built on top of bitcoin. Like bitcoin, it's made up of a network of nodes, but these nodes are connected through payment channels, allowing bitcoin to be sent between nodes quickly and efficiently.
Let's go over an easy example.
Suppose Alice wants to send Bob some sats. To do this, Alice opens a payment channel between her node and Bob's node through a funding transaction. Think of this payment channel like a rope with beads on it, where the beads represent bitcoin.
When the channel (rope) is first opened, all the beads are on Alice's side. As Alice wants to pay Bob, she slides beads along the rope towards Bob. Each bead she moves represents a portion of Bitcoin being sent over the Lightning Network.
These beads (Bitcoin) can move back and forth between Alice and Bob as they transact, without needing to record each transaction on the Bitcoin blockchain (Layer 1). These are off-chain transactions.
If Alice wants to pay someone who isn't directly connected to her but is connected through Bob, the network can route her payment through multiple nodes:
- The payment (beads) hops from Alice to Bob, and then to the next node, until it reaches the recipient.
- Each node along the route takes a very small fee, usually amounting to a fraction of a cent.
- This requires that all channels along the route have enough liquidity to support the transaction.
When either Alice or Bob decides to close the channel, the final position of the beads is recorded on the Bitcoin blockchain through a settlement transaction, effectively settling to Layer 1. Only the final balance of the channel is recorded, minimizing the number of transactions on the main Bitcoin network.
Complexities of the Lightning Network
The Lightning Network is more complex than this simplified overview, but this gives you a basic understanding of how it works. One of the key challenges involves liquidity.
Using our bead analogy:
- If Alice has all the beads on her side of the rope and wants to receive funds from Bob, she faces a problem.
- There are no beads on Bob's side to slide back to her.
- This means Alice cannot receive payments from Bob unless there are enough beads (Bitcoin) on Bob's side of the channel.
Lightning liquidity is a big topic, and there are a lot of companies popping up looking to address this issue.
Conclusion
And with that, you should have a strong understanding of the basics of the lightning network! If you enjoyed this write-up please do reach out and let me know! I love hearing that people are finding value in the content I put out.
Stay tuned for more content like this coming soon!
- Andrew