Capital allocation dashboard open on a desk in a DeFi protocol operations setting.
Protocols

Atomic Swap Failures Between Runes and Other Bitcoin Assets

Technical analysis of atomic swap failures between Runes and other Bitcoin-native assets like inscriptions, where flaws in HTLC or PSBT construction allowed one party to claim both sides of the trade or permanently lock the assets.
introduction
ATOMIC SWAP FAILURE ANALYSIS

Introduction

A technical breakdown of how flawed HTLC and PSBT constructions in Runes atomic swaps lead to bilateral loss or unilateral claim scenarios.

Atomic swaps between Runes and other Bitcoin-native assets, such as inscriptions, rely on Hash Time-Locked Contracts (HTLCs) and Partially Signed Bitcoin Transactions (PSBTs) to achieve trustless exchange. However, the interaction between Runes' UTXO-based state model and Bitcoin's scripting system introduces failure modes not present in standard Bitcoin atomic swaps. A flaw in the construction of the swap—specifically in how the Runes protocol transfers tokens within an HTLC execution branch—can allow one party to claim both the Runes and the counterparty asset, or permanently lock both assets in an unrecoverable state.

The core risk lies in the mismatch between the atomicity expected by the swap contract and the actual atomicity provided by the Runes protocol's transfer semantics. A Runes transfer is executed by consuming a UTXO holding a specific Runes balance and creating new UTXOs with the appropriate distribution. If the HTLC script does not strictly bind the Runes distribution to the same spending conditions as the Bitcoin output, a party can satisfy the hashlock or timelock to claim the Bitcoin while structuring the transaction to redirect the Runes to an address they control, violating the swap's intent. Alternatively, an incorrectly constructed fallback path can lead to a deadlock where neither party can finalize the trade without the other's cooperation.

Teams building decentralized trading infrastructure for Runes should treat these swaps as a novel security domain, not a simple extension of existing Bitcoin HTLC patterns. A security review must verify that the PSBT construction enforces simultaneous asset transfer, that the Runes distribution is cryptographically bound to the same witness that satisfies the HTLC, and that all timeout and refund paths correctly handle the Runes-bearing UTXOs without allowing partial claim or permanent lockup. Chainscore Labs can conduct a targeted review of your atomic swap contract logic and PSBT construction to identify these failure modes before they result in asset loss.

ATOMIC SWAP FAILURE MODES

Quick Facts

Operational facts and failure modes for atomic swaps between Runes and other Bitcoin-native assets that teams must validate to prevent bilateral loss or theft.

FieldValueWhy it matters

Primary failure mode

Flawed HTLC or PSBT construction allowing one party to claim both sides of the trade

A single logic error in the script or transaction construction can result in total loss for one counterparty, not just a failed trade

Affected asset pairs

Runes-for-inscriptions, Runes-for-BTC, Runes-for-Runes across different UTXOs

Each asset type has different witness encoding and indexer tracking behavior, creating edge cases in the swap contract that must be handled separately

Key technical dependency

Correct construction and verification of Partially Signed Bitcoin Transactions (PSBTs)

PSBTs are the standard for multi-party transaction construction on Bitcoin; incorrect handling of input types, sighash flags, or witness data leads to swap failure

Time-lock risk

Improper relative or absolute timelock configuration can permanently lock assets

If the refund path is not correctly timelocked or is blocked by a competing spending condition, assets become unspendable by either party

Indexer dependency

Swap logic often relies on off-chain indexers to verify asset ownership and state

Indexer lag, state divergence, or reorgs can cause the swap contract to operate on stale data, leading to incorrect claim or refund execution

Who is affected

Decentralized trading infrastructure, OTC desks, cross-asset marketplaces, and any protocol building trustless Runes exchange

Any team facilitating non-custodial swaps between Runes and other Bitcoin assets is exposed to this class of failure

Remediation urgency

Teams should conduct a security review of their atomic swap contract logic and PSBT construction before deploying to mainnet

The irreversible nature of Bitcoin transactions means post-deployment bugs cannot be patched; assets lost to flawed swap logic are permanently unrecoverable

Chainscore service angle

Atomic swap contract review, PSBT construction audit, and indexer dependency analysis

Chainscore Labs can review your swap protocol's script logic, transaction construction, and off-chain dependencies to identify failure modes before they result in asset loss

technical-context
HTLC AND PSBT CONSTRUCTION FLAWS

Root Cause Pattern

Atomic swap failures between Runes and other Bitcoin-native assets stem from mismatches between the trustless swap contract logic and the UTXO-based asset model.

