GUIDE TO THE LIGHTNING NETWORK – How to make fast and cheap Bitcoin payments with Lightning

Posted by

Due to its security, the Bitcoin network is ideal for the transfer of larger amounts. However, the network is not really suitable for daily use to quickly pay small amounts at the supermarket, the station kiosk, etc. This is due to the low transaction rates, the low transaction speeds and the high transaction costs. In this blog post, I will explain how the Lightning Network bypasses these vulnerabilities and enables you to transfer the smallest amounts of Bitcoin immediately and almost free of charge. I also show you step by step with screenshots how to use your Lightning wallet to transfer bitcoins super easy.

Limits of Bitcoin as a payment network for everyday use

In order for a payment network to be suitable for everyday use and, for example, to be used to pay for morning coffee at the station kiosk (i.e., small amount, little time), it must basically meet four factors: high acceptance among sellers, high transaction rate, high transaction speed and low transaction costs. Bitcoin is struggling with all four factors today:

a) Acceptance by shops

Have you ever tried to pay your coffee at your favorite coffee shop with Bitcoin? Almost everywhere you will probably hear (at best) a “Sorry, we don’t accept Bitcoins!” as an answer. Here is an overview by Coinmap showing the shops, cafes, bars, hotels etc. that accept Bicoin in the city of Zurich. These are not many places that accept Bitcoin.

Overview of shops, cafes, hotels, etc. that accept Bitcoin in Zurich (Source: coinmap.org)

I recently went to a restaurant marked as Bitcoin-friendly on the coinmap and wanted to pay for a coke there with Bitcoin. This caused a great deal of excitement there, as the restaurant has accepted Bitcoin as a means of payment for over two years, but there was never ever a guest who really asked to pay with Bitcoin.

b) Transaction rate

A payment network is only suitable for the masses if it can also process mass transactions. According to a Visa fact sheet from this year, the Visa network currently averages around 7,000 transactions per second (TPS), although the network also has to deal with significantly higher peaks. With Bitcoin, the world looks a bit different: With the current block size of 1 MB and a block time of 10 minutes, Bitcoin gets a maximum of 7 TPS with a transaction size of 250 bytes. This is clearly not suitable for the masses.

c) Transaction speed

A new Bitcoin block is created every 10 minutes. This means that as a seller I have to wait an average of 5 minutes until I see the payment on the blockchain (if I agree to a block depth of 1, which is no problem for small amounts). Now imagine you let the seller at the supermarket checkout wait a few minutes during rush hour for your payment to go through. You don’t make friends there!

d) Transaction costs

The fees for Bitcoin transactions are currently around USD 1.70 and are thus massively lower than the peak of over USD 60 in April 2021. Nevertheless: If a payment of a few dollars for a coffee has a transaction fee of more than one dollar, then you will probably not find many users.

Bitcoin transaction fees in USD (7-day average) (Source: Blockchain.com)

The idea behind the Lightning Network

In the previous section, we saw that the Bitcoin network is not (yet) fit for the daily use of the masses. This is what the Lightning Network is trying to solve.

The basic idea behind the Lightning Network is that not every bitcoin transaction has to actually be published on the bitcoin blockchain in order to be valid. Yes, you are right, in order for everyone in this world to recognize that I am in possession of a Bitcoin, the corresponding transaction must be immortalized on the blockchain for everyone to see. But is that also the case if only two people want to make a “private” Bitcoin transaction between them? Probably not! Because if two people want to record a Bitcoin transaction between them, it is first sufficient for them to just write down the Bitcoin transaction and sign it with the private key. You don’t have to publish the transaction on the blockchain immediately. Both people are already in possession of a validly signed Bitcoin transaction and they both know that they can publish this transaction on the Bitcoin blockchain at any time and independently of the other in order to finally execute the transaction.

And that’s exactly what the Lightning network does: Lightning is a decentralized, non-custodial (i.e., coins are not controlled by a central custodian) network that sits on top of the Bitcoin blockchain (i.e., Bitcoin is a layer 1 network and Lightning is a layer 2 network) and allows two persons to execute Bitcoin transactions off-chain – i.e. outside of the Bitcoin blockchain. This off-chain nature enables instant and near-free Bitcoin transactions for the masses. I.e., we use the Lightning Network to solve Bitcoin’s limitations around the transaction rate, transaction speed and transaction costs, which we looked at in the first section. However, what the Lightning Network cannot offer at this point in time is mass acceptance among retailers. Just like with Bitcoin, you have to search for quite a long time before you find a restaurant that accepts Bitcoin via the Lightning Network.

How the Lightning Network works… explained using an example

This probably sounds pretty abstract to you. Let’s look at a concrete example of a Lightning transaction to make this more tangible. In our example, Alex wants to send two Bitcoins to Barbara via the Lightning Network (for the sake of simplicity, we assume whole Bitcoins in this example).

Step 1 – Open a payment channel

