The solution designed to address Bitcoin’s scalability problem. Instant transactions and minimal fees, inheriting the security of the blockchain
- A solution to scalability: History and key concepts of the Lightning Network
- Technical capabilities: Payment channels, multisig and transactions
- Pathfinding: how the Lightning Network identifies optimal paths for transactions
- The role of routing and HTLCs in Lightning Network Payments
A solution to scalability: history and key concepts of the Lightning Network
The issue of scalability has always been one of the thorniest problems for Bitcoin. Security and the extensive decentralisation of the network lead to an inevitable trade-off: a slow and inefficient blockchain in terms of the amount of transactions supported (around 280,000 per day). The creation of the Lightning Network (LN) was a strategic move to address this problem without compromising the first layer of Bitcoin’s architecture, also referred to as Layer 1.
In 2015, Joseph Poon and Thaddeus Dryja published a paper entitled The Bitcoin Lightning Network: Scalable Off-Chain Instant Payments. Three years later, the Lightning Network began operating as a second layer on top of Layer 1, which consists of approximately 50,000 nodes distributed worldwide. Layer 2 has approximately 17,000 nodes and offers a solution that enables instant and potentially unlimited payments without constantly involving the blockchain.
Technical functionalities: multisig payment channels and transactions
On the technical side, the Lightning Network uses a structure of payment channels between two nodes. If Alice and Bob wish to make frequent transactions, they can open a payment channel. Initially, they both have to deposit a certain amount of bitcoin into a multisig address, which is essentially a shared vault registered on the blockchain. This is the payment channel: the initial balance could be, say, 0.3 BTC.
Within this channel, an unlimited number of transactions can take place without having to register every single transaction on the blockchain. Each transaction simply updates the channel’s internal balance. This is particularly advantageous because it avoids transaction fees and waiting times for confirmation on the blockchain.
When they decide to close the channel, the final balance will be recorded on the blockchain with a single transaction. Thus, even after hundreds of transactions within the channel, only two transactions will be recorded on the blockchain: one to open the channel and one to close it.
It is important to note that the funds in the payment channel are blocked only in the sense that they are reserved for transactions within it. This does not mean that they are inaccessible; rather, they are specifically allocated to facilitate quick and low-cost exchanges between channel participants.
Pathfinding: how the Lightning Network identifies optimal paths for transactions
Pathfinding is a process that allows transactions to flow through various nodes. Users do not necessarily have to establish a direct channel with every counterparty they wish to transact with.
The Lightning Network is itself a network of interconnected nodes. This architecture allows payments to be routed through multiple nodes, as long as there is a path for the transaction to reach its intended destination.
Let us imagine that Node A wishes to send a payment to Node D. Provided a path exists through which the transaction can take place, the payment can be successfully routed. This is where the algorithmic process of pathfinding comes into play. With a network consisting of over 16,000 nodes and about 43,000 channels, with an average liquidity of 4 million sats, finding a path is not complicated.
The real difficulty arises when it comes to selecting paths that have sufficient liquidity to support payment. If Node A opens a channel with Node B with a liquidity of 1 million sats, the channel is initially unbalanced: Node A has 1 million sats of liquidity outgoing and Node B incoming. When A sends 500,000 sats to B, the channel becomes balanced with 500,000 sats of liquidity in and out for both nodes.
If Node A wishes to send 500,000 sats to Node D via B and C, but even one channel in the path does not have this liquidity, the transaction fails. Therefore, the role of pathfinding algorithms extends beyond simply finding a path; it must also ascertain that the path has sufficient liquidity for the transaction to be successfully processed.
The role of routing and HTLCs in Lightning Network payments
Once a route has been found, it is also necessary to guarantee the security of payments as they transit from one node to another. How does the Lightning Network ensure that a node within the payment path does not act maliciously, stealing funds?
Consider Alice who wishes to send 100 sats to David via Bob and Carol. Bob and Carol provide their cash to complete this transaction and are incentivised by a commission. Alice sends 106 sats to Bob, who keeps 3 sats and sends 103 sats to Carol. Carol keeps her 3 sats and forwards 100 sats to David, thus successfully completing the payment. To prevent Bob or Carol from trying to collect the full amount, the Lightning Network employs what can essentially be called a smart-contract: the Hashed Timelock Contract (HTLC)
David, the recipient of the payment, starts by generating a random value known as the Payment Secret and calculates its SHA-256 hash. The Payment Hash is then sent to Alice, the sender. A recurring contract is then established:
- Alice deposits 106 sats which Bob can only unlock by revealing the Payment Secret behind the Payment Hash;
- Bob agrees to pay 103 of the 106 sats he will receive from Alice to Carol, provided Carol reveals the Payment Secret behind the Payment Hash;
- Carol agrees to pay 100 of the 103 sats she will receive from Bob to David, provided that David discloses the Payment Secret behind the Payment Hash.
In this way, David can reveal his original Payment Secret to Carol, who will verify its correspondence with the Payment Hash and proceed to send the agreed sum of 100 sats. Carol will then pass the Payment Secret to Bob to receive her 103 sats, and Bob will finally reveal the Payment Secret to Alice to unlock her 106 sats.
Conclusions
The Lightning Network represents a significant advancement in Bitcoin scalability. It offers a solution that inherits the integrity, security and decentralisation of layer 1, enabling instant payments on a higher layer. With mechanics such as pathfinding and routing, this network-over-network represents a vital innovation that is likely to drive the future of digital transactions.