# Submarine Swaps ## Resources - Description on [[docs.lightning.engineering]] - https://docs.lightning.engineering/the-lightning-network/lightning-overview/understanding-submarine-swaps ## General ### ([[Muun]] Blog) [A Closer Look at Submarine Swaps in the Lightning Network](https://blog.muun.com/a-closer-look-at-submarine-swaps-in-the-lightning-network/) [[2019-05-23]] (Excerpt) **HTLCs in Submarine Swaps** HTLCs can be included in both, on-chain and off-chain, transactions. In fact, they can be used to chain payments that happen between an on-chain sender and an off-chain receiver, and vice versa. These are submarine swaps. Let’s suppose you want to pay something in the Lightning Network but don’t want to manually manage channels yourself. Submarine swaps allow you to use your on-chain bitcoins to pay the lightning invoice, through a swap provider. How would this work? The Lightning merchant generates a QR code hinting you the secret you should ask the swap provider to reveal in order to claim the money you will send them. You can now safely send the swap provider your bitcoin, making an on-chain HTLC. The swap provider cannot spend the bitcoin you just sent to him because he doesn’t know the secret yet. Instead, he will transfer a bitcoin to the Lightning merchant, via Lightning, adding the clause that to claim the fund, the merchant has to reveal the secret. The Lightning merchant already knows the secret, but to claim the money he has to reveal it. In that process, the swap provider gets to know it, and claims the money you sent them. Both, the swap provider and the merchant, claim the money received, but there’s a difference: while the swap provider claims the money on-chain, the merchants does it off-chain. **What are Submarine Swaps useful for?** Submarine swaps might be the easiest way for someone to make their first payment via Lightning. While you still incur in on-chain fees, the payment flow is similar to one on-chain and payments can be instant (depending on the implementation). Also, if you are just looking to try the Lightning Network, opening a channel itself also requires an on-chain transaction. Since we are in the early days of Lightning, having an easy on-ramp for people to try it is important. This is the reason why we implemented submarine swaps in [Muun Wallet](https://blog.muun.com/lightning-payments-easier-than-ever/). Submarine swaps can also be useful for cases where users need to move part of their money on-chain to off-chain, and the other way around. For instance, after a successful week of sales via Lightning, a merchant might need to get on-chain bitcoins to pay providers. [Loop Out](https://blog.lightning.engineering/posts/2019/03/20/loop.html) provides a way of doing a reverse submarine swap, and at the same time [rebalance channels](https://blog.muun.com/rebalancing-in-the-lightning-network/) to get [inbound capacity](https://blog.muun.com/the-inbound-capacity-problem-in-the-lightning-network/). Finally, and given that submarine swaps can also be done with other coins, you could use for instance Litecoin, which has lower fees and faster confirmation times, to make a Lightning payment to a merchant or provide more liquidity to your channels. Submarine swaps started as an idea by Alex Bosworth and Olaoluwa Osuntokun from Lightning Labs and have gained more popularity with time. Although not without its downsides, it has some interesting applications that can help the network in its early days in two big fronts: liquidity and adoption. ### ["Pay from Bitcoin Mainnet to Lightning and Back: Submarine Swaps are now Live](https://bitcoinmagazine.com/technical/pay-bitcoin-mainnet-lightning-and-back-submarine-swaps-are-now-live) Michael Taiberg for [[Bitcoin Magazine]] on [[2018-08-30]] “Submarine Swaps” allow users to make trustless transactions between lightning addresses and on-chain addresses in either direction. “I think this makes it a lot more attractive to run a lightning-only service,” Submarine Swap’s developer Alex Bosworth told _Bitcoin Magazine_, as on-chain users wouldn’t beexcluded. “You don't have to \[...\] worry about including the on-chain people,” he said. “You can outsource that to somebody else, and you don’t have to trust them.” If one lightning network user wants to send funds to an on-chain user, for example, the middleman will transfer these funds to its own lightning wallet, if (and only if) he sends a transaction with comparable funds on the Bitcoin blockchain to the desired on-chain address. The process works the same in the inverse if an on-chain address wants to send funds to a lightning address. “There's lots of different ways it can be used,” Bosworth said. “So let's say an exchange wants to send to a lightning invoice but it doesn’t have lightning funds, or it doesn't have a lightning wallet; in that case, it could ask somebody who does have that to assist them, and then they could do so in a way where its locked to their on-chain unit.” He continued to explain that the feature could ultimately be integrated into wallets, enabling an on-chain client “that doesn’t even know about lightning” to transact with its users. Bosworth also pointed out that the swap providers could be the one and the same person. “It’s flexible in that respect. So you can have it be either a third party or it could even be yourself.” When asked if the swapping mechanism would want for liquidity, Bosworth said that he believes transaction rewards will incentivize enough users to front their bitcoin for transactions. “Users are incentivized by the swap rate to provide liquidity, I think that will attract more liquidity. This is a low risk operation, so I can either have my coins just sit there doing nothing or I can have them available for swaps and generate some revenue,” he stated. The Submarine Swaps concept was originally [conceptualized](https://twitter.com/roasbeef/status/964608261830750208) by Lightning Labs CTO Olaoluwa Osuntokun — though Bosworth came up with the same idea independently. The technology can be applied in various use cases, as Bosworth envisions. The technology is still in its infancy, as Bosworth explained, and it’s also contingent on the development of existing lightning network applications. “I’ve started doing tests on mainnet, and you can try testing it out on Submarine Swaps so you can see a swap in action, but there’s lots of stuff to work out and the LND still needs work; they’re working on a major new release, so things are moving along but I wouldn’t say it's like super safe because not everything is 100 percent yet.”