Atomic swaps between Runes and other Bitcoin-native assets like inscriptions rely on Hash Time-Locked Contracts (HTLCs) and Partially Signed Bitcoin Transactions (PSBTs) to ensure that either both sides of the trade complete or neither does. The root cause of most failures is a fundamental impedance mismatch: standard HTLC patterns designed for homogeneous Bitcoin outputs do not account for the heterogeneous nature of UTXOs carrying Runes or inscriptions. A swap contract that correctly locks the bitcoin value of a UTXO may fail to constrain the transfer of the Runes or Ordinal data payload attached to it, allowing a counterparty to claim the bitcoin while the meta-protocol asset is routed to an unintended output or burned as fees.

The most common failure pattern occurs in the PSBT construction phase. When a swap is partially signed, the transaction's output structure must precisely map the intended asset transfer. A flaw in the PSBT's output ordering, an incorrect change address, or a missing OP_RETURN commitment for the Runes protocol can create a transaction that is valid at the Bitcoin consensus layer but semantically invalid for the Runes or Ordinals indexer. An attacker who recognizes this gap can sign and broadcast the transaction, claiming their counterparty's asset while the victim's indexer-dependent wallet sees the swap as incomplete or failed. In more severe cases, a poorly constructed timelock branch allows one party to claim both sides of the trade after the timeout expires, exploiting the fact that the refund transaction does not properly invalidate the asset transfer path.

A secondary pattern involves indexer state divergence during the swap's critical path. If the two parties rely on different indexer implementations that disagree on the location or validity of the Runes or inscription involved, one party may believe the swap has failed and broadcast a refund transaction that the other party's indexer interprets as a valid asset transfer. This creates a double-spend scenario at the meta-protocol layer even though the Bitcoin consensus layer sees no conflict. Teams building decentralized trading infrastructure for Runes and Ordinals should conduct a security review of their HTLC contract logic and PSBT construction against these specific failure modes, ensuring that asset transfer constraints are enforced at the meta-protocol level and not solely at the Bitcoin script level.

IMPACT ANALYSIS

Affected Systems and Actors

Protocol Implementers

Teams building decentralized trading infrastructure for Runes and other Bitcoin-native assets are directly affected. The core risk is in the HTLC or PSBT construction logic, where a flaw can allow one party to claim both sides of the trade or permanently lock assets.

Action Items:

  • Conduct a security review of your atomic swap contract logic, focusing on timelock asymmetry and script-path validation.
  • Verify that your PSBT construction correctly handles the non-finalized state of Runes transfers alongside other asset types.
  • Test failure modes where one party aborts after the counterparty has committed, ensuring assets are recoverable.

Chainscore Labs can perform a targeted review of your swap protocol design and PSBT construction to identify these failure modes before deployment.

implementation-impact
ATOMIC SWAP FAILURE MODES

Operational Impact and Detection

Operational impact areas and detection strategies for teams building or integrating decentralized trading infrastructure that handles Runes and other Bitcoin-native assets via atomic swaps.

01

HTLC and PSBT Construction Review

The core failure mode in Runes atomic swaps is a flaw in the Hash Time-Locked Contract (HTLC) or Partially Signed Bitcoin Transaction (PSBT) construction that allows one party to claim both sides of the trade or permanently lock assets. Teams must verify that their PSBT logic correctly handles the Runes UTXO selection, prevents transaction malleability, and enforces the atomicity condition. A single off-by-one error in a timelock or an incorrectly set sequence number can break the swap's security model. Chainscore Labs can conduct a targeted review of your swap contract logic and PSBT construction against known Runes-specific edge cases.

02

Mempool Monitoring and Fee Sniping Detection

Pending atomic swap transactions are vulnerable to replacement cycling and fee sniping attacks where an attacker outbids the original fee to delay or steal the swap. Operators must implement mempool monitoring that detects unexpected RBF bumps, conflicting transactions spending the same Runes UTXO, or abnormal fee pressure on in-flight swaps. Detection rules should flag any transaction that attempts to spend a UTXO currently locked in a pending HTLC. Without real-time mempool visibility, a swap can be broken before it confirms.

03

Timelock Expiry and Asset Recovery Procedures

When an atomic swap fails—whether due to counterparty abandonment, network congestion, or a bug—the timelock expiry becomes the critical recovery path. Teams must have operational playbooks for monitoring timelock expiration, broadcasting recovery transactions, and handling edge cases where the counterparty attempts a late claim. Runes tokens add complexity because the recovery transaction must correctly select the locked UTXO without accidentally spending other Runes-bearing outputs. Custody providers and exchanges should rehearse these recovery procedures before deploying swap infrastructure.

