Lhe payment channels or Payments Channels, are a means designed for users of cryptocurrencies can carry out instant and low-cost transactions without having a negative impact on the blockchain.
This need is motivated by the limitations that cryptocurrencies have such as Bitcoin, and most of the system's cryptocurrencies, in terms of their scalability in transactions per second and the total space of the blockchain. Thus, a payment channel allows many people to carry out a large number of transactions in the background, but in the main blockchain only two transactions are accounted for.
Of course, when opening a payment channel (no English payment channel), the nodes must lock the currencies of the users so that these cannot be used outside the channel during the useful life of the same. This has a huge cost that makes it unattractive to keep payment channels open. But for this reason, payment channels are still a very effective way of providing great scalability to cryptocurrencies.
At this point you will surely wonder how do they work? They're safe? What systems exist today? We will answer all these questions below in this new article from Bit2Me Academy.
Origin of payment channels in cryptocurrencies
The idea of payment channels in cryptocurrencies is not new. From the beginning of the development of technology this idea was there. Satoshi Nakamoto he presented it as a technological possibility applicable to Bitcoin. This supported by OP_CODES de Bitcoin Script that were used to replace transactions and control their validation. We talk about OP_CODES nSequence y nLockTime, which allowed two or more parties to repeatedly update the status of an unconfirmed transaction before it was committed.
Nakamoto's rudimentary system would allow creating transactions that could contain multiple entries. Each of these entries would be signed and verified by the user and holder of the funds described in said entry. Thus with each new signature, the value of nSequence changes to a higher value, until the signature chain ends with the confirmation of the transaction in a block. And at the same time, the transaction contains internal accounting with which users agree.
Thus, a single transaction can mean several different transactions for different users. The system also allows the ability that, in case the results are not agreed, the user in question avoids the signature and thus exits the system. In that case, the funds are back under your control and you can proceed without problems.
On the other hand, Nakamoto explained that nLockTime can be used in high frequency trading between a set of parties. To achieve this, nLockTime would allow to continue updating a certain transaction in mempool, if there is a unanimous agreement between the parties. In this way, the transaction would be updated every time one of the parties wants to participate in the transaction (which acts as a payment channel). When the parties agree to close the channel, the signatures of all the participants arrive and set the final nLockTime for the transaction, and wait for it to be confirmed. With its confirmation the channel is closed and all the operations described by the inputs and outputs are carried out in the same transaction.
However, both options are insecure. The nSequence and nLockTime values could be manipulated by a malicious miner or even a malicious node. However, the basic idea of payment channels had emerged, and behind it would begin extensive research to develop a better secure solution for everyone.
Development of the first payment channels begins
Satoshi Nakamoto's ideas quickly caught the attention of the community developers, who soon encountered a complex problem to solve. How to make multiple people participate in a secure, decentralized, instant payment system built on the Bitcoin protocol without unnecessarily altering it? Devising a functionality like this is a complicated topic, but it is more complicated to program it, and if we add to this that such programming is compatible without breaking any of the above, it is extremely complex. Even so, two ways to make payment channels quickly emerged and we explain them below.
Types of Payments Channels
The simplest payment channel system is the one-way channel system. In this system, user A can make a payment B. A new user C can join the channel, and make a payment to D. And in this way, the chain of payments in the channel can continue to expand.
Those payments are controlled and secured by transactions of the type multi-signaturesTherefore, in order to be carried out, the parties involved must sign in accordance with the data shown in the inputs and outputs of the transaction. As the channel grows, the system firms also grow and everyone must sign for the funds to be released.
Additionally, an nLockTime of 50 blocks is applied, to prevent users from using the money immediately, but on the contrary, the money will only be available after 50 blocks have been confirmed. At this point, you can see the nLockTime as a check that is only valid after a certain date, before that date it is just a worthless piece of paper. The nLockTime can be adjusted in any way the parties wish.
In this way, all participants can be sure that the payment has been made, but they will only receive the money after the additional conditions of negotiating that payment are met. For example, it should be understood that A paid B to fix a computer, and B has approximately 500 minutes to repair said computer. Otherwise, A may still intervene in the transaction, change its value, and get her money back.
Two-way payment channels are actually two one-way channels working together. Thanks to this, A and B can send payments in a bidirectional way, without the need to close a previous channel and open another new channel for payment operations. The basic operation is maintained, with the exception that the bidirectional channels are perfect for performing more dynamic operations between two users or entities.
Why were the payment channels or payment channels created?
In Bitcoin, transactions can only be confirmed if they are included in a block within the blockchain. A process that happens approximately every 10 minutes and in which only 1 MB of information can enter. This greatly limits the number of transactions that can be confirmed in each block, with approximately 2200 transactions being confirmed every 10 minutes.
But how about we cheat? What if we include many inputs and outputs in a transaction and the parties involved in that transaction sign the transaction to give their approval? With this, the transaction is finally issued to the network and validated, and thus a transaction would make the equivalent of several individual transactions. A very subtle trap, true, but also very useful and it is precisely what a payment channel does. At least in its most basic features.
In this way, the payment channels or payments channels are transformed into a second layer solution that allows users to carry out transactions without having to depend directly on the next block for a transaction to be considered complete. Thus, we can make instant transactions that will later be recorded unanimously on the main blockchain, when the payment channel is closed. Nothing is lost, no coins are created out of nothing, in the end everything ends in the same accounting, and the numbers just add up.
There is why the payment channels were created. It is a perfect tool to make the payment more flexible using cryptocurrencies, and all this, without altering the current protocols.
Advantages and disadvantages of payment channels
- They offer the ability to make payments instantly between the parties participating in the payment channel. But it also allows you to schedule payments, and make them safer under certain conditions.
- You can make micropayments, even send few satoshis.
- It allows to lower the transaction fees, thanks to the fact that the payment of the on-chain confirmation fee is made among all the participants of the channel.
- It enables the ability for businesses to receive payments in cryptocurrencies leaving behind on-chain confirmation times, but without giving up security.
- Under the current payment channel specifications it is very difficult (if not impossible) to steal funds. This is because the payment channel implementations use the multi-signature address scheme, where the actions are only carried out if they carry the signatures of all the participants.
- There is a limit on the number of transactions that we can do with a payment channels.
- The funds to spend on a payment channels must be placed in advance. This means that if the channel runs out of money, it will be necessary to open a new one to carry out more operations.
- There are still some security issues regarding payment channels. Cases such as vulnerabilities in client codes and nodes for this type of system. Or even vulnerabilities in the operating structure itself, as in the case of Temporal Dilation Attack. These are some of the problems to be solved before the massification of these systems.