Skip to main content
New to these terms? The swap terms glossary defines each one in a line.

One secret, two locks

Every swap except pay-through and atomic RGB swaps works the same way. One side generates a random secret, the preimage, and shares only its hash. Both legs of the swap are locked to that hash:
  • the Lightning payment, as a hold invoice that settles only when someone reveals the preimage, and
  • the on-chain funds, in a lockup output that can be spent in two ways: with the preimage (the claim), or by the original sender after a deadline (the refund).
Claiming the on-chain funds reveals the preimage on chain, and that is exactly what the other side needs to settle the Lightning payment. So either both legs settle, or neither does and the money goes back.

Who does what on each route

The technical names in parentheses (submarine, reverse, chain) come from the Boltz protocol the SDK speaks. The SDK methods use them: createSubmarineSwap, createReverseSwap, createChainSwap.

Cheap path and safe path

A lockup can be spent cooperatively (you and the maker sign together: cheaper, and a refund needs no deadline) or alone through the script (with the secret, or after the deadline). The SDK tries the first and falls back to the second, so a swap never depends on the maker. See Claims and refunds. Atomic RGB swaps and pay-through work differently: see Swap BTC and USDT on RGB and Pay an address from Lightning. Next: Swap states follows each route step by step.