Lightning Network: How it works and why Bitcoin needs it for mass adoption

Jason Yanowitz | May 22, 2018

Ever sent money to your friend using Bitcoin? It probably took a couple hours for the money to transfer and cost you a hefty fee.

It's hard to argue that Bitcoin's most pressing issue is scalability. Visa can process several thousands transactions per second. At around seven transactions per second, Bitcoin can't compete. Because of this, the Bitcoin network suffers from congestion. This congestion then causes processing fees that have reached $50!

Satoshi Nakamoto envisioned "A Peer-to-Peer Electronic Cash System" in the original Bitcoin whitepaper. Clearly, with the high fees and slow processing times, this is not possible.

Or is it...

 

Quick Overview + the Importance of the Lightning Network

By moving most of the Bitcoin transaction "off chain," the Lightning Network enables instant payments and the ability to process thousands of transactions per second. Instant payments and zero congestion would enable the peer-to-peer system that Satoshi originally envisioned.

The Lightning Network does not replace the Bitcoin blockchain, but rather creates a second layer on top of the regular Bitcoin protocol (the Lightning Network can be built on top of any existing blockchain, but for simplicity's sake, this post will use the Bitcoin blockchain as an example).

This second layer, or off-chain layer, utilizes multisig wallets and open payment channels to reduce congestion on the main Bitcoin network and scale Bitcoin transactions to thousands per second.

Lightning Networks are primarily designed for lower-value transactions, such as micropayments, and enable an unlimited number of near-instant and virtually feeless transactions.

By offloading the bulk of small transactions to the Lightning Network, the transactional load on the underlying Bitcoin blockchain will be greatly reduced and will further improve the transaction times and fee costs of the regular blockchain.

 

How Does it Work?

This explanation assumes a basic understanding of how transactions take place using the current Bitcoin proof of work process.

The backbone of the Lightning Network is something called Multiple Signature (multisig) wallets. These are just like regular cryptowallets, except they require more than one signature to enact a transaction.

First, the two parties, Bob and Alice (otherwise known as everybody's favorite crypto characters), set up a multisig wallet. Bob and Alice each distribute some amount of Bitcoin into the multisig wallet and the wallet address gets saved to the blockchain.

This sets up the Open Payment Channel. Open payment channels allow Bob and Alice to conduct an unlimited number of transactions without ever touching the blockchain. Essentially, they are sending the Bitcoin to each other "off chain."

By pushing their transactions "off chain" to open payment channels, transactions are able to circumvent the traditional 10 minute block times of Bitcoin.

With each transaction, both parties sign an updated balance sheet that reflects how much of the Bitcoin stored in the wallet belongs to each.

After they are done sending Bitcoin to each other, they close the channel, and the resulting balance is relayed to the miners in the Bitcoin network and registered on the blockchain. And, if they don't agree with the final balance, they just use the most recently signed balance sheet to recover their share of the wallet.

 

Let's recap:

  • Open Payment Channel: Created when a payment is initiated but not broadcast to the Bitcoin network
  • Closed Payment Channel: Created when both people sign the transaction and the payment is broadcast to the Bitcoin network and registered on the blockchain

Makes sense? Great. Doesn't make sense? Let's simplify.

Think of these open payment channels like a safety deposit box where both Bob and Alice deposit an equal amount of Bitcoin and then put a lock on it.

Let's imagine Bob and Alice are playing three games of chess and the winner of each game gets 0.1 Bitcoin.

So, Bob and Alice have each put in 0.5 Bitcoin into the safety box. This action of opening the box and putting money in gets registered on the blockchain.

Now they have a total of 1 Bitcoin to transact with.

So, Alice wins the first game of chess. Without the Lightning Network, Bob would have to send Alice 0.1 BTC and register that transaction on the blockchain. He would get charged a fee and it would take awhile to settle.

However, because they have put their Bitcoin into a box (opened a payment channel), they simply register that Alice now has 0.6 BTC in the box and Bob has 0.4 BTC in the box. Alice goes on to win the next two games. After each game, they each register that Alice has 0.7 BTC and Bob has 0.3 BTC, and then 0.8 BTC and 0.2 BTC, respectively. None of these 0.1 BTC transactions are recorded on the Bitcoin blockchain, but rather, they are recorded “off-chain."

Now though, the three games are over and they are done playing for the day. Bob and Alice sign off on the final amount and the new balances are broadcast to the Bitcoin network and registered on the blockchain.

So, now you understand bi-directional payment channels on the Lightning Network. Let's get into what really makes the Lightning Network so powerful... multiple channel payments.

Join us on August 7th 

Lightning Network Explained

 

The Real Lightning Network

We know that Bob and Alice have an established payment channel. Let’s add in some other folks - we'll call them Charles and Lily. Alice has a payment channel with Charles. And Charles has a payment channel with Lily. 

If Bob wants to send 0.1 BTC to Lily, he does not need to do this “on-chain.” Instead, he can simply user Alice and Charles to route his payment to Lily. 

How does this work? 

Bob needs to find a route to Lily and discovers that he can hop over Alice and Charles.

Lily creates a random number R, but keeps it secret. Instead she sends the hash of R, otherwise known as H(R) to Bob. The hash function is important because H(R) is easy to compute if you know R but inferring R from H(R) is basically impossible. 

Bob then creates a Hash Time-Locked Contract (HTLC) with Alice (HTLCs are another way a payment channel can be opened. These contracts delayed the spending of a payment until “X” amount of time has passed). 

Bob signs a transaction saying that Alice is entitled to 0.1 BTC if he figures out R (with hash value H(R)) within 3 days. 

Alice then does the same with Charles and, in turn, Charles with Lily. 

Remember, Lily knows R because she created it. Because of this, she can settle the payment with Charles. 

Lily now tells R to Alice and Charles. This makes it so they can settle their open payments of 0.1 BTC with Alice and Bob, respectively. 

In conclusion, Bob has transferred 0.1 BTC indirectly to Lily via Alice and Charles. 

Confused? I don’t blame you! This is confusing stuff and will take most a couple read throughs to understand. 

But, it’s important to understand because if enough people are interconnected, the majority of transactions can happen off chain and Bitcoin's congestion problem is a thing of the past.

 

Lightning Network

 

 

Lightning Network Use Cases

I hope you now understand the importance of the Lightning Network and the basics behind how it works (if you don't, this should help).

Because the transactions are just between you and me, or Bob and Alice, and don't need to be broadcast to the whole network, they are almost instantaneous. And because there are no miners that need incentivizing, transaction fees are low or even non-existent.

When might we see this in action?

Some initial ideas come to mind:

  1. You will be able to only pay for a partial video you’ve watched. Say, for instance, that you wanted to only pay for a movie as you watched, rather than paying $10 for the entire movie online. With the Lightning Network, you could pay for each minute of the movie that you watched, rather than for the entire movie. You and the streaming platform would open up a lightning channel, and as the minutes rolled by, periodic payments would be made from your wallet to theirs. When you're done watching, you would close the channel to settle the net amount on the Bitcoin blockchain.
  2. Similar to the example above, the Lightning Network will better enable pay-as-you-go phones.
  3. Your smartphone could use the Lightning Network to make automatic micro-transaction payments to WiFi hotspots that it connects to
  4. You can pay workers for the number of minutes (or even seconds) they’ve worked, rather than upfront for a 40 hour week.

In general, these automated micropayments become possible with sufficiently cheap transfers.

Of course, bringing it back to Satoshi's vision of a peer-to-peer network of electronic cash, the Lightning Network enables Bitcoin and other cryptocurrencies to compete with the Visas of the world for retail transactions.

Just like any technological innovation, it will take a long time to implement. However, in theory, instant and near-feeless Lightning payments will allow Bitcoin to replace cash, credit cards, and other payment methods for peer-to-peer transactions like buying coffee. While Bitcoin has proven extremely useful in the digital realm, Lightning may enable it to make the jump into more real-world applications.

View All News Posts

Jason Yanowitz

Co-Founder of BWG