First, Alex and Barbara have to create a so-called payment channel between them. This is a key point: Lightning Network transactions always run through payment channels between two parties. To set up a payment channel, Alex and Barbara first create a 2-of-2 multi-signature address on the Bitcoin blockchain (i.e., on-chain at layer 1). A 2-of-2 multisignature address is a blockchain address that needs the signatures of Alex AND Barbara to execute a transaction from that address.

However, the created channel is still empty (i.e., it has no liquidity), which is why no payments can be made yet. I.e., next Alex and Barbara have to add liquidity to the channel. Alex deposits 20 BTC in the payment channel and Barbara deposits 10 BTC. Technically this means the following: Before Alex transfers the 20 BTC to the multisignature address, he creates a Bitcoin transaction, which closes the payment channel again and transfers all 20 BTC of the multisignature address to him, has this transaction signed by Barbara and saves this signed transaction with him (i.e., he is not yet executing the transaction on the Bitcoin blockchain). Only after Barbara has signed this transaction does Alex send his 20 BTC to the multisignature address. In this way, Alex ensures that he can unilaterally close the payment channel at any time and withdraw his 20 BTC from the multisignature address. Barbara does the same with her 10 BTC: She only transfers the 10 BTC to the multisignature address after Alex and she have signed a Bitcoin transaction, which closes the payment channel and sends 20 BTC to Alex and 10 BTC to Alexandra.

So Alex and Barbara have now opened a functioning payment channel. There are a total of 30 BTC in the payment channel, of which 20 BTC belong to Alex (he can deduct these at any time with the transaction that has already been jointly signed) and 10 BTC Barbara (she can deduct these at any time with the transaction that has already been jointly signed). From Alex’s perspective, the payment channel has an inbound capacity of 10 BTC (he can receive up to 10 BTC from Barbara) and an outbound capacity of 20 BTC (he can send Barbara up to 20 BTC). From Barbara’s point of view, inbound and outbound capacity are exactly the opposite. This one-time setup of a paymant channel is executed on-chain on the Bitcoin blockchain and is associated with corresponding one-off costs and waiting times.

Step 2 – Transfer Bitcoin via the payment channel

Now that the payment channel is set up, Alex and Barbara can send Bitcoin back and forth as often as they like within their established inbound and outbound capacity and all these transactions only take place on Layer 2 of the Lightning Network (i.e., off-chain), without a single transaction being published on the Bitcoin blockchain. This means that all these transactions are lightning fast and almost free. Let’s see what happens, for example, when Alex sends 2 BTC to Barbara via the payment channel: After transferring 2 BTC from Alex to Barbara, Alex owns 18 BTC (i.e., 20 minus 2) from the payment channel and Barbara owns 12 BTC (i.e., 10 plus 2). Accordingly, Alex and Barbara create a Bitcoin transaction together, which would close the payment channel and transfer 18 BTC to Alex and 12 BTC to Barbara from the shared multi-signature address. Both Alex and Barbara sign this transaction, but again they do not publish it on the Bitcoin blockchain, they just save it for themselves.

Thus, each of the two could unilaterally close the payment channel at any time with this saved Bitcoin transaction and receive their corresponding share of the 30 BTC without the other being able to prevent this.

Step 3 – Close the payment channel

At some point after any number of bitcoin transactions between the two on the Lightning Network, either Alex or Barbara decides to close the common payment channel, which means that the last Bitcoin transaction signed by both and stored off-chain by both is finally actually published on the Bitcoin blockchain and according to this transaction the 30 BTC of the multisignature address are transferred to Alex and Barbara in the correct ratio.

However, a crucial question arises: After each transaction via the payment channel, a new Bitcoin transaction signed by both parties was created and saved. I.e., there are potentially many signed Bitcoin transactions, but only the most recent (i.e., the latest) should be executed and the earlier ones should never be able to be executed because they have become obsolete. How is this technically solved? Bitcoin transactions can not be torn by hand! This is solved in such a way that a secret number is added to each Bitcoin transaction when Alex and Barbara sign it. If Alex knows the PIN that Barbara added, then he can use that PIN to invalidate the transaction. And the same goes for Barbara. However, these secret numbers are only communicated to the other person when a new Bitcoin transaction is created, which thus invalidates the previous transaction.

Connection of payment channels

The example above shows that the Lightning Network is now working perfectly: Two people can set up a payment channel, send an unlimited number of super cheap Bitcoin transactions and then close the payment channel again. But does our day-to-day payment really work like that? Probably not. We don’t have hundreds of transactions with the same person, we carry out numerous transactions with very different people or merchants every day; often only once with a specific counterpart. If I have to set up an expensive payment channel with a long waiting time every time, then I quickly lose interest in Lightning. There is the following solution for this: Payment channels are connected to each other. In order for Alex to be able to send bitcoins to Barbara, he does not need to be directly connected to Barbara. The payment can be routed to Barbara via several connected payment channels, with each payment channel used receiving a small routing fee as compensation.