04

Indexer State Consistency During Swaps

Atomic swaps between Runes and inscriptions depend on both parties agreeing on the current state of the assets. If the two parties rely on different indexers that have diverged—due to reorg handling, cursed inscription recognition, or Runes balance interpretation—one side may believe they are receiving an asset that the other indexer does not recognize. Swap infrastructure must verify indexer consensus before locking assets and should incorporate a state consistency check into the pre-swap negotiation phase. Teams running custom indexers need a divergence detection system.

05

Multi-Asset UTXO Contamination Risk

A Runes-bearing UTXO may also contain an inscription or be marked as a satoshi of numismatic value. An atomic swap designed only for Runes may inadvertently transfer or destroy these co-located assets. Swap contracts must include explicit checks for additional asset envelopes on the UTXO being traded and either reject contaminated UTXOs or ensure the swap terms account for all assets present. Wallet and marketplace integrations should surface co-located asset warnings to users before they commit to a swap.

06

Cross-Protocol Swap Failure Audit

Teams that have already deployed atomic swap infrastructure for Runes should conduct a retrospective audit of failed or disputed swaps to identify whether the root cause was a protocol-level flaw, an indexer inconsistency, or a mempool attack. This audit should examine on-chain data for any swap where the HTLC was claimed by the wrong party, where assets remain locked beyond the timelock, or where the final settlement did not match the agreed terms. Chainscore Labs can assist with forensic analysis of failed swaps and recommend architectural changes to prevent recurrence.

ATOMIC SWAP FAILURE MODES

Risk Matrix

Operational and technical risks arising from flawed HTLC or PSBT construction in atomic swaps between Runes and other Bitcoin-native assets, and the affected parties who must act.

RiskFailure modeSeverityAffected actorsMitigation

Unilateral claim

A flaw in the HTLC script or timelock logic allows one party to claim both the Runes and the counterparty asset without fulfilling their side of the trade.

Critical

DEX builders, liquidity providers, end users

Conduct a formal verification and security review of all custom HTLC and PSBT construction logic.

Permanent asset lock

A logic error in the refund path or a mismatch in timeout values causes the assets to become unspendable by either party after the swap expires.

Critical

DEX builders, end users, custody providers

Audit timelock symmetry and ensure both parties have a valid, tested refund transaction path before swap initiation.

Indexer state divergence

The swap relies on an off-chain indexer to verify Runes balances or inscription ownership. Indexer lag or a chain reorganization causes the swap contract to see an incorrect state, allowing a fraudulent fill.

High

DEX builders, indexer operators, relayers

Do not rely solely on a single indexer for swap-critical state. Use multiple indexers or wait for sufficient block confirmations before finalizing the swap.

Mempool-based front-running

An attacker monitors the mempool for a broadcast PSBT and uses Replace-By-Fee (RBF) to alter the transaction, redirecting the Runes output before the swap can complete.

High

DEX builders, traders, wallet developers

Implement anti-exfiltration PSBT signing and avoid broadcasting partially signed transactions that are vulnerable to modification.

Fee mismanagement

The swap transaction's fee rate is insufficient for timely confirmation, causing the timelock to expire and triggering a refund while the counterparty's transaction is still pending, leading to a race condition.

Medium

DEX builders, wallet developers, end users

Use Child-Pays-For-Parent (CPFP) aware fee strategies and ensure wallets can bump fees on pending swap transactions without breaking the contract logic.

Multi-envelope confusion

A single UTXO contains both a Runes token and another asset (e.g., an inscription). The swap logic correctly handles one but burns or misinterprets the other, leading to partial asset loss.

Medium

DEX builders, wallet developers, indexer operators

Review parsing logic to ensure all meta-protocol envelopes on a UTXO are accounted for and explicitly handled in the swap contract.

Wallet incompatibility

A user's wallet does not recognize the custom PSBT or script type used in the atomic swap, preventing them from signing or broadcasting the transaction correctly.

Low

Wallet developers, end users

Wallet teams should test compatibility with common atomic swap PSBT formats and provide clear user guidance on supported transaction types.

ATOMIC SWAP FAILURE RESPONSE

Remediation and Prevention Checklist

A structured checklist for engineering and security teams to investigate, contain, and remediate an atomic swap failure between Runes and other Bitcoin-native assets. This guide focuses on verifying the integrity of the HTLC/PSBT logic, securing remaining funds, and implementing long-term preventative measures.

