Skip to content

Commit

Permalink
openingd: allow channel_type to *downgrade* from default.
Browse files Browse the repository at this point in the history
e.g. you can negotiate anchor_outputs, but still ask for a
non-anchor-output channel.

If/when we make those features compulsory, downgrade will
not be allowed.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Sep 9, 2021
1 parent 2d4b00d commit 67a518f
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions openingd/openingd.c
Original file line number Diff line number Diff line change
Expand Up @@ -831,27 +831,30 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg)
"Parsing open_channel %s", tal_hex(tmpctx, open_channel_msg));
set_remote_upfront_shutdown(state, open_tlvs->upfront_shutdown_script);

state->channel_type
= default_channel_type(state,
state->our_features, state->their_features);

/* BOLT-channel-types #2:
* The receiving node MUST fail the channel if:
*...
* - It supports `channel_type`, `channel_type` was set, and the
* `type` is not suitable.
*/

/* FIXME: We in fact insist on the exact type we want! */
if (open_tlvs->channel_type
&& !featurebits_eq(state->channel_type->features,
open_tlvs->channel_type)) {
negotiation_failed(state, false,
"Did not support channel_type %s",
fmt_featurebits(tmpctx,
open_tlvs->channel_type));
return NULL;
}
if (open_tlvs->channel_type) {
state->channel_type =
channel_type_accept(state,
open_tlvs->channel_type,
state->our_features,
state->their_features);
if (!state->channel_type) {
negotiation_failed(state, false,
"Did not support channel_type %s",
fmt_featurebits(tmpctx,
open_tlvs->channel_type));
return NULL;
}
} else
state->channel_type
= default_channel_type(state,
state->our_features,
state->their_features);

/* BOLT #2:
*
Expand Down

0 comments on commit 67a518f

Please sign in to comment.