Skip to content

Commit

Permalink
openingd: Clean up channel_type_accept
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cdecker committed Aug 18, 2023
1 parent 8821242 commit 50058df
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 25 deletions.
12 changes: 1 addition & 11 deletions common/channel_type.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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]);
Expand Down
3 changes: 1 addition & 2 deletions common/channel_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions openingd/dualopend.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
19 changes: 9 additions & 10 deletions openingd/openingd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 50058df

Please sign in to comment.