Submarine Swap

Submarine Swaps are atomic on-chain to off-chain swaps (and vice versa) of cryptocurrencies.

This was made possible (and put into production) by Alex Bosworth. Olaoluwa Osuntokun originally coined the term Submarine Swap—one half is above water (on-chain), one half is below water (off-chain).

Examples

Lightning Labs has released Loop, a submarine swap service that plugs into LND. Loop allows users running LND nodes to exchange BTC in Lightning channels for BTC on-chain, and vice-versa. Loop charges a fee (0.1% as of 2019-10-24) for this service. The Loop client is open source but the server is proprietary—to perform a swap, you have to perform it with Lightning Labs.

The Loop swap server is hosted on this node:

03fb2a0ca79c005f493f1faa83071d3a937cf220d4051dc48b8fe3a087879cf14a

It's not possible to connect to this node directly, but you can connect to this node that acts as a gateway to the Loop node:

021c97a90a411ff2b10dc2a8e32de2f29d2fa49d41bfbb52bd416e460db0747d0d@18.224.56.146:9735

A Loop server is also available on the Bitcoin testnet at this node:

0223acffd7f363b4591ce860eda870fea352e981212d8a25e96a0ebea37faae288@40.71.39.161:9735

Alex Bosworth released an early demo of submarine swaps using fully open-source code:

Boltz Exchange has also open-sourced an implementation that is also compatible with Litecoin LN:

Technical Details

Problem

Transactions between on-chain blockchain addresses and off-chain Lightning addresses are not directly compatible. This creates a transaction barrier between the underlying blockchain and the off-chain Lightning Network, regardless of implementation.

Submarine swaps solve this issue by enabling Lightning channels to be refilled via an on-chain transfer from the underlying blockchain to the off-chain LN channel.

Structure

A submarine swap essentially looks like this:

  1. Alice produces or retrieves a Lightning Network payment invoice. It doesn't matter whether the Lightning payment is to Alice or to someone else that Alice is trying to pay.

  2. Alice presents the Lightning invoice to Bob, a "submarine swap provider".

  3. Bob quotes what he must be paid on chain in order to pay the Lightning invoice off-chain.

  4. If Alice accepts the exchange rate, Bob and Alice work together and construct an HTLC that creates a conditional on-chain payment to Bob.

  5. Alice makes the conditional payment to Bob.

  6. The conditional payment to Bob is hashlocked with the same secret that will be revealed if the Lightning invoice is paid. Bob can only redeem the conditional payment from Alice by making the Lightning payment.

  7. Bob pays the Lightning invoice, forcing the Lightning payment recipient to reveal the secret S.

  8. Bob uses the secret S to redeem the conditional payment from Alice.

If Bob does not pay the Lightning invoice before it expires, Bob is not able to redeem the conditional payment from Alice. In this case, Alice can wait for the HTLC to expire, then redeem the conditional payment's funds back to herself.

What do submarine swaps allow you to do?

  • trustlessly pay someone on-chain to perform an off-chain payment for you

  • trustlessly pay someone on-chain to buy coins on the Lightning Network from them

This means that a user can make Lightning Network payments without being on the Lightning Network, rebalance their Lightning Network channels with a fast and low-cost payment on another chain, and perform fast trustless swaps where the usual slow step is made instant.

Submarine conditional swaps have been demonstrated on the Bitcoin and Litecoin Lightning Networks, using on-chain payments on Bitcoin, Litecoin, and BCH. They should also be possible (albeit with more steps) using on-chain payments on other Bitcoin derivatives, Ethereum, Stellar, Ripple, and more.

Resources

Submarine Swaps

Key People

See also

Submarine Swaps Service

References

[1] https://submarineswaps.org/