{
 "openapi": "3.0.3",
 "info": {
  "title": "POLLA public API",
  "version": "1.0.0",
  "description": "Public API of POLLA, a verifiable Lightning lottery. Only public routes: no admin panel, no test-mode routes, nothing of NWC. Production is Bitcoin mainnet when `testMode` is false in `/api/health`. The lottery key (the auditor) signs sales, commitments, anchors and results; that is part of the design. Prize payouts are manual (`payouts: false`): a claim never triggers a payment by itself. Never send, log or paste an nsec, an NWC connection string or a claim code (`POLLA-…` / `LOTTO-…`); only their hashes go anywhere. Purchase guide: https://polla21.org/docs/AGENT-BUY.md · Verification: https://polla21.org/docs/VERIFY-DRAW.md",
  "license": {
   "name": "MIT"
  }
 },
 "servers": [
  {
   "url": "https://polla21.org/api",
   "description": "Production (mainnet)"
  }
 ],
 "tags": [
  {
   "name": "read"
  },
  {
   "name": "verify"
  },
  {
   "name": "buy"
  },
  {
   "name": "claim"
  }
 ],
 "paths": {
  "/health": {
   "get": {
    "tags": [
     "read"
    ],
    "summary": "Server state",
    "description": "Fields useful to a buyer or verifier. Other fields the server may add (panel settings, wallet methods) are not part of this contract.",
    "operationId": "health",
    "responses": {
     "200": {
      "description": "OK",
      "headers": {
       "Cache-Control": {
        "$ref": "#/components/headers/NoStore"
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Health"
        }
       }
      }
     }
    }
   }
  },
  "/draws": {
   "get": {
    "tags": [
     "read"
    ],
    "summary": "Catalog of draws and whether each can be bought now",
    "description": "`onSale` is true exactly when `POST /invoice` would sell that draw now. Do not infer sales from dates or from `enabledDraws`.",
    "operationId": "draws",
    "parameters": [
     {
      "$ref": "#/components/parameters/AcceptLanguage"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "headers": {
       "Cache-Control": {
        "$ref": "#/components/headers/NoStore"
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Catalog"
        }
       }
      }
     }
    }
   }
  },
  "/pause": {
   "get": {
    "tags": [
     "read"
    ],
    "summary": "Sales paused by the organiser",
    "operationId": "pause",
    "responses": {
     "200": {
      "description": "OK",
      "headers": {
       "Cache-Control": {
        "$ref": "#/components/headers/NoStore"
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "paused": {
           "type": "object",
           "additionalProperties": {
            "$ref": "#/components/schemas/Pause"
           }
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/results/index": {
   "get": {
    "tags": [
     "verify"
    ],
    "summary": "Ids of draws with published results",
    "operationId": "resultsIndex",
    "responses": {
     "200": {
      "description": "OK",
      "headers": {
       "Cache-Control": {
        "$ref": "#/components/headers/NoStore"
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "draws": {
           "type": "array",
           "items": {
            "type": "string"
           }
          }
         }
        },
        "example": {
         "draws": [
          "2511"
         ]
        }
       }
      }
     }
    }
   }
  },
  "/results/{id}": {
   "get": {
    "tags": [
     "verify"
    ],
    "summary": "Published result (plain JSON, with payment states)",
    "description": "The signed version is `/results/{id}/proof`; verify that one. 404 = no result published yet (not a routing error).",
    "operationId": "results",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "description": "Draw id (letters, digits, - and _; 1–20).",
      "schema": {
       "type": "string",
       "pattern": "^[A-Za-z0-9_-]{1,20}$"
      }
     },
     {
      "$ref": "#/components/parameters/AcceptLanguage"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "headers": {
       "Cache-Control": {
        "$ref": "#/components/headers/NoStore"
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Results"
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/results/{id}/proof": {
   "get": {
    "tags": [
     "verify"
    ],
    "summary": "Result signed by the lottery key, with its OpenTimestamps stamp",
    "operationId": "resultProof",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "description": "Draw id (letters, digits, - and _; 1–20).",
      "schema": {
       "type": "string",
       "pattern": "^[A-Za-z0-9_-]{1,20}$"
      }
     },
     {
      "$ref": "#/components/parameters/AcceptLanguage"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "headers": {
       "Cache-Control": {
        "$ref": "#/components/headers/NoStore"
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/SignedRecord"
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/commitment/{id}": {
   "get": {
    "tags": [
     "verify"
    ],
    "summary": "Signed pre-draw list of participants (commitment)",
    "description": "Signed after the close and before the draw time. `n: 0` = zero tickets, signed. 404 = never fixed (no verifiable result).",
    "operationId": "commitment",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "description": "Draw id (letters, digits, - and _; 1–20).",
      "schema": {
       "type": "string",
       "pattern": "^[A-Za-z0-9_-]{1,20}$"
      }
     },
     {
      "$ref": "#/components/parameters/AcceptLanguage"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "headers": {
       "Cache-Control": {
        "$ref": "#/components/headers/NoStore"
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Commitment"
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/anchor/{id}": {
   "get": {
    "tags": [
     "verify"
    ],
    "summary": "Signed block anchor (blockRule anchor-v1)",
    "operationId": "anchor",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "description": "Draw id (letters, digits, - and _; 1–20).",
      "schema": {
       "type": "string",
       "pattern": "^[A-Za-z0-9_-]{1,20}$"
      }
     },
     {
      "$ref": "#/components/parameters/AcceptLanguage"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "headers": {
       "Cache-Control": {
        "$ref": "#/components/headers/NoStore"
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/SignedRecord"
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/proof/{id}": {
   "get": {
    "tags": [
     "verify"
    ],
    "summary": "Everything needed to verify a draw, in one answer",
    "description": "Bundle of what is already public: the catalog entry, the signed result, the commitment and the anchor (null if its rule has none), plus links. 404 when there is no signed result yet (e.g. a draw held without a published result).",
    "operationId": "proof",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "description": "Draw id (letters, digits, - and _; 1–20).",
      "schema": {
       "type": "string",
       "pattern": "^[A-Za-z0-9_-]{1,20}$"
      }
     },
     {
      "$ref": "#/components/parameters/AcceptLanguage"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "headers": {
       "Cache-Control": {
        "$ref": "#/components/headers/NoStore"
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ProofBundle"
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/seed/{id}": {
   "get": {
    "tags": [
     "read"
    ],
    "summary": "LOTTO21 owner's contribution state",
    "operationId": "seed",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "description": "Draw id (letters, digits, - and _; 1–20).",
      "schema": {
       "type": "string",
       "pattern": "^[A-Za-z0-9_-]{1,20}$"
      }
     },
     {
      "$ref": "#/components/parameters/AcceptLanguage"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "headers": {
       "Cache-Control": {
        "$ref": "#/components/headers/NoStore"
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Seed"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/basket": {
   "get": {
    "tags": [
     "read"
    ],
    "summary": "Numbers held in live baskets of a draw (not purchasable meanwhile)",
    "operationId": "basketHolds",
    "parameters": [
     {
      "name": "draw",
      "in": "query",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "$ref": "#/components/parameters/AcceptLanguage"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "headers": {
       "Cache-Control": {
        "$ref": "#/components/headers/NoStore"
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "held": {
           "type": "array",
           "items": {
            "type": "string"
           }
          },
          "seconds": {
           "type": "integer"
          }
         }
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error"
     },
     "404": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/invoices": {
   "get": {
    "tags": [
     "read"
    ],
    "summary": "Public list of a draw's purchases (paid, or pending and unexpired)",
    "description": "No payment hash, no invoice, no claim code: only the public view.",
    "operationId": "invoices",
    "parameters": [
     {
      "name": "draw",
      "in": "query",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "$ref": "#/components/parameters/AcceptLanguage"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "headers": {
       "Cache-Control": {
        "$ref": "#/components/headers/NoStore"
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "txs": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/Tx"
           }
          }
         }
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/invoice": {
   "post": {
    "tags": [
     "buy"
    ],
    "summary": "Create the Lightning invoice of a purchase",
    "description": "The server computes the amount itself (numbers × sum of prices + tip) and locks the numbers. Check `tx.amount` against your own computation and do not pay if it differs. Mainnet when `testMode` is false. Idempotent with `requestId`: the same request returns the same invoice; a different one with the same id is 409.",
    "operationId": "createInvoice",
    "parameters": [
     {
      "$ref": "#/components/parameters/AcceptLanguage"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/InvoiceRequest"
       },
       "example": {
        "draws": [
         "EXAMPLE"
        ],
        "nums": [
         "007"
        ],
        "claim": "0000000000000000000000000000000000000000000000000000000000000000",
        "requestId": "0000000000000000000000000000000000000000000000000000000000000000",
        "tip": 0
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "OK",
      "headers": {
       "Cache-Control": {
        "$ref": "#/components/headers/NoStore"
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "tx": {
           "$ref": "#/components/schemas/OwnTx"
          }
         }
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error"
     },
     "409": {
      "$ref": "#/components/responses/Error"
     },
     "413": {
      "$ref": "#/components/responses/Error"
     },
     "415": {
      "$ref": "#/components/responses/Error"
     },
     "429": {
      "$ref": "#/components/responses/Error"
     },
     "502": {
      "$ref": "#/components/responses/Error"
     },
     "503": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/invoice/{key}": {
   "get": {
    "tags": [
     "buy"
    ],
    "summary": "State of a purchase (poll until settled_at or expiry)",
    "operationId": "invoice",
    "parameters": [
     {
      "name": "key",
      "in": "path",
      "required": true,
      "description": "Purchase id (`tx.key`, 64 hex).",
      "schema": {
       "type": "string",
       "pattern": "^[0-9a-fA-F]{64}$"
      }
     },
     {
      "$ref": "#/components/parameters/AcceptLanguage"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "headers": {
       "Cache-Control": {
        "$ref": "#/components/headers/NoStore"
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "tx": {
           "$ref": "#/components/schemas/Tx"
          }
         }
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error"
     },
     "404": {
      "$ref": "#/components/responses/Error"
     },
     "429": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/claim": {
   "post": {
    "tags": [
     "claim"
    ],
    "summary": "Claim a prize (signed with the key derived from the purchase's secret code)",
    "description": "`payouts` is false on purpose: a claim is stored for human review and paid by hand; it never triggers a payment by itself. The secret code never travels: the event is signed with the key derived from it. Never put the code in URLs, logs, issues or examples.",
    "operationId": "claim",
    "parameters": [
     {
      "$ref": "#/components/parameters/AcceptLanguage"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/ClaimRequest"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "OK",
      "headers": {
       "Cache-Control": {
        "$ref": "#/components/headers/NoStore"
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "description": "The claim and its review state (it is not a payment)."
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error"
     },
     "409": {
      "$ref": "#/components/responses/Error"
     },
     "415": {
      "$ref": "#/components/responses/Error"
     },
     "429": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/claim/{id}": {
   "get": {
    "tags": [
     "claim"
    ],
    "summary": "Review state of a claim (not a payment)",
    "operationId": "claimStatus",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^[0-9a-f]{24}$"
      }
     },
     {
      "$ref": "#/components/parameters/AcceptLanguage"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "headers": {
       "Cache-Control": {
        "$ref": "#/components/headers/NoStore"
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "id": {
           "type": "string"
          },
          "status": {
           "type": "string"
          },
          "total": {
           "type": "integer"
          },
          "created_at": {
           "type": "integer"
          },
          "paid_at": {
           "type": "integer"
          },
          "picks": {
           "type": "array",
           "items": {
            "type": "object"
           }
          }
         }
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  }
 },
 "components": {
  "headers": {
   "NoStore": {
    "description": "Every API answer is no-store.",
    "schema": {
     "type": "string",
     "example": "no-store"
    }
   }
  },
  "parameters": {
   "AcceptLanguage": {
    "name": "Accept-Language",
    "in": "header",
    "required": false,
    "description": "Language of `error` texts and reasons (en, es…). Ids and dates never change.",
    "schema": {
     "type": "string"
    }
   }
  },
  "responses": {
   "Error": {
    "description": "Error",
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/Error"
      },
      "example": {
       "error": "Sales for that draw are closed"
      }
     }
    }
   }
  },
  "schemas": {
   "Error": {
    "type": "object",
    "required": [
     "error"
    ],
    "properties": {
     "error": {
      "type": "string"
     }
    },
    "additionalProperties": true
   },
   "Health": {
    "type": "object",
    "properties": {
     "ok": {
      "type": "boolean"
     },
     "wallet": {
      "type": "boolean"
     },
     "testMode": {
      "type": "boolean",
      "description": "false = mainnet, real sats"
     },
     "mock": {
      "type": "boolean"
     },
     "payouts": {
      "type": "boolean",
      "description": "false on purpose: prizes are paid by hand"
     },
     "enabledDraws": {
      "type": "array",
      "items": {
       "type": "string"
      },
      "description": "Not a sales catalog: use /draws"
     },
     "paused": {
      "type": "object"
     },
     "signer": {
      "type": "string",
      "nullable": true,
      "description": "Lottery public key (hex) that signs"
     },
     "backend": {
      "type": "string"
     },
     "lnBackend": {
      "type": "string"
     },
     "publication": {
      "type": "object",
      "description": "Whether the configured relays meet the publication rule (counts only)"
     }
    }
   },
   "Pause": {
    "type": "object",
    "properties": {
     "at": {
      "type": "integer"
     },
     "reason": {
      "type": "string"
     },
     "maintenance": {
      "type": "boolean"
     },
     "event": {
      "type": "string"
     },
     "note": {
      "type": "string"
     }
    }
   },
   "CatalogDraw": {
    "type": "object",
    "required": [
     "id",
     "status",
     "onSale"
    ],
    "properties": {
     "id": {
      "type": "string"
     },
     "title": {
      "type": "string"
     },
     "game": {
      "type": "string",
      "enum": [
       "numbers",
       "lotto"
      ]
     },
     "kind": {
      "type": "string"
     },
     "price": {
      "type": "integer",
      "description": "sats per number or per combination"
     },
     "tickets": {
      "type": "integer"
     },
     "maxPerBuy": {
      "type": "integer"
     },
     "invoiceExpiry": {
      "type": "integer",
      "description": "seconds"
     },
     "lotto": {
      "type": "object",
      "properties": {
       "pick": {
        "type": "integer"
       },
       "max": {
        "type": "integer"
       },
       "bonus": {
        "type": "boolean"
       },
       "reimbursement": {
        "type": "boolean"
       },
       "seed": {
        "type": "integer",
        "description": "sats the owner adds to the top category of this draw"
       },
       "jackpot": {
        "type": "boolean",
        "description": "true: the top category is only paid to its own winners; without them all of it rolls over to the next draw"
       },
       "carryIn": {
        "type": "integer",
        "description": "sats of carry-over (jackpot) this draw received from earlier draws; goes entirely to the top category"
       },
       "carryFrom": {
        "type": "string",
        "description": "id of the draw whose signed result (carryNext) gives this draw its carry-over"
       },
       "carryPending": {
        "type": "boolean",
        "description": "true while the carryFrom draw has no result yet (carryIn not known)"
       }
      }
     },
     "openAt": {
      "type": "string",
      "format": "date-time",
      "nullable": true
     },
     "closeAt": {
      "type": "string",
      "format": "date-time"
     },
     "drawAt": {
      "type": "string",
      "format": "date-time"
     },
     "blockRule": {
      "type": "string"
     },
     "confirmations": {
      "type": "integer"
     },
     "status": {
      "type": "string",
      "enum": [
       "onSale",
       "announced",
       "paused",
       "closed",
       "drawn"
      ]
     },
     "onSale": {
      "type": "boolean"
     },
     "reason": {
      "type": "string"
     },
     "reasonText": {
      "type": "string"
     },
     "enabled": {
      "type": "boolean"
     },
     "paused": {
      "type": "boolean"
     },
     "listed": {
      "type": "boolean"
     },
     "hasResults": {
      "type": "boolean"
     },
     "resultsAt": {
      "type": "string",
      "format": "date-time",
      "description": "When the final result was stored (its generatedAt); absent without a result."
     },
     "hasCommitment": {
      "type": "boolean"
     },
     "hasAnchor": {
      "type": "boolean"
     }
    }
   },
   "Catalog": {
    "type": "object",
    "properties": {
     "v": {
      "type": "integer"
     },
     "generatedAt": {
      "type": "string",
      "format": "date-time"
     },
     "testMode": {
      "type": "boolean"
     },
     "lotteryPubkey": {
      "type": "string",
      "nullable": true
     },
     "draws": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/CatalogDraw"
      }
     }
    }
   },
   "NostrEvent": {
    "type": "object",
    "description": "NIP-01 event; sig = BIP340 over id.",
    "properties": {
     "id": {
      "type": "string"
     },
     "pubkey": {
      "type": "string"
     },
     "created_at": {
      "type": "integer"
     },
     "kind": {
      "type": "integer"
     },
     "tags": {
      "type": "array",
      "items": {
       "type": "array",
       "items": {
        "type": "string"
       }
      }
     },
     "content": {
      "type": "string"
     },
     "sig": {
      "type": "string"
     }
    }
   },
   "Ots": {
    "type": "object",
    "nullable": true,
    "description": "Pending OpenTimestamps file of the event id (base64); upgrade and check with `ots`.",
    "properties": {
     "ots": {
      "type": "string"
     },
     "calendars": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "digest": {
      "type": "string"
     },
     "at": {
      "type": "integer"
     }
    }
   },
   "SignedRecord": {
    "type": "object",
    "properties": {
     "event": {
      "$ref": "#/components/schemas/NostrEvent"
     },
     "ots": {
      "$ref": "#/components/schemas/Ots"
     },
     "relays": {
      "type": "integer"
     },
     "published": {
      "type": "boolean",
      "description": "Accepted by ≥ 2 relay hosts, at least one third party"
     }
    }
   },
   "Commitment": {
    "type": "object",
    "properties": {
     "commitment": {
      "type": "object",
      "description": "Signed content: v, d, game, blockRule, closeAt, drawAt, at, n, revenue, pot, hash, sold, hashPurchases"
     },
     "event": {
      "$ref": "#/components/schemas/NostrEvent"
     },
     "ots": {
      "$ref": "#/components/schemas/Ots"
     },
     "relays": {
      "type": "integer"
     },
     "published": {
      "type": "boolean"
     },
     "close": {
      "allOf": [
       {
        "$ref": "#/components/schemas/NostrEvent"
       }
      ],
      "nullable": true
     }
    }
   },
   "Results": {
    "type": "object",
    "properties": {
     "v": {
      "type": "integer"
     },
     "draw": {
      "type": "string"
     },
     "method": {
      "type": "string",
      "enum": [
       "block",
       "manual",
       "manual-test",
       "no-sales"
      ]
     },
     "winner": {
      "type": "string"
     },
     "block": {
      "type": "object",
      "properties": {
       "height": {
        "type": "integer"
       },
       "hash": {
        "type": "string"
       }
      }
     },
     "confirmations": {
      "type": "integer"
     },
     "prizes": {
      "type": "array",
      "items": {
       "type": "object"
      }
     },
     "commitment": {
      "type": "string"
     },
     "blockRule": {
      "type": "string"
     }
    },
    "additionalProperties": true
   },
   "ProofBundle": {
    "type": "object",
    "properties": {
     "v": {
      "type": "integer"
     },
     "draw": {
      "type": "string"
     },
     "catalog": {
      "$ref": "#/components/schemas/CatalogDraw"
     },
     "result": {
      "$ref": "#/components/schemas/SignedRecord"
     },
     "commitment": {
      "allOf": [
       {
        "$ref": "#/components/schemas/Commitment"
       }
      ],
      "nullable": true
     },
     "anchor": {
      "allOf": [
       {
        "$ref": "#/components/schemas/SignedRecord"
       }
      ],
      "nullable": true
     },
     "verify": {
      "type": "object",
      "properties": {
       "doc": {
        "type": "string"
       },
       "command": {
        "type": "string"
       }
      }
     }
    }
   },
   "Seed": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string"
     },
     "required": {
      "type": "integer"
     },
     "status": {
      "type": "string",
      "enum": [
       "none",
       "missing",
       "pending",
       "expired",
       "paid"
      ]
     },
     "amount": {
      "type": "integer"
     },
     "paid_at": {
      "type": "integer"
     }
    }
   },
   "Tx": {
    "type": "object",
    "description": "Public view of a purchase: no payment hash, no invoice.",
    "properties": {
     "key": {
      "type": "string"
     },
     "description": {
      "type": "string"
     },
     "amount": {
      "type": "integer"
     },
     "received": {
      "type": "integer"
     },
     "created_at": {
      "type": "integer"
     },
     "expires_at": {
      "type": "integer"
     },
     "settled_at": {
      "type": "integer",
      "description": "0 until paid"
     },
     "type": {
      "type": "string"
     },
     "hn": {
      "type": "object",
      "additionalProperties": {
       "type": "string"
      }
     }
    }
   },
   "OwnTx": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Tx"
     },
     {
      "type": "object",
      "properties": {
       "payment_hash": {
        "type": "string"
       },
       "invoice": {
        "type": "string",
        "description": "BOLT11 to pay (lnbc… on mainnet)"
       }
      }
     }
    ],
    "description": "Only in the answer to the creator of the invoice. Once paid, a repeated requestId returns the public view."
   },
   "InvoiceRequest": {
    "type": "object",
    "required": [
     "draws",
     "nums",
     "claim"
    ],
    "properties": {
     "draws": {
      "type": "array",
      "minItems": 1,
      "items": {
       "type": "string"
      },
      "description": "Ids with onSale: true, of the same game and shape (one invoice can cover several draws)."
     },
     "nums": {
      "type": "array",
      "minItems": 1,
      "items": {
       "type": "string"
      },
      "description": "Numbers zero-padded to the board's digits (\"007\"), or LOTTO21 entries as the website writes them."
     },
     "claim": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$",
      "description": "Claim HASH of the purchase (never the secret code): sha256(\"POLLA-claim-hash-v1|\" ‖ pubkey), pubkey = secp256k1 x-only key of sk = sha256(\"POLLA-claim-sk-v1|\" ‖ 18-byte secret). See docs/AGENT-BUY.md."
     },
     "contact": {
      "type": "string",
      "description": "Optional, encrypted to the lottery's contactKey (format e1.…). Leave empty if you cannot encrypt it."
     },
     "tip": {
      "type": "integer",
      "minimum": 0,
      "description": "Optional tip in sats, added to the amount."
     },
     "requestId": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$",
      "description": "Idempotency key: the website uses the claim hash. Same body + same id → same invoice."
     },
     "hn": {
      "type": "object",
      "additionalProperties": {
       "type": "string",
       "pattern": "^[0-9a-f]{64}$"
      },
      "description": "Optional bearer tickets: one claim hash per \"draw:number\", covering exactly the purchase."
     },
     "expiry": {
      "type": "integer",
      "description": "Optional shorter expiry in seconds (≥ 60)."
     },
     "sid": {
      "type": "string",
      "description": "Optional live-basket session id of the website."
     }
    }
   },
   "ClaimRequest": {
    "type": "object",
    "required": [
     "event"
    ],
    "properties": {
     "event": {
      "allOf": [
       {
        "$ref": "#/components/schemas/NostrEvent"
       }
      ],
      "description": "kind 30078, tag [\"t\",\"polla-claim-api\"], signed with the claim key; content JSON {v:1, h: claim hash, k: purchase key, picks:[{d,n}], pay: BOLT11 / Lightning address / LNURL, c: optional contact, at}. created_at within 10 min of the server's clock."
     },
     "binding": {
      "allOf": [
       {
        "$ref": "#/components/schemas/NostrEvent"
       }
      ],
      "description": "With a BOLT11 destination: the signed binding to its payment hash (tag polla-payment-binding)."
     }
    }
   }
  }
 }
}
