Subscribe Right arrow
Blockchain Basics// 6 min read

The Lightning Network Explained

The Lightning Network Explained

The Lightning Network is currently the most avidly pursued scaling solution for bitcoin0.048018244044414%. It enables instant payments and the ability process thousands of transactions per second. This is a vast improvement over the current Bitcoin network which only blocks every 10 minutes on average.

How Does it Work?

The backbone of the Lightning Network is something called Multiple Signature (MultiSig) wallets. These are just like your regular cryptowallets, except that it requires multiple people to send a transaction.

For example, let’s say Alice and Carol decide to create a 2 of 2 MultiSig wallet together. This means that the single wallet has 2 owners and requires 2 signatures for Bitcoin to be spent.

Now let’s say that Alice wants to send BTC out of the wallet. She first initiates a payment out of the MultiSig wallet by signing the transaction. By doing this, Alice creates something called an “open payment channel.” In other words, the payment remains in a suspended state until it is closed. This open payment channel can only be closed if Carol also signs the transaction that Alice initiated. Once Carol does, the transaction gets relayed to the miners in the Bitcoin network.

Let’s quickly recap because open and closed payment channels are important to understanding how the Lightning Network works. Open payment channels are created when a payment is initiated but not broadcast to the Bitcoin network. A closed payment channel is when the transaction is.

In order to further solidify these two concepts, let’s look at the example above of a 2 of 2 MultiSig wallet. An open payment channel is created when only 1 person of the 2 signs a transaction out of the MultiSig wallet. It’s open because a payment has been initiated but not broadcast to the network yet.  This payment channel can then be closed when both people sign the transaction.

Another way a payment channel can be opened is through something called Hash Time Lock Contracts. These contracts delay the spending of a payment until “X” amount of time has passed. Keep this in mind as we’ll see how the Lightning Network leverages this technology later on in the article.

The Lightning Network (2 People)

Now let’s look at what the Lightning Network might look between Alice, an employer, and Carol, an employee.

Alice decides to hire Carol for her company and they both agree to biweekly Bitcoin payments.  In order to save money on transaction fees, Alice decides to utilize the Lightning Network. In order to set this up, Alice sends 1 BTC into a 2 of 2 MultiSig wallet that she and Carol own together. This means that a payment can only be sent out if both parties sign the transaction.

This presents a problem for Alice, because she must trust that Carol will always provide the second signature or else the BTC will be stuck forever. In light of this, Alice and Carol both sign a time-locked contract that specifies 1 BTC will be sent to Alice’s personal address after 10 months as insurance. This opens the payment channel between Alice and Carol which they then have to pay a small fee, one smaller than the normal Bitcoin transaction fee.

The Lightning Network - 2 People

Alice Pays Carol (1 Job)

Two weeks have passed and Alice must now pay Carol. Alice opens a payment channel by signing for a transaction that sends 0.1 BTC out of the 2 of 2 MultiSig to Carol’s personal BTC address.

Now Carol has two options:

  1. She can leave the 0.1 BTC “offer”on the table.
  2. She can sign her transaction and close out the channel.

Carol decides to leave the 0.1 BTC offer on the table because she wants to receive more payments from Alice. If she chooses to close this channel, Alice would no longer be able to send any more BTC to her.

Alice Pays Carol (2+ Jobs)

Another 2 weeks have passed and Alice pays Carol 0.2 BTC for 2 weeks. Alice doesn’t have to pay a transaction fee because the payment channel is already open. There now exists 2 offers on the table:

  1. 0.1 BTC
  2. 0.2 BTC

Carol can only choose the most recent offer due to something called “Relative Time Locks.” Should Carol try to cash out on a previous state (0.1 BTC), then a punishing contract is broadcast sending everything in the wallet to Alice. This is particularly important if a previous offer (0.3 BTC) is greater than the most recent one (0.2 BTC). Carol decides not to sign off on the most recent offer because she wants to keep getting paid by Alice. As time passes, Alice continues to increase her offer to Carol by 0.1 BTC every 2 weeks.

At the end of 5 months, Alice and Carol decide to part ways as Carol has found a better job elsewhere. Alice makes a final offer of 1 BTC to Carol which Carol immediately signs in order to obtain it. By closing the channel, another small fee is paid. In the end, Alice has paid Carol 10 times but with a total fee of 1 Bitcoin transaction (the opening channel fee + the closing channel fee).

