What is the Lightning Network and what is it for?
“BTC Lightning network”, a second new layer of BTC blockchain which works off-chain to achieve instant transactions with great cost-efficiency.Source: medium.com
Many people believe that Bitcoin is the future of our financial system, but there is a problem in achieving this goal and it is called "Scalability Deficiency".
Let's put a comparison, the VISA payment provider processes on average 4,000 transactions per second and it can scale up to 65,000 per second at any given time, however Bitcoin can process up to 7 transactions per second in a block size of 1 MB, not tens of thousands of transactions like the other method but only 7.
It's obvious that if Bitcoin wants to achieve mass adoption this is a big obstacle. Clearly the main blockchain of BTC (The Bitcoin Core) is not scalable at all, and that's why the forks occurred with Bitcoin Cash and Bitcoin SV (see articles on the BTC forks and Bitcoin SV). But it doesn't have to be that way.
The BTC developer community has developed a new technology called "Lightning Network" to solve scalability problems without having to resort to forks that lead to the creation of a new cryptocurrency.
The key idea is that small and daily transactions do not have to be stored in the main blockchain but in off-chain channels, thus exceeding the limit of 7 transactions per second is possible thanks to this "Off-Chain Approach".
But, how does it work?
The best way to show how it works is through an example: let's imagine that Maria has a cup of coffee every day at the coffee shop near the office before starting her work day. If we had to create a blockchain transaction for each coffee would be exaggerated, you would end up paying more commissions than the value of a cup of coffee, however with Lightning Network, Maria can establish a payment channel with the coffee shop and to do this, Maria and the Coffee Shop create a payment channel, where Maria deposits bitcoins as a provision of funds in what is called a "multi-signature address".Source: Cryptonomist.ch
Maria deposits about 0.005 BTC in that joint account and the coffee shop does not provide anything because it does not admit refunds. A multi-signature BTC address is like a safe, which can only be opened when both parties agree to a transaction (serving and receiving a cup of coffee).
When a payment channel is opened, a balance account is opened that shows the funds and which have to be distributed, so now Maria has 0.005 BTC and the coffe shop has none yet. When this payment channel is opened, it is registered in the main blockchain for total transparency. The coffee shop knows now that Maria has deposited the funds and that they are safe to perform transactions to receive the money once the account/payment channel is closed.
Well, once the channel is open, Maria can order her coffee, and each coffee costs 0.0005 BTC (ten times less than the funds deposited, then Maria can order up to 10 coffees before all the funds are spent), so with the first coffee the balance begins to change and pass the amount of the first coffee to the balance of the coffee shop. Thus, right after the first transaction Maria has 0.0045 BTC left and the coffee shop would have 0.0005 BTC. And so on, until the balance is used up and all the funds remain in the cafeteria's favour. For each transaction both sign it with their private keys, it stays sealed and each one keeps their copy.
Maria can obviously continue to order her coffees if she still has a balance in the payment channel. Both can make hundreds of transactions this way without limit but they are not recorded in the main blockchain until the channel is closed. And this can be closed by each one, Maria or the coffee shop. And in that case all it has to be done is taking the balance that each one has left, and it is transmitted to the bitcoin main network, in an immediate settlement process. The miners can now validate the signatures on the channel's balance sheet and if correct will release the funds to each party according to the final balance, and this closure only creates a simple transaction on the main blockchain network.
The Lightning Network can significantly reduce the load of the main blockchain, since only two transactions are required in the blockchain, one when opening the payment channel and another when closing it, but in the middle hundreds or thousands of transactions may have been made without having to record them in the main blockchain. It is fast and highly efficient
The system ensures that only the last signed balance can be used to release the money and because both parties have a signed copy of the balance, they can release the funds at any time without waiting for the collaboration of the other party. This way Maria can't take back the funds used for the purchase of the coffees and the coffee shop can't claim the balance not used by Maria.
But there's more, we don't have to open a payment channel directly with everyone we want to send bitcoins to, we can simply use the network to pass the coins, so Martha is a Maria's friend, she can have a coffee at Maria's coffee shop without having to open a payment channel with the coffee shop, simply using the payment channel there is between Maria and the coffee shop, and so everything is simplified even more.
Well, the "proof of concept" for the implementation of the BTC Lightning Network was done during 2018 running on the Bitcoin Testnet network, and now throughout 2020, there is a remarkable expansion of its use and adoption, after numerous updates that have made it more operational and secure as a second layer ecosystem of the Bitcoin Blockchain Core. The adoption of this network by the nodes is increasing every month with increases of 50% since the beginning of this year, with more than 7600 payment channels available to the public.Source: cfhu.org