What is the Lightning Network and does it actually work?

Last Update: June 17, 2023 (originally on Reddit – this is now the new main archive of this research)

What is the “Lightning Network” (LN) and how does it really work?

You hear that LN is going to fix all of Bitcoin’s scalability problems… but is that true?

Everybody’s heard of LN, but you don’t seem to get specifics on how it works, or else it seems, the specifics are way technical and over everybody’s head, or they’re just grandiose claims (like “a million transactions per second!”) devoid of any specifics that can be actually qualified. So can the network be appropriately described in ways that we all can understand?

I think so. Let’s hash out the best analogies based on sharing knowledge about how the system works.

Here are some of the take-aways that I’ve come up with – I welcome your comments, criticisms, clarifications and other thoughts…

Background

As we know (NOTE: expressing this factual information on subreddits like /r/bitcoin and /r/cryptocurrency can get you banned), Bitcoin’s network is hamstrung by the built-in-by-design limitation of about 3-7 transactions per second. (4.7 tps on average)

If you tally up how many credit card transactions happen in the US alone, it’s over 39 billion a year (source). This comes out to about 108.6 Million transactions per day. This comes out to 4.5M/hr, 75k/minute and 1257 transactions per second. Just in the US alone.

So the existing number of credit card transactions in the US alone is 267 x more than the bitcoin network can handle. And this just takes into account the US, and it assumes all those transactions are equally spread over a 24 hour period, which is obviously not true. In reality, those transactions are probably spread over half that amount of time given that most people aren’t doing transactions when they’re sleeping.

So obviously even if each person in America did one bitcoin transaction per day, the network still couldn’t handle it.

Lightning Network

Enter LN – the system that’s supposed to save crypto.

What is LN and how does it save bitcoin?

Well, IMO, it doesn’t, and it’s a really, really bad copy of a debit card network. Actually a pre-paid debit network.

First and foremost, LN seems to have some centralized authority in its operation and management (I’d like to get more clarification on this), but there is some system in place to verify and authenticate what are called “channels”.

Presumptions

LN is supposedly faster than Bitcoin, but this is misleading. First, in order for that to be true, it presupposes a number of things:

  1. A LN channel for you is already setup and open.
  2. LN channels from you to whoever you’re transacting with are open and available.
  3. There’s adequate pre-funding in the channel(s) to support the transaction you want to execute.
  4. Everybody pretends that the LN P2P is “the transaction” which completes whatever sale you’re making (which is misleading).
  5. Tokens transferred on LN stay on LN unless/until a channel is closed. This means if you send crypto to person B, that person does not have custody of that crypto until they close the channel (and if they want to do more LN transactions, they then have to open another channel)

In reality, a LN transaction involves a lot of steps – it’s not just a single transaction.

Example

Let’s go through a hypothetical LN situation (and correct me if I’m wrong)…

Let’s make some assumptions to make the transaction easier, which are not something I feel anybody should take for granted but to not make this too long, let’s just assume everybody involved has all the proper software on their devices, internet connectivity and knows how to use the software.

Let’s say I want to buy something for $100. Right now everything is priced in fiat. That’s just the way it is. So we’ll use fiat as a measurement of value.

First, you have to make sure you have a LN channel open. In order to do this several things have to happen:

  1. You need to open a LN channel, and have the appropriate crypto in a wallet to seed the channel (this means you will have had to already go through purchasing bitcoin with fiat at some sort of CEX or other transaction – which can be very elaborate and fraud-ridden as well but we’ll gloss over that for now) In order to open a LN channel, you have to execute a transaction on Bitcoin’s blockchain. So to open a channel, you are hamstrung by Bitcoin’s limited transaction rate of 4.7 TPS (but even that figure is misleading – that’s just the time it takes for the transaction to enter the mempool – it could be anywhere from seconds to an hour for your transaction to actually end up codified on chain – again, another tangent we won’t go off on right now)
  2. You have to fund the LN channel with a certain amount including what you need to cover transaction principals and fees. At present LN fees are claimed to be about $0.04/trx (source). UPDATE:” The fees can vary depending upon whether you’re using a direct channel to the recipient, or going through other LN channels – the more you pass through, the higher the fees will be.

So you have to give custody of your bitcoin to a third party – the LN system, in order to even begin to use LN.

Remember, Not your keys, not your coins? Well, that is in effect when you use LN. Any vulnerabilities and hacking in the network can mean you can lose all your principal. And you have to seed your channel with as much crypto as you think will cover whatever purchases you might make. So in this respect it’s like a pre-paid debit card but instead of depositing this money with a bank or established institution that has consumer protections, you take your chances and use a system with nonexistent safeguards if something goes wrong.

