The Lightning network explained simply

What is the Lightning Network (LN)?

In July 2015, the Lightning Network was introduced as a protocol for scaling blockchain technologies, in particular the Bitcoin network. Almost three years later, in March 2018, the first beta version was finally released and the network was launched. Even today, we can still say that the Lightning Network is still in its infancy and still has a lot of potential for further development. But what is this Lightning Network actually?

The Lightning Network, often abbreviated as "LN", is currently one of the most exciting developments in the Bitcoin and blockchain cosmos, as it is revolutionizing the way value is transferred. The free and open network brings great improvements for Bitcoin, but theoretically also for other blockchain applications. As a so-called "second layer" technology, the LN builds on existing blockchain systems to improve existing features (e.g. transaction speed) or even add new functionalities (e.g. anonymity or micropayments).

Why do we need the LN?

As the Bitcoin blockchain is essentially a global database in which every transaction made must be validated by every participant and then stored for eternity, it is an almost hopeless undertaking to scale this construct in terms of transaction speed. This does not really make the Bitcoin network an alternative to modern payment service providers such as VISA, Mastercard or PayPal. However, this is not what Satsohi Nakamoto had in mind for his invention: Bitcoin was created to offer a secure, free, non-manipulable and uncensorable alternative to the world's existing monetary systems. In an increasingly digitized and globalized world, Bitcoin provides the infrastructure for a globally operating and secure monetary network. In order to achieve this noble goal, two characteristics of the network must be particularly pronounced: security and decentralization.
Bitcoin must be as decentralized and secure as possible in order to be truly free and, in an emergency, be able to withstand attempts at censorship or manipulation by large nation states.
Over time, as interest in Bitcoin has grown, so has the number of transactions to be processed via the network. As each transaction requires some space in a block of the blockchain and these blocks are limited in size, however, not every transaction always manages to become part of the next block directly. In addition, the Bitcoin protocol is programmed in such a way that a new block can only be found every 10 minutes on average. A queue of surplus transactions therefore forms in the so-called mempool, which are processed by the miners according to the principle "the more fees are paid, the sooner the transaction will be included in the next block". This in turn means that the cost of writing a transaction to the blockchain within a reasonable period of time increases enormously as soon as the number of desired transactions exceeds the capacity of the blocks. If you are not prepared to pay high transaction fees, it can take hours or even days for your transaction to be confirmed by the network.

[The men (transactions) with the large coins (fees) may add the transaction to the block first].

Now, of course, it would make sense to either reduce the time between two blocks or to increase the maximum size of the blocks in order to be able to process more transactions. However, this approach would not be a good solution for several reasons and would create many problems elsewhere. For example, the costs of operating a so-called full node (i.e. a computer that stores the entire blockchain and validates the transactions) would increase immensely. The larger the block size, the greater the requirements for bandwidth, processing and storage space for each individual full node. Increasing transaction capacity in this way would have the undesirable effect of centralizing the system, as only a few entities would be able to afford to operate it. Antonopoulos, Pickhart and Osuntokun state in their work "Mastering the Lightning Network" that it would take around 8GB per block to get close to the transaction volume of VISA, for example (40,000 Tx per second). This would mean that approximately one terabyte of new data would have to be stored every day, which would definitely only be affordable for large companies and would make the operation of full nodes for private individuals de facto impossible. In this context, the crypto community often talks about the so-called "trilemma". This describes the fact that a distributed database can only ever maximize two of the three properties of security, decentralization or scalability. It is considered impossible for a blockchain to be decentralized and secure and still be extremely scalable.

Even in the early years of the Bitcoin network, it was clear that it would not be possible to scale a decentralized and secure data structure, such as the Bitcoin blockchain, in terms of transaction processing. Hal Finney, one of the earliest Bitcoin pioneers and recipient of the first Bitcoin transaction said the following back in 2010:

"Bitcoin itself cannot scale so that every single financial transaction in the world could be transmitted to everyone and added to the blockchain. There needs to be a second layer of payment systems that is lighter and more efficient."

Hal Finney in 2010

