patch remove-payer-backcompat.patch

This commit is contained in:
Rusty Russell
2021-07-05 15:53:13 +09:30
committed by neil saitug
parent e4e1396447
commit 424ac84263
9 changed files with 18 additions and 132 deletions

View File

@@ -674,10 +674,7 @@ static void json_add_invoice_request(struct json_stream *js,
* - MUST fail the request if there is no `payer_signature` field.
* - MUST fail the request if `payer_signature` is not correct.
*/
/* 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",
@@ -691,21 +688,7 @@ static void json_add_invoice_request(struct json_stream *js,
} 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",
"recurrence_signature",
invreq->payer_key,
invreq->recurrence_signature)) {
json_add_string(js, "warning_invoice_request_invalid_recurrence_signature",
"Bad recurrence_signature");
valid = false;
}
valid = false;
}
json_add_bool(js, "valid", valid);

View File

@@ -408,21 +408,6 @@ static struct command_result *check_previous_invoice(struct command *cmd,
return send_outreq(cmd->plugin, req);
}
/* Obsolete recurrence_signature; we still check if present. */
static bool check_recurrence_sig(const struct tlv_invoice_request *invreq,
const struct pubkey32 *payer_key,
const struct bip340sig *sig)
{
struct sha256 merkle, sighash;
merkle_tlv(invreq->fields, &merkle);
sighash_from_merkle("invoice_request", "recurrence_signature",
&merkle, &sighash);
return secp256k1_schnorrsig_verify(secp256k1_ctx,
sig->u8,
sighash.u.u8, &payer_key->pubkey) == 1;
}
/* BOLT-offers #12:
* - MUST fail the request if `payer_signature` is not correct.
*/
@@ -721,17 +706,13 @@ static struct command_result *listoffers_done(struct command *cmd,
return err;
}
/* FIXME: payer_signature is now always required, but we let it go
* for now. */
if (!deprecated_apis) {
err = invreq_must_have(cmd, ir, payer_signature);
if (err)
return err;
if (!check_payer_sig(ir->invreq,
ir->invreq->payer_key,
ir->invreq->payer_signature)) {
return fail_invreq(cmd, ir, "bad payer_signature");
}
err = invreq_must_have(cmd, ir, payer_signature);
if (err)
return err;
if (!check_payer_sig(ir->invreq,
ir->invreq->payer_key,
ir->invreq->payer_signature)) {
return fail_invreq(cmd, ir, "bad payer_signature");
}
if (ir->offer->recurrence) {
@@ -748,23 +729,6 @@ static struct command_result *listoffers_done(struct command *cmd,
err = invreq_must_have(cmd, ir, recurrence_counter);
if (err)
return err;
if (deprecated_apis) {
if (ir->invreq->recurrence_signature) {
if (!check_recurrence_sig(ir->invreq,
ir->invreq->payer_key,
ir->invreq->recurrence_signature)) {
return fail_invreq(cmd, ir,
"bad recurrence_signature");
}
} else {
/* You really do need payer_signature if
* you're using recurrence: we rely on it! */
err = invreq_must_have(cmd, ir, payer_signature);
if (err)
return err;
}
}
} else {
/* BOLT-offers #12:
* - otherwise (the offer had no `recurrence`):