diff --git a/common/channel_type.c b/common/channel_type.c index d4569f40a..80a9138f7 100644 --- a/common/channel_type.c +++ b/common/channel_type.c @@ -122,7 +122,8 @@ 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) + const u8 *their_features, + bool accept_zeroconf) { struct channel_type *ctype, proposed; /* Need to copy since we're going to blank variant bits for equality. */ @@ -161,6 +162,15 @@ 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 f4df925c6..28096f3c2 100644 --- a/common/channel_type.h +++ b/common/channel_type.h @@ -38,7 +38,8 @@ 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); + const u8 *their_features, + bool accept_zeroconf); /* 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 5375331aa..49ce872d1 100644 --- a/openingd/dualopend.c +++ b/openingd/dualopend.c @@ -2284,7 +2284,8 @@ 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->their_features, + state->minimum_depth == 0); if (!state->channel_type) { negotiation_failed(state, "Did not support channel_type %s", diff --git a/openingd/openingd.c b/openingd/openingd.c index 9e746a846..1b15e9f5d 100644 --- a/openingd/openingd.c +++ b/openingd/openingd.c @@ -905,7 +905,8 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg) channel_type_accept(state, open_tlvs->channel_type, state->our_features, - state->their_features); + state->their_features, + state->minimum_depth == 0); if (!state->channel_type) { negotiation_failed(state, "Did not support channel_type %s",