Even then, he was already talking about second layer payment systems, the so-called second layer technologies, such as the Lightning Network. Within this wider network, the trade-offs for the trilemma can be distributed differently. The Lightning Network per se focuses on scalability and decentralization. By building directly on the Bitcoin blockchain as the base layer, it can still offer a high level of security. Although the trilemma is not solved by the Lightning Network, it is at least elegantly circumvented in combination with the Bitcoin network.

What can the LN do?

Real-time payments

As already mentioned, the Lightning Network has a number of advantages. First and foremost, it enables its users to process transactions in real time and almost free of charge . Unlike the Bitcoin network, there is no average waiting time of 10 minutes in the LN to be able to make the next series of transactions. As the name of the network suggests, payments via the LN are lightning-fast and virtually instantaneous.

Low costs

As no miners have to be paid in the network, transactions can be processed for a fraction of a cent or even completely free of charge in some cases. As of Q1 2021, the average fee for a payment of an average amount in the Lightning Network is around 4-5 Satoshi, which is equivalent to less than one euro cent.

Greater flexibility

While a satoshi is the smallest possible transferable unit in the Bitcoin network, the LN even allows payments in the milisatoshi (mSat) range, which also offers an enormous advantage and improved flexibility for certain use cases in the area of so-called microtransactions. We will go into this in more detail in the section "What else can I do with the LN?".

Anonymity

Another advantage of the Lightning Network is the significantly increased privacy compared to the base layer ("main layer") of the Bitcoin network. While individual entities there are at best pseudonymous and transactions in the blockchain can be traced back to the so-called genesis block with full transparency, the Lightning Network shines with a lack of transparency and anonymity. No one in the network can trace who is sending how much to whom.

How does the LN work?

The basic concept of the Lightning Network is the so-called payment channels. Network participants can then use these to send and receive payments. Unlike so-called "on-chain" transactions, i.e. those that are processed directly via the Bitcoin blockchain, Lightning payments are made exclusively between two parties without any real intermediary mechanism.

Entries on the blockchain, on the other hand, only happen when these channels are opened or closed. All transactions that take place in the meantime happen virtually in real time and without fees. The main layer is only used for the so-called "settlement". Basically, the concept can be compared to a letter on a beer mat in a pub.

You and the pub open a payment channel, the beer mat. The friendly waitress notes all transactions that take place during your visit so that you don't have to pay for each order individually. You would have to get your wallet out for every beer and snack you order. Since you don't always have it handy, the waitress has to rummage in the change pocket every time you pay to give you your change. In the worst case scenario, she doesn't have the right coins in her purse and has to go to the till to bring you your change. All of this takes time and , as we know, time is money. So to save time and money, the beer mat is used as a kind of payment channel or register and a single ("on-chain") transaction only takes place between you and the pub for the final bill. Regular customers in particular are not always billed on the same day, but at (un)regular intervals.

How does the "Lightning beer cap" work?

On a digital and decentralized level, opening a beer mat or payment channel naturally works a little differently than in the real world. To open a payment channel between two parties, a so-called multi-signature transaction is required, in which each channel partner locks a certain amount of bitcoins in a multisig wallet and then receives one of a total of two required keys. By locking away the amount of BTC on the Bitcoin blockchain, a payment channel is opened in the Lightning Network with a capacity equal to the amount locked away.

This payment channel now represents a kind of register in which, however, not every transaction is individually noted and recorded, but only the respective status of how the deposited amount is distributed in the corresponding channel.

Assuming Alice and Bob each deposit 2.5 BTC in the shared multisig wallet, a payment channel would be opened in which each has 2.5 BTC on their side. If Alice now sends a payment of 0.5 BTC to Bob, the status of the channel would change fromAlice: 2.5 BTC | Bob: 2.5 BTCtoAlice: 2 BTC | Bob: 3 BTCwould change. If Bob then in turn sends a payment of 2BTC to Alice, the status changes toAlice: 4 BTC | Bob: 1 BTCand so on.

Within this channel, any number of transactions can now be processed free of charge without having to write them to the blockchain each time, which in turn would incur costs in the form of transaction fees. Only when both parties make the final settlement and close the payment channel is the current status, i.e. the distribution of coins, immortalized again in the Bitcoin main layer.

