Note: I originally published this blog on June 5th, 2016 on LinkedIn. I’d make a few changes now, but I decided to leave it as-is.
One of the prime criticisms of the Bitcoin protocol is its inability to scale. Today, Bitcoin can process roughly 7 transactions per second (tps) on average. Further the aggregate size of all transactions in every ten-minute period is restricted to 1 megabyte. Legacy payment networks like Visa and MasterCard are capable of processing many thousands of transactions per second (on the order of 50,000). Obviously, the current throughput of the Bitcoin blockchain is not acceptable for proponents wanting to see it become a global payments network.
Fortunately, a number of scalability ideas have been proposed by the Bitcoin development community. The most important of these ideas is a concept called the Lightning Network.
The Lightning Network has been compared with Layer 2 and 3 of the OSI Layer in networking. If the Bitcoin blockchain is a media where every node on the network hears every transaction (e.g., hub, repeater), then the Lightning Network works in part like a Layer 2 switch by restricting communication between two parties (i.e., sender and receiver). The Lightning Network also implements a transaction routing layer (i.e., Layer 3 in the OSI model) on top of Bitcoin, as we’ll see later.
How does the Lightning Network achieve all of this? It does this by effectively using the Bitcoin blockchain as a medium where account balances among participants are “eventually settled” (i.e., a settlement layer). For the most part, payments can occur over the Lightning Network without interacting with the Bitcoin blockchain. Any number of transactions can occur “off-chain”, and account balances can be settled at any time by any participant, all without introducing counterparty risk (i.e., you still don’t have to trust anyone).
There are two primary concepts that allow for the Lightning Network to function. The first concept is called a bidirectional payment channel. These payment channels are created between any two Bitcoin participants. Any pair of people (or institutions) wanting to transact first broadcast to the blockchain (i.e., on-chain) their intent to transact. This intent is the payment channel, which is nothing more than a SmartContract. Once a payment channel is established, transactions between those two participants can occur off-chain provided amounts do not exceed the terms defined in the payment channel (discussed below). When either of those two participants want to redeem or settle their account balances, they can simply broadcast the latest transaction to the Bitcoin blockchain. Participants of a bidirectional payment channel can conduct any number of transactions off-chain in any way they both agree to. For any transaction to be valid, both participants are required to consent to it, which usually means both participants have signed an updated transaction.
When a bidirectional payment channel is established between two people, participants encumber a certain amount of money. One can think of this as collateral for the person with whom you’re transacting—they’ll want to know that you have money to actually pay them. Participants might also want to know that they’ll get their original money back in the event of a problem, so bidirectional payment channels also have an “expiration” date whereby encumbered funds get returned to the rightful owner. Note that this expiration date is really considered a failsafe mechanism to be used only when a participant doesn’t proactively settle their account balances.
Let’s explore the lifecycle of a payment channel with a simple example. Suppose Bob agrees to mow Alice’s lawn based on the time it takes him to complete it. Alice and Bob start by establishing a payment channel. In this payment channel, Alice will encumber an amount of money in excess of what Bob intends to charge her. Once that payment channel is broadcast and recorded to the blockchain, Bob has cryptographic assurance that Alice can pay him because she’s effectively escrowed the money for the exchange into the payment channel.
When Bob begins mowing, he keeps track of the amount of time worked. Periodically (e.g., every 10 minutes), Bob pays himself for the time worked by creating a transaction that debits Alice’s encumbered funds. (The remainder of Alice’s encumbered funds get sent back to her.) Alice will also sign this transaction because she wants to pay Bob for the time worked as well as incentivize him to continue the job. These intermediate transactions are never broadcast to the blockchain because the account balances are still in a state of flux (i.e., Bob is still mowing and getting paid incrementally). But when Bob completes the job, he or Alice can close the payment channel. When this occurs, the latest transaction that was signed by both Bob and Alice will be broadcast to the Bitcoin blockchain. The payment channel is now closed and account balances are settled. Bob gets paid with a portion of Alice’s encumbered funds, while the remainder goes back to Alice to use as she wishes.
But bidirectional payment channels are not enough to really scale Bitcoin. The most important innovation with the Lightning Network is its ability to route transactions among a network of users with established payment channels. To illustrate, suppose that Alice and Bob have a payment channel opened with each other. Further assume that Bob has a payment channel opened with Carol. Considering this arrangement, is there a way that Alice can transact with Carol by way of Bob? With the Lightning Network, the answer is yes.
Routing payments using a network of payment channels looks very much like Layer 3 of the OSI model. Instead of routing packets among a network of links, the Lightning Network routes transactions among a network of payment channels. This arrangement has can be compared with routing protocols. The magnitude of encumbered funds, for example, might be compared with the payment channel’s “bandwidth”. Constraints like latency, availability, or fee schedules (someone may charge a small fee to facilitate payment routing) may further alter routing decisions. Off-chain transactions among a diverse network of users simply results in the “rebalancing” of encumbered funds among adjacent participants. (It is important to keep in mind that throughout this process, no one in the ecosystem needs to accept any counterparty risk. That is, Alice has no need for Bob to have custodial control over her funds, and Bob has no need for Alice to have custodial control of his funds.)
Payment channels among participants will come and go like links in a network, resulting in a change in the network topology. Therefore, routing of transactions through this network of payment channels must be dynamic. This is the role for Lightning Network implementations, such as the Thunder Network. These implementations route transactions in a secure, trustless, and instantaneous manner.
What does this mean for Bitcoin scalability? Initial tests of the Thunder Network have shown that a “better-than-Visa” scale (e.g., 100,000+ tps) can be achieved. The authors of the Thunder Network assert that its scalability properties are similar to the underlying peer-to-peer Bitcoin network; the more Bitcoin nodes on the network, the greater the transaction throughput. (Decentralized systems exhibit excellent scalability, availability, and antifragility properties.)
There are other notable features provided by Lightning Network implementations like the Thunder Network:
- Privacy: Any number of transactions can occur between any two individuals so long as terms of intermediate bidirectional payment channels aren’t violated. This means that people can keep atomic transactions private. Instead of disclosing atomic transactions (e.g., a cup of coffee, which I’m sure no one cares about), account balances are simply re-balanced to account for the purchase, then settled at some point in the future. This feature allows for all atomic transactions to be hidden from prying eyes.
- Security: all communications between Lightning Network nodes and wallets are encrypted using best-of-breed encryption techniques, preventing mass surveillance.
- Automatic Settlement – Nodes running Lightning Network software are capable of settling account balances before the expiration of the payment channel using the latest agreed upon transaction. Lightning Network nodes may “store-and-forward” transactions as needed.
- Trustless: As mentioned, the Lightning Network does not require any third-party trust, so your funds are never subject to counterparty risk and no one ever has custodial control (i.e., title) over your money.
- Instantaneous Payments: Since payments occur off-chain, transactions can occur at a rate dictated by the underlying communications medium (e.g., fiber, copper, etc.).
Unfortunately, full-scale Lightning Network implementations cannot yet operate until some important changes to the Bitcoin protocol are implemented. The first among these changes includes the addition of an opcode to the Bitcoin scripting language called CHECKSEQUENCEVERIFY (CSV). CSV allows a payment channel to have an arbitrary time limit. At the time of this writing, CSV has been locked-in and is awaiting a mandatory waiting period before it goes active on the production Bitcoin blockchain.
Another important improvement called Segregated Witness (segwit for short) was just merged with the Bitcoin core code base. Segwit improves Bitcoin in several ways. Segwit eliminates an entire class of vulnerabilities (called transaction malleability) and increases the effective block size by separating signature data (called the witness) from the transaction data. Segwit also makes future upgrades of the Bitcoin scripting language easier. Segwit is likely to be scrutinized closely by the entire Bitcoin community due to its complexity and implications, so it may take six or more months before it is enforced on the network.
It’s clear to see that the Lightning Network is an innovation on par with Bitcoin itself (though not quite in my opinion). It adds important layers onto the Bitcoin blockchain, allowing transactions to occur at a rate exceeding leading payment processors like Visa and MasterCard. Combine that with the fact that Bitcoin is a worldwide currency with excellent monetary properties, and you get a force to be reckoned with. But before we can see any of these benefits, the Bitcoin protocol needs to mature, and infrastructure needs to be built. After that, the next major problem to be tackled is adoption.