Understanding the Lightning Network(1)
In the previous article, Why We Need the Lightning Network, we explored the necessity and importance of the Lightning Network. As a peer-to-peer network built on the Bitcoin blockchain, the Lightning Network not only effectively addresses Bitcoin's "slow and expensive" issues but also has unparalleled advantages in the field of crypto payments. It forms the foundation of a peer-to-peer economy and is a crucial part of the envisioned Web5 world.
In this article, we will continue to introduce the Lightning Network, explaining its working principles and related technologies.
The Cornerstone of the Lightning Network: Payment Channels
The Lightning Network is essentially a well-designed system of payment channels. Using the example of transactions between Alice and Bob, their settlement process in the Lightning Network goes through three key stages: opening the channel, conducting transactions, and closing the channel.
Opening the Channel: Building a Bridge of Trust
Opening a channel essentially involves creating a multi-signature wallet controlled jointly by both parties, into which they deposit funds. The total amount in this wallet represents the balance of the channel.
Assume Alice and Bob each hold 100,000 satoshis of BTC. First, they need to transfer 100,000 satoshis each into a jointly controlled multi-signature wallet address as collateral to establish the channel. This transaction, known as a "Funding Transaction" or "Anchor Transaction," must be broadcast to the network and recorded on the Bitcoin blockchain, marking the official opening of the channel. In this example, the payment channel connecting Alice and Bob is effectively a standard 2-of-2 multi-signature wallet with a balance of 200,000 satoshis (for simplicity, we’ll ignore the miner fee required for opening the channel).
Initiating Transactions: The Art of Off-Chain Transactions
Once the channel is open, all subsequent transactions between the participants are conducted off the Bitcoin blockchain, enabling efficient off-chain settlement. Let’s assume the following three transactions occur between Alice and Bob:
Alice sends 10,000 satoshis to Bob; now Alice has 90,000, and Bob has 110,000.
Alice sends another 20,000 satoshis to Bob; now Alice has 70,000, and Bob has 130,000.
Bob sends 10,000 satoshis back to Alice; now Alice has 80,000, and Bob has 120,000.
From these examples, we can see that no matter how many times Alice and Bob transact, the total balance in their channel remains at 200,000 satoshis. Each time Alice and Bob transact, they must update their respective balances within the channel and exchange signed “Commitment Transactions.” These transactions are valid and can be broadcast to the Bitcoin network at any time, but the participants usually save them instead of broadcasting unless they intend to close the channel. As a result, Alice and Bob’s balance states within the channel can change multiple times per second, with the update speed limited only by their ability to create, sign, and send commitment transactions to each other.
Closing the Channel: The Moment of Final Settlement
Closing the channel can occur in two ways: both parties agree to close it, sending a settlement transaction to the Bitcoin network; or one party decides to close it unilaterally by sending the latest commitment transaction to the Bitcoin network. The latter design prevents one party’s funds from being indefinitely locked in the channel if the other party goes offline.
In Alice and Bob’s case, they decide to close the channel after three transactions. After closing, Alice retrieves 80,000 satoshis, and Bob retrieves 120,000 (again, ignoring any miner fees incurred when closing the channel for simplicity).
Security in Bidirectional Payment Channels: From LN-Penalty to eltoo to Daric
As mentioned above, channel closure can be agreed upon by both parties or decided by one party unilaterally. So, how can fraud be prevented in bidirectional payment channels? For example, in the above scenario, how can we prevent Bob from using the second commitment transaction instead of the third to close the channel? If Bob used the second commitment transaction to close the channel, he could deny the last payment of 10,000 satoshis to Alice, which might be tempting.
The Bitcoin Lightning Network introduces the LN-Penalty mechanism to prevent one party from closing the channel with an outdated but favorable state. LN-Penalty uses complex techniques like "asymmetric commitment transactions" and "revocation keys" to ensure that if Bob attempts to use an outdated commitment transaction to close the channel, Alice has the right to claim the entire 200,000 satoshis in the channel. This penalty mechanism effectively deters potential fraud.
However, LN-Penalty has its limitations: aside from its complexity, it also imposes a storage burden, as users must save the data from each channel state update, and rare circumstances could inadvertently punish honest users. To address these drawbacks, the Bitcoin community proposed a solution in 2018 called "eltoo," which eliminates the storage burden and the risk of accidental punishment. In this solution, users only need to keep the latest commitment and settlement transactions. However, the eltoo proposal is not yet available, as it requires a soft fork of Bitcoin to introduce a new signature hash type, SIGHASH_ANYPREVOUT.
Nervos CKB's Lightning Network Fiber Network adopted the 2022-proposed Daric solution. Daric, based on eltoo, effectively addresses the cost and security issues of watchtowers. Watchtowers are Lightning Network nodes operating on independent machines and networks, monitoring payment channels and executing penalty transactions to protect user funds if malicious behavior is detected. Node operators typically run their own watchtowers to protect their nodes.
Conclusion
As a Bitcoin scalability solution, the Lightning Network’s core lies in its cleverly designed payment channel system. Through the three stages of opening a channel, off-chain transactions, and closing a channel, the Lightning Network significantly improves transaction speed and reduces costs. To ensure the security of bidirectional payment channels, the Lightning Network employs the LN-Penalty mechanism, while the Bitcoin community has proposed enhanced security mechanisms such as eltoo and Daric to prevent potential fraud effectively. These innovations enhance security and bring significant performance improvements to the Bitcoin network, paving the way for fast, low-cost micropayments.

