Lendasat LogoLendasat Docs
Handle Refunds & Failures

Refund Locktime & Conditions

Understanding when and how refunds become available based on locktime expiration.

Security by Design: Timelocks are essential for atomic swap security. They ensure that either both parties complete the swap, or both can recover their funds.

Timeout Summary

TypeDurationPurpose
Swap Request30 minTime to make initial payment
Lightning Invoice10 minLightning payment window
EVM HTLC10-30 minTime for user to claim EVM funds
Arkade VHTLC2 hoursTime for service to claim
Onchain HTLC24-48 hoursTime for onchain refund

Locktime Hierarchy

In an atomic swap, timelocks are staggered to ensure safe completion:

┌─────────────────────────────────────────────────────────────────┐
│                      LOCKTIME HIERARCHY                         │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  User's HTLC (BTC side)      Service's HTLC (EVM side)         │
│  ─────────────────────       ───────────────────────           │
│                                                                 │
│  Locktime: 24-48 hours       Locktime: 10-30 minutes           │
│         ▲                           ▲                          │
│         │                           │                          │
│         │                           └── Shorter: Service       │
│         │                               claims first or        │
│         │                               user refunds           │
│         │                                                      │
│         └── Longer: User has time                              │
│             to claim or refund                                 │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Locktime Values by Swap Type

Swap TypeYour LocktimeService LocktimeReason
BTC → EVM (Arkade)2 hours30 minutesService claims first
BTC → EVM (Onchain)24-48 hours2 hoursOnchain needs more time
EVM → BTC30 minutes10 minutesFast EVM settlement
Lightning10 min invoiceN/ALightning is instant

Check Refundable Amount

Use the SDK to check if a swap has funds available for refund:

// Check swap status and refund availability
const swap = await client.getSwap(swapId);
console.log("Status:", swap.status);

// Attempt refund — the SDK checks locktime automatically
const result = await client.refundSwap(swapId, {
  destinationAddress: "bc1q...", // or "ark1q..." for Arkade swaps
});

if (!result.success) {
  // If locktime hasn't expired, message tells you when it does
  console.log(result.message);
}

Refund Decision Flowchart

                ┌──────────────┐
                │ Check Swap   │
                │   Status     │
                └──────┬───────┘

      ┌────────────────┼────────────────┐
      │                │                │
      ▼                ▼                ▼
┌───────────┐    ┌───────────┐    ┌───────────┐
│  Pending  │    │  Funded   │    │ Terminal  │
│           │    │           │    │           │
└─────┬─────┘    └─────┬─────┘    └─────┬─────┘
      │                │                │
      ▼                ▼                ▼
┌───────────┐    ┌───────────┐    ┌───────────┐
│ No funds  │    │ Check     │    │ Already   │
│ to refund │    │ locktime  │    │ resolved  │
└───────────┘    └─────┬─────┘    └───────────┘

                ┌──────┴──────┐
                │             │
                ▼             ▼
          ┌──────────┐ ┌──────────┐
          │ Expired  │ │ Active   │
          │ → Refund │ │ → Wait   │
          └──────────┘ └──────────┘

Best Practices

Priority: Always try to complete the swap first. Refunds should only be used when completion is impossible.

  1. Claim before refund - If ServerFunded, claim instead of waiting for refund
  2. Don't rush - Wait for locktime to expire naturally
  3. Monitor status - Keep checking until resolved
  4. Have patience - Onchain refunds may take 24-48 hours to become available
  5. Check both HTLCs - Some swaps have funds on both sides

Common Scenarios

ScenarioWhat HappenedAction
Service unresponsiveYou paid, service didn't fundWait for locktime, then refund
Forgot to claimService funded, you didn't claimClaim immediately if still ServerFunded
Network issuesTransaction stuckWait for confirmation or refund
Changed mindWant to cancel swapWait for locktime (cannot cancel early)