zeroconf: don't accept channel_type with option_zeroconf unless we're really zeroconf.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: Protocol: we will upfront reject channel_open which asks for a zeroconf channel unless we are going to do a zerconf channel.
This commit is contained in:
Rusty Russell
2023-04-10 09:51:56 +09:30
parent 7e5146ab0c
commit 355aa8f497
4 changed files with 17 additions and 4 deletions

View File

@@ -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]);

View File

@@ -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);

View File

@@ -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",

View File

@@ -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",