{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://bitcoin-noc.github.io/network-entities/schema.json",
  "title": "Bitcoin network entities",
  "description": "Entities on the Bitcoin peer-to-peer network documented on https://bitcoin-noc.github.io/network-entities/",
  "type": "object",
  "required": [
    "generated",
    "source",
    "tags",
    "entities"
  ],
  "additionalProperties": false,
  "properties": {
    "$schema": {
      "type": "string"
    },
    "generated": {
      "type": "string",
      "format": "date-time"
    },
    "source": {
      "type": "string",
      "format": "uri"
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "tag",
          "description"
        ],
        "additionalProperties": false,
        "properties": {
          "tag": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9-]*$"
          },
          "description": {
            "type": "string"
          }
        }
      }
    },
    "entities": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/entity"
      }
    }
  },
  "$defs": {
    "entity": {
      "type": "object",
      "required": [
        "slug",
        "name",
        "summary",
        "added",
        "inactive",
        "inactive_reason",
        "active",
        "tags",
        "user_agents",
        "references",
        "description",
        "networks"
      ],
      "additionalProperties": false,
      "properties": {
        "slug": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9-]*$"
        },
        "name": {
          "type": "string"
        },
        "summary": {
          "type": "string"
        },
        "added": {
          "type": "string",
          "format": "date",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        },
        "inactive": {
          "oneOf": [
            {
              "type": "string",
              "format": "date",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
            },
            {
              "type": "null"
            }
          ],
          "description": "Set once the entity is no longer observed on the network."
        },
        "inactive_reason": {
          "type": [
            "string",
            "null"
          ]
        },
        "active": {
          "type": "boolean",
          "description": "False once the entity is no longer observed on the network."
        },
        "tags": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "user_agents": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "references": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "url",
              "title",
              "date"
            ],
            "additionalProperties": false,
            "properties": {
              "url": {
                "type": "string",
                "format": "uri"
              },
              "title": {
                "type": "string"
              },
              "date": {
                "oneOf": [
                  {
                    "type": "string",
                    "format": "date",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            }
          }
        },
        "description": {
          "type": "string"
        },
        "networks": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/network"
          }
        }
      }
    },
    "network": {
      "type": "object",
      "required": [
        "cidr",
        "added",
        "removed",
        "note",
        "active"
      ],
      "additionalProperties": false,
      "properties": {
        "cidr": {
          "type": "string",
          "description": "IPv4/IPv6 address or CIDR network. Single hosts are written without a prefix length."
        },
        "added": {
          "type": "string",
          "format": "date",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        },
        "removed": {
          "oneOf": [
            {
              "type": "string",
              "format": "date",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
            },
            {
              "type": "null"
            }
          ]
        },
        "note": {
          "type": [
            "string",
            "null"
          ]
        },
        "active": {
          "type": "boolean",
          "description": "False once the entity stopped using the network."
        }
      }
    }
  }
}