Can I close the channel at any time?

In short: Yes.

Basically, there are three ways in which the payment channel can be closed.

  1. Collaborative: This means that both parties agree to close the channel. The funds are to be used freely immediately after confirmation of the closure.
  2. Unilateral: Either party can also close a Lightning Channel independently without the consent of the other party. However, in order to prevent fraud, this is linked to a time lock during which the other party could raise an objection if necessary. If this does not happen, the funds are free after the time lock expires.
  3. As an emergency solution in the event of violations: Lightning transactions can be seen as a kind of list that is always signed and timestamped by both parties. Only the distribution of the coins in the channel varies. As already indicated in point 2, one of the two parties could want to cheat and try to close the channel with an old status in which it holds more BTC than it is actually entitled to. In this case, the other party has the option of sending a so-called "breach remedy" transaction (also known as a "justice transaction") to the network during the time block and thus paying out the entire channel capacity itself. This would therefore also be a direct punishment for the fraudster. The justice transaction is signed by the other party with every channel update and the coins can therefore be paid out directly without a time lock.
Info

Excursus: Lightning watchtower
To minimize the risk of being cheated out of your money in a scenario like this, so-called watchtowers can be used. Suppose Alice and Bob have carried out a transaction in their shared channel in which Bob has purchased goods worth 1BTC from Alice. As soon as Alice logs out of her system, Bob could propagate the initial state (each has 2.5BTC) to the network and close the channel. Bob would have received goods worth 1BTC without owning less BTC.
The Watchtowers are effectively third party software that can be used to detect and uncover such fraudulent activity so that Alice can use the Justice transaction in time to prevent the fraud.

So do I need a channel for every person in the world?

No! Of course you don't have to open a channel with every friend, merchant or stranger, even though you only do one transaction with them. To send payments where you do not have a direct payment channel to the recipient, you can also use the channels of other network participants. You can send your payment to the desired destination via several channels (so-called "hops"). So if, for example, Alice wants to send a payment to Satoshi but only has one channel to Bob, she can still do so under certain conditions.

Alice sends the desired amount to Bob. He in turn sends the exact same amount via another channel that he has to Marie, who in turn forwards the same amount via one of her own channels, etc., so that the payment ultimately reaches Satoshi. For forwarding the transaction, the corresponding nodes that are used for routing usually charge a small fee, which is usually only a fraction of a cent. A lighning node is normally configured in such a way that it always looks for the cheapest route to the destination.

The more participants there are in the network, the better, faster and more powerful the LN becomes. More participants mean more channels and therefore more potential routes to get a payment to its destination.

Important: Even nodes that act as nodes on the payment route do not affect your privacy. Nodes on the route cannot recognize who a payment originally comes from and where it ultimately goes. In addition, the routing is also trustless. A payment cannot be stolen by an intermediary node. Either a payment reaches the desired destination or it is canceled.

What else can I do with the LN?

At this point, it may also be worth mentioning that the Lightning Network is not exclusively limited to Bitcoin. It is a free and open network and can theoretically also be used to process payments with ETH, LTC or other cryptocurrencies. All in all, the Lightning Network offers a wide range of possible use cases. We would like to give you a few examples here:

Money streaming

The streaming market has gained enormous momentum in recent years. Nowadays, almost anything can be streamed over the internet. Music, films, video games and, with the help of the Lightning network, even money.
The popular Lightning client "Breez" has recently added a feature that has been very well received, especially in the podcaster scene. With "Podcasting 2.0", the LN supports content creators in the distribution and monetization of their content.

As a rule, the creators of podcasts and similar formats can only rely on large platforms and the insertion of advertising. However, portals such as Anchor or Spotify demand large portions of the revenue generated or even exercise censorship.
The Lightning Network can remedy this situation by enabling consumers to stream the minutes they listen to to content creators in real time.

In this video, Jack Mallers, CEO of Zap and Strike, shows us another use case for money streaming. While employees usually only receive a salary once a month, the Lightning Network makes it possible to pay for time worked to the second.

Gaming

