Skip to main content

Compared with Boltz

The nearest neighbours are the Rust clients of the Boltz exchange: boltz-client (boltz-rust, by Bull Bitcoin) and lwk_boltz, part of Blockstream's Liquid Wallet Kit and built on boltz-client. The protocols are close: funds lock in a taproot script spendable by preimage, by a cooperative keypath, or by the funder after a timeout. A submarine swap is a SwapIn, and a reverse swap a SwapOut. This page is as of boltz-client 0.4.1 and LWK 0.19.

AnySwap SDKboltz-clientlwk_boltz
LanguagesRust, TypeScriptRustRust, and JavaScript through LWK's wasm bindings
In a browserthe TypeScript SDK, or Rust on wasm32builds for wasm32through LWK's wasm bindings
Swap typesSwapIn, SwapOutsubmarine, reverse, chainsubmarine, reverse, chain
Runs a swapone driver for every stored swapyour code, step by stepa state machine per swap, advanced by your code
Moves a swap forwardthe chain, read on every passyour codethe server's WebSocket events
Keysderived from the mnemonic and the swap_ida keypair and preimage you createderived from the session mnemonic and a key index you persist
Recovery without the storethe server returns your own signed request, verified locallynonethe server returns the swaps of your session

All three check the counterparty's script before funds move. After that, an AnySwap status comes from the chain, so a missed or false server event cannot put a swap in a wrong state, and a client that was offline finds where it stands from the chain alone. A restored AnySwap swap is the request you signed, so a server can hide a swap but not alter one.

boltz-client expects one output of exactly the swap amount at the swap address. The AnySwap driver refunds everything there worth its refund: a wrong amount, a second deposit, a late one.

The map​

With BoltzWith AnySwap
BoltzApiClientV2, BoltzSessionHttpClient and Driver
Pair info and limitsdriver.quote
A keypair and preimage per swapderived by the driver
next_index_to_use, the key counter you persistnothing
WebSocket status eventsthe driver's status; the server's label is server_status, for display
advance loops per swap (lwk_boltz)one run for every stored swap
BtcSwapTx, LBtcSwapTx claims and refundsthe driver claims and refunds
DynStore, an encrypted key-value storea store of three methods over JSON records
swap_restore, the rescue filerestore_all

Migrating​

Coming from Boltz
Goes awaygenerating keys and preimages, checking scripts, watching addresses, building claims and refunds, event handlers, the loop per swap and the restore wiring
You writethe setup, a store over your database, and a chain client if your chain data comes from Electrum
Stays yoursthe Lightning node and the addresses: mint the SwapIn invoice, pay the SwapOut hold invoice, give claim and refund addresses

Map your UI to the statuses, not to Boltz events. Like the Boltz clients, the SDK holds no funds: any wallet provides the addresses.