{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "forwards"
  ],
  "properties": {
    "forwards": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "in_channel",
          "in_msat",
          "status",
          "received_time"
        ],
        "properties": {
          "in_channel": {
            "type": "short_channel_id",
            "description": "the channel that received the HTLC"
          },
          "in_htlc_id": {
            "type": "u64",
            "description": "the unique HTLC id the sender gave this (not present if incoming channel was closed before ugprade to v22.11)"
          },
          "in_msat": {
            "type": "msat",
            "description": "the value of the incoming HTLC"
          },
          "status": {
            "type": "string",
            "enum": [
              "offered",
              "settled",
              "local_failed",
              "failed"
            ],
            "description": "still ongoing, completed, failed locally, or failed after forwarding"
          },
          "received_time": {
            "type": "number",
            "description": "the UNIX timestamp when this was received"
          },
          "out_channel": {
            "type": "short_channel_id",
            "description": "the channel that the HTLC (trying to) forward to"
          },
          "out_htlc_id": {
            "type": "u64",
            "description": "the unique HTLC id we gave this when sending (may be missing even if out_channel is present, for old forwards before v22.11)"
          },
          "style": {
            "type": "string",
            "enum": [
              "legacy",
              "tlv"
            ],
            "description": "Either a legacy onion format or a modern tlv format"
          }
        },
        "allOf": [
          {
            "if": {
              "required": [
                "out_msat"
              ]
            },
            "then": {
              "additionalProperties": false,
              "required": [
                "fee_msat",
                "out_msat",
                "out_channel"
              ],
              "properties": {
                "in_channel": {},
                "in_htlc_id": {},
                "in_msatoshi": {},
                "in_msat": {},
                "status": {},
                "style": {},
                "received_time": {},
                "resolved_time": {},
                "out_channel": {},
                "out_htlc_id": {},
                "failcode": {},
                "failreason": {},
                "fee_msat": {
                  "type": "msat",
                  "description": "the amount this paid in fees"
                },
                "out_msat": {
                  "type": "msat",
                  "description": "the amount we sent out the *out_channel*"
                }
              }
            },
            "else": {
              "additionalProperties": false,
              "required": [],
              "properties": {
                "in_channel": {},
                "in_htlc_id": {},
                "in_msatoshi": {},
                "in_msat": {},
                "status": {},
                "style": {},
                "received_time": {},
                "resolved_time": {},
                "failcode": {},
                "failreason": {},
                "out_channel": {}
              }
            }
          },
          {
            "if": {
              "properties": {
                "status": {
                  "type": "string",
                  "enum": [
                    "settled",
                    "failed"
                  ]
                }
              }
            },
            "then": {
              "additionalProperties": false,
              "required": [
                "resolved_time"
              ],
              "properties": {
                "in_channel": {},
                "in_htlc_id": {},
                "in_msatoshi": {},
                "in_msat": {},
                "status": {},
                "style": {},
                "received_time": {},
                "out_channel": {},
                "out_htlc_id": {},
                "fee": {},
                "fee_msat": {},
                "out_msatoshi": {},
                "out_msat": {},
                "failcode": {},
                "failreason": {},
                "resolved_time": {
                  "type": "number",
                  "description": "the UNIX timestamp when this was resolved"
                }
              }
            },
            "else": {
              "additionalProperties": false,
              "properties": {
                "in_channel": {},
                "in_htlc_id": {},
                "in_msatoshi": {},
                "in_msat": {},
                "status": {},
                "style": {},
                "received_time": {},
                "out_channel": {},
                "out_htlc_id": {},
                "fee": {},
                "fee_msat": {},
                "failcode": {},
                "failreason": {},
                "out_msatoshi": {},
                "out_msat": {}
              }
            }
          },
          {
            "if": {
              "properties": {
                "status": {
                  "type": "string",
                  "enum": [
                    "local_failed",
                    "failed"
                  ]
                }
              }
            },
            "then": {
              "additionalProperties": false,
              "required": [],
              "properties": {
                "in_channel": {},
                "in_htlc_id": {},
                "in_msatoshi": {},
                "in_msat": {},
                "status": {},
                "style": {},
                "received_time": {},
                "out_channel": {},
                "out_htlc_id": {},
                "fee": {},
                "fee_msat": {},
                "out_msatoshi": {},
                "out_msat": {},
                "resolved_time": {},
                "failcode": {
                  "type": "u32",
                  "description": "the numeric onion code returned"
                },
                "failreason": {
                  "type": "string",
                  "description": "the name of the onion code returned"
                }
              }
            },
            "else": {
              "additionalProperties": false,
              "required": [],
              "properties": {
                "in_channel": {},
                "in_htlc_id": {},
                "in_msatoshi": {},
                "in_msat": {},
                "status": {},
                "style": {},
                "received_time": {},
                "out_channel": {},
                "out_htlc_id": {},
                "fee": {},
                "fee_msat": {},
                "out_msatoshi": {},
                "out_msat": {},
                "resolved_time": {}
              }
            }
          }
        ]
      }
    }
  }
}
