bolt12: import latest spec (timestamp -> created_at).

@shesek points out that we called this field created_at in bolt11 decode,
which makes more sense anyway.

Changelog-EXPERIMENTAL: bolt12 decode `timestamp` field deprecated in favor of new name `created_at`.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2021-07-21 11:01:39 +09:30
committed by neil saitug
parent 90c5f9a051
commit 7769903f1a
13 changed files with 82 additions and 75 deletions

View File

@@ -543,13 +543,16 @@ static void json_add_b12_invoice(struct json_stream *js,
tal_bytelen(invoice->payer_note));
/* BOLT-offers #12:
* - MUST reject the invoice if `timestamp` is not present.
* - MUST reject the invoice if `created_at` is not present.
*/
if (invoice->timestamp)
json_add_u64(js, "timestamp", *invoice->timestamp);
else {
json_add_string(js, "warning_invoice_missing_timestamp",
"invoices without a timestamp are invalid");
if (invoice->created_at) {
/* FIXME: Remove soon! */
if (deprecated_apis)
json_add_u64(js, "timestamp", *invoice->created_at);
json_add_u64(js, "created_at", *invoice->created_at);
} else {
json_add_string(js, "warning_invoice_missing_created_at",
"invoices without created_at are invalid");
valid = false;
}
@@ -567,7 +570,7 @@ static void json_add_b12_invoice(struct json_stream *js,
/* BOLT-offers #12:
*
* - if the expiry for accepting payment is not 7200 seconds after
* `timestamp`:
* `created_at`:
* - MUST set `relative_expiry`
*/
if (invoice->relative_expiry)