Overview
A submarine swap is a trustless mechanism for exchanging on-chain bitcoin for Lightning Network bitcoin (or vice versa). It bridges the gap between Bitcoin's base layer and the Lightning Network, enabling users to move funds between layers without relying on a centralized exchange or custodian.
How It Works
Submarine swaps leverage HTLCs (Hash Time-Locked Contracts) to ensure atomicity — either both sides of the swap complete, or neither does.
On-Chain to Lightning (Loop Out):
Alice (has LN sats) Swap Service
| |
|--- LN payment (HTLC) --->|
| locked to hash(H) |
| |
|<-- On-chain tx (HTLC) ---|
| locked to same hash(H) |
| |
|--- Reveal preimage H ---->|
| (claims on-chain tx) |
| |
| Service claims LN |
| payment using H |
The critical property is that the same hash preimage locks both the Lightning payment and the on-chain transaction. When one party reveals the preimage to claim their funds, the other party can use that same preimage to claim theirs.
Use Cases
- Receiving on-chain: A Lightning user who wants to move funds to cold storage can swap Lightning sats for an on-chain UTXO.
- Receiving on Lightning: A user with on-chain funds can open or refill Lightning channels via a swap.
- Channel rebalancing: Submarine swaps help manage Lightning channel liquidity without closing and reopening channels.
- Exchange withdrawals: Some services offer Lightning withdrawals via submarine swaps even if they operate primarily on-chain.
Notable Implementations
Services like Loop (by Lightning Labs) and Boltz Exchange implement submarine swaps, providing user-friendly interfaces for moving between layers. These services charge a small fee for facilitating the swap but cannot steal funds due to the atomic nature of the HTLC mechanism.
Edge Cases
If the swap does not complete within the timelock period, the HTLC expires and both parties reclaim their original funds. This ensures that funds are never permanently lost in a failed swap, though on-chain fees for the refund transaction are still incurred.