diff --git a/doc/lightning-decode.7.md b/doc/lightning-decode.7.md index aa8144756..1ecf05503 100644 --- a/doc/lightning-decode.7.md +++ b/doc/lightning-decode.7.md @@ -60,6 +60,10 @@ If **type** is "bolt12 offer", and **valid** is *true*: - **seconds\_before** (u32): seconds prior to period start - **seconds\_after** (u32): seconds after to period start - **proportional\_amount** (boolean, optional): amount should be scaled if payed after period start (always *true*) + - **unknown\_offer\_tlvs** (array of objects, optional): Any extra fields we didn't know how to parse: + - **type** (u64): The type + - **length** (u64): The length + - **value** (hex): The value - the following warnings are possible: - **warning\_unknown\_offer\_currency**: The currency code is unknown (so no `currency_minor_unit`) @@ -115,6 +119,10 @@ If **type** is "bolt12 invoice_request", and **valid** is *true*: - **invreq\_payer\_note** (string, optional): a note attached by the payer - **invreq\_recurrence\_counter** (u32, optional): which number request this is for the same invoice - **invreq\_recurrence\_start** (u32, optional): when we're requesting to start an invoice at a non-zero period + - **unknown\_invoice\_request\_tlvs** (array of objects, optional): Any extra fields we didn't know how to parse: + - **type** (u64): The type + - **length** (u64): The length + - **value** (hex): The value - the following warnings are possible: - **warning\_unknown\_offer\_currency**: The currency code is unknown (so no `currency_minor_unit`) @@ -195,6 +203,10 @@ If **type** is "bolt12 invoice", and **valid** is *true*: - **invoice\_features** (hex, optional): the feature bits of the invoice - **invoice\_node\_id** (pubkey, optional): the id to pay (usually the same as offer_node_id) - **invoice\_recurrence\_basetime** (u64, optional): the UNIX timestamp to base the invoice periods on + - **unknown\_invoice\_tlvs** (array of objects, optional): Any extra fields we didn't know how to parse: + - **type** (u64): The type + - **length** (u64): The length + - **value** (hex): The value - the following warnings are possible: - **warning\_unknown\_offer\_currency**: The currency code is unknown (so no `currency_minor_unit`) @@ -290,4 +302,4 @@ RESOURCES Main web site: -[comment]: # ( SHA256STAMP:e5791741d8b466b2f080dcde3e5a7770ce3a820d0b7e5635e6b6cfd1f104c09d) +[comment]: # ( SHA256STAMP:1d13c0e0619d05d8c49cf9fbed90f0baf260d59fd8c16bd283d3b211e8be9878) diff --git a/doc/schemas/decode.schema.json b/doc/schemas/decode.schema.json index ee5935418..ca5d94358 100644 --- a/doc/schemas/decode.schema.json +++ b/doc/schemas/decode.schema.json @@ -221,6 +221,33 @@ } } } + }, + "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" + } + } + } } } } @@ -264,6 +291,7 @@ "absolute_expiry": {}, "paths": {}, "quantity_max": {}, + "unknown_offer_tlvs": {}, "recurrence": {}, "warning_missing_offer_node_id": { "type": "string", @@ -530,6 +558,33 @@ "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" + } + } + } } } } @@ -984,6 +1039,33 @@ "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" + } + } + } } } } diff --git a/plugins/offers.c b/plugins/offers.c index dc7c7d1ad..89e0a3340 100644 --- a/plugins/offers.c +++ b/plugins/offers.c @@ -432,6 +432,29 @@ static bool json_add_offer_fields(struct json_stream *js, return valid; } +static void json_add_extra_fields(struct json_stream *js, + const char *fieldname, + const struct tlv_field *fields) +{ + bool have_extra = false; + + for (size_t i = 0; i < tal_count(fields); i++) { + if (fields[i].meta) + continue; + if (!have_extra) { + json_array_start(js, fieldname); + have_extra = true; + } + json_object_start(js, NULL); + json_add_u64(js, "type", fields[i].numtype); + json_add_u64(js, "length", fields[i].length); + json_add_hex(js, "value", + fields[i].value, fields[i].length); + } + if (have_extra) + json_array_end(js); +} + static void json_add_offer(struct json_stream *js, const struct tlv_offer *offer) { struct sha256 offer_id; @@ -465,6 +488,7 @@ static void json_add_offer(struct json_stream *js, const struct tlv_offer *offer "offers without a node_id are invalid"); valid = false; } + json_add_extra_fields(js, "unknown_offer_tlvs", offer->fields); json_add_bool(js, "valid", valid); } @@ -665,6 +689,7 @@ static void json_add_invoice_request(struct json_stream *js, valid = false; } + json_add_extra_fields(js, "unknown_invoice_request_tlvs", invreq->fields); json_add_bool(js, "valid", valid); } @@ -815,6 +840,7 @@ static void json_add_b12_invoice(struct json_stream *js, /* invoice_decode checked this */ json_add_bip340sig(js, "signature", invoice->signature); + json_add_extra_fields(js, "unknown_invoice_tlvs", invoice->fields); json_add_bool(js, "valid", valid); }