mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-04 04:54:47 +01:00
fe161ff962
If we have conditional fields, we often set `additionalProperties` `true` at the top-level, but then we have to make sure to cover all the possible combinations in conditionals, so unintended additions don't appear. This revealed missing fields in delinvoice, for example. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
153 lines
3.4 KiB
JSON
153 lines
3.4 KiB
JSON
{
|
|
"$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"
|
|
},
|
|
"msatoshi": {
|
|
"deprecated": "true"
|
|
},
|
|
"amount_msat": {
|
|
"type": "msat",
|
|
"description": "the amount required to pay this invoice"
|
|
},
|
|
"description": {
|
|
"type": "string",
|
|
"description": "description used in the invoice"
|
|
},
|
|
"payment_hash": {
|
|
"type": "hex",
|
|
"description": "the hash of the *payment_preimage* which will prove payment",
|
|
"maxLength": 64,
|
|
"minLength": 64
|
|
},
|
|
"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"
|
|
}
|
|
}
|
|
},
|
|
"else": {
|
|
"required": [ "bolt11" ],
|
|
"additionalProperties": false,
|
|
"properties": {
|
|
"label": { },
|
|
"bolt11": { },
|
|
"status": { },
|
|
"expires_at": { },
|
|
"msatoshi": { },
|
|
"amount_msat": { },
|
|
"description": { },
|
|
"payment_hash": { },
|
|
"pay_index": { },
|
|
"amount_received_msat": { },
|
|
"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": { },
|
|
"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": "hex",
|
|
"description": "SHA256 of this is the *payment_hash* offered in the invoice",
|
|
"maxLength": 64,
|
|
"minLength": 64
|
|
}
|
|
}
|
|
},
|
|
"else": {
|
|
"additionalProperties": false,
|
|
"properties": {
|
|
"label": { },
|
|
"bolt11": { },
|
|
"bolt12": { },
|
|
"status": { },
|
|
"msatoshi": { },
|
|
"amount_msat": { },
|
|
"description": { },
|
|
"payment_hash": { },
|
|
"expires_at": { },
|
|
"pay_index": { },
|
|
"local_offer_id": { }
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|