Payments Channels are a technology designed to allow instant payments without custody between two or more people who use a cryptocurrency. This in order to offer a better payment experience with excellent security and very low commissions. 

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

Unidirectional

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. 

Bidirectional

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

Advantages

  1. 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. 
  2. You can make micropayments, even send few satoshis.
  3. 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.
  4. It enables the ability for businesses to receive payments in cryptocurrencies leaving behind on-chain confirmation times, but without giving up security.
  5. 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.  

Disadvantages

  1. There is a limit on the number of transactions that we can do with a payment channels. 
  2. 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. 
  3. 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. 

How much do you know, cryptonuta?

Are Payments Channels an insecure solution to scale cryptocurrencies?

FALSE!

There is a myth in which many users of cryptocurrencies like Bitcoin fall, and that is, many say that payment channels like Lightning Network are insecure. The reality is that even though the technology is still in its development phase, payment channels like LN are very secure. This is unlike other options such as those based on high-speed consensus protocols and which in turn lead to centralization (such as PoA or PoET).

First implementations of Payments Channels

Now, the implementations of payments channels or payment channels have evolved in recent years, and it continues to evolve. Here we will name some proposals and what have been their most outstanding achievements.

BitcoinJ and its payments channels

Developers Mike Hearn and Matt Corallo added support for payment channels on  Bitcoinj, on June 27, 2013. With the implementation, BitcoinJ became the first external library to Bitcoin Core able to safely support this system. Bitcoin Core could use this type of payment system, but as we mentioned at the beginning of this page, it was insecure because miners or nodes could manipulate these channels using the existing means (nLockTime and nSequence). 

BitcoinJ the first external library to support Payments Channels

BIP-65, the birth of CLTV

Bitcoin Core made a breakthrough in the ability to create payments channels with activation OP_CHECKLOCKTIMEVERIFY or CLTV, a new OP_CODE for Bitcoin.  

Thanks to this code it is possible to prove that it is impossible to spend a transaction output until some time in the future. This is possible thanks to the fact that CLTV allows you to implement a test capable of knowing whether a valid signature has been created for a different transaction that spends a certain output. If that case is detected, CLTV can invalidate the new transaction, avoiding possible double-spending schemes.  

Simply put, the BIP-65 allows you to create a method of verifying funds spending that nLockTime is unable to handle, allowing the creation of safe two-way channels. 

HTLC

The HTLC They are another development in favor of payment channels. Basically HTLCs work on payment routing. In other words, they direct payments securely through multiple payment channels. In this way, HTLC avoids one of the problems of payment channels: the cost of opening new payment channels. Thus HTLC is able to use always open payment channels and route the payments of all people between those payments. The result is a huge network of payment channels open almost permanently, ready to enable two-way payments within them.  

This functionality has made HTLCs an integral part of the design of more advanced payment channels, such as those used by Lightning Network.

Lightning Network explorer nodes

Payments Channels on other blockchains

As you may know, Bitcoin is not the only cryptocurrency blockchain, nor is it the only one in which it is capable of integrating payment channel protocols. Cryptocurrencies like Litecoin o Ethereum, they are also capable of using this type of systems. Almost every cryptocurrency with scalability issues has looked for a method to use payment channels to scale. The reason is simple: payment channels are easier to implement than a rewriting of the already proven protocols of those blockchains. 

For example in Litecoin we can use Lightning Network today, and in Ethereum we can use Raiden Network or Liquidity Network, although the latter uses a different payment channel scheme. 

As you are seeing Blockchain does not rest, and the innovation around it is incessant. The payment channels seem to have come to stay, and despite being in early stages, they aim to stay, especially if we want to see cryptocurrencies in a massive way around the world.