When Lightning strikes

How Lightning network improves Bitcoin scalability

Naomiii
The Capital
Published in
9 min readJul 12, 2021

--

If you’re anything like me, you’ve never used your Bitcoin to pay for real-life purchases. Up to today, the only thing I’ve settled with BTC are transaction fees to get my BTC from my exchange account into my wallet and vice versa. Maybe you’ve already bought stuff with BTC; if yes, I’d be intrigued to know what.

Anyone transacting with Bitcoin for the first time will soon realize that it takes a few minutes, if not longer, for your transaction to be confirmed. What’s “worse” for small amounts the Bitcoin transaction fee is pretty high. Currently, to get your transaction verified within the next hour, you’d have to pay $8.88. If you just wanted to buy a coffee, clearly that’s disproportionally high. And having to wait 10 minutes until the transaction is confirmed, your coffee would be only lukewarm by that time.

The root of the problem lies in the scalability problem. Scalability describes how many transactions a network can handle. Centralized payment providers like PayPal (150 transactions/second) and Visa (up to 5600 tps) can verify transactions within seconds, making them a convenient option for all of us to go about our daily purchases. However, as centralized networks, they’re susceptible to attacks, and customers are at their mercy.

Bitcoin, created as peer-to-peer electronic cash, was set to change how we transfer value to a decentralized paradigm. More than ten years later, we’re still far from having all moved to use crypto. But, there’s some serious work being done to make Bitcoin easier to use for smaller payments — namely, the lightning network.

What is the Lightning Network?

First things first, if you’re still wondering why Bitcoin has a scalability problem when other cryptocurrencies such as Litecoin or Ripple don’t seem to. Bitcoin relies on Proof-of-Work, meaning that all nodes in the network are simultaneously racing to solve a riddle to verify transactions. The bigger the network grows, the more nodes participate in consensus, making the network highly secure, decentralized, and censorship-resistant. Proof-of-Work itself limits the scalability as all nodes need to agree. In contrast, in Proof-of-Stake networks, it’s just a limited set of nodes meaningfully participating.

Additionally, another limitation to scalability on Bitcoin is the block size. If only a certain amount of transactions can be included in a block, it automatically limits throughput.

Did you know that Bitcoin Cash grew out of a part of the Bitcoin Community that wanted to increase scalability by increasing blocksize? It was created through a hard fork of the Bitcoin Network in a process that increased block size to 32 MB to enable higher scalability. Additionally, difficulty levels for mining respond to transaction and verification speed and not to the overall number of miners — making BCH fast and a viable option for small purchases.

A scalability solution for Bitcoin was first proposed in 2015 by Thaddeus Dryja and Joseph Poon. Instead of making drastic changes to the network they suggested a layer two solution. Adding another layer to the Bitcoin main chain would enable users to conduct small and medium transactions without handling all of the information on-chain. Since transactions are then settled near instantly, it’s called a lightning network.

The lightning network is a decentralized network run by thousands of users on top of the Bitcoin blockchain. Currently, more than 22,441 nodes are active on lightning.

How does it work?

So far, we know that lightning is another network layer on top of the Bitcoin chain that lets users transact for less. In the next part, I’ll cover how that is achieved.

The lightning network creates a network of payments channels through which users can transact with each other. Let’s say I decide to pay my local coffee shop with Bitcoin for each coffee to give a simplistic example. Instead of spending every time manually, we can set up a payment channel. In the first transaction, the anchor transaction, we’d create a contract stating all the critical conditions, and I’d deposit some Satoshis into the contract. Then whenever I go to the coffee shop and buy coffee, we’d settle my bill through the payment channel.

Once my funds are exhausted, and I feel like I need to detox a bit from coffee, we close the channel. All transactions up until now have been off the Bitcoin main chain. When closing a payment channel, the final balance is reported to the main chain and included in the ledger. Therefore, instead of reporting all the 30 times I bought coffee on the Bitcoin blockchain, we added just two transactions:

  • the anchor transaction
  • final balance

We assumed that both the coffee shop and I’d be running a lightning node for this example. However, that’s not necessary. As long as both of us have a lightning wallet, we can use the lightning network. Instead of using a payment channel established between the coffee shop and me, the lightning network would find an optimal route for our transaction through existing payment channels.

Payment channels link up with each other to create an ever-increasing network. The more payment channels are opened, the more routes are available, offering fast transactions cheaply for users.

Multi-Sig

One crucial element in this setup is Multi-sig. Multi-sig is short for multi signatures and describes a lock that only opens with enough keys out of a predetermined set of keys. It’s useful when managing a joint account and to add extra security to an individual account.

