Many people believe that Bitcoin is the future of our financial system, but there is a big issue standing in the way of this goal and that is scalability. Let me give an example: the payment provider VISA processes on average around 4000 transactions per second can scale up to a maximum of 65,000.
Bitcoin, on the other hand, can handle up to 7 transactions per second with the current block size of 1MB. Not tens of thousands, but just 7! Clearly, the main blockchain isn’t very scalable, but it doesn’t have to be! The community has come up with a new technique called the Lightning Network to solve the scalability issues. The key idea is that small, everyday transactions don’t have to be stored on the main blockchain.
This avoids the 7 transactions per second limit and is also called the off-chain approach. So how does it work?
Well, let’s take a look at an example. Let’s say that every morning Bob buys a cup of coffee on his way to work. Creating a transaction on the blockchain for a simple coffee is really overkill. He might end up paying more fees than the actual price of his coffee. However, with the lightning network, Bob can set up a payment channel with the coffee shop. To do that, both the coffee shop and Bob deposit a certain amount of Bitcoin in what is called a multi-signature address.
Let’s assume that Bob deposits 0.05 BTC and the coffee shop deposits nothing because they don’t offer refunds. This multi-signature address is basically like a safe that can only be opened when both parties agree. When we open the payment channel we also make a balance sheet that says how the funds in the address should be distributed. So right now it says, “Bob will get 0.05 BTC and the coffee shop will get 0 BTC.” The same as they deposited.
Opening the payment channel happens on the main blockchain so that there is full transparency. The coffee shop owner can see that Bob has deposited 0.05 BTC and they can rest assured that they will get his money once the channel closes. Now that the channel is open, Bob can order his morning coffee!
Let’s say that the coffee costs 0.001 BTC. To pay for it, Bob simply changes the balance sheet. He subtracts the cost of coffee from his balance and adds it to the coffee shop’s balance. So now it says “Bob gets 0.045 BTC and the coffee shop gets 0.005 BTC.”
Bob and the coffee shop now sign the updated balance sheet with their private keys, they then each keep a copy of it but they don’t do anything else with it. Bob can keep order coffees for as long as he has a balance in the payment channel. Both of them can make hundreds of thousands of transactions between them. There is really no limit because this happens away from the main blockchain.
But all good stories come to an end.
The payment channel can be closed at any time by either Bob or the coffee shop. All they have to do is take the latest balance sheet, which was signed by both parties and broadcast it to the Bitcoin network.
Miners will then validate the signatures on the balance sheet and – if everything checks out – release the funds according to the balance sheet. This will create a single transaction on the Bitcoin blockchain.
So the lightning network can significantly reduce the load on the main blockchain. It only requires two transactions on the blockchain: one to open the payment channel and another one to close it. It’s also very safe.
The system ensures that only the latest signed balance sheet can be used to unlock the money, and because both parties have a signed copy of the balance sheets, they can release the funds at any time, even if the other doesn’t want to cooperate anymore.
So, for example, Bob cannot hold the money hostage that belongs to the coffee shop and vice versa. But it doesn’t end there.
You don’t need to open a direct payment channel with everyone you want to send Bitcoins to. You can simply use the network to pass your coins around. Here is Alice, she’s a friend of Bob They’ve exchanged money on the lightning network before, so they have an active payment channel. Now let’s say Alice wants to buy a coffee.
Instead of opening a direct channel to the coffee shop, she can transfer the money to Bob, who will then transfer it to the coffee shop. So there’s no need to create a payment channel for everyone! In the lightning network, your payment tries to find a route from person A to person B. It tries to do this with the least amount of intermediates and the least amount of fees.
This further reduces the strain on the blockchain but it requires the intermediates to have enough money in their payment channels.