UPDATE: Supposedly there’s a way for you to have some degree of “self-custody” if you run your own LN node – although this apparently is expensive and tedious to set up, and if the node doesn’t stay 100% online, you can lose your crypto. (more details on this needed)

How long does it take to initially set up a LN channel?

Good question – How many confirmations are needed by LN to assume the base transaction to open/fund your LN channel is open and ready to use? If that’s 2 confirmations, then you’re looking at an average of ~20+ minutes before the channel can be ready. According to these LN developer docs it usually takes 6 confirmation before a channel is open and ready. That means at least an hour to open a LN channel!

It should be noted that you can have what are called “0-confirmation channels” but they’re ill-advised:

Why does the number of confirmations matter?

It’s a way to measure the security and finality of transactions. The only way a miner can reverse a transaction is by a process called reorganization. This requires the miner to build a chain of blocks with more work than the currently accepted chain. Each block mined on top of a block that contains a transaction makes it harder to reorganize. In bitcoin’s history, we’ve seen a 4-block reorganization only a couple of times, a 3-block reorganization a handful of times, a 2-block reorganization a few dozen times, and hundreds of 1-block reorganizations.

This is why you should wait six confirmations before considering a high-value transaction complete. A 0-conf transaction is dangerous to accept if you don’t trust the sender since there’s no guarantee that it will ever be included in a block. It’s possible that the fee is too low or another transaction double spends its inputs.

So at any time, it’s technically possible if you use less than 6 confirmations, for the transaction to fail to codify on the blockchain, potentially causing double spending issues between BTC and LN. (again, a problem that centralized traditional systems don’t have to deal with and solved decades ago)

So, you’re looking at an hour or more to set up your LN channel. When people talk about the speed of LN, they assume this has already been done.

Also note that since you can’t transact in more than what you’ve seeded your channel with, if you don’t have enough crypto seeding your LN channel to complete the transaction, you can’t do the transaction (just like a debit card won’t let you take out more than your available balance). In such a case you need to add more money to your balance. Using LN, this requires another BTC on-chain transaction, which means another hour+ to add more to your LN channel/balance. UPDATE: There appears to be no way to add more crypto to a channel – you instead have to create a new channel.

And this is just the hassle you have to deal with IN ADVANCE, before you even begin to consider doing a transaction.

But it gets worse….. (and correct me if I’m wrong in any of these assumptions)

“Transactions”

After you’re set up, now you have to assume there’s a path from your channel to the merchant. They have to go through the same process on their end. And if you don’t have a channel between yourself and the merchant, a “path” needs to be found using other LN users, and they too have to have all this setup beforehand, AND they have to have enough money in their channels to meet the transaction requirements, AND (here’s another hefty requirement) they have to have LN up and running 24/7 – this can’t be a background process on somebody’s phone. It needs to be a dedicated LN node online willing to ferry transactions.

So are you with me this far? We haven’t even gotten to the point where we’re doing the LN transaction. We’re still discussing all the things that have to be set up PRIOR.

It’s obviously a lot of steps, but also remember, in the world of “de-centralization” nobody is in charge of anything; nobody is responsible to anybody else; “code is law”. So all these nodes that will help ferry transactions between point A and B are presumed to be online – BUT nobody really is forced to have them online, and it’s nobody’s job to make sure you have a path from you (point A) to the merchant (point B).

Let’s use another analogy to describe what’s going on.

Imagine a bowling alley. When you show up to bowl, but need special shoes if you don’t have your own. There’s a good chance the bowling alley has shoes in your size because it’s their job to make sure people use the right shoes, and they know they need a large central inventory to accommodate the public. They take on that responsibility.

Now imagine a public “de-centralized” bowling alley. Ok, there’s some base infrastructure that people have set up: the lanes and the pins, but they don’t supply the shoes. Everybody who plays hopefully brings extra shoes in case other people don’t have them. You wear a size 14 wide. What are the odds someone is there with an extra pair of size 14w bowling shoes?

That’s the kind of logistics you have with LN. You have to assume someone else has their LN node on and properly funded and has a path to the merchant if you don’t open one up yourself. It’s strictly a voluntary thing to do, and how can anybody know what “size” the next person needs?

So the whole network is basically a de-centralized hot mess.

And we haven’t even gotten to the part where the transaction is supposed to happen.

Are we there yet?

Ok, so let’s assume everything is in place and we’re going to do this $100 transaction from A to B. Let’s assume everything goes smoothly with all parties involved and the transaction can/does go through.

