Reintroduce support for the old submarine swap protocol#10650
Conversation
Co-authored-by: dejfcz <dejfcz@users.noreply.github.com>
Co-authored-by: dejfcz <dejfcz@users.noreply.github.com>
9762103 to
1f587fd
Compare
|
|
||
| can_route = False | ||
|
|
||
| # 2. send htlcs | ||
| async for sent_htlc_info, cltv_delta, trampoline_onion in routes: | ||
| if probe_only: | ||
| can_route = True | ||
| continue | ||
|
|
||
| await self.pay_to_route( | ||
| paysession=paysession, | ||
| sent_htlc_info=sent_htlc_info, | ||
| min_final_cltv_delta=cltv_delta, | ||
| trampoline_onion=trampoline_onion, | ||
| fw_payment_key=fw_payment_key, | ||
| ) | ||
|
|
||
| if probe_only: | ||
| return can_route |
There was a problem hiding this comment.
So you are not actually probing? HTLCs are not sent, this is just testing if the offline path finder can create some routes at all.
E.g. if Alice is trying to pay Bob, this is just testing that Alice has enough outbound capacity on the direct channel, and that some path can be found in the graph from Alice to Bob based on the gossip and the invoice r hints only. If Alice is using trampoline, it is checking even less, as Alice does not even have the graph.
Consider that Bob has a channel with the ACINQ node, and Alice has a channel with the "Electrum Trampoline" node. Bob likely only generates a bolt11 invoice if the Bob<->ACINQ channel has liquidity. Similarly, Alice knows if the Alice<->"Electrum Trampoline" channel has liquidity. Whether there is liquidity on any path from "Electrum Trampoline" to ACINQ is not checked here.
There was a problem hiding this comment.
So you are not actually probing? HTLCs are not sent, this is just testing if the offline path finder can create some routes at all.
Yes, the check is very basic. It was somewhat intentional to get some feedback.
E.g. if Alice is trying to pay Bob, this is just testing that Alice has enough outbound capacity on the direct channel, and that some path can be found in the graph from Alice to Bob based on the gossip and the invoice r hints only. If Alice is using trampoline, it is checking even less, as Alice does not even have the graph.
Consider that Bob has a channel with the ACINQ node, and Alice has a channel with the "Electrum Trampoline" node. Bob likely only generates a bolt11 invoice if the Bob<->ACINQ channel has liquidity. Similarly, Alice knows if the Alice<->"Electrum Trampoline" channel has liquidity. Whether there is liquidity on any path from "Electrum Trampoline" to ACINQ is not checked here.
Thank you for the elaboration. Please help me understand if you find this to be a hard requirement for this PR, or not. I'm not sure how to add this behavior at the moment (perhaps @dejfcz does). If you do know how to add it, any pointer would be very helpful and much appreciated. It would save us time. :)
There was a problem hiding this comment.
some path can be found in the graph from Alice to Bob based on the gossip
Yes. The suggestion is to start with something trivial, which can later be improved by someone with deeper knowledge of Electrum code base. As it is now, it does prevent accepting swap in some scenarios, but of course full probing would be much better. So it is more about setting up the interface (probe_only parameter) for now.
3223fc6 to
0a9d13e
Compare
Closes #10611
This PR
forwardv1(the old protocol).Motivation
We've been trying to expand Electrum Swap ecosystem by creating interface – https://whales.exchange – for people who do not use Electrum Wallet. We have released the first public version of https://whales.exchange where we implemented support for reverse swaps. We would like to support forward swap as well in order to provide complete swap gateway to Electrum Swaps.
The current implementation of submarine swaps in Electrum require control over user's LN wallet which https://whales.exchange does not control (see the design). However, Electrum used to implement a different protocol, so called old flow or simply v1 flow, for submarine swaps which did not have the requirement. The old implementation was removed because:
This PR attempts to bring back the old flow, so Electrum would support the old and the new submarine protocols. Moreover, to address the above issue, a new preliminary "is-there-a-LN-payment-route" check was added to somewhat mitigate the issue.
A short description of both protocols follows:
Old submarine swap flow (v1) is
New submarine swap flow is:
Discussions
(edit: Rebased to b9be974. Originally, it was based on 9b26c18.)