Skip to content

Commit

Permalink
opening: helper for anchor flagged, use in dualopend also
Browse files Browse the repository at this point in the history
There's two anchor flags, we should check both. Also have dualopend
check this as well!
  • Loading branch information
niftynei authored and rustyrussell committed Feb 4, 2023
1 parent ef3f05b commit ad1893f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
17 changes: 11 additions & 6 deletions openingd/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,16 @@ u8 *no_upfront_shutdown_script(const tal_t *ctx,
return NULL;
}

bool anchors_negotiated(struct feature_set *our_features,
const u8 *their_features)
{
return feature_negotiated(our_features, their_features,
OPT_ANCHOR_OUTPUTS)
|| feature_negotiated(our_features,
their_features,
OPT_ANCHORS_ZERO_FEE_HTLC_TX);
}

char *validate_remote_upfront_shutdown(const tal_t *ctx,
struct feature_set *our_features,
const u8 *their_features,
Expand All @@ -220,13 +230,8 @@ char *validate_remote_upfront_shutdown(const tal_t *ctx,
bool anysegwit = feature_negotiated(our_features,
their_features,
OPT_SHUTDOWN_ANYSEGWIT);
bool anchors = feature_negotiated(our_features,
their_features,
OPT_ANCHOR_OUTPUTS)
|| feature_negotiated(our_features,
their_features,
OPT_ANCHORS_ZERO_FEE_HTLC_TX);

bool anchors = anchors_negotiated(our_features, their_features);
/* BOLT #2:
*
* - MUST include `upfront_shutdown_script` with either a valid
Expand Down
3 changes: 3 additions & 0 deletions openingd/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ bool check_config_bounds(const tal_t *ctx,
bool option_anchor_outputs,
char **err_reason);

bool anchors_negotiated(struct feature_set *our_features,
const u8 *their_features);

u8 *no_upfront_shutdown_script(const tal_t *ctx,
struct feature_set *our_features,
const u8 *their_features);
Expand Down
12 changes: 8 additions & 4 deletions openingd/dualopend.c
Original file line number Diff line number Diff line change
Expand Up @@ -2265,7 +2265,8 @@ static void accepter_start(struct state *state, const u8 *oc2_msg)
state->min_effective_htlc_capacity,
&tx_state->remoteconf,
&tx_state->localconf,
true, /* v2 means we use anchor outputs */
anchors_negotiated(state->our_features,
state->their_features),
&err_reason)) {
negotiation_failed(state, "%s", err_reason);
return;
Expand Down Expand Up @@ -2968,7 +2969,8 @@ static void opener_start(struct state *state, u8 *msg)
state->min_effective_htlc_capacity,
&tx_state->remoteconf,
&tx_state->localconf,
true, /* v2 means we use anchor outputs */
anchors_negotiated(state->our_features,
state->their_features),
&err_reason)) {
negotiation_failed(state, "%s", err_reason);
return;
Expand Down Expand Up @@ -3255,7 +3257,8 @@ static void rbf_local_start(struct state *state, u8 *msg)
state->min_effective_htlc_capacity,
&tx_state->remoteconf,
&tx_state->localconf,
true, /* v2 means we use anchor outputs */
anchors_negotiated(state->our_features,
state->their_features),
&err_reason)) {
open_err_warn(state, "%s", err_reason);
goto free_rbf_ctx;
Expand Down Expand Up @@ -3386,7 +3389,8 @@ static void rbf_remote_start(struct state *state, const u8 *rbf_msg)
state->min_effective_htlc_capacity,
&tx_state->remoteconf,
&tx_state->localconf,
true, /* v2 means we use anchor outputs */
anchors_negotiated(state->our_features,
state->their_features),
&err_reason)) {
negotiation_failed(state, "%s", err_reason);
goto free_rbf_ctx;
Expand Down
10 changes: 4 additions & 6 deletions openingd/openingd.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,9 +504,8 @@ static u8 *funder_channel_start(struct state *state, u8 channel_flags)
state->min_effective_htlc_capacity,
&state->remoteconf,
&state->localconf,
feature_negotiated(state->our_features,
state->their_features,
OPT_ANCHOR_OUTPUTS),
anchors_negotiated(state->our_features,
state->their_features),
&err_reason)) {
negotiation_failed(state, "%s", err_reason);
return NULL;
Expand Down Expand Up @@ -1012,9 +1011,8 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg)
state->min_effective_htlc_capacity,
&state->remoteconf,
&state->localconf,
feature_negotiated(state->our_features,
state->their_features,
OPT_ANCHOR_OUTPUTS),
anchors_negotiated(state->our_features,
state->their_features),
&err_reason)) {
negotiation_failed(state, "%s", err_reason);
return NULL;
Expand Down

0 comments on commit ad1893f

Please sign in to comment.