The opportunities that LN offers for the gaming sector go hand in hand with money streaming. By implementing Lightning payments in computer games, completely new incentives can be created. Gamers can now play for real money in the form of Bitcoin or Satoshi and receive real rewards for good performance in the game. Examples include Lightnite (a Lightning version of the popular online shooter "Fortnite") and Bitcoin Bounty Hunt.

Messaging

In addition to sending monetary transactions, the LN allows additional data to be attached to Lightning transactions, which makes it possible to send messages. Even though Lightning messaging services such as Sphinx, Whatsat and Juggernaut are still in their infancy, they and the LN have enormous potential to revolutionize the sending of direct messages in the future.

Messaging via LN applications instead of the familiar WhatsApp, Telegram and other services offers enormous advantages. Firstly, of course, there is the obvious argument of sending money via Messenger. Creating and paying invoices and sending payments directly in the messaging app is no longer a dream of the future but already a reality and as easy as sending a text message.
Here is an example:

Another advantage is that the messages in the LN no longer run via central servers, but via a network of thousands of Lightning nodes. On the one hand, this minimizes the risk of outages, as it eliminates a single point of failure, and on the other hand it increases the censorship resistance and privacy of your own message histories.

Ergo, the LN enables free or cheap, confidential and censorship-resistant messages, which can also be provided with additional features via the payment functions. For example, it could be set that every message in a forum costs a small amount of money, which would reduce spam enormously.

Sign-in service

To avoid having to log in to every website with a separate account, large services such as Google and Facebook allow their users to log in to other services with the corresponding accounts.

The LN also offers the option of authentication on websites - but without a central instance. The Lightning Authenticator from Lapps.co uses the unique Lightning Node ID as proof of identity without linking it to the user's personal data. Social media accounts, email password combinations and the like are no longer necessary. This increases security, user-friendliness and user privacy.

What criticism is there?

As mentioned above, the Lightning Network is still in its infancy. As a result, there are some critical points and problems that need to be solved in the future:

User experience/usability

Some technical understanding is still a basic requirement and most applications for the LN are not yet easy to use for everyone. Projects such as Raspiblitz or getUmbrel, but also custodial wallet providers such as Bluewallet or Zebedee are doing a very good job in this respect and making the LN suitable for the masses.

Liquidity

In order to be able to send or receive payments via the LN, your own channels require sufficient liquidity - both outgoing and incoming. As long as you do not have channel partners who provide incoming liquidity on their side of the payment channel, it is not possible to receive payments. Services such as https://lightningto.me/ provide a remedy here. Furthermore, this "problem" even provides another use case for Lightning and Bitcoin. Users can provide liquidity in the form of BTC for other network participants and receive interest in return.

LN nodes must always be online

A frequently mentioned criticism is the fact that an LN user's node must always be online if they want to send or receive a payment. Usually, 08/15 users do not always have their devices online at home. For (semi-)professional Bitcoiners, this is of course not a major hurdle, as a mini-computer (usually a Raspberry Pi) is usually set up, which can run 24/7 without any problems. The average user, on the other hand, is dependent on (centralized) third-party providers for the smooth use of LN applications, which speaks against the decentralized nature of the network.
However, as a Lightning Node does not need any major technical requirements, a lot can certainly happen on this front in the future. For example, the routers of your own Internet provider (which usually run 24/7) could be delivered directly with an integrated Fullor Lightning Node.

Routing

When it comes to routing, i.e. the search for suitable routes in the network in order to be able to send payments across multiple channels, there are also one or two problems that need to be solved or improved. One of these is primarily related to the issue of "liquidity". When sending larger amounts, it can happen that the nodes cannot find a suitable route with sufficient liquidity to carry out the transaction. However, one solution to this is to automatically split the large transaction and send it via several routes with lower liquidity.

Alex Bosworthfrom Lightning Labs tweeted some time ago about the causes of routing errors that can be identified:

  1. You lack inbound liquidity
  2. Your node is not online long enough
  3. The capital is tied to competing target nodes
  4. The capital is tied to destination nodes that nobody wants to send to
  5. Your fees are set too high
  6. Your incoming liquidity does not have enough incoming liquidity itself

