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

@@ -19,6 +19,7 @@
#define ERROR_USAGE 3
static bool well_formed = true;
bool deprecated_apis = true;
/* Tal wrappers for opt. */
static void *opt_allocfn(size_t size)
@@ -72,6 +73,12 @@ static void print_chains(const struct bitcoin_blkid *chains)
printf("\n");
}
static void print_chain(const struct bitcoin_blkid *chain)
{
printf("chain: %s\n",
type_to_string(tmpctx, struct bitcoin_blkid, chain));
}
static bool print_amount(const struct bitcoin_blkid *chains,
const char *iso4217, u64 amount)
{
@@ -532,8 +539,8 @@ int main(int argc, char *argv[])
if (!invreq)
errx(ERROR_BAD_DECODE, "Bad invoice_request: %s", fail);
if (invreq->chains)
print_chains(invreq->chains);
if (invreq->chain)
print_chain(invreq->chain);
if (must_have(invreq, payer_key))
print_payer_key(invreq->payer_key, invreq->payer_info);
if (invreq->payer_note)
@@ -541,7 +548,7 @@ int main(int argc, char *argv[])
if (must_have(invreq, offer_id))
print_offer_id(invreq->offer_id);
if (must_have(invreq, amount))
well_formed &= print_amount(invreq->chains,
well_formed &= print_amount(invreq->chain,
NULL,
*invreq->amount);
if (invreq->features)
@@ -569,14 +576,14 @@ int main(int argc, char *argv[])
if (!invoice)
errx(ERROR_BAD_DECODE, "Bad invoice: %s", fail);
if (invoice->chains)
print_chains(invoice->chains);
if (invoice->chain)
print_chain(invoice->chain);
if (invoice->offer_id) {
print_offer_id(invoice->offer_id);
}
if (must_have(invoice, amount))
well_formed &= print_amount(invoice->chains,
well_formed &= print_amount(invoice->chain,
NULL,
*invoice->amount);
if (must_have(invoice, description))