Download our Crypto 101 Guide

Receive exclusive content that you won't find anywhere else other than on my list. Not only that, but you'll be the first to access new content, tools and offers. that will help accelerate your knowledge of crypto.

The Lightning Network Expanded (3 People)

Now let’s look at how the Lightning Network would look between three people: Alice, Bob, and Carol.

Let’s say Alice has a 2 of 2 MultiSig with Bob. Bob also has a MultiSig with Carol. But Alice and Carol do not have a MultiSig. Alice can still pay Carol by routing the payment through Bob. Here’s how it works:

  1. Carol first generates a secret number (R).
  2. She then hashes this number creating a seemingly random set of numbers (H).
  3. She then sends Alice (H).
  4. Alice takes (H) and creates a condition that states her BTC can only be cashed out if the recipient can provide (R).
  5. Alice sends her payment of [0.1 BTC + (H)] to Bob through the MultiSig that they share. Bob receives this payment of [0.1 BTC + (H)] but can’t cash out on it because he can’t provide (R).
  6. Bob takes (H) + his own 0.1 BTC and pushes it to Carol through the MultiSig that they share. Carol is satisfied because she sees (H) and then provides (R) to cash out the 0.1 BTC. Now that Bob has (R) he can cash out the 0.1 BTC offer he received from Alice.
  7. Alice has successfully routed her 0.1 BTC payment to Carol through Bob.

The Lightning Network Expanded 3 People

By pushing Bitcoin transactions “off chain” to payment channels, transactions are able to circumvent the traditional 10 minute block times of Bitcoin. As you can see, this results in a powerful protocol that allows people to make instant payments limited only by how fast the payment channel can be updated. It also allows for fees to decrease exponentially as each additional payment in the open payment channel cuts the normal Bitcoin transaction fee in half. Finally, payments can be easily be routed to anyone in the Lightning Network as long as the middlemen have enough funds to front your payments.

“As you can see, this results in a powerful protocol that allows people to make instant payments limited only by how fast the payment channel can be updated.”

Is it Being Used Today?

Amazingly enough, yes it is!  As of February 23, 2018 there are 842 nodes and 1,653 channels hosting almost $40,000 worth of Bitcoin (https://lnmainnet.gaben.win/). In fact, Blockstream opened a store where developers brave enough to risk their funds could buy stickers.  TorGuard also has pushed the envelope by allowing people to pay for their anonymous VPN service with Lightning Network BTC payments.

Yet despite these advances, the Lightning Network is not ready to be fully scaled and implemented worldwide. Edge-cases must continually be tested and the protocol is not yet quite stable. It is also continually evolving as more elements are being added such as the SPV wallet “Neutrino” or “Autopilot,” which automatically opens and closes channels based on the needs of the network.

Although the development of the Lightning Network is exciting for Bitcoin, it also positively impacts the larger cryptoeconomy as well. Blockchains, such as Litecoin and Vertcoin, also have plans to implement the Lightning Network. Not only will they have access to the same type of instant and exponentially fee decreasing abilities as Bitcoin, but the Lightning Network will also facilitate the peer-to-peer exchange of cryptocurrencies through something called “Atomic Swaps.”

Atomic Swaps leverages the time-locked contracts of the Lightning Network by allowing the instantaneous exchange between two cryptocurrencies. In other words, Alice and Carol can exchange BTC and LTC without having to go through an exchange. This has already been demonstrated by the LND developers who performed “off-chain” atomic swaps between Bitcoin and Litecoin. However, the instantaneous and automatic exchange between currencies isn’t just limited to Litecoin. In fact, any blockchain that adheres to the BOLT standards set out by all the Lightning Network development teams will eventually be able to participate in this ecosystem.

In this way, the Lightning Network via Atomic Swaps is set out to continue to decentralize the cryptoeconomy by offering not only instant payments and exponentially decreasing fees, but a peer-to-peer method of exchange.

Written by:

Author of "Understanding Litecoin: The Digital Currency for Payments."

POST A COMMENT

Leave a Reply

Your email address will not be published. Required fields are marked *

*

loading