The Lightning Network is a protocol to allow quick payments through a network of bidirectional payment channels. It is a second layer of Bitcoin that, through mutual cooperation, takes place outside the blockchain, and can use it to establish the balance sheets of the channels.
The idea was presented in February 2015 by Joseph Poon and Thadeus Dryja. The first nodes of the network were implemented in early 2018.
The Lightning Network is a protocol to allow quick payments through a network of bidirectional payment channels. It is a second layer of Bitcoin that, through mutual cooperation, takes place outside the blockchain, and can use it to establish the balance sheets of the channels.
The idea was presented in February 2015 by Joseph Poon and Thadeus Dryja. The first nodes of the network were implemented in early 2018.
The Lightning Network aims to improve Bitcoin in 3 ways:
Scalability - Bitcoin's blockchain allows only 7 transactions per second (tps) to be made. In comparison, it is estimated that the Visa network can support up to 47000 tps. Now, for Bitcoin to be an alternative payment system, it must allow removing transactions from the blockchain, in order to overcome the capacity already installed by current systems. It is expected that with the implementation and expansion of the network, billions of tps will be reached, exceeding the capacity of current systems by several orders of magnitude. If we add the Internet of Things (IoT), and allowing devices to exchange value between themselves, needs escalate quickly. Imagine that your smart fridge can make the purchase of the week, directly to the grocery store of your choice. The Lightning Network will be able to handle all of these transactions!
Speed - Bitcoin transactions can take up to 1 hour to be valid. A transaction is considered safe after 6 confirmations. A confirmation is equivalent to a mined block, which happens on average every 10 minutes. 6 blocks therefore require 60 minutes. At Lightning Network, transactions are instantly validated. This network allows you to create a point of sale in your neighborhood's cafe so you can pay with Bitcoin and be able to taste your favorite coffee before it cools down!
Micro-payments - due to the fees necessary for the survival of the network, transfers of reduced Bitcoin fractions are not attractive. The fees will be even lower than on the Bitcoin network allowing only 0.00000001 BTC to be transferred per transaction. The example we saw of streaming video paid at 1 satoshi per second is possible on the Lightning Network.
How it works?
The Lightning Network (LN) is a set of payment channels, identical to the ones we learned in the last articles. The nodes establish channels with each other in order to create a network that will transmit the payments until they reach the final recipient.
When a node wants to send a payment to another, with which it does not have an open direct channel, it must first build a path connecting other channels and verifying that they have the capacity for the payment that it intends to make.
You can do this because the nodes openly publish 3 pieces of information:
- the channels they have open;
- the capabilities of these channels;
- and the fees they charge for transmitting payments.
Based on this information, the node will then build the most efficient route to the final recipient.
At LN, the advanced transaction known as the Time Lock Dispersion Contract - HTLC is used. This allows you to block a payment for a key that must be exchanged in advance, if the transaction is not claimed the money is returned to the origin.
Thus, even before carrying out the transaction in LN, the node that will be the final recipient builds a key - a secret that will be encrypted. The issuing node receives the secret already encrypted and creates a payment that will be blocked to the secret. Then it sends it to the first node that you defined in the path, starting the transmission. As with blockchain, it adds some extra money to cover the fees charged by the transmitting nodes.
Payments are built on an “onion type” protocol, similar to the Tor browser. This protocol is composed of layers and each node can only open and see the layer addressed to it. By the way the network is designed, no node knows where in the sequence it is. It does not know how many "jumps" from node to node have already been made or how many are left to be done. Each node that opens its layer sees the payment as 20 hops away, the maximum number of hops a payment can take. Information is added to simulate these additional jumps. Even the recipient node receives payment as if 20 more hops were missing. After realizing that the payment is for you, you will turn that additional information into garbage and then process the payment.
This creates the security of being able to send money through a third party without the third party knowing the value or the final recipient of these funds. Thus, even if a payment passes through a given node, that node is not able to “filter” payments to specific addresses. Everyone is free to participate in the network without censorship.
Each transmitting node receives the payment, opens the layer to which it has access and sees that the payment is addressed to the secret. If I knew the secret I could collect the money. As you don't have it, you create a new payment with the initial amount minus your transmission fee and send it to the next node, which is already defined in the previous payment. The node does not receive its fee immediately because the payment it received is addressed to the secret that it does not yet know. You will have to wait for it to be shared with him.
This process is repeated until the final recipient who, by presenting the secret to payment, is able to claim it. Now that you have your money safe, the recipient will send you the secret that allows you to unlock all payments to do the opposite way. In this way, each transmitting node is able to claim the payment it received. The transmission fee for each node is the difference between the money you received and the money you sent, being rewarded when the final recipient confirms that he has received your payment.