• etonec

How does the Bitcoin Lightning Network work technically?

Authors: Dr. Jonas Gross, Jonathan Knoll, Denis Scheller


Summary

In the first two parts of our article series, we showed what the Bitcoin Lightning Network is, what it can be used for, and how to set up a wallet and perform transactions. In the third article of the series, we focus on the technical functionality of the Lightning Network. We will explain the most important technical concepts used in the Lightning Network to enable fast, scalable, and cost-effective transactions.


Key technological concepts of the Lightning Network

The technical functionality of Lightning seems relatively intuitive due to the ease of use of Lightning (see Article 2). However, in the background, the network is highly complex. Creating a global payment system without intermediaries is no simple undertaking. The Lightning Network draws on numerous innovative technical concepts that are interconnected and integrated to enable low-cost global payments with real-time settlement. The basis for this is a global network of payment channels based on multisig wallets, commitment transactions and hash time-locked contracts.


Multisig Wallets

From a technological point of view, a Lightning payment channel between two people or between a person and a merchant is a multisignature wallet (also called "multisig wallet"). When money is deposited into a payment channel through a so-called "funding transaction" on the Bitcoin blockchain, the money can only be spent after both payment channel parties agree to the transactions. Therefore, both parties must always confirm updates to the account balances. When a transaction is carried out via Lightning, new account balances are ultimately negotiated in the background.


We can use the example of Alice and Bob to illustrate how this works. Assuming Alice has deposited 0.5 BTC into a payment channel with Bob, this payment channel has a maximum capacity of 0.5 BTC. For example, if Alice now wants to send 0.1 BTC to Bob via Lightning, then Bob's account balance in the payment channel is increased by 0.1 BTC (new account balance Bob: 0.1 BTC) and Alice's is reduced by 0.1 BTC (new account balance Alice: 0.4 BTC). To finally execute the payment of the 0.1 BTC via Lightning, this account update must be confirmed, i.e., signed, by both Alice and Bob. However, this signed account update is not published as a transaction via the Bitcoin blockchain but is created and held back as a so-called “commitment transaction.”


Commitment Transaction

In a commitment transaction, both parties commit to the payment of the last agreed-upon account balance. This ensures that payment partners do not have to trust each other to complete a transaction but rather rely on the Lightning Network. By signing the commitment transaction, the payment channel partners commit to the current account balance and allow the other party to pay out their money when needed, without needing the other party to agree again.


Assume that after Alice has sent 0.1 BTC to Bob, Bob stops responding to Alice’s messages. He does not get back to her for days and is offline. The current account balances are 0.1 BTC for Bob and 0.4 BTC for Alice. Since Bob must also agree to new transactions, Alice would normally not be able to get her 0.4 BTC back. Consequently, they would be "locked" in their payment channel - Alice would have to rely on Bob's cooperation. To solve this trust problem, Alice and Bob have previously created a commitment transaction. The commitment transaction now allows Alice to get back the last agreed balance without Bob's cooperation (i.e., Bob: 0.1 BTC, Alice 0.4 BTC). Thus, Alice can now initiate an on-chain transaction that will pay out the 0.4 BTC.


It should be noted that the commitment transactions are only published in extreme cases - e.g. when the counterparty can no longer be reached. This is because high transaction costs and a relatively long waiting period for transaction execution are generally incurred for the on-chain execution of a commitment transaction. Commitment transactions, therefore, provide security in an emergency - but can be published at any time if required.


Hash time-locked Contracts

Hash time-locked contracts (HTLCs) are another core technical component of the Lightning Network. HTLCs are particularly important for routing. Let's assume Alice wants to send money to another person, Charles. As we know from the aforementioned example, Alice already has a payment channel with Bob. We now assume that Bob maintains a channel with Charles. Alice can now use Bob's channel with Charles to send money to Charles. She does not need to open her own payment channel with Charles. Bob acts as a "middleman" in the payment process here. This process is called routing. For Bob to have the incentive to route the payment to Charles, Bob receives compensation in the form of a transaction fee. In this context, the capacity of the payment channel mentioned at the beginning also plays an important role. In order to send a transaction of 0.5 BTC from one party to the other, all channels along the way must have this capacity.


In the Lightning Network, the routing process works as follows. Alice wants to send money to Charles. As a start, Charles defines a secret that only he knows. In Lightning, this secret is typically a very long number that cannot be guessed within a reasonable time. Charles then sends a hash of the secret to Alice and Bob. The payment chain is now rolled up "back to front." Bob sends money to Charles when he has received the secret. Alice, in turn, sends money to Bob only when she has received the secret. Thus, it is a conditional payment that only occurs when Alice and Bob know the secret.


What happens if Charles does not forward the secret? Then, no payment would take place because the conditions for payment are not met. In Lightning, there is a deadline for forwarding the secret. The payment is canceled if the secret is not forwarded within the specified deadline. Technologically, this is implemented via HTLCs. These HTLCs expire after a certain amount of time, typically two weeks. The payment is only executed if the secret is entered correctly within this timeframe. If the time expires or the secret is incorrect, the payment is canceled. This mechanism is very important so that the network is not clogged and liquidity is available to individuals again. After all, while the money is locked in HTLCs, this liquidity cannot be used elsewhere.


Conclusion

The Bitcoin Lightning Network combines highly sophisticated technological concepts to provide users with an international payment system without intermediaries. The basis of the concept consists of a network of payment channels. Cryptographic ideas such as multisig wallets and commitment transactions ensure that account balances in payment channels can be updated and paid out at any time by the parties to the payment channel. HTLCs ensure that transactions are sent efficiently from sender to receiver when there is no direct channel between the parties. The next article will show practical examples of how the Lightning Network is used.




 

About the authors

Dr. Jonas Gross is Head of Digital Assets and Currencies at etonec GmbH. Jonas holds a Ph.D. in economics from the University of Bayreuth (Germany), and his main fields of interest are central bank digital currencies, stablecoins, cryptocurrencies, and monetary policy. Further, Jonas is Chairman of the Digital Euro Association (DEA), co-host of the German podcast "Bitcoin, Fiat, & Rock'n' Roll," and member of the Expert Panel of the European Blockchain Observatory and Forum. You can reach Jonas via jonas@etonec.com.


Jonathan Knoll is Founder and Managing Director at etonec GmbH. He has more than 25 years of experience in the payment & banking and blockchain industry working for innovative companies such as Sun Microsystems, PayPal/eBay, and Libra/Diem, where he was Head of Strategic Partnerships. At etonec, he is excited about building solutions at the intersection of crypto, payments & banking, and regulation. You can reach Jonathan via jonathan@etonec.com.


Denis Scheller is Senior Manager Bitcoin Suisse Pay at Bitcoin Suisse. Denis holds a degree in International Business Administration from Cooperative State University Mannheim (Germany) and has worked many years in payments and e-commerce. At Bitcoin Suisse Pay, Denis helps build crypto payment infrastructure. He is interested in macroeconomics and how bitcoin and lightning technology can enable a fairer society. You can reach Denis via denis.scheller@bitcoinsuisse.com.


This article does not represent any financial advice, advertisement or similar.


 

130 views0 comments

Recent Posts

See All