Multi-sig is also behind the creation of payment channels as these require each user to provide information for transactions to occur, including their key pairs. If either party fails to provide information, transactions won’t happen.

Security

You might wonder, but what about security? Sure, the Bitcoin blockchain is very hard to crack, but when it’s just a handful of us with our own payment channels — that seems less secure. And you’d be right if it wasn’t for several features such as smart contracts.

Smart contracts guard all micropayments by establishing a set of rules that need to be followed. For example, users can attach fees to transactions that are only paid to lightning nodes once the money has reached its destination address. Therefore, nodes have no incentive to do anything stupid.

Onion routing wraps the optimal route calculated based on current network status into various encrypted layers. Opening the routing map is like peeling an onion — with less crying involved. 🧅 Each node only sees the top layer of the map while the rest remains encrypted. Due to this encryption, no one knows how many transactions are handled by the lightning network.

Timelocks integrated into payment channels set an upper limit on how long a channel stays operational. This ensures that no one user can disappear and leave the balance in the channel “untouchable.” If one user in the channel decided to leave, timelocks allow the other user to claim the amount left in the channel at a pre-defined time (in the example below, after 1000 blocks).

With asymmetric revocation, commitments conditions can be defined to punish users trying to cheat and remove their share of the channel. For example, you could determine that if one user tried to cheat, the other would be eligible to claim the entire balance of the wallet, leaving the cheater with nothing.

A few more things to note on LN

The lightning network follows the spirit of Bitcoin and is an open-source software developed by various companies in the space. ACINQ, Blockstream, and lightning labs worked together to define specs for the scalability solution. While the idea was proposed in 2015, it took a change to the Bitcoin network — the introduction of SegWit — in 2017 to make the Lightning network possible. In March 2018, a tool for developers to build lightning apps such as payment services was published. Among the first lightning apps was Poketoshi, an app that allowed players to bid on controlling famous pokemon characters.

In 2018, the still-new lighting network fell prey to a DDoS attack. Since then, developers have continuously worked on improving the system and securing it against future attacks.

A more prominent criticism of the network is the fear of bigger operators dominating in the long run. When opening a lightning channel, operators have to stake an arbitrary amount of Bitcoin in their channel — limiting the size of transactions they can process. If bigger operators started putting vast amounts into their channels, it might reduce decentralization.

However, so far, the lighting network is run by everyday people like you and me who use their laptops, desktops, or Raspberry Pis to run the lighting network.

Another drawback of lightning is that users are limited in the size of their transactions to the smallest amount held by any channel that they cross on their route. There is currently also no support to conduct transactions offline — which can be a challenge, when in a place with bad network connectivity. Like some villages in Germany for example.😅

On using lightning

With the lightning network, transaction fees are kept low as users don’t have to pay miners, and nodes asking for higher prices will slowly but surely be driven out by market forces. Payments are settled fast, making them useful in everyday purchases. It also allows you to tip people online, like with Tippin, where you can tip your favorite content on Twitter with Satoshis.

To use a lightning network, you’ll need to get a wallet that supports it, such as BlueWallet or the Wallet of Satoshi. Once you’ve added some funds to that wallet, you’re ready to spend.

To spend your Satoshis, you can scan a QR code created by the seller. However, unlike transactions on Bitcoin, you won’t have a Blockexplorer to check on the status of your transaction — but since it’s confirmed in seconds, you’d probably have a hard time being faster than that anyway.

And lastly, we cannot not mention El Salvador. Sorry.

While the country has made headlines with its decision to make Bitcoin legal tender, what caught even more attention was their promise to distribute $30 in Bitcoin to every citizen who would sign up and install the state-backed wallet: Chivo.

In El Salvador, where per-capita income averages around $4000 per year, receiving $30 is a serious incentive for people to sign up. However, with Bitcoin network fees currently between $7–9, it’d be quite an expensive move for the government to cover that cost. Instead, the El Salvadorian government will work together to use the lightning network for this “airdrop” with its development partner strike. Strike is already used in LATAM; however, while it does use Lightning Network for its internal operations, that doesn’t mean that end-users will receive the lightning properties. Strike controls users’ private keys, and only once they withdraw their funds, they’ll own their Satoshis.

Lastly, in terms of privacy, if users have to KYC, it’d immediately give the government a record of who owns what Bitcoin address. And it might be naive to assume that every El Salvadorian who claims their Bitcoin will know how to create a new wallet or how to withdraw their Bitcoin.

Regardless of what will happen in El Salvador, the Lightning network despite its small flaws continues growing and offers anyone looking to spend their Bitcoin in real life a fast and cheap way to do so.

You can track how the network is doing here:

--

--

Naomiii
The Capital

Writer | Reader | Find me on paragraph (@cryptonao)