Loop In/Out

Swapping between on-chain coins and Lightning balances without giving up custody, to rebalance.

Basically

Loop lets you move bitcoin between the Bitcoin network and the Lightning Network. No one else holds your money during the swap.

Key Takeaways

  • Loop moves funds between on-chain bitcoin and Lightning without custody. Loop In converts on-chain bitcoin to Lightning balance, while Loop Out converts Lightning balance to on-chain bitcoin, without trusting a third party with your funds.
  • Submarine swaps use HTLCs for all-or-nothing execution. Either the swap completes entirely or both parties get their funds back, so no counterparty can steal funds mid-swap.
  • Node operators use Loop to manage Lightning liquidity. They can rebalance channels, acquire inbound liquidity, and move funds on or off Lightning without closing channels or using custodial exchanges.

What Is Loop In/Out?

Loop In and Loop Out move bitcoin between the on-chain layer and the Lightning Network through submarine swaps. Lightning Labs' Loop service introduced the terms, but the underlying technique works with any submarine swap provider.

Loop Out sends funds from Lightning to an on-chain address. You pay through Lightning and receive bitcoin on-chain, so you can get on-chain funds without closing channels.

Loop In sends funds from on-chain to Lightning. You pay from an on-chain wallet and receive the equivalent amount in your Lightning channels, adding inbound capacity from the swap provider's perspective.

Submarine swaps power both operations through atomic exchanges, with one leg on-chain and the other on Lightning. Cryptographic hash locks connect both transactions, so neither party can cheat and the swap needs no trust.

How Submarine Swaps Work

Submarine swaps extend the hash time-locked contract (HTLC) mechanism behind Lightning payments to on-chain Bitcoin transactions. The same hash locks funds on both layers at once, which coordinates the two sides of the swap.

The atomic swap pattern links both transactions to one secret, called a preimage. Each party can claim funds only by revealing that preimage, while a timelock provides a refund path.

Atomicity makes the swap all or nothing. If one party reveals the preimage to claim funds, the other party learns it and can claim their side; if nobody reveals it before the timeout, both parties recover their original funds through the timelock path.

Loop Out Explained

Loop Out converts Lightning balance to on-chain bitcoin. It is the most common use case because Lightning users often need on-chain funds without closing channels.

The Loop Out process links your Lightning payment to the service's on-chain payment. The same preimage controls both sides, so either both payments complete or both parties can recover their funds.

The service cannot steal your funds because it learns the preimage only after locking on-chain funds to you. You cannot steal the service's funds because you receive the preimage only after your Lightning payment is locked.

Loop In Explained

Loop In converts on-chain bitcoin to Lightning balance. It increases your inbound liquidity because the swap provider pushes funds to you through existing channels.

The Loop In process, in simplified terms, links your on-chain payment to the service's Lightning payment. The same preimage and timelocks protect both sides of the swap.

Loop In is especially useful for receiving payments. After a Loop In, the service's node gives you fresh inbound capacity, so others can pay you through that channel.

Channel Liquidity Management

Running a Lightning node requires channel liquidity management. Routing payments or spending shifts your local balance until channels become depleted, with all funds on one side, and need rebalancing.

Loop Out drains Lightning balance to on-chain without closing channels, freeing inbound capacity on those channels. Loop In reverses the process by converting on-chain funds to Lightning capacity without opening new channels.

Merchant Offramp

Merchants accepting Lightning payments eventually need to convert funds to fiat or on-chain bitcoin. Loop Out gives them a non-custodial path from Lightning to on-chain, after which funds can move to an exchange for fiat conversion.

Loop Out avoids closing channels. Closing channels would require reopening them later and paying on-chain fees twice.

Inbound Liquidity Acquisition

New Lightning nodes struggle to receive payments because they lack inbound liquidity. Opening channels creates only outbound capacity. Loop In solves this: you pay on-chain, receive Lightning balance pushed to you, and gain inbound capacity from the swap provider's perspective.

Non-Custodial Exchange

Submarine swaps let you move between layers without trusting an exchange. Loop In/Out services provide these swaps trustlessly. They are popular in privacy-conscious communities where avoiding KYC exchanges matters.

Cold Storage Integration

Loop Out lets you move Lightning funds to cold storage without closing channels. A merchant could Loop Out weekly earnings to a hardware wallet address, limiting hot wallet exposure while maintaining channel relationships.

Lightning Loop

Lightning Labs operates Loop, the most established submarine swap service. Loop is integrated into LND and many Lightning wallets and offers both Loop In and Loop Out with competitive fees. The service is non-custodial but centralised, with Lightning Labs operating the swap server.

Boltz Exchange

Boltz provides submarine swaps with a focus on privacy and decentralisation. Boltz requires no accounts, supports Tor, and runs open-source swap infrastructure. Boltz also supports swaps between Bitcoin and Liquid Network.

Deezy

Deezy offers instant swaps between on-chain and Lightning, including integration with its node-in-a-box solution. Deezy is known for fast execution and node operator tools.

Self-Hosted Options

The Boltz backend is open source, so anyone can run their own submarine swap service. Businesses can use it to offer swaps to customers without relying on third-party services.

Trustless Execution

Submarine swaps are cryptographically trustless because the HTLC construction prevents either party from stealing funds. The swap service could still refuse to complete swaps, known as griefing, or go offline mid-swap. In those cases, the timelock returns funds to the original owner.

Timing Considerations

On-chain confirmation times create timing risks. If a Loop Out takes hours to confirm on-chain in a high-fee environment, the Lightning HTLC may approach timeout. Services manage this risk by adjusting fees and timeouts based on mempool conditions.

Fee Economics

Submarine swaps involve on-chain fees paid by one party, Lightning routing fees, and service fees. Total costs depend on on-chain congestion, swap size, and service pricing. High-fee periods make small swaps uneconomical.

Privacy Considerations

Centralised swap services see your on-chain addresses and Lightning invoices. They could correlate these for chain analysis. Privacy-focused users prefer services like Boltz that require no accounts and support Tor.

0

← All 1876 glossary terms