BOLT 12: switch invoice_request/invoice to singular chain field.

We keep the now-removed chains field, and in deprecated mode, we set it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-EXPERIMENTAL: bolt12: `chains` in invoice_request and invoice is deprecated, `chain` is used instead.
This commit is contained in:
Rusty Russell
2021-10-08 13:57:29 +10:30
committed by Christian Decker
parent 45bf7a3974
commit c92ce59892
13 changed files with 98 additions and 41 deletions

View File

@@ -565,6 +565,8 @@ static void json_add_b12_invoice(struct json_stream *js,
if (invoice->chains)
json_add_chains(js, invoice->chains);
if (invoice->chain)
json_add_sha256(js, "chain", &invoice->chain->shad.sha);
if (invoice->offer_id)
json_add_sha256(js, "offer_id", invoice->offer_id);
@@ -700,7 +702,8 @@ static void json_add_b12_invoice(struct json_stream *js,
json_add_u32(js, "min_final_cltv_expiry", 18);
if (invoice->fallbacks)
valid &= json_add_fallbacks(js, invoice->chains,
valid &= json_add_fallbacks(js,
invoice->chain ? invoice->chain : invoice->chains,
invoice->fallbacks->fallbacks);
/* BOLT-offers #12:
@@ -749,6 +752,9 @@ static void json_add_invoice_request(struct json_stream *js,
if (invreq->chains)
json_add_chains(js, invreq->chains);
if (invreq->chain)
json_add_sha256(js, "chain", &invreq->chain->shad.sha);
/* BOLT-offers #12:
* - MUST fail the request if `payer_key` is not present.
* - MUST fail the request if `chains` does not include (or imply) a supported chain.