USER JOURNEY: Set up a Lightning Network wallet and transfer Bitcoin

Now you know (almost) all the details about how the Lightning Network works. Now let’s go through a concrete user journey. Usually, when it comes to the user journeys in my blog posts, I assume that you already have the necessary wallet. But because probably very few have a Lightning wallet available, I will start here at the beginning and first help you set up your own Lightning wallet. Let’s now do exactly that!

Step 1: First you need to install a Lightning wallet. Let’s install the Phoenix Wallet, which is available for Android and iOS. Behind the Phoenix wallet is the company ACINQ from Paris, which focuses on the scaling of Bitcoin. Unlike many other lighting wallets, it is non-custodial (meaning you always own your bitoins). In addition, it offers a great user experience, so that it is looks and feels pretty much the same as a simple Bitcoin wallet. You can use it to easily send and receive bitcoins and don’t have to worry about managing the payment channels. All of the Lightning-specific details related to setting up the payment channels and managing inbound and outbound liquidity are taken care of for you by the wallet under the hood. But if you start the Phoenix app, you actually have a real Lightning Network node running on your smartphone. And by the way: The Phoenix wallet is exclusively a Lightning wallet and not a Bitcoin at the same time.

Step 2: After installing you set up the wallet step by step according to the instructions. This is very simple and self-explanatory. Just a note: Don’t forget to write your wallet’s 12-word seed phrase on a piece of paper as a backup. If you lose your smartphone or delete your app, you can only get back to your lighting payment channels with this seed phrase.1)

Step 3: So, the wallet is now set up. But before you can make your first payment, you have to load a few Sat (1 Sat = 1 Satoshi = 0.00000001 Bitcoin) into the wallet by clicking receive.

Step 4: You now have the choice of loading your wallet either via a Lightning payment request or via a Bitcoin address. In both cases you will be presented with a QR code that you can use to deposit. In our example we choose the Bitcoin address method and scan the Bitcoin QR code with a Bitcoin wallet (I take the Trust wallet from Binance) and thus transfer 50,000 Sat.

Step 5: Now we need a bit of patience and have to wait about 10 minutes for the Sat to be transferred on-chain. After the transaction is through, we see in our Phoenix wallet 47’000 Sat credited. The following happened behind the scenes: The Bitcoin address to which we sent the 50,000 Sat was not our own Bitcoin address but the address of ACINQ, the company behind the Phoenix wallet stands. The ACINQ node used these 50,000 satellites to build up a payment channel to our Phoenix wallet. The following is important for understanding: Payment channels are always exclusively between the Phoenix wallet and the ACINQ node! And this process is NOT trustless but trusted! I.e., I have to hand over my 50,000 Sat to the ACINQ node in good faith and trust that it will build up a payment channel to my wallet. Such trusted operations aren’t really ideal… but they greatly improve the user experience (i.e., trade-off in favor of UX). ACINQ charged 3,000 Sat for setting up the payment channel, which is why we do not see 50,000 Sat but 47,000 Sat credited to our wallet.

Step 6: Now the payment channel is set up and we can use our 47,000 Sat for lightning-fast small payments. Let’s make a payment to a colleague! We now click Send and scan the payment request on our colleague’s smartphone to transfer 10,000 sat to him.

Step 7: In a fraction of a second, the colleague received the 10,000 sat (minus payment channel setup fees of 3,000 because he did not yet have a payment channel).

In our Phoenix wallet we see that we were not charged 10,000 Sat but 10,006 Sat for sending 10,000 Sat. This means that we were only charged a fee of 6 Sat = 0.0003 USD for the transaction.

Step 8: So… now we’re almost at the end. Finally, we want to get our Sat back from the Phoenix wallet and put it into our normal Bitcoin wallet. For that we click Send and then scan the Bitcoin address of the recipient wallet. As with the deposit of Bitcoin in step 4, the withdrawal of Bitcoin is a trusted step via the ACINQ node and not a trustless step. This means that we have to trust ACINQ again here.

So… that was a really long post. If you’ve read this far, then congratulations on the new knowledge you’ve gained about the Lightning Network!

1) Creating a backup of a Bitcoin wallet is super easy: you just have to write down the seed phrase and you’re done. It’s not that easy with Lightning wallets because backups of the payment channels have to be updated after each transaction. Here Phoenix takes a simple approach: The Phoenix wallet sends an update of the payment channel data to its peer, the ACINQ node, which stores the payment channel data after each transaction. If you should uninstall your Phoenix app or lose your smartphone, all you have to do is reinstall the Phoenix app with the same seed phrase (yes… this only works with the Phoenix app) and you will immediately have access to your payment channels again.

(Disclaimer)

GET NOTIFIED ABOUT NEW POSTS!

Sign up to get an email notification every time we publish a new blog post.

We don’t spam! See our privacy policy.