mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-09 08:04:19 +01:00
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:
@@ -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]);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user