Skip to main content
This guide walks through an atomic swap (direct node-to-node) end to end with the KaleidoSDK, in both TypeScript and Python. Atomic swaps are trustless: the maker never takes custody, because your own RGB Lightning Node holds the keys and has to whitelist the swap before it can settle. That also means you need an RLN node running alongside the client — see Node Hosting for the options.

Setup

Both a baseUrl and a nodeUrl are required: the first reaches the maker, the second reaches your node.

Step 1: Get a Quote

Request a quote for the pair you want to swap. Amounts are always raw integer units — see Utilities for conversion helpers.
The rfq_id on the response is what ties the next step to this price. Quotes expire — do not hold an rfq_id across user think-time, or initSwap will raise QuoteExpiredError.

Step 2: Initialize the Swap

Lock the swap with the maker against that quote. This returns the swapstring and the payment_hash you need for every remaining step, plus the access_token that authorizes status polling — it is only returned here, so store it alongside the payment hash.

Step 3: Whitelist on Your Taker Node

Your node has to authorize the swapstring before it will honour the incoming HTLC. This is the only step that runs against client.rln.
Skipping this step is the most common cause of a SwapError on execute: init succeeds, then execution fails because the taker side never agreed to the swap.

Step 4: Execute the Swap

Hand the maker your node’s details so it can settle.

Step 5: Track Settlement

executeSwap returning is not the same as the swap having settled. Poll the status by payment_hash, passing the access_token from initSwap, until it reaches a terminal state.
If a transfer sits pending longer than expected, client.rln.refreshTransfers() / refresh_transfers() advances pending RGB transfers, and client.rln.listSwaps() gives you the node’s own view. See Troubleshooting for the failure modes.

Next Steps

Error Handling

The exception hierarchy and retry patterns around each step.

Swap Protocol

The HTLC flow underneath, endpoint by endpoint, with the sequence diagram.

WebSocket

Stream live quotes instead of requesting them one at a time.

Client Reference

Every method on client.maker and client.rln.