What happens?

The LN side of the transaction may go through quickly. This may be where they claim they can do “a million transactions per second” – although I’m incredibly dubious of such a claim – random, decentralized systems are physically impossible to out perform centralized systems, but for the sake of argument and staying on point, we’ll leave that tangent alone.

At this point, LN says the transaction went through.

It’s now up to the merchant to accept that part of the transaction as a “completed transaction” or truly settle the transaction. This is where another set of processes comes into play.

At this point, whatever “value” has passed from point A to B is still under the custodianship of LN. Not the merchant. They still do not have access to this “money.” It’s locked up on LN. Not their keys, not their coins.

So, if the merchant decides the transaction is complete, they can give you the item you paid $100 for. However, their end of the transaction is not really settled. And it won’t be settled until they close/settle that channel/transaction – which means another 60+ minutes to transfer the BTC on LN back to Bitcoin’s blockchain. Until that is done, the merchant does NOT have custody of the “money.”

UPDATE: It seems by default, LN transactions settle on the LN network – which means the transaction is basically never automatically settled back on the BTC blockchain (this was a false assumption on my part) – that’s only accomplished when you close the channel. The premise behind LN is supposed to be, you don’t need to close the channel. Person B simply uses the money they have on account to pay person C, etc. (assuming you can find anybody using the network). This is one of those “Nirvana Fallacies” where in order to promote the value of the system you assume eventually everybody will be using it so there’s no need to settle on L1. That’s incredibly wishful thinking, and not something that many people apparently are aware of when told about LN.

So in reality, both the sender and the receiver have issues, even assuming LN works exactly as prescribed with no problems:

  1. If you want your crypto, you have to close the channel.
  2. If you want to send more LN transactions, you have to open another channel if you don’t have enough BTC on account with your existing channel.

Both processes involve L1 settlement, which is a 60 minute process.

Remember, we’re still assuming all the fiat-to-crypto and crypto-to-fiat conversions can be done, and not factoring any of that into the time/hassle – which is another large, time consuming, fee-ridden, time-delayed process.

So in comparing this to a pre-paid debit card, I think it’s still not a good analogy. Because with a pre-paid debit card, there is no “L2”. It’s all done on one layer. But also, you can recharge a debit card in seconds. From what I gather it takes another 60 minutes to augment the balance on your LN channel? And then, if your channel is used by someone else, your available spending balance is limited until that transaction settles? This is mind numbingly inefficient IMO.

So, is there anything wrong in my characterization of LN? Am I leaving more stuff out? What are your thoughts?

Force Closings

In LN, one or both parties can “close” a channel. Sometimes a channel will be closed for other reasons depending upon the software you’re using (and for example, if one party loses connectivity). The ones where both parties don’t agree to close are called, “force closings” and they can happen at random.

When they do, this can cause losses, sometimes big losses. Here’s an example of someone who had their channel force closed and lost a lot of money.

In the decentralized world of crypto, there are no standards regarding transaction fees, and there are fees-o-plenty. Every entity in a LN transaction can charge their own set of fees. There’s also fees when a channel closed that are assessed on the BTC blockchain. So if a channel is closed during a time of congestion on the BTC blockchain, you can end up with huge transaction fees, even more than the actual transaction amounts.

False Sense of Security

At Bitcoin 2023, there was a panel that discussed many of the problems with LN.

In theory, off-BTC-chain transactions on LN are supposed to be private. They’re not stored on a public blockchain, so in theory people aren’t supposed to know who’s sending crypto to whom, but this is misleading, because of the design of LN, it’s relatively easy for an entity that wants to know where transactions are going to do several things to discover who is sending crypto to whom and how much:

  • It’s possible for law enforcement or companies like ChainAnalysis to set up their own LN nodes and track the payments – especially if they have highly-liquid channels which are rare and sought after by people.
  • While those who operate channels can choose to be private about the nature of their channels, many nodes will advertise how much liquidity they have to encourage people to use their channel – this public information can be used to identify when payments are routed through those nodes.
  • It’s also very likely that routing nodes could make more money selling transaction information to authorities, surveillance companies and corporations, than they could via standard transaction fees.

By virtue of the fact that all these decentralized systems have to be able to communicate with each other, and there’s no central authority to differentiate between a legitimate node, and a node set up for surveillance, there’s absolutely no guarantee anybody’s transactional privacy can be preserved.

