{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "nodes"
  ],
  "properties": {
    "nodes": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "nodeid"
        ],
        "properties": {
          "nodeid": {
            "type": "pubkey",
            "description": "the public key of the node"
          },
          "last_timestamp": {
            "type": "u32",
            "description": "A node_announcement has been received for this node (UNIX timestamp)"
          }
        },
        "allOf": [
          {
            "if": {
              "required": [
                "last_timestamp"
              ]
            },
            "then": {
              "additionalProperties": false,
              "required": [
                "nodeid",
                "last_timestamp",
                "alias",
                "color",
                "features",
                "addresses"
              ],
              "properties": {
                "nodeid": {},
                "last_timestamp": {},
                "option_will_fund": {},
                "alias": {
                  "type": "string",
                  "description": "The fun alias this node advertized",
                  "maxLength": 32
                },
                "color": {
                  "type": "hex",
                  "description": "The favorite RGB color this node advertized",
                  "minLength": 6,
                  "maxLength": 6
                },
                "features": {
                  "type": "hex",
                  "description": "BOLT #9 features bitmap this node advertized"
                },
                "addresses": {
                  "type": "array",
                  "description": "The addresses this node advertized",
                  "items": {
                    "type": "object",
                    "required": [
                      "type",
                      "port"
                    ],
                    "additionalProperties": true,
                    "properties": {
                      "type": {
                        "type": "string",
                        "enum": [
                          "dns",
                          "ipv4",
                          "ipv6",
                          "torv2",
                          "torv3"
                        ],
                        "description": "Type of connection (until 23.08, `websocket` was also allowed)"
                      },
                      "port": {
                        "type": "u16",
                        "description": "port number"
                      }
                    },
                    "if": {
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "dns",
                            "ipv4",
                            "ipv6",
                            "torv2",
                            "torv3"
                          ]
                        }
                      }
                    },
                    "then": {
                      "required": [
                        "type",
                        "address",
                        "port"
                      ],
                      "additionalProperties": false,
                      "properties": {
                        "type": {},
                        "port": {},
                        "address": {
                          "type": "string",
                          "description": "address in expected format for **type**"
                        }
                      }
                    },
                    "else": {
                      "required": [
                        "type",
                        "port"
                      ],
                      "additionalProperties": false,
                      "properties": {
                        "type": {},
                        "port": {}
                      }
                    }
                  }
                }
              }
            },
            "else": {
              "additionalProperties": false,
              "properties": {
                "nodeid": {}
              }
            }
          },
          {
            "if": {
              "required": [
                "option_will_fund"
              ]
            },
            "then": {
              "additionalProperties": true,
              "required": [
                "option_will_fund"
              ],
              "properties": {
                "option_will_fund": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "lease_fee_base_msat",
                    "lease_fee_basis",
                    "funding_weight",
                    "channel_fee_max_base_msat",
                    "channel_fee_max_proportional_thousandths",
                    "compact_lease"
                  ],
                  "properties": {
                    "lease_fee_base_msat": {
                      "type": "msat",
                      "description": "the fixed fee for a lease (whole number of satoshis)"
                    },
                    "lease_fee_basis": {
                      "type": "u32",
                      "description": "the proportional fee in basis points (parts per 10,000) for a lease"
                    },
                    "funding_weight": {
                      "type": "u32",
                      "description": "the onchain weight you'll have to pay for a lease"
                    },
                    "channel_fee_max_base_msat": {
                      "type": "msat",
                      "description": "the maximum base routing fee this node will charge during the lease"
                    },
                    "channel_fee_max_proportional_thousandths": {
                      "type": "u32",
                      "description": "the maximum proportional routing fee this node will charge during the lease (in thousandths, not millionths like channel_update)"
                    },
                    "compact_lease": {
                      "type": "hex",
                      "description": "the lease as represented in the node_announcement"
                    }
                  }
                }
              }
            }
          }
        ]
      }
    }
  }
}
