{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/bitview-space/json-schema/bitview-space-transaction-schema.json",
  "title": "Transaction",
  "description": "Transaction information compatible with mempool.space API format",
  "x-generated": "2026-11-16",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/bitview-space-openapi.json#/components/schemas/Transaction",
  "type": "object",
  "properties": {
    "index": {
      "description": "Internal transaction index (brk-specific, not in mempool.space)",
      "anyOf": [
        {
          "$ref": "#/$defs/TxIndex"
        },
        {
          "type": "null"
        }
      ]
    },
    "txid": {
      "allOf": [
        {
          "$ref": "#/$defs/Txid"
        }
      ]
    },
    "version": {
      "description": "Transaction version (the protocol's 32 bits read unsigned, as Esplora reports them; may contain non-standard values in coinbase txs)",
      "allOf": [
        {
          "$ref": "#/$defs/TxVersionRaw"
        }
      ]
    },
    "locktime": {
      "allOf": [
        {
          "$ref": "#/$defs/RawLockTime"
        }
      ]
    },
    "vin": {
      "description": "Transaction inputs",
      "type": "array",
      "items": {
        "$ref": "#/$defs/TxIn"
      }
    },
    "vout": {
      "description": "Transaction outputs",
      "type": "array",
      "items": {
        "$ref": "#/$defs/TxOut"
      }
    },
    "size": {
      "description": "Transaction size in bytes",
      "type": "integer",
      "format": "uint",
      "minimum": 0
    },
    "weight": {
      "allOf": [
        {
          "$ref": "#/$defs/Weight"
        }
      ]
    },
    "sigops": {
      "description": "BIP-141 signature-operation cost",
      "allOf": [
        {
          "$ref": "#/$defs/SigOps"
        }
      ]
    },
    "fee": {
      "description": "Transaction fee in satoshis",
      "allOf": [
        {
          "$ref": "#/$defs/Sats"
        }
      ]
    },
    "status": {
      "$ref": "#/$defs/TxStatus"
    }
  },
  "required": [
    "txid",
    "version",
    "locktime",
    "vin",
    "vout",
    "size",
    "weight",
    "sigops",
    "fee",
    "status"
  ],
  "$defs": {
    "Address": {
      "description": "Bitcoin address, or the hex public key of a P2PK output.",
      "type": "string"
    },
    "BlockHash": {
      "description": "Double-SHA256 block-header hash, serialized in Bitcoin's conventional\nhexadecimal byte order.",
      "type": "string",
      "pattern": "^[0-9a-f]{64}$"
    },
    "Height": {
      "description": "A block height: how many blocks came before it.",
      "type": "integer",
      "format": "uint32",
      "minimum": 0
    },
    "Hex": {
      "description": "Hex-encoded data as a JSON string.",
      "type": "string",
      "pattern": "^([0-9a-f]{2})*$"
    },
    "OutputTypeNormalized": {
      "description": "Output type names used by Esplora and mempool.space.",
      "type": "string",
      "enum": [
        "p2pk",
        "p2pkh",
        "multisig",
        "p2sh",
        "op_return",
        "v0_p2wpkh",
        "v0_p2wsh",
        "v1_p2tr",
        "anchor",
        "empty",
        "unknown"
      ]
    },
    "RawLockTime": {
      "description": "Transaction locktime. Values below 500,000,000 are interpreted as block heights; values at or above are Unix timestamps.",
      "type": "integer",
      "format": "uint32",
      "minimum": 0
    },
    "Sats": {
      "description": "An amount in satoshis (100,000,000 to a bitcoin).",
      "type": "integer",
      "format": "uint64",
      "minimum": 0
    },
    "SigOps": {
      "description": "BIP-141 signature-operation cost: legacy and P2SH-redeem sigops count four and witness sigops\none. Sums over many transactions or blocks use the full 64 bits.",
      "type": "integer",
      "format": "uint64",
      "minimum": 0
    },
    "Timestamp": {
      "description": "A Unix timestamp, in seconds.",
      "type": "integer",
      "format": "uint32",
      "minimum": 0
    },
    "TxIn": {
      "type": "object",
      "properties": {
        "txid": {
          "description": "Transaction ID of the output being spent",
          "allOf": [
            {
              "$ref": "#/$defs/Txid"
            }
          ]
        },
        "vout": {
          "description": "Output index being spent (coinbase: 4294967295)",
          "allOf": [
            {
              "$ref": "#/$defs/Vout"
            }
          ]
        },
        "prevout": {
          "description": "The output being spent",
          "anyOf": [
            {
              "$ref": "#/$defs/TxOut"
            },
            {
              "type": "null"
            }
          ]
        },
        "scriptsig": {
          "description": "Signature script in hex (empty for native SegWit inputs)",
          "allOf": [
            {
              "$ref": "#/$defs/Hex"
            }
          ]
        },
        "scriptsig_asm": {
          "description": "Signature script in assembly format",
          "type": "string"
        },
        "witness": {
          "description": "Witness data (stack items, present for SegWit inputs; hex-encoded on the wire)",
          "type": "array",
          "items": {
            "$ref": "#/$defs/Hex"
          }
        },
        "is_coinbase": {
          "type": "boolean"
        },
        "sequence": {
          "type": "integer",
          "format": "uint32",
          "minimum": 0
        },
        "inner_redeemscript_asm": {
          "description": "Inner redeemscript in assembly (P2SH inputs)",
          "type": "string"
        },
        "inner_witnessscript_asm": {
          "description": "Inner witnessscript in assembly (P2WSH and P2SH-P2WSH: the witness script; P2TR script path: the leaf script)",
          "type": "string"
        }
      },
      "required": [
        "txid",
        "vout",
        "prevout",
        "scriptsig",
        "scriptsig_asm",
        "is_coinbase",
        "sequence"
      ]
    },
    "TxIndex": {
      "description": "Chain-wide transaction index (0 = the genesis coinbase). For an\nin-block position, use `BlockTxIndex` instead.",
      "type": "integer",
      "format": "uint32",
      "minimum": 0
    },
    "TxOut": {
      "type": "object",
      "properties": {
        "scriptpubkey": {
          "description": "Script pubkey (locking script), encoded as hexadecimal.",
          "allOf": [
            {
              "$ref": "#/$defs/Hex"
            }
          ]
        },
        "scriptpubkey_asm": {
          "description": "Script pubkey in assembly format.",
          "type": "string"
        },
        "scriptpubkey_type": {
          "description": "Esplora/mempool.space script type.",
          "allOf": [
            {
              "$ref": "#/$defs/OutputTypeNormalized"
            }
          ]
        },
        "scriptpubkey_address": {
          "description": "Bitcoin address, omitted for scripts without an address (P2PK included, as Esplora).",
          "allOf": [
            {
              "$ref": "#/$defs/Address"
            }
          ]
        },
        "value": {
          "description": "Value of the output in satoshis.",
          "allOf": [
            {
              "$ref": "#/$defs/Sats"
            }
          ]
        }
      },
      "required": [
        "scriptpubkey",
        "scriptpubkey_asm",
        "scriptpubkey_type",
        "value"
      ]
    },
    "TxStatus": {
      "type": "object",
      "properties": {
        "confirmed": {
          "type": "boolean"
        },
        "block_height": {
          "description": "Block height (only present if confirmed)",
          "anyOf": [
            {
              "$ref": "#/$defs/Height"
            },
            {
              "type": "null"
            }
          ]
        },
        "block_hash": {
          "description": "Block hash (only present if confirmed)",
          "anyOf": [
            {
              "$ref": "#/$defs/BlockHash"
            },
            {
              "type": "null"
            }
          ]
        },
        "block_time": {
          "description": "Block timestamp (only present if confirmed)",
          "anyOf": [
            {
              "$ref": "#/$defs/Timestamp"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "confirmed"
      ]
    },
    "TxVersionRaw": {
      "description": "Raw transaction version: the protocol's 32 bits read unsigned, as Esplora reports them.\nUnlike TxVersion (u8, indexed), this preserves non-standard values\nused in coinbase txs for miner signaling/branding.",
      "type": "integer",
      "format": "uint32",
      "minimum": 0
    },
    "Txid": {
      "description": "A transaction ID: its hash.",
      "type": "string",
      "pattern": "^[0-9a-f]{64}$"
    },
    "Vout": {
      "description": "Index of the output being spent in the previous transaction (coinbase inputs: 4294967295)",
      "type": "integer",
      "format": "uint32",
      "minimum": 0
    },
    "Weight": {
      "description": "Weight in weight units (WU): non-witness bytes count four and witness bytes one. A block holds\nat most 4,000,000 WU; sums over many blocks use the full 64 bits.",
      "type": "integer",
      "format": "uint64",
      "minimum": 0
    }
  }
}