3 upvotes, 2 direct replies (showing 2)
View submission: Lightning Network Megathread
Ok, now I began to read more and think more..
How does lightning handle cross chain swaps?? (atomic swap exchange)
I mean, I can barely understand what keeps the balance between two parties in check, funds are kept in a multi-sig vault and both parties can cooperatively announce a closing of channels and the balance is reflected on chain, in event of dispute, the stakes are kept in BTC in that multisig wallet.
In case of cross chain swaps, what happens when users do not cooperatively close channels, if you do not have both coins for staking?
Comment by Cryptoconomy at 03/01/2018 at 03:04 UTC
3 upvotes, 0 direct replies
We will use a Litecoin/Bitcoin swap for example. The swap would be a person who had one channel on the bitcoin network, and a different channel on the Litecoin network, but allowed forwarding based on some agreed or advertised ratio (likely spot price minus some fee). Therefore, the Litecoin channel close would be with only Litecoin, and the bitcoin channel would only have bitcoin. So either the transaction happens at an agreed upon swap value, or the person holding both coin channels merely doesn't go through with the swap.
So essentially its the same as any single node deciding whether to forward the payment, just the added task of deciding and confirming LTC/BTC ratio. There isn't actually a *channel* across both chains, just a node.
Comment by tripledogdareya at 03/01/2018 at 03:08 UTC
2 upvotes, 1 direct replies
Cross chain swaps would happen by transacting on two channels, one backed on either chain. In the simplest set up you would share two channels with a single partner, one BTC and one e.g. LTC. You issue an HTLC on the BTC channel requesting some amount of LTC be credited on the LTC channel. The partner issues an HTLC on the LTC channel requesting the secret required to complete the BTC contract. You claim the LTC by releasing that secret, which in turn allows the partner to claim the BTC. Swap complete.
This could be extended with any amount of routing before or after the swap, just so long as you eventually reach a node which has reachable channels for the coins you're trying to swap. It could even go further and involve a swap to some intermediate coin before swapping to the desired currency.