⚡ The Lightning Network, Part #1: The Basics Of The Technology


Enabling instant decentralized transactions using micropayment channels and Bitcoin

via Lightning Network Explorer

Many in the Bitcoin community eventually want to see Bitcoin being used as a global currency, used for everyday transactions. However, as of now, this is unfeasible due to potential network congestion, high transaction fees, along with the need to wait at least ten minutes to make sure that a transaction is confirmed.

Note: You can check out one of my previous articles for an introduction to Bitcoin:

Bitcoin Is Here To Stay, Whether You Like It Or Not

Bitcoin Has Significant Barriers To Global Implementation

Three key problems need to be solved before we can start using Bitcoin for everyday payments.

The first is that the way Bitcoin is structured right now, every node in the Bitcoin network knows about every single transaction occurring on the network. While this is what makes Bitcoin decentralized, it has proven to be a challenge when it comes to scalability. If we perform all of our small transactions with Bitcoin, it will quickly congest the network, since, as of now, one block is mined every 10 minutes, and there is a block size limit of 1 megabyte.

According to The Bitcoin Lightning Network: Scalable Off-Chain Instant Payments (the paper introducing the concept of a lightning network written by Joseph Poon and Thaddeus Dryja), this means that Bitcoin confirms a mere 7 transactions per second. The paper goes on to note that if we started making continuous small transactions the Bitcoin network would either crash or make it very expensive to run a Bitcoin node or miner. This would defeat the purpose of Bitcoin as a decentralized currency that everyone can afford.

Secondly, even in the current state of Bitcoin, it takes far too long to confirm a transaction. Not only do you have to wait around 10 minutes for a transaction to be added to a blockchain by a miner, but it is recommended to wait for 3–6 confirmations(number of blocks mined on top of the block containing your transaction) to confirm that a transaction is not being double-spent.

Another issue is that transaction fees can be high as a result of network congestion. This is because if a large number of people have unconfirmed transactions in the mempool, the miner has to choose which of those transactions to include in the block it will try to mine(because of the block size limit). The miner will choose the transactions with the highest fees in order to maximize profits.

Eliminating these problems will help us reduce the friction involved with using Bitcoin for everyday activities.

Introducing… The Lightning Network

The Lightning Network is a network of decentralized off-chain micropayment channels that can be layered on top of any blockchain-based cryptocurrency like Bitcoin, which is why it’s called a layer 2 technology. With the Lightning Network, transactions are instantaneous and transaction fees are insignificant. The only time you have to pay a full transaction fee is when opening and closing a micropayment channel. Even though the Lightning Network is off-chain, meaning that its transactions don’t occur on the blockchain, it is still secured by the blockchain, allowing for fast, cheap, and secure transactions.

Micropayment Channels

The lightning network is comprised of numerous micropayment channels. A micropayment channel is a channel in which two parties open to exchange funds by consistently updating the balances of both parties. Unlike using traditional methods of transacting Bitcoin, or other cryptocurrencies for that matter, here whenever the balance is updated, it’s not immediately broadcast to the nodes in the Bitcoin network.

While at first, it seems like both parties are required to trust each other, this is far from the truth as the lightning network doesn’t clash with one of the original principles of Bitcoin, that you shouldn’t need to trust a third party or each other to safely transact your funds.

Opening A Payment Channel & Committing Funds

A payment channel is opened by both parties committing funds to a multi-signature address. A multi-signature address is an address containing multiple valid signatories along, with a certain number of those signatories required to sign a transaction to validate it.

With a micropayment channel on the lightning network, the parties commit funds to a 2-of-2 multi-signature address. “2-of-2” means that there are two valid signatories, and both of those signatories are required to validate a transaction. Either party can get a refund of their funds whenever they wish. So far, the only thing that has been broadcast to the network is the deposit of funds into the multi-signature address.

Because anyone can create a payment channel, we need a set of standards in order to make sure that our micropayment channels can work together. These standards are called the BOLT(Basis Of Lightning Technology) standards.

Transacting Funds Using A Private Micropayment Channel

A transaction on the Lightning Network is just a matter of updating the amount of money the two parties can redeem. A transaction can be made by both parties creating a new spend from the multi-signature address.

There is only ever going to be one correct state of balances in the micropayment channel, the most recent one. To ensure that one of the parties doesn’t redeem funds from a previous spend(one which has been followed by a new spend), all old transactions are invalidated and only the new transaction is valid. In addition, the party which tried to broadcast the invalid state is forced to give all of their funds to the other party involved.

This makes it so that the lightning network is secured by the blockchain even though the transactions which take place on the lightning network aren’t broadcast to the blockchain. It’s the best of both worlds since by having transactions take place on the lightning network, transactions are instant and transaction fees are greatly minimized.

Closing Payment Channels & The Settlement Transaction

The last transaction in a micropayment is the settlement transaction, which is broadcast to all Bitcoin nodes. Either party can make a settlement transaction.

Note that the two parties never actually need to settle, in fact the original lightning network paper notes that “it is possible to create a near-infinite amount of transactions inside this network.”

Routing Payments Through The Lightning Network With Public Micropayment Channels

So far, we’ve only been talking about payments between two parties that have opened a micropayment channel, but if you have to open a payment channel every time you need to make a transaction to a new person, that defeats the purpose of the lightning network because we’re trying to minimize the number of transactions we need to broadcast to the network.

With the lightning network, you can also route payments to someone with whom you haven’t opened a channel through someone you have opened one with. It will be easiest to explain this using an example, so let’s say that Alice wants to send some Bitcoin to Carol, but doesn’t want to open a micropayment channel with her. Alice, however, has a channel open with Bob, who in turn has one open with Carol.

First, Carol randomly generates a secret(R) which only she knows. She generates the hash of this secret and sends it to Alice. Alice then constructs a payment that can only be redeemed using the secret R. Alice then sends the payment she just constructed to Bob who is incentivized to give it to carol because Alice will give Bob a certain amount of Bitcoin once he knows the secret. Bob sends this over to Carol, who does have the secret R, so Carol redeems her funds and back-propagates the secret to Bob, who gives it to Alice so that Alice sends him the Bitcoin she owes him.

A Future With Lightning Networks

Once the lightning network becomes mainstream, it will be easier to make instant transactions built on top of a secure, decentralized bitcoin blockchain with ease. We’re off to a strong start, with there currently being around 12,400 nodes in the network, and as lightning network expansion continues, we are getting closer and closer to such a reality.

Sources & Helpful Resources

The Bitcoin Lightning Network: Scalable Off-Chain Instant Payments

A Technical Introduction to The Lightning Network — We Are Developers 2020

The Lightning Network Could Make Bitcoin Faster — and Cheaper

About Me

Ishaana Misra is a high school freshman interested in AI, Medicine, and Blockchain.

Twitter: https://twitter.com/IshaanaMisra

Check out my newsletters: https://ishaana.substack.com

Join Coinmonks Telegram Channel and learn about crypto trading and investing

Also, Read

⚡ The Lightning Network, Part #1: The Basics Of The Technology was originally published in Coinmonks on Medium, where people are continuing the conversation by highlighting and responding to this story.