{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/bitview-space/json-schema/bitview-space-oracle-block-schema.json",
  "title": "OracleBlock",
  "description": "The oracle at one block: what it counted (`histogram`, `outputs`), where it looked (`first_bin`,\n`scores`) and what it found (`bin`, `price`).\n\nBins are the oracle's log scale of amounts in sats, 200 a decade: amount `sats` is in bin\n`round(log10(sats) * 200)`, bin 0 at 1 sat to bin 2399 just under 10^12. Read as where $100\nlands, a bin is a price: `10^(10 - bin / 200)` dollars, higher bins lower prices.",
  "x-generated": "2026-11-16",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/bitview-space-openapi.json#/components/schemas/OracleBlock",
  "type": "object",
  "properties": {
    "height": {
      "description": "The block's height; live with the mempool, the next block's.",
      "allOf": [
        {
          "$ref": "#/$defs/Height"
        }
      ]
    },
    "hash": {
      "description": "The confirmed block it was read at: this block's hash; live with the mempool, the tip's\n(block `height - 1`), the one the mempool is blended onto.",
      "allOf": [
        {
          "$ref": "#/$defs/BlockHash"
        }
      ]
    },
    "mempool": {
      "description": "Whether it's the live reading with the mempool blended in as the next block (`outputs` the\nmempool's), rather than a confirmed block's.",
      "type": "boolean"
    },
    "price": {
      "description": "The price it found, in dollars: `bin` as a price, to the cent.",
      "allOf": [
        {
          "$ref": "#/$defs/Dollars"
        }
      ]
    },
    "bin": {
      "description": "The bin it picked, refined between bins by a parabola through its score and its neighbours'\nwhen it's their local maximum.",
      "type": "number",
      "format": "double"
    },
    "first_bin": {
      "description": "The search window's first candidate bin: 12 below the block before's answer, rounded, 24\ncandidates in all.",
      "type": "integer",
      "format": "uint16",
      "minimum": 0,
      "maximum": 65535
    },
    "scores": {
      "description": "Each candidate's score, from `first_bin` on, unitless: for each of the 19 round-dollar\namounts ($1, 2, 3, 5, 10, 15, 20, 25, 30, 50, 100, 150, 200, 300, 500, 1k, 2k, 5k, 10k),\nthe histogram's count where that amount lands if $100 is at the candidate, over that\namount's peak in the window, summed. The pick is the highest of the candidates with counts on\nat least two amounts; without one, or with all zero (no payments in the window), the oracle\nkept the block before's answer.",
      "type": "array",
      "items": {
        "type": "number",
        "format": "double"
      }
    },
    "histogram": {
      "description": "The smoothed histogram it scored, 2,400 bins: the block's payments and the 11 blocks'\nbefore it (live, the mempool's as the next block's), each block's counts weighted\n`(2/7) * (5/7)^age`, the newest at age 0.",
      "type": "array",
      "items": {
        "type": "number",
        "format": "double"
      },
      "minItems": 2400,
      "maxItems": 2400
    },
    "outputs": {
      "description": "The block's own outputs (live, the mempool's) as the oracle's filter judged them.",
      "allOf": [
        {
          "$ref": "#/$defs/OracleOutputs"
        }
      ]
    }
  },
  "required": [
    "height",
    "hash",
    "mempool",
    "price",
    "bin",
    "first_bin",
    "scores",
    "histogram",
    "outputs"
  ],
  "$defs": {
    "BlockHash": {
      "description": "Double-SHA256 block-header hash, serialized in Bitcoin's conventional\nhexadecimal byte order.",
      "type": "string",
      "pattern": "^[0-9a-f]{64}$"
    },
    "Dollars": {
      "description": "An amount in US dollars.",
      "type": "number",
      "format": "double"
    },
    "Height": {
      "description": "A block height: how many blocks came before it.",
      "type": "integer",
      "format": "uint32",
      "minimum": 0
    },
    "OracleOutputs": {
      "description": "A block's outputs as the oracle's filter judged them: each skipped one under the first rule\nthat skips it, in the filter's order, and the payments it kept. They add up to the block's\noutputs.",
      "type": "object",
      "properties": {
        "coinbase": {
          "description": "The coinbase's: new coins, not payments.",
          "type": "integer",
          "format": "uint32",
          "minimum": 0
        },
        "fan_out": {
          "description": "Those of transactions with more outputs than the fan-out cap (250; 100 before height\n630,000): batch payouts.",
          "type": "integer",
          "format": "uint32",
          "minimum": 0
        },
        "op_return": {
          "description": "Those of transactions carrying an OP_RETURN output: data, not payments.",
          "type": "integer",
          "format": "uint32",
          "minimum": 0
        },
        "taproot": {
          "description": "Taproot outputs: mostly protocol traffic.",
          "type": "integer",
          "format": "uint32",
          "minimum": 0
        },
        "dust": {
          "description": "Under 1,000 sats.",
          "type": "integer",
          "format": "uint32",
          "minimum": 0
        },
        "round_btc": {
          "description": "Round amounts in bitcoin (within 0.1% of 1, 2, 3, 5 or 6 times a power of ten sats).",
          "type": "integer",
          "format": "uint32",
          "minimum": 0
        },
        "payments": {
          "description": "The rest: the payments it counted.",
          "type": "integer",
          "format": "uint32",
          "minimum": 0
        }
      },
      "required": [
        "coinbase",
        "fan_out",
        "op_return",
        "taproot",
        "dust",
        "round_btc",
        "payments"
      ]
    }
  }
}