Additional Elements

  • Concerning Centralization and Wealth Concentration on LN – According to this 2020 Study, 80% of the LN liquidity is maintained by 10% of the channel operators.
  • According to this source: Simplified Payment Verification (SPV). – It can verify payments without needing to download the entire blockchain. It is often used for Bitcoin wallet apps on smartphones by using special SPV nodes that act as an intermediary between the app and a mining node. So basically in order to “verify payments” you (ideally) have to have an entire copy of the blockchain. As of now that’s 15 Gigabytes. This seems beyond absurd, which is why they have to invent a work-around, which obviously introduces central authorities and potential fraud into the mix.
  • Hot wallets. – The funds you store in a Lightning wallet are online all the time. This makes them vulnerable. Hence, you should not store large amounts in a Lightning wallet. Large amounts should be kept in a cold wallet that is not online and which can transact only on-chain. Ironically, the only way to make LN work is to seed it with money in a hot wallet. Which means your tokens are vulnerable while they’re in the process of providing precious liquidity for the network. Even LN experts agree this is dangerous. (In contrast, bank deposits, which fuel the fiat liquidity market, are FDIC insured against all manner of problems)
  • Off-Chain Sweep. – A second Lightning node that is not advertised on the network. You can establish large capacity channels from your public node (e.g. the one running your shop) to your unadvertised (hidden) node. On a regular basis, “sweep” funds by making a Lightning payment to your hidden node. Since holding crypto on LN is inherently more risky, especially on public channels, many recommend using this technique, of having a private LN channel to “sweep” liquidity off the main channel to avoid its exposure. There are various ways to lose crypto on LN when you’re peered with other channels. Moving this liquidity to a private channel you exclusively control is one way to mitigate some of these risks, but this also introduces more risks because this is also a “hot wallet” that is vulnerable too. So in the end it just adds more complexity while not really solving any problems.
  • Looping/In Out – A node operator can avoid closing a channel by sending crypto to a third party who will cash it out for them. This involves handing your crypto to a central third party who “promises” to give it back to you in some form. Good luck with that.
  • Routing fees. – Are set by two parameters on each channel: a fixed base fee that is charged for any payment and an additional variable fee rate that is proportional to the payment amount. Yes, you read that right… there are multiple fees, and each node operator can set them however they want.
  • “Payment channels in Lightning are based on a 2-of-2 multisig address, with the two channel partners as signers in the multisig. At this time, channels are funded only by one of the two channel partners: When you choose to “open” a channel you deposit funds into the 2-of-2 multisig address with a transaction. Once that transaction is mined and the funds are in the multisig, you can’t get them back without cooperation from your channel partner, because you need their signature (also) to spend the 2-of-2.” One person funds the channel, but both exclusively control it? Who thought of that scheme?

EDIT:

Additional Notes:

  • As /u/IsilZha pointed out, a huge majority of LN transactions typically fail for a variety of reasons, including the inability to have adequate channels set up, and the absolutely crazy idea that you don’t know if there’s enough liquidity on any given channel until you try it first, and that a huge percentage of transactions (99% as of 2018) fail if the transfer amount exceeds $200. UPDATE: right now on the LN subreddit, there’s a thread of people sharing node addresses and what’s most interesting is it seems everybody is looking for channels with at least 1M sats capacity (that’s currently ~ $221) so it appears 5 years later, this same problem still exists on LN: sending a transaction over $200 may be extremely difficult.
  • Computer Scientist Jorge Stolfi via Mastodon writes, And Starbutts Coffee could connect to the LN through a chain of 20 nodes of its own, each charging $0.05 of fee. Customers who try to pay through the LN are charged $7.00 for the coffee plus $1.00 of LN fees. What can they do but pay those fees? They may notice that weird topology, but have no way of knowing that those nodes belong to Starbutts. Moreover, Starbutts may disguise the chain with a few parallel channels that seem to provide shorter and cheaper routes, but actually refuse to carry payments when queried. So that the payments end up routed through the long chain. And an attacker bent on disrupting the LN can sprinkle thousands of nodes that advertise good connectivity and cheap fees, but whenever someone tries to route payments through them they will stop responding during the negotiation, until the negotiation times out. Conversely, a node that enters into a payment relay negotiation in good faith must reserve the required capacity from its relevant channels until the negotiation completes, successfully or not. So a malicious Alice can sabotage the LN also by requesting lots of path payments to her buddy Charlie through other Bob nodes, and letting those requests fail by timeout at either end.
  • I also posted in the lightningnetwork subreddit inviting them to come and “fact check” this post. That basically resulted in them calling me names and saying this sub was a bunch of haters (surprise, surprise)

Additional third party critical resources:

Leave a Reply

Your email address will not be published. Required fields are marked *