What to check: Identify and halt all active or pending atomic swap contracts that use the vulnerable PSBT or HTLC construction. Why it matters: A flaw in the swap logic can allow a counterparty to claim both sides of the trade or permanently lock assets. Stopping new swaps prevents further financial loss while the root cause is investigated. Readiness signal: All swap-initiating API endpoints are disabled, and a circuit breaker has been activated. A transaction monitoring alert is configured to flag any on-chain interaction with the vulnerable contract pattern.

Chains We Build On

Looking to build on a specific blockchain?

We build smart contracts, DeFi applications, wallets, tokenization platforms, and blockchain infrastructure across the major ecosystems teams choose today. That includes Ethereum, Arbitrum, Optimism, Polygon, Avalanche, Solana, Sui, Aptos, Hedera, Stellar, and NEAR, with support for additional EVM and non-EVM networks based on your product requirements.

EVM ecosystems

  • Ethereum logo
    Ethereum
  • Arbitrum logo
    Arbitrum
  • Optimism logo
    Optimism
  • Polygon logo
    Polygon
  • Avalanche logo
    Avalanche
  • Cronos logo
    Cronos

Non-EVM ecosystems

  • Solana logo
    Solana
  • Sui logo
    Sui
  • Aptos logo
    Aptos
  • Hedera logo
    Hedera
  • Stellar logo
    Stellar
  • NEAR logo
    NEAR

Additional ecosystems

  • Polkadot logo
    Polkadot
  • Cosmos logo
    Cosmos
  • TON logo
    TON
  • Cardano logo
    Cardano
  • Algorand logo
    Algorand
  • Tempo logo
    Tempo

Also available for Base, appchains, custom EVM networks, and cross-chain product architecture.

ATOMIC SWAP FAILURE ANALYSIS

Frequently Asked Questions

Operational and technical questions for teams diagnosing or preventing atomic swap failures between Runes and other Bitcoin-native assets.

The primary failure mode is a mismatch between the off-chain indexer state and the on-chain UTXO set. An atomic swap contract (HTLC or PSBT-based) correctly enforces the Bitcoin script conditions, but one side of the trade delivers a UTXO that the Runes or Ordinals indexer interprets differently than the counterparty expects. This can result in a scenario where the swap completes on-chain, but one party receives an asset that is unrecognized, cursed, or valued at zero by the dominant indexer. The root cause is not a Bitcoin consensus failure, but a failure to synchronize the meta-protocol state with the swap contract's execution conditions.

Trusted by Industry Leaders

Delivering blockchain solutions for 5+ years.

We have partnered with 50+ leading DeFi protocols, NFT ecosystems, and fintech innovators to build secure, scalable, and capital-efficient blockchain products.

Selected Partners & Clients

ChainVote logo
Reax logo
Sokail logo
Swapsicle logo
SyntheX logo
Tekika logo
Telos logo
Zexe logo
ChainVote logo
Reax logo
Sokail logo
Swapsicle logo
SyntheX logo
Tekika logo
Telos logo
Zexe logo
ChainVote logo
Reax logo
Sokail logo
Swapsicle logo
SyntheX logo
Tekika logo
Telos logo
Zexe logo
ChainVote logo
Reax logo
Sokail logo
Swapsicle logo
SyntheX logo
Tekika logo
Telos logo
Zexe logo
“I've been working with Chainscore Labs for last 3+ years, they've consistently delivered with strong ownership across multiple projects. The team is reliable and detail-oriented.”
L
Lee Erswell
CEO, Telos Foundation
how to get started

How to get started?

If you're looking for blockchain integration, ChainScore Labs has 5+ years of experience helping teams build and integrate exchanges, wallets, smart contracts, tokenization solutions, and protocol-connected products, we can help you choose the right path, integrate securely, and get to production faster. Our team consists of experienced blockchain developers and architects who can help you with your blockchain integration needs.

01

Exploration & Strategy

Define your product goals and choose the right blockchain architecture for your use case.

02

Architecture & Design

Design the smart contracts, tokenomics, and security parameters of your system.

03

Development & Integration

Build and integrate with wallets, oracles, and front-end dApps for a seamless experience.

04

Security & Launch

Comprehensive audits followed by a risk-managed mainnet deployment to protect your users.

Start a build

Need a blockchain engineering team?

Send the project context and we will respond with next steps, scope questions, and a practical path to delivery.