mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 22:45:27 +01:00
decode: print unknown fields in bolt12 strings.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
ef2f4a0648
commit
bc283cecf2
3 changed files with 121 additions and 1 deletions
|
@ -60,6 +60,10 @@ If **type** is "bolt12 offer", and **valid** is *true*:
|
||||||
- **seconds\_before** (u32): seconds prior to period start
|
- **seconds\_before** (u32): seconds prior to period start
|
||||||
- **seconds\_after** (u32): seconds after 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*)
|
- **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:
|
- the following warnings are possible:
|
||||||
- **warning\_unknown\_offer\_currency**: The currency code is unknown (so no `currency_minor_unit`)
|
- **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\_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\_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
|
- **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:
|
- the following warnings are possible:
|
||||||
- **warning\_unknown\_offer\_currency**: The currency code is unknown (so no `currency_minor_unit`)
|
- **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\_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\_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
|
- **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:
|
- the following warnings are possible:
|
||||||
- **warning\_unknown\_offer\_currency**: The currency code is unknown (so no `currency_minor_unit`)
|
- **warning\_unknown\_offer\_currency**: The currency code is unknown (so no `currency_minor_unit`)
|
||||||
|
|
||||||
|
@ -290,4 +302,4 @@ RESOURCES
|
||||||
|
|
||||||
Main web site: <https://github.com/ElementsProject/lightning>
|
Main web site: <https://github.com/ElementsProject/lightning>
|
||||||
|
|
||||||
[comment]: # ( SHA256STAMP:e5791741d8b466b2f080dcde3e5a7770ce3a820d0b7e5635e6b6cfd1f104c09d)
|
[comment]: # ( SHA256STAMP:1d13c0e0619d05d8c49cf9fbed90f0baf260d59fd8c16bd283d3b211e8be9878)
|
||||||
|
|
|
@ -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": {},
|
"absolute_expiry": {},
|
||||||
"paths": {},
|
"paths": {},
|
||||||
"quantity_max": {},
|
"quantity_max": {},
|
||||||
|
"unknown_offer_tlvs": {},
|
||||||
"recurrence": {},
|
"recurrence": {},
|
||||||
"warning_missing_offer_node_id": {
|
"warning_missing_offer_node_id": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
@ -530,6 +558,33 @@
|
||||||
"signature": {
|
"signature": {
|
||||||
"type": "bip340sig",
|
"type": "bip340sig",
|
||||||
"description": "BIP-340 signature of the `invreq_payer_id` on this invoice_request"
|
"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": {
|
"signature": {
|
||||||
"type": "bip340sig",
|
"type": "bip340sig",
|
||||||
"description": "BIP-340 signature of the `offer_node_id` on this invoice"
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -432,6 +432,29 @@ static bool json_add_offer_fields(struct json_stream *js,
|
||||||
return valid;
|
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)
|
static void json_add_offer(struct json_stream *js, const struct tlv_offer *offer)
|
||||||
{
|
{
|
||||||
struct sha256 offer_id;
|
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");
|
"offers without a node_id are invalid");
|
||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
|
json_add_extra_fields(js, "unknown_offer_tlvs", offer->fields);
|
||||||
json_add_bool(js, "valid", valid);
|
json_add_bool(js, "valid", valid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -665,6 +689,7 @@ static void json_add_invoice_request(struct json_stream *js,
|
||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
json_add_extra_fields(js, "unknown_invoice_request_tlvs", invreq->fields);
|
||||||
json_add_bool(js, "valid", valid);
|
json_add_bool(js, "valid", valid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -815,6 +840,7 @@ static void json_add_b12_invoice(struct json_stream *js,
|
||||||
/* invoice_decode checked this */
|
/* invoice_decode checked this */
|
||||||
json_add_bip340sig(js, "signature", invoice->signature);
|
json_add_bip340sig(js, "signature", invoice->signature);
|
||||||
|
|
||||||
|
json_add_extra_fields(js, "unknown_invoice_tlvs", invoice->fields);
|
||||||
json_add_bool(js, "valid", valid);
|
json_add_bool(js, "valid", valid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue