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).
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:
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:
A Loop server is also available on the Bitcoin testnet at this node:
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:
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.
A submarine swap essentially looks like this:
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.
Alice presents the Lightning invoice to Bob, a "submarine swap provider".
Bob quotes what he must be paid on chain in order to pay the Lightning invoice off-chain.
If Alice accepts the exchange rate, Bob and Alice work together and construct an HTLC that creates a conditional on-chain payment to Bob.
Alice makes the conditional payment to Bob.
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.
Bob pays the Lightning invoice, forcing the Lightning payment recipient to reveal the secret S.
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.