{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/hashlock-markets/json-schema/hashlock-markets-swap-schema.json",
  "title": "Swap",
  "description": "leg a = what the maker gives, leg b = what the maker wants",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/hashlock-markets-openapi.json#/components/schemas/Swap",
  "type": "object",
  "required": [
    "id",
    "threadId",
    "status",
    "makerId",
    "takerId",
    "initiatorUserId",
    "hashlock",
    "aAssetId",
    "aChain",
    "aAmount",
    "aTimelock",
    "bAssetId",
    "bChain",
    "bAmount",
    "bTimelock"
  ],
  "properties": {
    "id": {
      "type": "string"
    },
    "rfqId": {
      "type": [
        "string",
        "null"
      ]
    },
    "threadId": {
      "type": "string"
    },
    "status": {
      "type": "string"
    },
    "makerId": {
      "type": "string"
    },
    "takerId": {
      "type": "string"
    },
    "initiatorUserId": {
      "type": "string",
      "description": "funds the long leg first and holds the secret"
    },
    "hashlock": {
      "type": "string",
      "description": "sha256(secret), hex"
    },
    "secretCiphertext": {
      "type": [
        "string",
        "null"
      ],
      "description": "the secret once revealed on chain; null before"
    },
    "meta": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": true,
      "description": "server bookkeeping; `meta.fundIntent[leg].at` is a funding in flight (see fund-intent)"
    },
    "feeBps": {
      "type": "integer"
    },
    "feeAmount": {
      "type": "string",
      "description": "base units of feeAssetId, paid by the taker"
    },
    "feeAssetId": {
      "type": [
        "string",
        "null"
      ]
    },
    "aAssetId": {
      "type": "string"
    },
    "aChain": {
      "type": "string"
    },
    "aAmount": {
      "type": "string",
      "description": "base units"
    },
    "aTimelock": {
      "type": "string",
      "format": "date-time"
    },
    "aPayoutAddress": {
      "type": [
        "string",
        "null"
      ]
    },
    "aClaimTo": {
      "type": [
        "string",
        "null"
      ],
      "description": "Bitcoin: where this leg's claim pays (its receiver's wallet unless they named another address)"
    },
    "aRefundAddress": {
      "type": [
        "string",
        "null"
      ]
    },
    "aHtlcAddress": {
      "type": [
        "string",
        "null"
      ]
    },
    "aFundTx": {
      "type": [
        "string",
        "null"
      ]
    },
    "aFundOutpoints": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "$ref": "#/$defs/FundOutpoint"
      },
      "description": "Bitcoin: the funding outputs a claim or refund spends"
    },
    "aClaimTx": {
      "type": [
        "string",
        "null"
      ]
    },
    "aRefundTx": {
      "type": [
        "string",
        "null"
      ]
    },
    "bAssetId": {
      "type": "string"
    },
    "bChain": {
      "type": "string"
    },
    "bAmount": {
      "type": "string",
      "description": "base units"
    },
    "bTimelock": {
      "type": "string",
      "format": "date-time"
    },
    "bPayoutAddress": {
      "type": [
        "string",
        "null"
      ]
    },
    "bClaimTo": {
      "type": [
        "string",
        "null"
      ],
      "description": "Bitcoin: where this leg's claim pays (its receiver's wallet unless they named another address)"
    },
    "bRefundAddress": {
      "type": [
        "string",
        "null"
      ]
    },
    "bHtlcAddress": {
      "type": [
        "string",
        "null"
      ]
    },
    "bFundTx": {
      "type": [
        "string",
        "null"
      ]
    },
    "bFundOutpoints": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "$ref": "#/$defs/FundOutpoint"
      },
      "description": "Bitcoin: the funding outputs a claim or refund spends"
    },
    "bClaimTx": {
      "type": [
        "string",
        "null"
      ]
    },
    "bRefundTx": {
      "type": [
        "string",
        "null"
      ]
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    }
  },
  "$defs": {
    "FundOutpoint": {
      "type": "object",
      "properties": {
        "txid": {
          "type": "string"
        },
        "vout": {
          "type": "integer"
        },
        "value": {
          "type": "integer",
          "description": "sats"
        }
      }
    }
  }
}