{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "accounts"
  ],
  "properties": {
    "accounts": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "account",
          "balances"
        ],
        "properties": {
          "account": {
            "type": "string",
            "description": "The account name. If the account is a channel, the channel_id"
          },
          "balances": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "balance_msat",
                "coin_type"
              ],
              "properties": {
                "balance_msat": {
                  "type": "msat",
                  "description": "Current account balance"
                },
                "coin_type": {
                  "type": "string",
                  "description": "coin type, same as HRP for bech32"
                }
              }
            }
          }
        },
        "if": {
          "required": [
            "peer_id"
          ]
        },
        "then": {
          "required": [
            "account",
            "balances",
            "peer_id",
            "we_opened",
            "account_closed",
            "account_resolved"
          ],
          "additionalProperties": false,
          "properties": {
            "account": {},
            "balances": {},
            "peer_id": {
              "type": "pubkey",
              "description": "Node id for the peer this account is with"
            },
            "we_opened": {
              "type": "boolean",
              "description": "Did we initiate this account open (open the channel)"
            },
            "account_closed": {
              "type": "boolean",
              "description": ""
            },
            "account_resolved": {
              "type": "boolean",
              "description": "Has this channel been closed and all outputs resolved?"
            },
            "resolved_at_block": {
              "type": "u32",
              "description": "Blockheight account resolved on chain"
            }
          }
        },
        "else": {
          "properties": {
            "account": {},
            "balances": {}
          },
          "additionalProperties": false
        }
      }
    }
  }
}
