{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "required": [
    "type",
    "valid"
  ],
  "properties": {
    "type": {
      "type": "string",
      "enum": [
        "bolt12 offer",
        "bolt12 invoice",
        "bolt12 invoice_request",
        "bolt11 invoice",
        "rune"
      ],
      "description": "what kind of object it decoded to"
    },
    "valid": {
      "type": "boolean",
      "description": "if this is false, you *MUST* not use the result except for diagnostics!"
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "bolt12 offer"
            ]
          },
          "valid": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        }
      },
      "then": {
        "required": [
          "offer_id",
          "offer_node_id",
          "offer_description"
        ],
        "additionalProperties": false,
        "properties": {
          "type": {},
          "valid": {},
          "offer_id": {
            "type": "hex",
            "description": "the id we use to identify this offer",
            "maxLength": 64,
            "minLength": 64
          },
          "offer_chains": {
            "type": "array",
            "description": "which blockchains this offer is for (missing implies bitcoin mainnet only)",
            "items": {
              "type": "hash",
              "description": "the genesis blockhash"
            }
          },
          "offer_metadata": {
            "type": "hex",
            "description": "any metadata the creater of the offer includes"
          },
          "offer_currency": {
            "type": "string",
            "description": "ISO 4217 code of the currency (missing implies Bitcoin)",
            "maxLength": 3,
            "minLength": 3
          },
          "warning_unknown_offer_currency": {
            "type": "string",
            "description": "The currency code is unknown (so no `currency_minor_unit`)"
          },
          "currency_minor_unit": {
            "type": "u32",
            "description": "the number of decimal places to apply to amount (if currency known)"
          },
          "offer_amount": {
            "type": "u64",
            "description": "the amount in the `offer_currency` adjusted by `currency_minor_unit`, if any"
          },
          "offer_amount_msat": {
            "type": "msat",
            "description": "the amount in bitcoin (if specified, and no `offer_currency`)"
          },
          "offer_description": {
            "type": "string",
            "description": "the description of the purpose of the offer"
          },
          "offer_issuer": {
            "type": "string",
            "description": "the description of the creator of the offer"
          },
          "offer_features": {
            "type": "hex",
            "description": "the feature bits of the offer"
          },
          "offer_absolute_expiry": {
            "type": "u64",
            "description": "UNIX timestamp of when this offer expires"
          },
          "offer_quantity_max": {
            "type": "u64",
            "description": "the maximum quantity (or, if 0, means any quantity)"
          },
          "offer_paths": {
            "type": "array",
            "description": "Paths to the destination",
            "items": {
              "type": "object",
              "required": [
                "first_node_id",
                "blinding",
                "path"
              ],
              "additionalProperties": false,
              "properties": {
                "first_node_id": {
                  "type": "pubkey",
                  "description": "the (presumably well-known) public key of the start of the path"
                },
                "blinding": {
                  "type": "pubkey",
                  "description": "blinding factor for this path"
                },
                "path": {
                  "type": "array",
                  "description": "an individual path",
                  "items": {
                    "type": "object",
                    "required": [
                      "blinded_node_id",
                      "encrypted_recipient_data"
                    ],
                    "additionalProperties": false,
                    "properties": {
                      "blinded_node_id": {
                        "type": "pubkey",
                        "description": "node_id of the hop"
                      },
                      "encrypted_recipient_data": {
                        "type": "hex",
                        "description": "encrypted TLV entry for this hop"
                      }
                    }
                  }
                }
              }
            }
          },
          "offer_node_id": {
            "type": "pubkey",
            "description": "public key of the offering node"
          },
          "offer_recurrence": {
            "type": "object",
            "description": "how often to this offer should be used",
            "required": [
              "period",
              "time_unit"
            ],
            "additionalProperties": false,
            "properties": {
              "time_unit": {
                "type": "u32",
                "description": "the BOLT12 time unit"
              },
              "time_unit_name": {
                "type": "string",
                "description": "the name of `time_unit` (if valid)"
              },
              "period": {
                "type": "u32",
                "description": "how many `time_unit` per payment period"
              },
              "basetime": {
                "type": "u64",
                "description": "period starts at this UNIX timestamp"
              },
              "start_any_period": {
                "type": "u64",
                "description": "you can start at any period (only if `basetime` present)"
              },
              "limit": {
                "type": "u32",
                "description": "maximum period number for recurrence"
              },
              "paywindow": {
                "type": "object",
                "description": "when within a period will payment be accepted (default is prior and during the period)",
                "required": [
                  "seconds_before",
                  "seconds_after"
                ],
                "additionalProperties": false,
                "properties": {
                  "seconds_before": {
                    "type": "u32",
                    "description": "seconds prior to period start"
                  },
                  "seconds_after": {
                    "type": "u32",
                    "description": "seconds after to period start"
                  },
                  "proportional_amount": {
                    "type": "boolean",
                    "enum": [
                      true
                    ],
                    "description": "amount should be scaled if payed after period start"
                  }
                }
              }
            }
          },
          "unknown_offer_tlvs": {
            "type": "array",
            "description": "Any extra fields we didn't know how to parse",
            "items": {
              "type": "object",
              "required": [
                "type",
                "length",
                "value"
              ],
              "additionalProperties": false,
              "properties": {
                "type": {
                  "type": "u64",
                  "description": "The type"
                },
                "length": {
                  "type": "u64",
                  "description": "The length"
                },
                "value": {
                  "type": "hex",
                  "description": "The value"
                }
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "bolt12 offer"
            ]
          },
          "valid": {
            "type": "boolean",
            "enum": [
              false
            ]
          }
        }
      },
      "then": {
        "required": [],
        "additionalProperties": false,
        "properties": {
          "type": {},
          "valid": {},
          "offer_id": {},
          "node_id": {},
          "signature": {},
          "chains": {},
          "currency": {},
          "minor_unit": {},
          "warning_unknown_offer_currency": {},
          "amount": {},
          "amount_msat": {},
          "send_invoice": {},
          "description": {},
          "vendor": {},
          "features": {},
          "absolute_expiry": {},
          "paths": {},
          "quantity_max": {},
          "unknown_offer_tlvs": {},
          "recurrence": {},
          "warning_missing_offer_node_id": {
            "type": "string",
            "description": "`offer_node_id` is not present"
          },
          "warning_invalid_offer_description": {
            "type": "string",
            "description": "`offer_description` is not valid UTF8"
          },
          "warning_missing_offer_description": {
            "type": "string",
            "description": "`offer_description` is not present"
          },
          "warning_invalid_offer_currency": {
            "type": "string",
            "description": "`offer_currency_code` is not valid UTF8"
          },
          "warning_invalid_offer_issuer": {
            "type": "string",
            "description": "`offer_issuer` is not valid UTF8"
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "bolt12 invoice_request"
            ]
          },
          "valid": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        }
      },
      "then": {
        "required": [
          "offer_node_id",
          "offer_description",
          "invreq_metadata",
          "invreq_payer_id",
          "signature"
        ],
        "additionalProperties": false,
        "properties": {
          "type": {},
          "valid": {},
          "offer_id": {
            "type": "hex",
            "description": "the id we use to identify this offer",
            "maxLength": 64,
            "minLength": 64
          },
          "offer_chains": {
            "type": "array",
            "description": "which blockchains this offer is for (missing implies bitcoin mainnet only)",
            "items": {
              "type": "hex",
              "description": "the genesis blockhash",
              "maxLength": 64,
              "minLength": 64
            }
          },
          "offer_metadata": {
            "type": "hex",
            "description": "any metadata the creator of the offer includes"
          },
          "offer_currency": {
            "type": "string",
            "description": "ISO 4217 code of the currency (missing implies Bitcoin)",
            "maxLength": 3,
            "minLength": 3
          },
          "warning_unknown_offer_currency": {
            "type": "string",
            "description": "The currency code is unknown (so no `currency_minor_unit`)"
          },
          "currency_minor_unit": {
            "type": "u32",
            "description": "the number of decimal places to apply to amount (if currency known)"
          },
          "offer_amount": {
            "type": "u64",
            "description": "the amount in the `offer_currency` adjusted by `currency_minor_unit`, if any"
          },
          "offer_amount_msat": {
            "type": "msat",
            "description": "the amount in bitcoin (if specified, and no `offer_currency`)"
          },
          "offer_description": {
            "type": "string",
            "description": "the description of the purpose of the offer"
          },
          "offer_issuer": {
            "type": "string",
            "description": "the description of the creator of the offer"
          },
          "offer_features": {
            "type": "hex",
            "description": "the feature bits of the offer"
          },
          "offer_absolute_expiry": {
            "type": "u64",
            "description": "UNIX timestamp of when this offer expires"
          },
          "offer_quantity_max": {
            "type": "u64",
            "description": "the maximum quantity (or, if 0, means any quantity)"
          },
          "offer_paths": {
            "type": "array",
            "description": "Paths to the destination",
            "items": {
              "type": "object",
              "required": [
                "first_node_id",
                "blinding",
                "path"
              ],
              "additionalProperties": false,
              "properties": {
                "first_node_id": {
                  "type": "pubkey",
                  "description": "the (presumably well-known) public key of the start of the path"
                },
                "blinding": {
                  "type": "pubkey",
                  "description": "blinding factor for this path"
                },
                "path": {
                  "type": "array",
                  "description": "an individual path",
                  "items": {
                    "type": "object",
                    "required": [
                      "blinded_node_id",
                      "encrypted_recipient_data"
                    ],
                    "additionalProperties": false,
                    "properties": {
                      "blinded_node_id": {
                        "type": "pubkey",
                        "description": "node_id of the hop"
                      },
                      "encrypted_recipient_data": {
                        "type": "hex",
                        "description": "encrypted TLV entry for this hop"
                      }
                    }
                  }
                }
              }
            }
          },
          "offer_node_id": {
            "type": "pubkey",
            "description": "public key of the offering node"
          },
          "offer_recurrence": {
            "type": "object",
            "description": "how often to this offer should be used",
            "required": [
              "period",
              "time_unit"
            ],
            "additionalProperties": false,
            "properties": {
              "time_unit": {
                "type": "u32",
                "description": "the BOLT12 time unit"
              },
              "time_unit_name": {
                "type": "string",
                "description": "the name of `time_unit` (if valid)"
              },
              "period": {
                "type": "u32",
                "description": "how many `time_unit` per payment period"
              },
              "basetime": {
                "type": "u64",
                "description": "period starts at this UNIX timestamp"
              },
              "start_any_period": {
                "type": "u64",
                "description": "you can start at any period (only if `basetime` present)"
              },
              "limit": {
                "type": "u32",
                "description": "maximum period number for recurrence"
              },
              "paywindow": {
                "type": "object",
                "description": "when within a period will payment be accepted (default is prior and during the period)",
                "required": [
                  "seconds_before",
                  "seconds_after"
                ],
                "additionalProperties": false,
                "properties": {
                  "seconds_before": {
                    "type": "u32",
                    "description": "seconds prior to period start"
                  },
                  "seconds_after": {
                    "type": "u32",
                    "description": "seconds after to period start"
                  },
                  "proportional_amount": {
                    "type": "boolean",
                    "enum": [
                      true
                    ],
                    "description": "amount should be scaled if payed after period start"
                  }
                }
              }
            }
          },
          "invreq_metadata": {
            "type": "hex",
            "description": "the payer-provided blob to derive invreq_payer_id"
          },
          "invreq_payer_id": {
            "type": "hex",
            "description": "the payer-provided key"
          },
          "invreq_chain": {
            "type": "hex",
            "description": "which blockchain this offer is for (missing implies bitcoin mainnet only)",
            "maxLength": 64,
            "minLength": 64
          },
          "invreq_amount_msat": {
            "type": "msat",
            "description": "the amount the invoice should be for"
          },
          "invreq_features": {
            "type": "hex",
            "description": "the feature bits of the invoice_request"
          },
          "invreq_quantity": {
            "type": "u64",
            "description": "the number of items to invoice for"
          },
          "invreq_payer_note": {
            "type": "string",
            "description": "a note attached by the payer"
          },
          "invreq_recurrence_counter": {
            "type": "u32",
            "description": "which number request this is for the same invoice"
          },
          "invreq_recurrence_start": {
            "type": "u32",
            "description": "when we're requesting to start an invoice at a non-zero period"
          },
          "signature": {
            "type": "bip340sig",
            "description": "BIP-340 signature of the `invreq_payer_id` on this invoice_request"
          },
          "unknown_invoice_request_tlvs": {
            "type": "array",
            "description": "Any extra fields we didn't know how to parse",
            "items": {
              "type": "object",
              "required": [
                "type",
                "length",
                "value"
              ],
              "additionalProperties": false,
              "properties": {
                "type": {
                  "type": "u64",
                  "description": "The type"
                },
                "length": {
                  "type": "u64",
                  "description": "The length"
                },
                "value": {
                  "type": "hex",
                  "description": "The value"
                }
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "bolt12 invoice_request"
            ]
          },
          "valid": {
            "type": "boolean",
            "enum": [
              false
            ]
          }
        }
      },
      "then": {
        "required": [],
        "additionalProperties": false,
        "properties": {
          "type": {},
          "valid": {},
          "offer_id": {},
          "offer_chains": {},
          "offer_metadata": {},
          "offer_currency": {},
          "warning_unknown_offer_currency": {},
          "currency_minor_unit": {},
          "offer_amount": {},
          "offer_amount_msat": {},
          "offer_description": {},
          "offer_issuer": {},
          "offer_features": {},
          "offer_absolute_expiry": {},
          "offer_quantity_max": {},
          "offer_paths": {},
          "offer_node_id": {},
          "offer_recurrence": {},
          "invreq_metadata": {},
          "invreq_payer_id": {},
          "invreq_chain": {},
          "invreq_amount_msat": {},
          "invreq_features": {},
          "invreq_quantity": {},
          "invreq_payer_note": {},
          "invreq_recurrence_counter": {},
          "invreq_recurrence_start": {},
          "warning_invalid_offer_description": {
            "type": "string",
            "description": "`offer_description` is not valid UTF8"
          },
          "warning_missing_offer_description": {
            "type": "string",
            "description": "`offer_description` is not present"
          },
          "warning_invalid_offer_currency": {
            "type": "string",
            "description": "`offer_currency_code` is not valid UTF8"
          },
          "warning_invalid_offer_issuer": {
            "type": "string",
            "description": "`offer_issuer` is not valid UTF8"
          },
          "warning_missing_invreq_metadata": {
            "type": "string",
            "description": "`invreq_metadata` is not present"
          },
          "warning_missing_invreq_payer_id": {
            "type": "string",
            "description": "`invreq_payer_id` is not present"
          },
          "warning_invalid_invreq_payer_note": {
            "type": "string",
            "description": "`invreq_payer_note` is not valid UTF8"
          },
          "warning_missing_invoice_request_signature": {
            "type": "string",
            "description": "`signature` is not present"
          },
          "warning_invalid_invoice_request_signature": {
            "type": "string",
            "description": "Incorrect `signature`"
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "bolt12 invoice"
            ]
          },
          "valid": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        }
      },
      "then": {
        "required": [
          "offer_node_id",
          "offer_description",
          "invreq_metadata",
          "invreq_payer_id",
          "invoice_paths",
          "invoice_created_at",
          "invoice_payment_hash",
          "invoice_amount_msat",
          "signature"
        ],
        "additionalProperties": false,
        "properties": {
          "type": {},
          "valid": {},
          "offer_id": {
            "type": "hex",
            "description": "the id we use to identify this offer",
            "maxLength": 64,
            "minLength": 64
          },
          "offer_chains": {
            "type": "array",
            "description": "which blockchains this offer is for (missing implies bitcoin mainnet only)",
            "items": {
              "type": "hex",
              "description": "the genesis blockhash",
              "maxLength": 64,
              "minLength": 64
            }
          },
          "offer_metadata": {
            "type": "hex",
            "description": "any metadata the creator of the offer includes"
          },
          "offer_currency": {
            "type": "string",
            "description": "ISO 4217 code of the currency (missing implies Bitcoin)",
            "maxLength": 3,
            "minLength": 3
          },
          "warning_unknown_offer_currency": {
            "type": "string",
            "description": "The currency code is unknown (so no `currency_minor_unit`)"
          },
          "currency_minor_unit": {
            "type": "u32",
            "description": "the number of decimal places to apply to amount (if currency known)"
          },
          "offer_amount": {
            "type": "u64",
            "description": "the amount in the `offer_currency` adjusted by `currency_minor_unit`, if any"
          },
          "offer_amount_msat": {
            "type": "msat",
            "description": "the amount in bitcoin (if specified, and no `offer_currency`)"
          },
          "offer_description": {
            "type": "string",
            "description": "the description of the purpose of the offer"
          },
          "offer_issuer": {
            "type": "string",
            "description": "the description of the creator of the offer"
          },
          "offer_features": {
            "type": "hex",
            "description": "the feature bits of the offer"
          },
          "offer_absolute_expiry": {
            "type": "u64",
            "description": "UNIX timestamp of when this offer expires"
          },
          "offer_quantity_max": {
            "type": "u64",
            "description": "the maximum quantity (or, if 0, means any quantity)"
          },
          "offer_paths": {
            "type": "array",
            "description": "Paths to the destination",
            "items": {
              "type": "object",
              "required": [
                "first_node_id",
                "blinding",
                "path"
              ],
              "additionalProperties": false,
              "properties": {
                "first_node_id": {
                  "type": "pubkey",
                  "description": "the (presumably well-known) public key of the start of the path"
                },
                "blinding": {
                  "type": "pubkey",
                  "description": "blinding factor for this path"
                },
                "path": {
                  "type": "array",
                  "description": "an individual path",
                  "items": {
                    "type": "object",
                    "required": [
                      "blinded_node_id",
                      "encrypted_recipient_data"
                    ],
                    "additionalProperties": false,
                    "properties": {
                      "blinded_node_id": {
                        "type": "pubkey",
                        "description": "node_id of the hop"
                      },
                      "encrypted_recipient_data": {
                        "type": "hex",
                        "description": "encrypted TLV entry for this hop"
                      }
                    }
                  }
                }
              }
            }
          },
          "offer_node_id": {
            "type": "pubkey",
            "description": "public key of the offering node"
          },
          "offer_recurrence": {
            "type": "object",
            "description": "how often to this offer should be used",
            "required": [
              "period",
              "time_unit"
            ],
            "additionalProperties": false,
            "properties": {
              "time_unit": {
                "type": "u32",
                "description": "the BOLT12 time unit"
              },
              "time_unit_name": {
                "type": "string",
                "description": "the name of `time_unit` (if valid)"
              },
              "period": {
                "type": "u32",
                "description": "how many `time_unit` per payment period"
              },
              "basetime": {
                "type": "u64",
                "description": "period starts at this UNIX timestamp"
              },
              "start_any_period": {
                "type": "u64",
                "description": "you can start at any period (only if `basetime` present)"
              },
              "limit": {
                "type": "u32",
                "description": "maximum period number for recurrence"
              },
              "paywindow": {
                "type": "object",
                "description": "when within a period will payment be accepted (default is prior and during the period)",
                "required": [
                  "seconds_before",
                  "seconds_after"
                ],
                "additionalProperties": false,
                "properties": {
                  "seconds_before": {
                    "type": "u32",
                    "description": "seconds prior to period start"
                  },
                  "seconds_after": {
                    "type": "u32",
                    "description": "seconds after to period start"
                  },
                  "proportional_amount": {
                    "type": "boolean",
                    "enum": [
                      true
                    ],
                    "description": "amount should be scaled if payed after period start"
                  }
                }
              }
            }
          },
          "invreq_metadata": {
            "type": "hex",
            "description": "the payer-provided blob to derive invreq_payer_id"
          },
          "invreq_payer_id": {
            "type": "hex",
            "description": "the payer-provided key"
          },
          "invreq_chain": {
            "type": "hex",
            "description": "which blockchain this offer is for (missing implies bitcoin mainnet only)",
            "maxLength": 64,
            "minLength": 64
          },
          "invreq_amount_msat": {
            "type": "msat",
            "description": "the amount the invoice should be for"
          },
          "invreq_features": {
            "type": "hex",
            "description": "the feature bits of the invoice_request"
          },
          "invreq_quantity": {
            "type": "u64",
            "description": "the number of items to invoice for"
          },
          "invreq_payer_note": {
            "type": "string",
            "description": "a note attached by the payer"
          },
          "invreq_recurrence_counter": {
            "type": "u32",
            "description": "which number request this is for the same invoice"
          },
          "invreq_recurrence_start": {
            "type": "u32",
            "description": "when we're requesting to start an invoice at a non-zero period"
          },
          "invoice_paths": {
            "type": "array",
            "description": "Paths to pay the destination",
            "items": {
              "type": "object",
              "required": [
                "first_node_id",
                "blinding",
                "payinfo",
                "path"
              ],
              "additionalProperties": false,
              "properties": {
                "first_node_id": {
                  "type": "pubkey",
                  "description": "the (presumably well-known) public key of the start of the path"
                },
                "blinding": {
                  "type": "pubkey",
                  "description": "blinding factor for this path"
                },
                "payinfo": {
                  "type": "object",
                  "required": [
                    "fee_base_msat",
                    "fee_proportional_millionths",
                    "cltv_expiry_delta",
                    "features"
                  ],
                  "additionalProperties": false,
                  "properties": {
                    "fee_base_msat": {
                      "type": "msat",
                      "description": "basefee for path"
                    },
                    "fee_proportional_millionths": {
                      "type": "u32",
                      "description": "proportional fee for path"
                    },
                    "cltv_expiry_delta": {
                      "type": "u32",
                      "description": "CLTV delta for path"
                    },
                    "features": {
                      "type": "hex",
                      "description": "features allowed for path"
                    }
                  }
                },
                "path": {
                  "type": "array",
                  "description": "an individual path",
                  "items": {
                    "type": "object",
                    "required": [
                      "blinded_node_id",
                      "encrypted_recipient_data"
                    ],
                    "additionalProperties": false,
                    "properties": {
                      "blinded_node_id": {
                        "type": "pubkey",
                        "description": "node_id of the hop"
                      },
                      "encrypted_recipient_data": {
                        "type": "hex",
                        "description": "encrypted TLV entry for this hop"
                      }
                    }
                  }
                }
              }
            }
          },
          "invoice_created_at": {
            "type": "u64",
            "description": "the UNIX timestamp of invoice creation"
          },
          "invoice_relative_expiry": {
            "type": "u32",
            "description": "the number of seconds after *invoice_created_at* when this expires"
          },
          "invoice_payment_hash": {
            "type": "hex",
            "description": "the hash of the *payment_preimage*",
            "maxLength": 64,
            "minLength": 64
          },
          "invoice_amount_msat": {
            "type": "msat",
            "description": "the amount required to fulfill invoice"
          },
          "invoice_fallbacks": {
            "type": "array",
            "description": "onchain addresses",
            "items": {
              "type": "object",
              "required": [
                "version",
                "hex"
              ],
              "additionalProperties": false,
              "properties": {
                "version": {
                  "type": "u8",
                  "description": "Segwit address version"
                },
                "hex": {
                  "type": "hex",
                  "description": "Raw encoded segwit address"
                },
                "address": {
                  "type": "string",
                  "description": "bech32 segwit address"
                }
              }
            }
          },
          "invoice_features": {
            "type": "hex",
            "description": "the feature bits of the invoice"
          },
          "invoice_node_id": {
            "type": "pubkey",
            "description": "the id to pay (usually the same as offer_node_id)"
          },
          "invoice_recurrence_basetime": {
            "type": "u64",
            "description": "the UNIX timestamp to base the invoice periods on"
          },
          "signature": {
            "type": "bip340sig",
            "description": "BIP-340 signature of the `offer_node_id` on this invoice"
          },
          "unknown_invoice_tlvs": {
            "type": "array",
            "description": "Any extra fields we didn't know how to parse",
            "items": {
              "type": "object",
              "required": [
                "type",
                "length",
                "value"
              ],
              "additionalProperties": false,
              "properties": {
                "type": {
                  "type": "u64",
                  "description": "The type"
                },
                "length": {
                  "type": "u64",
                  "description": "The length"
                },
                "value": {
                  "type": "hex",
                  "description": "The value"
                }
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "bolt12 invoice"
            ]
          },
          "valid": {
            "type": "boolean",
            "enum": [
              false
            ]
          }
        }
      },
      "then": {
        "required": [],
        "additionalProperties": false,
        "properties": {
          "type": {},
          "valid": {},
          "offer_id": {},
          "offer_chains": {},
          "offer_metadata": {},
          "offer_currency": {},
          "warning_unknown_offer_currency": {},
          "currency_minor_unit": {},
          "offer_amount": {},
          "offer_amount_msat": {},
          "offer_description": {},
          "offer_issuer": {},
          "offer_features": {},
          "offer_absolute_expiry": {},
          "offer_quantity_max": {},
          "offer_paths": {},
          "offer_node_id": {},
          "offer_recurrence": {},
          "invreq_metadata": {},
          "invreq_payer_id": {},
          "invreq_chain": {},
          "invreq_amount_msat": {},
          "invreq_features": {},
          "invreq_quantity": {},
          "invreq_payer_note": {},
          "invreq_node_id": {},
          "invreq_recurrence_counter": {},
          "invreq_recurrence_start": {},
          "warning_invalid_offer_description": {
            "type": "string",
            "description": "`offer_description` is not valid UTF8"
          },
          "warning_missing_offer_description": {
            "type": "string",
            "description": "`offer_description` is not present"
          },
          "warning_invalid_offer_currency": {
            "type": "string",
            "description": "`offer_currency_code` is not valid UTF8"
          },
          "warning_invalid_offer_issuer": {
            "type": "string",
            "description": "`offer_issuer` is not valid UTF8"
          },
          "warning_missing_invreq_metadata": {
            "type": "string",
            "description": "`invreq_metadata` is not present"
          },
          "warning_invalid_invreq_payer_note": {
            "type": "string",
            "description": "`invreq_payer_note` is not valid UTF8"
          },
          "warning_missing_invoice_paths": {
            "type": "string",
            "description": "`invoice_paths` is not present"
          },
          "warning_missing_invoice_blindedpay": {
            "type": "string",
            "description": "`invoice_blindedpay` is not present"
          },
          "warning_missing_invoice_created_at": {
            "type": "string",
            "description": "`invoice_created_at` is not present"
          },
          "warning_missing_invoice_payment_hash": {
            "type": "string",
            "description": "`invoice_payment_hash` is not present"
          },
          "warning_missing_invoice_amount": {
            "type": "string",
            "description": "`invoice_amount` is not present"
          },
          "warning_missing_invoice_recurrence_basetime": {
            "type": "string",
            "description": "`invoice_recurrence_basetime` is not present"
          },
          "warning_missing_invoice_node_id": {
            "type": "string",
            "description": "`invoice_node_id` is not present"
          },
          "warning_missing_invoice_signature": {
            "type": "string",
            "description": "`signature` is not present"
          },
          "warning_invalid_invoice_signature": {
            "type": "string",
            "description": "Incorrect `signature`"
          },
          "fallbacks": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "version",
                "hex"
              ],
              "properties": {
                "version": {},
                "hex": {},
                "address": {},
                "warning_invoice_fallbacks_version_invalid": {
                  "type": "string",
                  "description": "`version` is > 16"
                }
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "bolt11 invoice"
            ]
          },
          "valid": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        }
      },
      "then": {
        "required": [
          "currency",
          "created_at",
          "expiry",
          "payee",
          "min_final_cltv_expiry",
          "payment_hash",
          "signature"
        ],
        "additionalProperties": false,
        "properties": {
          "type": {},
          "valid": {},
          "currency": {
            "type": "string",
            "description": "the BIP173 name for the currency"
          },
          "created_at": {
            "type": "u64",
            "description": "the UNIX-style timestamp of the invoice"
          },
          "expiry": {
            "type": "u64",
            "description": "the number of seconds this is valid after `created_at`"
          },
          "payee": {
            "type": "pubkey",
            "description": "the public key of the recipient"
          },
          "amount_msat": {
            "type": "msat",
            "description": "Amount the invoice asked for"
          },
          "payment_hash": {
            "type": "hash",
            "description": "the hash of the *payment_preimage*"
          },
          "signature": {
            "type": "signature",
            "description": "signature of the *payee* on this invoice"
          },
          "description": {
            "type": "string",
            "description": "the description of the purpose of the purchase"
          },
          "description_hash": {
            "type": "hash",
            "description": "the hash of the description, in place of *description*"
          },
          "min_final_cltv_expiry": {
            "type": "u32",
            "description": "the minimum CLTV delay for the final node"
          },
          "payment_secret": {
            "type": "secret",
            "description": "the secret to hand to the payee node"
          },
          "features": {
            "type": "hex",
            "description": "the features bitmap for this invoice"
          },
          "payment_metadata": {
            "type": "hex",
            "description": "the payment_metadata to put in the payment"
          },
          "fallbacks": {
            "type": "array",
            "description": "onchain addresses",
            "items": {
              "type": "object",
              "required": [
                "type",
                "hex"
              ],
              "additionalProperties": false,
              "properties": {
                "type": {
                  "type": "string",
                  "description": "the address type (if known)",
                  "enum": [
                    "P2PKH",
                    "P2SH",
                    "P2WPKH",
                    "P2WSH"
                  ]
                },
                "addr": {
                  "type": "string",
                  "description": "the address in appropriate format for *type*"
                },
                "hex": {
                  "type": "hex",
                  "description": "Raw encoded address"
                }
              }
            }
          },
          "routes": {
            "type": "array",
            "description": "Route hints to the *payee*",
            "items": {
              "type": "array",
              "description": "hops in the route",
              "items": {
                "type": "object",
                "required": [
                  "pubkey",
                  "short_channel_id",
                  "fee_base_msat",
                  "fee_proportional_millionths",
                  "cltv_expiry_delta"
                ],
                "additionalProperties": false,
                "properties": {
                  "pubkey": {
                    "type": "pubkey",
                    "description": "the public key of the node"
                  },
                  "short_channel_id": {
                    "type": "short_channel_id",
                    "description": "a channel to the next peer"
                  },
                  "fee_base_msat": {
                    "type": "msat",
                    "description": "the base fee for payments"
                  },
                  "fee_proportional_millionths": {
                    "type": "u32",
                    "description": "the parts-per-million fee for payments"
                  },
                  "cltv_expiry_delta": {
                    "type": "u32",
                    "description": "the CLTV delta across this hop"
                  }
                }
              }
            }
          },
          "extra": {
            "type": "array",
            "description": "Any extra fields we didn't know how to parse",
            "items": {
              "type": "object",
              "required": [
                "tag",
                "data"
              ],
              "additionalProperties": false,
              "properties": {
                "tag": {
                  "type": "string",
                  "description": "The bech32 letter which identifies this field",
                  "maxLength": 1,
                  "minLength": 1
                },
                "data": {
                  "type": "string",
                  "description": "The bech32 data for this field"
                }
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "rune"
            ]
          },
          "valid": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        }
      },
      "then": {
        "required": [
          "string",
          "restrictions",
          "valid"
        ],
        "additionalProperties": false,
        "properties": {
          "unique_id": {
            "type": "string",
            "description": "unique id (always a numeric id on runes we create)"
          },
          "version": {
            "type": "string",
            "description": "rune version, not currently set on runes we create"
          },
          "valid": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "type": {},
          "string": {
            "type": "string",
            "description": "the string encoding of the rune"
          },
          "restrictions": {
            "type": "array",
            "description": "restrictions built into the rune: all must pass",
            "items": {
              "type": "object",
              "required": [
                "alternatives",
                "summary"
              ],
              "additionalProperties": false,
              "properties": {
                "alternatives": {
                  "type": "array",
                  "description": "each way restriction can be met: any can pass",
                  "items": {
                    "type": "string",
                    "description": "the alternative of form fieldname condition fieldname"
                  }
                },
                "summary": {
                  "type": "string",
                  "description": "human-readable summary of this restriction"
                }
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "rune"
            ]
          },
          "valid": {
            "type": "boolean",
            "enum": [
              false
            ]
          }
        }
      },
      "then": {
        "required": [
          "valid"
        ],
        "additionalProperties": false,
        "properties": {
          "valid": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "type": {},
          "warning_rune_invalid_utf8": {
            "type": "string",
            "description": "the rune contains invalid UTF-8 strings"
          },
          "hex": {
            "type": "hex",
            "description": "the raw rune in hex"
          }
        }
      }
    }
  ]
}
