opening: helper for anchor flagged, use in dualopend also

There's two anchor flags, we should check both. Also have dualopend
check this as well!
This commit is contained in:
niftynei 2022-10-19 12:09:41 -05:00 committed by Rusty Russell
parent ef3f05b52a
commit ad1893f83f
4 changed files with 26 additions and 16 deletions

View File

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

View File

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

View File

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

View File

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