XMR to BTC Atomic Swap Tutorial: Trustless Cross-Chain
XMR to BTC Atomic Swap Tutorial: Trustless Cross-Chain
An atomic swap between XMR and BTC is the most private and trustless method available for exchanging Monero for Bitcoin. Unlike centralized swap services or even no-KYC instant-swap platforms — where a third party briefly holds or intermediates your funds — an atomic swap uses pure cryptography to enforce the exchange directly between two parties. If either side fails to complete the trade at any point, both parties automatically receive their funds back. No trust in any service. No custodian. No KYC. No risk of exit-scam or service failure. This comprehensive tutorial walks through the complete process using the best available open-source tooling in 2026.
What Is an Atomic Swap and Why Does It Matter?
An atomic swap is a cryptographic protocol enabling two parties to exchange different cryptocurrencies directly from their own wallets, without ever transferring assets to any third party. The word "atomic" refers to the all-or-nothing property: the swap either completes in full (both parties receive their coins) or fails completely (both parties keep their original assets). There is no intermediate state where one party gains at the other's expense.
This property matters enormously in high-stakes privacy transactions. When you use even a reputable no-KYC instant-swap service, you are trusting that service not to exit with your funds, not to be seized by authorities mid-swap, and not to experience a critical technical failure at the worst moment. Atomic swaps eliminate this trust requirement entirely through mathematics rather than reputation.
The Cryptographic Challenge: Why XMR-BTC Atomic Swaps Are Unique
Standard atomic swaps between Bitcoin and most other blockchains use Hash Time-Locked Contracts (HTLCs) — smart contract scripts that enforce the exchange using a shared secret hash. However, Monero intentionally has no general-purpose smart contract capability, because supporting HTLCs directly would enable on-chain analysis attacks that undermine Monero's privacy guarantees.
The breakthrough that made XMR-BTC atomic swaps possible came from research published by the COMIT team in 2020. Their protocol uses adaptor signatures and a clever cryptographic construction that links an XMR transaction and a BTC transaction using a shared secret, without requiring any script on the Monero side. The XMR transaction looks completely normal on-chain — indistinguishable from any other Monero transfer — preserving all of Monero's privacy properties.
Tools and Prerequisites
The primary open-source implementation for XMR-BTC atomic swaps is the COMIT Network's xmr-btc-swap CLI tool. To run a swap, you will need:
- Operating system: Linux (Ubuntu 20.04+ recommended) or macOS 12+. Windows via WSL2 works but is not officially supported and may require additional configuration.
- Bitcoin infrastructure: A fully synced Bitcoin full node (Bitcoin Core), or access to a trusted Electrum server (Electrum Personal Server or public electrs instance). Bitcoin Core is strongly preferred for privacy.
- Monero infrastructure: A running
moneroddaemon (full node) or a trusted remote node connection. Your own full node is recommended for large swaps. - The swap binary: The latest release of
xmr-btc-swapfrom the COMIT GitHub repository (github.com/comit-network/xmr-btc-swap). Always verify the SHA256 checksum and release signature. - BTC for fees: You need a small BTC balance for on-chain transaction fees (typically 5,000–20,000 satoshis for the locking and claiming transactions).
- Tor: Recommended. The swap tool can route all peer communications through Tor by default, hiding your IP from counterparties and passive observers.
- Disk space: Bitcoin full node requires ~550GB as of 2026. Pruned node mode (~10GB) works for swap purposes but reduces privacy slightly.
Step-by-Step Tutorial: Swapping XMR for BTC
- Download and verify the swap tool. Visit the COMIT GitHub repository and download the latest release binary for your platform. The release page provides SHA256 checksums and a signed manifest. Verify the checksum using
sha256sum xmr-btc-swapbefore running the binary. This step is non-optional — running an unverified binary from any source risks fund loss. - Create the data directory. Run
mkdir -p ~/.swapto create the local data directory where the tool stores its SQLite swap state database and configuration. Back up this directory regularly — losing it mid-swap requires manual recovery assistance. - Configure node connections. Create or edit the tool's configuration file to point to your Bitcoin node RPC endpoint (or Electrum server URL) and your Monero daemon RPC address. Example configuration entries:
bitcoin.rpc_url = "http://127.0.0.1:8332"andmonero.daemon_host = "127.0.0.1:18081". Test both connections before proceeding. - Start the swap daemon. Run
swap --data-dir ~/.swap start --electrum-rpc tcp://127.0.0.1:50001(or the appropriate connection flag for your setup). The daemon initializes the local database, verifies node connectivity, and waits for commands. - Discover available sellers. Run
swap list-sellers --rendezvous-point /dns4/rendezvous.coblox.tech/tcp/8888/p2p/QmXXXXXto query the peer discovery network for active counterparties willing to sell BTC for XMR. The rendezvous point is a P2P discovery server — multiple public rendezvous points are published by the COMIT community. The output lists seller peer IDs, their BTC ask price, available liquidity, and current fee rate. - Request a quote. Run
swap buy-xmr --seller /ip4/X.X.X.X/tcp/9939/p2p/12D3KooWXXX --receive-address YOUR_XMR_ADDRESS --bitcoin-amount 0.005, substituting the seller peer address from step 5, your XMR receive address, and the BTC amount you want. The tool connects to the seller, negotiates the exchange rate, and displays the quoted XMR cost and all applicable fees. - Review and accept the quote. Examine the displayed rate against a reference (CoinGecko mid-market XMR/BTC). If the spread is acceptable, type
yto accept and initiate the swap. If not, try a different seller from the list or wait for better rates. - Fund the BTC lock. The tool will prompt you to fund a BTC timelock address with the swap amount plus fees. It will display the exact BTC address and amount. Send BTC from your wallet (or the tool will draw from an internal wallet if configured). This BTC is now locked in a script that only the seller can claim by revealing the atomic secret.
- Wait for XMR lock confirmation. Once your BTC lock transaction confirms (typically 1 Bitcoin confirmation), the seller locks the corresponding XMR amount in a Monero time-locked address. The swap tool monitors the Monero blockchain for this event automatically. This step typically takes 2–5 Monero blocks (4–10 minutes).
- Automatic secret exchange and claim. Once both locks are confirmed by their respective blockchains, the cryptographic protocol executes automatically. The tool claims your XMR by revealing the atomic secret; the seller simultaneously uses the revealed secret to claim the BTC. Both transactions are broadcast within the same protocol window. The swap tool prints "Swap completed successfully" and logs transaction IDs for both chains.
- Verify your XMR receipt. Check your Monero wallet (scanning from the appropriate restore height if using a view-only wallet). The XMR will appear as an incoming transaction with standard privacy properties — ring signatures, stealth address delivery, RingCT amount hiding.
Understanding the Timelock Safety Mechanism
The atomic swap protocol incorporates multiple timelocks to protect both parties from partial failures. Understanding these timelocks helps you know what to expect if something goes wrong.
Scenario 1: Buyer (You) Goes Offline After BTC Lock
If your BTC lock transaction confirms but you go offline before the XMR lock is detected, the protocol has a buyer-cancel timelock (typically set to 72–96 hours from BTC lock confirmation). After this timelock expires, you can reclaim your BTC by submitting a cancel transaction. The seller's XMR is never touched in this scenario. The swap tool handles this automatically when you restart it — it checks the timelock status and prompts for refund action.
Scenario 2: Seller Goes Offline After XMR Lock
If the seller locks XMR but then disappears before the secret exchange, a seller-punishment timelock (set later than the buyer-cancel timelock) eventually expires. The XMR remains inaccessible during the protocol window, but after both timelocks expire, the seller can reclaim their XMR. Meanwhile, the buyer-cancel timelock also allows you to reclaim your BTC. Both parties recover their original funds. Net result: no one loses money, just time.
Scenario 3: Network Disruption Mid-Swap
The swap daemon persists all state to a local SQLite database after every protocol step. If your internet connection drops, your machine restarts, or the tool crashes, simply restart the swap daemon. It reads the saved state, determines which protocol step it was at, and resumes automatically. Continuous operation is not required — the tool is designed for unreliable network conditions.
Privacy Properties of Atomic Swaps vs. Instant-Swap Services
Atomic swaps provide the strongest privacy properties of any available XMR-to-BTC exchange method, across multiple dimensions:
- No third-party custody — funds never leave cryptographic control during the entire swap. No service has custody of your XMR or BTC at any point, eliminating service-level privacy risks.
- No account or identity linkage — the swap is purely peer-to-peer. No service processes your transaction, no email or IP address is logged by a service operator, and no swap ID links to your identity.
- Monero on-chain privacy fully intact — the XMR side of the swap uses standard Monero transaction primitives. An on-chain observer cannot determine the nature of the transaction, its connection to a BTC swap, the amount transferred (hidden by RingCT), the sender (hidden by ring signatures), or the recipient (hidden by stealth address). This is fundamentally stronger than any instant-swap service, which generates internal records linking XMR deposits to BTC payouts.
- Tor-native routing — the default tool configuration routes all P2P communications through Tor, hiding both parties' IP addresses from each other and from any passive network-level observers.
- Open-source and auditable — the entire protocol implementation is publicly auditable. Unlike closed-source swap services, there is no hidden logic that could leak metadata or deanonymize users.
Fees and Expected Timing
Atomic swaps incur two categories of costs: network fees and seller spread.
Network fees consist of BTC transaction fees for the lock and claim transactions on the Bitcoin side, plus XMR transaction fees on the Monero side (typically built into the seller's rate). BTC fees vary with mempool congestion — budget 5,000–20,000 satoshis per transaction under normal conditions (50,000+ satoshis possible during high-congestion periods). In total, network fees for a complete swap typically run to 15,000–50,000 satoshis ($8–$30 equivalent at 2026 prices) depending on mempool conditions.
Seller spread on the COMIT network is set by individual counterparties. Competition among sellers keeps spreads in the range of 0.5–2% over mid-market in most conditions. During low-seller availability periods, you may encounter higher spreads — it is worthwhile to wait for more sellers to come online rather than accepting an unfavorable rate.
Total swap time depends on BTC block time (approximately 10 minutes average), Monero block time (approximately 2 minutes average), and counterparty responsiveness. Under normal conditions, expect 30–60 minutes from swap initiation to XMR receipt. In worst-case scenarios (slow BTC blocks, slow Monero blocks, counterparty latency), a swap can take up to 90 minutes while remaining fully on track.
For a detailed cost comparison across all XMR-to-BTC methods, see our fees, timing, and limits FAQ.
When Atomic Swaps Make Sense vs. Instant Swaps
Atomic swaps are the right choice when: maximum privacy and zero counterparty risk are required; you are comfortable with a command-line workflow and can invest 30–60 minutes in setup; you are converting significant value where service-level trust risk is unacceptable; or you have strong operational security requirements (running your own full nodes, Tor-only network access).
Instant-swap services like MoneroSwapper are better when: speed is a priority (15–30 minutes vs. 30–90 minutes); you want a simple web interface with no CLI setup; you are converting moderate amounts where service trust risk is acceptable; or you do not want to operate full Bitcoin and Monero nodes. For a full service comparison, see the best no-KYC XMR-to-BTC platforms guide.
Frequently Asked Questions
Do I need to run my own full Bitcoin and Monero nodes?
Running full nodes is the strongest privacy and security option. However, the xmr-btc-swap tool supports connecting to trusted remote Electrum servers and trusted remote Monero nodes. Using a third-party node means that node operator can see your transactions. For casual swaps or testing, public trusted nodes are acceptable. For high-value or sensitive swaps, running your own nodes eliminates this trust assumption entirely.
Is the xmr-btc-swap tool production-ready and safe for real funds?
Yes. The COMIT xmr-btc-swap tool has undergone security audits and has been used for real-value swaps since 2021. The protocol specification is publicly documented and peer-reviewed. That said, all software has residual risk — always start with a small test swap to verify your node configuration and tool setup before executing large amounts. Always use the latest release, as security patches are backported from ongoing protocol research.
Can I use this tool to go BTC to XMR instead of XMR to BTC?
The default buyer role in xmr-btc-swap provides BTC and receives XMR. For the reverse direction (provide XMR, receive BTC), you take on the seller role in the protocol. Seller-role operation requires different configuration and is generally more complex than the buyer flow described in this tutorial. Some community-built GUI frontends are experimenting with seller flows, but as of 2026, the buyer path (BTC-to-XMR) has the most polished tooling and the largest seller counterparty pool.
How do I find active counterparties for a swap?
The COMIT tool uses rendezvous point servers for P2P peer discovery. Multiple public rendezvous points are maintained by the COMIT community and listed in the project documentation. Typically 5–20 active sellers are online at any time on the main rendezvous point. Peak availability correlates with UTC business hours and community activity periods. The Monero community forums regularly post information about active sellers with verified track records.
What happens if the swap takes longer than 90 minutes?
Timelocks are set conservatively to accommodate Bitcoin block time variability (blocks can be 30–60 minutes apart during slow periods). If BTC blocks are slow, the swap may take longer than 90 minutes but will still complete as long as both parties remain online. The swap daemon handles all timelock monitoring automatically — you do not need to manually intervene unless you want to initiate a cancel. Restart the daemon if it crashes; it resumes from the last saved state immediately.
Can the swap be used to convert BTC to XMR for privacy purposes?
Yes, this is one of the most compelling use cases. Converting transparent BTC to privacy-preserving XMR via atomic swap provides a strong privacy upgrade: the BTC side is visible on-chain (as a normal Bitcoin transaction to a timelock script), but the XMR side is completely private. The link between your BTC origin and your XMR destination exists only in the cryptographic secret, which is never published in a form that links the two chains to an observer without access to your private keys.
🌍 Read in