From 50058df82049b10f32d0d6e832cd487e3bcc3147 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Fri, 18 Aug 2023 10:36:19 +0200 Subject: [PATCH] openingd: Clean up channel_type_accept The `accept_zeroconf` parameter is pointless, since it's too early to check that anyway. Keeping it in there would suggest otherwise, so remove it. --- common/channel_type.c | 12 +----------- common/channel_type.h | 3 +-- openingd/dualopend.c | 3 +-- openingd/openingd.c | 19 +++++++++---------- 4 files changed, 12 insertions(+), 25 deletions(-) diff --git a/common/channel_type.c b/common/channel_type.c index 546b21a90173..fef29e4cb3ad 100644 --- a/common/channel_type.c +++ b/common/channel_type.c @@ -142,8 +142,7 @@ struct channel_type *channel_type_from(const tal_t *ctx, struct channel_type *channel_type_accept(const tal_t *ctx, const u8 *t, const struct feature_set *our_features, - const u8 *their_features, - bool accept_zeroconf) + const u8 *their_features) { struct channel_type *ctype, proposed; /* Need to copy since we're going to blank variant bits for equality. */ @@ -183,15 +182,6 @@ struct channel_type *channel_type_accept(const tal_t *ctx, } } - /* BOLT #2: - * The receiving node MUST fail the channel if: - *... - * - if `type` includes `option_zeroconf` and it does not trust the - * sender to open an unconfirmed channel. - */ - if (feature_is_set(t, OPT_ZEROCONF) && !accept_zeroconf) - return NULL; - /* Blank variants so we can just check for equality. */ for (size_t i = 0; i< ARRAY_SIZE(variants); i++) featurebits_unset(&proposed.features, variants[i]); diff --git a/common/channel_type.h b/common/channel_type.h index eb22244eb377..c1f1d7978c67 100644 --- a/common/channel_type.h +++ b/common/channel_type.h @@ -42,8 +42,7 @@ bool channel_type_eq(const struct channel_type *a, struct channel_type *channel_type_accept(const tal_t *ctx, const u8 *t, const struct feature_set *our_features, - const u8 *their_features, - bool accept_zeroconf); + const u8 *their_features); /* Return an array of feature strings indicating channel type. */ const char **channel_type_name(const tal_t *ctx, const struct channel_type *t); diff --git a/openingd/dualopend.c b/openingd/dualopend.c index cbbd8e0d1150..f1e6f01487e8 100644 --- a/openingd/dualopend.c +++ b/openingd/dualopend.c @@ -2259,8 +2259,7 @@ static void accepter_start(struct state *state, const u8 *oc2_msg) channel_type_accept(state, open_tlv->channel_type, state->our_features, - state->their_features, - state->minimum_depth == 0); + state->their_features); if (!state->channel_type) { negotiation_failed(state, "Did not support channel_type %s", diff --git a/openingd/openingd.c b/openingd/openingd.c index 9fe0b0bc9036..84b7a5c09add 100644 --- a/openingd/openingd.c +++ b/openingd/openingd.c @@ -965,16 +965,9 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg) */ if (open_tlvs->channel_type) { open_channel_had_channel_type = true; - /* Tentatively accept OPT_ZEROCONF. We'll check - * further down again. This is required because we - * haven't talked to the openchannel hook at this - * point. */ - state->channel_type = - channel_type_accept(state, - open_tlvs->channel_type, - state->our_features, - state->their_features, - true); + state->channel_type = channel_type_accept( + state, open_tlvs->channel_type, state->our_features, + state->their_features); if (!state->channel_type) { negotiation_failed(state, "Did not support channel_type %s", @@ -1137,6 +1130,12 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg) return NULL; } + /* BOLT #2: + * The receiving node MUST fail the channel if: + *... + * - if `type` includes `option_zeroconf` and it does not trust the + * sender to open an unconfirmed channel. + */ if (channel_type_has(state->channel_type, OPT_ZEROCONF) && state->minimum_depth > 0) { negotiation_failed(