As the network grows, it should actually become easier to find suitable routes for a desired transaction. However, some critics fear the exact opposite. Since the Lightning Network is in a constant state of flux and the channel states change every day, opening and closing, and there is no central memory for the history to fall back on, the payment routes have to be recalculated each time. According to critics, if the network becomes very large, small nodes running on weak hardware, such as the Raspberry Pi 4, will no longer have a chance of calculating a suitable route. They fear that this could lead to only large nodes on high-performance hardware being suitable for calculating the routes, which could mean centralization again to a certain extent.

Griefing Attacks

So-called griefing attacks are a well-known problem in the Lightning network, for which there is no real solution yet - but the first promising proposals, e.g.Circuitbreakerby Jost Jager. An attacker could use special HTLCs (*see excursus), so-called "Hodl Invoices", to paralyze the victim's payment channels and demand payment of a ransom. It only takes 483 of these HTLCs to completely block a channel in one direction. Even a collaborative closure of the channel is no longer possible in this case. The problem with griefing attacks is that they can be maintained by the attacker indefinitely, even if a victim complies with the blackmail and pays the ransom.

Another reason for such an attack could be the blocking of competitors in a dispute over routing fees. By blocking competitors' channels, more transactions have to be routed via the attacker's own payment channel, which would result in higher revenues for the attacker.

Info

Excursus: HTLCs
A Hashed Time Lock Contract (HTLC) is a special type of transaction that is used to generate transactions that are linked to a condition. HTLCs in the Lightning Network are basically payments where the recipient or beneficiary must confirm receipt of the payment before a specified time or date.
The recipient must confirm this payment in the form of a cryptographic proof of payment, otherwise the sender has the option of claiming this payment and spending it before him.
An HTLC therefore practically implements time-bound transactions in the crypto world. If the recipient does not generate cryptographic proof of receipt of the payment within a certain predetermined time frame, they do not receive any money and the transaction becomes invalid. HTLCs are primarily used to minimize counterparty risk.

Flood and Loot

Flood & Loot " is also a theoretical problem for which there is as yet no real solution. This is a systematic attack on a large number of network participants. An attacker starts by opening as many payment channels as possible to his subsequent victims and uses these to send payments to a second node that also belongs to him. Then (usually when the transaction fees in the network are high anyway) the attacker accepts the transaction on one side without providing proof of HTLC on the other. As a result, the victim is forced to close the channel in order to claim their fair share before the deadline expires. However, because the attacker attempts this attack on a large number of people, the blockchain is "flooded" with transactions, which means that not everyone can claim their funds in time due to the resulting overload and these ultimately go to the attacker. The two researchers, Jona Harris and Aviv Zohar, were able to prove that just 85 simultaneously attacked payment channels are enough for the attacker to make a profit from the operation.

Particularly problematic is the fact that victims can hardly defend themselves against the attack and the stake or risk for the attacker is relatively limited, which increases the probability of flood & loot attacks enormously.

Conclusion

The Lightning Network is an impressive construct that has enormous potential beyond low-cost Bitcoin payments. It opens up many new possibilities and use cases that can help to make our world simpler, more decentralized and more secure.

Nevertheless, it should not be forgotten that the LN is not even 5 years old and is still in its infancy. There are still some problems for which solutions need to be found and certainly not everything is perfect yet. However, many great and very intelligent people around the world are working every day to improve and further develop the network - both at a technical level and in terms of usability. Because in the LN, as in almost every other network, the more participants, the greater the network effect. And the main way to attract more participants is to make it easy and secure to use. However, if you compare how quickly and rapidly the developments in LN have taken place, especially in the last two years, you can look to the future with excitement. It will be interesting to see where the Lightning Network will be in another two to three years. It will definitely be worth keeping an eye on it.

If you would also like to become part of the Lightning Network and get to grips with the functionalities, then take a look at the following two instructional videos on how to set up and operate your own Lightning Node.

In our free block trainer forum, the user "mrsieb" has written a comprehensive article on individual sub-items when using the Lightning Network. If you would like to learn more about the topic of LN, you should definitely take a look at the thread.

Here is the video for this article: