Lendasat LogoLendasat Docs
Handle Refunds & Failures

Refund VHTLC

Refund funds locked in a Virtual HTLC when a swap fails or times out.

Locktime Required: Refunds are only possible AFTER the VHTLC locktime expires. Attempting to refund early will fail.

When to Refund

Refunds are typically needed when:

  • The swap status becomes Expired (service never created HTLC)
  • The service is unresponsive
  • Network issues prevented swap completion
  • You changed your mind (after locktime expires)

Refund VHTLC

const result = await client.refundSwap(swapId, {
  destinationAddress: "ark1q...", // Your Arkade address
});

if (result.success) {
  console.log("Refunded:", result.txId);
  console.log("Amount:", result.refundAmount, "sats");
} else {
  console.error(result.message);
}

Complete Refund Flow

Full example with status checking:

const swap = await client.getSwap(swapId);
console.log("Status:", swap.status);

if (swap.status === "clientfundedserverrefunded" || swap.status === "expired") {
  const result = await client.refundSwap(swapId, {
    destinationAddress: "ark1q...",
  });
  console.log("Refund:", result.success ? "Success" : result.message);
}

Important Notes

Patience Required: VHTLC refunds are only available after the locktime expires. This is a security feature of the atomic swap protocol.

  1. Wait for locktime - Refunds are blocked until the timelock expires
  2. Check status first - Only refund swaps in appropriate states
  3. One-time refund - Once refunded, the VHTLC is empty
  4. Automatic return - Funds return to your Arkade wallet