{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "required": [
    "label",
    "payment_hash",
    "status",
    "expires_at"
  ],
  "additionalProperties": true,
  "properties": {
    "label": {
      "type": "string",
      "description": "Unique label given at creation time"
    },
    "bolt11": {
      "type": "string",
      "description": "BOLT11 string"
    },
    "bolt12": {
      "type": "string",
      "description": "BOLT12 string"
    },
    "amount_msat": {
      "type": "msat",
      "description": "the amount required to pay this invoice"
    },
    "description": {
      "type": "string",
      "description": "description used in the invoice"
    },
    "payment_hash": {
      "type": "hash",
      "description": "the hash of the *payment_preimage* which will prove payment"
    },
    "status": {
      "type": "string",
      "description": "State of invoice",
      "enum": [
        "paid",
        "expired",
        "unpaid"
      ]
    },
    "expires_at": {
      "type": "u64",
      "description": "UNIX timestamp when invoice expires (or expired)"
    }
  },
  "allOf": [
    {
      "if": {
        "required": [
          "bolt12"
        ]
      },
      "then": {
        "required": [],
        "additionalProperties": false,
        "properties": {
          "label": {},
          "bolt12": {},
          "status": {},
          "expires_at": {},
          "msatoshi": {},
          "amount_msat": {},
          "description": {},
          "payment_hash": {},
          "pay_index": {},
          "amount_received_msat": {},
          "paid_at": {},
          "payment_preimage": {},
          "local_offer_id": {
            "type": "hex",
            "description": "offer for which this invoice was created"
          },
          "invreq_payer_note": {
            "type": "string",
            "description": "the optional *invreq_payer_note* from invoice_request which created this invoice"
          }
        }
      },
      "else": {
        "required": [
          "bolt11"
        ],
        "additionalProperties": false,
        "properties": {
          "label": {},
          "bolt11": {},
          "status": {},
          "expires_at": {},
          "msatoshi": {},
          "amount_msat": {},
          "description": {},
          "payment_hash": {},
          "pay_index": {},
          "amount_received_msat": {},
          "msatoshi_received": {},
          "paid_at": {},
          "payment_preimage": {}
        }
      }
    },
    {
      "if": {
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "paid"
            ]
          }
        }
      },
      "then": {
        "additionalProperties": false,
        "required": [
          "pay_index",
          "amount_received_msat",
          "paid_at",
          "payment_preimage"
        ],
        "properties": {
          "label": {},
          "bolt11": {},
          "bolt12": {},
          "status": {},
          "expires_at": {},
          "msatoshi": {},
          "amount_msat": {},
          "description": {},
          "payment_hash": {},
          "invreq_payer_note": {},
          "local_offer_id": {},
          "pay_index": {
            "type": "u64",
            "description": "unique index for this invoice payment"
          },
          "amount_received_msat": {
            "type": "msat",
            "description": "how much was actually received"
          },
          "paid_at": {
            "type": "u64",
            "description": "UNIX timestamp of when payment was received"
          },
          "payment_preimage": {
            "type": "secret",
            "description": "SHA256 of this is the *payment_hash* offered in the invoice"
          }
        }
      },
      "else": {
        "additionalProperties": false,
        "properties": {
          "label": {},
          "bolt11": {},
          "bolt12": {},
          "status": {},
          "msatoshi": {},
          "amount_msat": {},
          "description": {},
          "payment_hash": {},
          "expires_at": {},
          "pay_index": {},
          "invreq_payer_note": {},
          "local_offer_id": {}
        }
      }
    }
  ]
}
