Monzero DEX · atomic swap

How a BTC / XMZ swap works

Two strangers trade Bitcoin for Monzero without an exchange, an escrow agent or trusting each other. The two blockchains enforce every step: either both sides get paid, or both get their coins back.

Test networks only. These swaps run on Bitcoin signet and the Monzero test network. Mainnet trading is switched off in the code.

The two traders

Bob · buying XMZ

Pays with Bitcoin

Uses the Bitcoin light wallet built into the Monzero app, so he doesn't need to run a Bitcoin node.

Alice · selling XMZ

Gets paid in Bitcoin

Uses her Monzero wallet. For now her app also needs a Bitcoin node to check the chain; a light-wallet option for sellers is being designed.

Step by step

Amounts are from the signet test swap on 25 October: 0.002 BTC for 1 XMZ, with a 36-block safety timelock.

STEP 1 · AGREE

Both apps sign the deal before any money moves

Bob accepts Alice's signed quote. The apps exchange identities, keys and proofs, then each saves pre-signed cancel and refund transactions. From here, either side can always get their coins back.

STEP 2 · BOB LOCKS BTC

0.002 BTC goes into a shared contract

Bob approves the payment in his app. The coins sit in a 2-of-2 contract: spending them needs both traders' keys, or the timelock to pass.

→Bitcoinlock confirms
Monzero←10 confirmations
STEP 3 · ALICE LOCKS XMZ

1 XMZ goes to a shared address

Alice's app checks Bob's lock first. Then she sends 1 XMZ plus a small fee reserve to an address that can only be spent with both traders' key shares.

STEP 4 · BOB HANDS OVER A LOCKED SIGNATURE

A signature with a catch

Bob checks the XMZ lock, then gives Alice an adaptor signature for claiming the BTC. To use it, Alice has to reveal her XMZ key share.

→sent app to app
Bitcoin←redeem published
STEP 5 · ALICE CLAIMS THE BTC

0.0019 BTC to Alice

While the timelock is still safely far away, Alice completes the signature and broadcasts it. 0.0001 BTC goes on the network fee. Publishing it puts her XMZ key share on the Bitcoin chain.

STEP 6 · BOB CLAIMS THE XMZ

Exactly 1 XMZ to Bob

Bob's app reads Alice's redeem from the Bitcoin chain, recovers her key share and sweeps the 1 XMZ to his wallet. The unused fee reserve goes back to Alice.

←swap done

Why neither side can cheat

Alice can only take the Bitcoin by publishing the very thing Bob needs to take the XMZ. If she never claims, the timelock runs out and Bob gets his Bitcoin back.

What if an app crashes mid-trade?

Everything is saved before it is sent

Each signed transaction is written to disk before broadcast. A reopened app sends the same bytes again: no double payment, and nothing is signed twice.

Tested with the power pulled

On 25 October the buyer's machine was switched off mid-swap without shutting down. After reboot its wallet and trade files were intact and the swap finished with exact amounts.

Approvals don't carry over

After a restart, any approval that hadn't been used is cleared. You review and approve again with fresh chain data.

Each app checks the chain itself

Neither app takes the other trader's word for a payment. Bob's light wallet verifies Bitcoin block headers and proofs; Alice's app checks with her own node.

Test runs so far

RunNetworkResultTime
Complete swapBitcoin signet1 XMZ to buyer, 0.0019 BTC to seller≈ 1 h 45 m
Refund after timelockBitcoin signet0.0018 BTC back to buyer, XMZ back to seller≈ 4 h 24 m
Refund after restartBitcoin testnet4Reopened app cancelled and refunded≈ 2 days*
Two separate machinesBitcoin signetSwap completed, exact amounts≈ 2 h 01 m
Buyer app stopped after signingBitcoin signetReopened, resent same lock, completed≈ 1 h 12 m
Buyer machine powered offBitcoin signetRebooted, files intact, completed≈ 1 h 39 m

* Testnet4 mined only empty blocks for about two days, so the cancel waited in the mempool.

Still to come before mainnet: a light-wallet option for sellers, independent review, and release validation.

Follow progress on the Monzero roadmap.