Qtum|Institute What is the potential exchange in the Lightning Network?

2,255 characters

Estimated reading time: 8 minutes

This article is the translation of Florencia Ravenna's article explaining Submarine swaps. (For the original English version, please click to read the original text at the end of the article to view)

The following is the original translation:

The discussion about potential exchange has been going on for some time, and there are some interesting manifestations in many products and services. But what exactly is latent exchange? How do people apply it in reality? Through this article, we will discuss these issues in depth.

To understand the principle of latent exchange, we first need to understand what HTLC is. HTLC is a hashed time-locked contract, in fact they are easier to understand than they sound. More importantly, understanding HTLC is not only the key to understanding the potential exchange, but also the key to understanding the Lightning Network itself.

01

HTLC as a building block

Suppose you are a Bitcoin holder. Earlier you sent some Bitcoins to the address of your friend Martin. To spend the bitcoin you sent, Martin needs to prove that he has the private key corresponding to the address. This is the most basic working principle of Bitcoin: Martin proves that he has ownership of the key before he can spend the Bitcoin you sent him.
The most basic principle is that if you want to restrict Martin from using the bitcoins you send, you can actually add more restrictions. For example, Martin must reveal a certain secret within a given period of time, otherwise these bitcoins may be used by the owner of another key after the time is up.
What is this secret? This secret is a message created by Martin or someone else on the network. If Martin had created this secret himself, of course he would know what it was. But if it is a secret created by others, Martin needs to find a way to find out the secret. In any case, as long as Martin knows the secret, he can use Bitcoin and further send the Bitcoin to his wallet address to prevent timeout. We call this action as fund acquisition.
This whole process is simply an HTLC: its essence is a contract, in a transaction, it requires the payee to prove that they know a specific secret within a certain period of time before they can spend money. It turns out that adding this condition will implement a very interesting and practical function: the link payment function. This may have nothing to do with on-chain transactions, because in on-chain transactions, people can pay directly to the final beneficiary, but this is very useful in the Lightning Network, because in the Lightning Network, if you pay directly to everyone, it will be very inefficient .
It is easier to understand the principle and purpose of HTLC in a routing network environment such as the Lightning Network. Let us first look at an example of off-chain payment. Before reading, please remember that HTLC can actually play a corresponding role no matter whether the transaction occurs on or off-chain, and they can even work in other blockchains (such as Litecoin).

02

HTLC in the Lightning Network

Suppose you want to pay 1 BTC to Sandra, but there is no payment channel between you and her. Thomas and you both have payment channels, so you can use Thomas to realize this transaction. Without HTLC, what problems might arise during this transaction? Depending on who pays first as a prerequisite, the following two problems may arise:


If you pay Thomas first and believe that he will pay Sandra, then it is very likely that Thomas will flee with the money.

If Thomas pays Sandra first, and believes you will pay him later, then you can ask Thomas to pay for you and never pay the money.

If you use HTLC, Sandra can create a secret that only she knows, and you can safely send Bitcoin to Thomas and add a restriction, such as he must reveal the secret within a certain period of time, otherwise you can use Bitcoin. And Sandra will show you her Lightning Network credentials, and the QR code above will prompt you with relevant information.

Due to the characteristics of HTLC, you will know whether Thomas revealed a secret created by Sandra, even if you don't know what the secret is in advance. Now, Thomas can send a bitcoin to Sandra with the same terms: if she wants to spend it, she needs to reveal the secret within a period of time. Sandra, who already knows the secret, can use the money immediately.

At the moment of obtaining the funds, Sandra reveals the secret, so Thomas can also use the bitcoin you sent him. The end result is that you successfully paid Sandra in Bitcoin through Thomas without trusting each other. Now that you and Thomas both know the secret created by Sandra, you can both use it as a proof of payment, because Sandra revealed the secret to get her money. It is worth noting that if Sandra refuses or fails to reveal the secret, the timeout restriction is very critical, which gives the possibility of transaction rollback. 

03

HTLC in latent exchange

We generally call ordinary Bitcoin transactions as on-chain transactions. After the Lightning Network channel is established, all transactions are off-chain transactions. It can also be understood that Lightning Payment is off-chain transactions, and HTLC can be in both on-chain and off-chain transactions. achieve. In fact, they can be used to link payments between on-chain and off-chain transactions, and vice versa. This is the potential exchange.

Suppose you want to implement a transaction in the Lightning Network, but you don't want to manage it yourself because of trouble. Potential exchange allows you to use bitcoin on the chain to pay for lightning credentials through an intermediary. How is this process achieved? The merchant in the Lightning Network will generate a QR code to remind you of the secret you need to obtain from the potential exchange provider. Only when this secret is revealed can you use the funds. After completing this step, you can safely send Bitcoin to the service provider to form an on-chain HTLC. The service provider does not know the secret, so it cannot immediately use the bitcoin you sent them. Instead, he will transfer Bitcoin to Lightning Network merchants and add a clause requiring Lightning Network merchants to disclose the corresponding secrets before they can obtain funds.

The Lightning Network merchant already knows this secret, but in order to obtain the money, he must reveal the secret. In the process, the exchange service provider will learn about this secret and get the money you pay them. Both the exchange service provider and the merchant can collect the corresponding money, but there is a difference: the exchange service provider receives the money on the chain, and the merchant receives the money off the chain.

04

What is the use of hidden exchange?

Potential exchange may be the easiest way to make payments through the Lightning Network. Although it still needs to pay on-chain fees, the payment process is similar to an on-chain payment process, and the payment can be instant (depending on the implementation). If users need to transfer part of their funds from on-chain to off-chain (or vice versa), the potential exchange will be very useful. For example, after a week of successful operations through the Lightning Network, the merchant may need to obtain bitcoins on the chain to pay the provider. The rollback mechanism provides a method of reverse submarine exchange, and at the same time, the channel can be rebalanced to obtain capacity.

Finally, considering that other tokens can also be potentially swapped, such as using Litecoin (with lower fees and shorter confirmation time) and merchants to complete lightning payments or provide more liquidity for your channels.

The potential exchange is an idea proposed by Alex Bosworth and Olaoluwa Osuntokun, and it has become more and more popular with the passage of time. Although latent exchange is not perfect, some of its existing applications can help the entire network to solve two major problems in the initial development process: liquidity and adoption rate.

Guess you like

Origin blog.csdn.net/weixin_42667079/article/details/103271494
Recommended