mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-04 14:54:26 +01:00
BOLT 12: update to include replace_invoice options.
We don't support it (yet), but update the spec to include it. We include the previous field (recurrence_signature) as a shim for the moment, for compat with existing nodes. It's ugly, but next release we'll stop *sending* it, then finally we'll stop accepting it! Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -665,14 +665,31 @@ static void json_add_invoice_request(struct json_stream *js,
|
||||
json_add_hex_talarr(js, "payer_info", invreq->payer_info);
|
||||
|
||||
/* BOLT-offers #12:
|
||||
* - if the offer had a `recurrence`:
|
||||
* - MUST fail the request if there is no `recurrence_counter` field.
|
||||
* - MUST fail the request if there is no `recurrence_signature` field.
|
||||
* - MUST fail the request if `recurrence_signature` is not correct.
|
||||
* - MUST fail the request if there is no `payer_signature` field.
|
||||
* - MUST fail the request if `payer_signature` is not correct.
|
||||
*/
|
||||
if (invreq->recurrence_signature) {
|
||||
json_add_bip340sig(js, "recurrence_signature",
|
||||
invreq->recurrence_signature);
|
||||
/* Older spec didn't have this, so we allow omission for now. */
|
||||
if (invreq->payer_signature) {
|
||||
json_add_bip340sig(js, "payer_signature",
|
||||
invreq->payer_signature);
|
||||
if (invreq->payer_key
|
||||
&& !bolt12_check_signature(invreq->fields,
|
||||
"invoice_request",
|
||||
"payer_signature",
|
||||
invreq->payer_key,
|
||||
invreq->payer_signature)) {
|
||||
json_add_string(js, "warning_invoice_request_invalid_payer_signature",
|
||||
"Bad payer_signature");
|
||||
valid = false;
|
||||
}
|
||||
} else {
|
||||
json_add_string(js, "warning_invoice_request_missing_payer_signature",
|
||||
"Missing payer_signature");
|
||||
if (!deprecated_apis)
|
||||
valid = false;
|
||||
}
|
||||
|
||||
if (deprecated_apis && invreq->recurrence_counter) {
|
||||
if (invreq->payer_key
|
||||
&& !bolt12_check_signature(invreq->fields,
|
||||
"invoice_request",
|
||||
@@ -680,13 +697,9 @@ static void json_add_invoice_request(struct json_stream *js,
|
||||
invreq->payer_key,
|
||||
invreq->recurrence_signature)) {
|
||||
json_add_string(js, "warning_invoice_request_invalid_recurrence_signature",
|
||||
"Bad recurrence_signature");
|
||||
"Bad recurrence_signature");
|
||||
valid = false;
|
||||
}
|
||||
} else if (invreq->recurrence_counter) {
|
||||
json_add_string(js, "warning_invoice_request_missing_recurrence_signature",
|
||||
"invoice_request requires recurrence_signature");
|
||||
valid = false;
|
||||
}
|
||||
|
||||
json_add_bool(js, "valid", valid);
|
||||
|
||||
Reference in New Issue
Block a user