[ad_1]
I came upon flip round these steps for the ‘reverse’ case.
Within the ahead case, the Lightning bill doesn’t should be generated by the Payer, however may be by a 3rd get together, as described within the query. Whether it is generated by the Payer, and there are solely two events concerned, then that case may be ‘turned’ round for the reverse, LN->BTC case, with very comparable vault utilization.
First I re-describe the ahead case, when it comes to two events, after which I describe the trustless answer for the reverse case. Word that I name the swapper actor Consumer (as a substitute of Payer).
Ahead case (BTC->LN):
- Actors: Consumer, who needs to swap onchain BTC to Lightning BTC, and Supplier of the swap service
Steps:
- Consumer creates a Lightning bill it needs to be paid, with desired quantity.
- Consumer initiates a request to the Supplier, with the main points of the bill (quantity, cost hash, timeouts, and so on.) and its personal pubkey.
- Supplier units up a ‘vault’ BTC handle, managed by a script, permitting to be spent by somebody who can show that the LN bill has been paid (regular department), or by the Consumer after a while (timeout refund department). Supplier communicates the vault handle, the script and the BTC quantity it expects to Consumer.
- Consumer verifies the script: that it has the correct amount, and it has a timeout department with its personal pubkey.
- Consumer performs the on-chain BTC cost to the vault handle.
- Supplier observes the cost, waits for affirmation, verifies it.
- Supplier pays the LN bill (from its LN funds).
- As soon as the bill is paid, Supplier transfers the BTC from the vault to an handle of its personal management.
Finish outcome: LN bill is paid, Consumer has much less BTC and extra LN-BTC, Supplier has much less LN-BTC however extra BTC.
Right here is the detailed description of the reverse, LN->BTC case:
Reverse case (LN->BTC):
Actors: Consumer, who needs to swap Lightning BTC to onchain BTC, and Supplier of the swap service.
Steps:
- Consumer initiates a request to the Supplier, with the specified quantity.
- Supplier creates a Lightning bill.
- Supplier units up a ‘vault’ BTC handle, managed by a script, permitting to be spent by somebody who can show that the LN bill has been paid (regular department), or by itself after a while (timeout refund department).
- Supplier makes BTC cost to the vault handle.
- Supplier communicates the lightning bill to Consumer (with out the cost secret, in fact), the vault handle and script.
- Consumer verifies the vault, that it has payout department secured by the cost hash of the bill.
- Consumer verifies that the vault has the correct amount of BTC, waits for affirmation if wanted.
- Consumer pays the Lighting bill.
- Now within the possession of the cost secret, Consumer transfers the BTC from the vault to itself.
Finish outcome: LN bill is paid, Consumer has much less LN-BTC and extra BTC, Supplier has much less BTC however extra LN-BTC.
Some notes:
- In each instances it’s the Supplier who units up the vault.
- I didn’t increase on the fallback case (ahead case: the shopper can get well its BTC if Supplier fails to satisfy; reverse case: Supplier can get well its BTC if Consumer fails to pay).
- The Supplier can add some further service price, the Consumer is conscious of the elevated quantity earlier than paying, however this must be agreed/communicated earlier than.
- Within the ahead case the Lightning bill may be created upfront by a 3rd get together, and the Consumer can prepare that bill to be paid straight, e.g. when eager to pay for an bill of a web-based service provider (this use case variant is within the authentic query). Within the reverse case this isn’t doable (to pay BTC on to the third get together), because the BTC recipient should do a particular operation (transferring the BTC from the vault handle).
[ad_2]
Supply hyperlink