lightningd: insist on payment_secret if bit compulsory on invoices.

This grandfathers in old invoices for the moment.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2021-07-13 06:18:58 +09:30
committed by neil saitug
parent 9eb531868f
commit e7716c86fb
2 changed files with 26 additions and 3 deletions

View File

@@ -1,3 +1,4 @@
#include <common/features.h>
#include <common/timeout.h>
#include <lightningd/htlc_end.h>
#include <lightningd/htlc_set.h>
@@ -114,6 +115,17 @@ void htlc_set_add(struct lightningd *ld,
return;
}
/* If we insist on a payment secret, it must always have it */
if (feature_is_set(details->features, COMPULSORY_FEATURE(OPT_PAYMENT_SECRET))
&& !payment_secret) {
log_debug(ld->log, "Missing payment_secret, but required for %s",
type_to_string(tmpctx, struct sha256,
&hin->payment_hash));
local_fail_in_htlc(hin,
take(failmsg_incorrect_or_unknown(NULL, ld, hin)));
return;
}
/* BOLT #4:
* - otherwise, if it supports `basic_mpp`:
* - MUST add it to the HTLC set corresponding to that `payment_hash`.