channeld: BOLT update, no longer allow creation of old (experimental-only!) non-zero-fee anchor channels.

These were removed from the spec.

We still support existing ones, though we were the only implementation
which ever did, and only in experimental mode, so we should be able to
upgrade them and avoid a forced close, with a bit of engineering...

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2024-06-19 09:31:01 +09:30
parent b6d7ee1f11
commit 7d3d763b96
26 changed files with 63 additions and 140 deletions

View File

@@ -19,7 +19,6 @@ bool check_config_bounds(const tal_t *ctx,
struct amount_msat min_effective_htlc_capacity,
const struct channel_config *remoteconf,
const struct channel_config *localconf,
bool option_anchor_outputs,
bool option_anchors_zero_fee_htlc_tx,
char **err_reason)
{
@@ -71,7 +70,7 @@ bool check_config_bounds(const tal_t *ctx,
* `to_remote_anchor` above its reserve.
*/
/* (We simply include in "reserve" here if they opened). */
if ((option_anchor_outputs || option_anchors_zero_fee_htlc_tx)
if (option_anchors_zero_fee_htlc_tx
&& !amount_sat_add(&reserve, reserve, AMOUNT_SAT(660))) {
*err_reason = tal_fmt(ctx,
"cannot add anchors to reserve %s",
@@ -92,7 +91,7 @@ bool check_config_bounds(const tal_t *ctx,
/* They have to pay for fees, too. Assuming HTLC is dust, though,
* we don't account for an HTLC output. */
fee = commit_tx_base_fee(feerate_per_kw, 0,
option_anchor_outputs,
false,
option_anchors_zero_fee_htlc_tx);
if (!amount_sat_sub(&capacity, capacity, fee)) {
*err_reason = tal_fmt(ctx, "channel_reserve_satoshis %s"
@@ -200,7 +199,7 @@ bool anchors_negotiated(struct feature_set *our_features,
const u8 *their_features)
{
return feature_negotiated(our_features, their_features,
OPT_ANCHOR_OUTPUTS)
OPT_ANCHOR_OUTPUTS_DEPRECATED)
|| feature_negotiated(our_features,
their_features,
OPT_ANCHORS_ZERO_FEE_HTLC_TX);

View File

@@ -16,7 +16,6 @@ bool check_config_bounds(const tal_t *ctx,
struct amount_msat min_effective_htlc_capacity,
const struct channel_config *remoteconf,
const struct channel_config *localconf,
bool option_anchor_outputs,
bool option_anchors_zero_fee_htlc_tx,
char **err_reason);

View File

@@ -2652,12 +2652,7 @@ static void accepter_start(struct state *state, const u8 *oc2_msg)
state->min_effective_htlc_capacity,
&tx_state->remoteconf,
&tx_state->localconf,
feature_negotiated(state->our_features,
state->their_features,
OPT_ANCHOR_OUTPUTS),
feature_negotiated(state->our_features,
state->their_features,
OPT_ANCHORS_ZERO_FEE_HTLC_TX),
channel_type_has(state->channel_type, OPT_ANCHORS_ZERO_FEE_HTLC_TX),
&err_reason)) {
negotiation_failed(state, "%s", err_reason);
return;
@@ -3334,12 +3329,7 @@ static void opener_start(struct state *state, u8 *msg)
state->min_effective_htlc_capacity,
&tx_state->remoteconf,
&tx_state->localconf,
feature_negotiated(state->our_features,
state->their_features,
OPT_ANCHOR_OUTPUTS),
feature_negotiated(state->our_features,
state->their_features,
OPT_ANCHORS_ZERO_FEE_HTLC_TX),
channel_type_has(state->channel_type, OPT_ANCHORS_ZERO_FEE_HTLC_TX),
&err_reason)) {
negotiation_failed(state, "%s", err_reason);
return;
@@ -3655,12 +3645,7 @@ static void rbf_local_start(struct state *state, u8 *msg)
state->min_effective_htlc_capacity,
&tx_state->remoteconf,
&tx_state->localconf,
feature_negotiated(state->our_features,
state->their_features,
OPT_ANCHOR_OUTPUTS),
feature_negotiated(state->our_features,
state->their_features,
OPT_ANCHORS_ZERO_FEE_HTLC_TX),
channel_type_has(state->channel_type, OPT_ANCHORS_ZERO_FEE_HTLC_TX),
&err_reason)) {
open_abort(state, "%s", err_reason);
return;
@@ -3811,12 +3796,7 @@ static void rbf_remote_start(struct state *state, const u8 *rbf_msg)
state->min_effective_htlc_capacity,
&tx_state->remoteconf,
&tx_state->localconf,
feature_negotiated(state->our_features,
state->their_features,
OPT_ANCHOR_OUTPUTS),
feature_negotiated(state->our_features,
state->their_features,
OPT_ANCHORS_ZERO_FEE_HTLC_TX),
channel_type_has(state->channel_type, OPT_ANCHORS_ZERO_FEE_HTLC_TX),
&err_reason)) {
negotiation_failed(state, "%s", err_reason);
goto free_rbf_ctx;

View File

@@ -352,8 +352,7 @@ static u8 *funder_channel_start(struct state *state, u8 channel_flags,
}
/* Which feerate do we use? (We can lowball fees if using anchors!) */
if (channel_type_has(state->channel_type, OPT_ANCHOR_OUTPUTS)
|| channel_type_has(state->channel_type, OPT_ANCHORS_ZERO_FEE_HTLC_TX)) {
if (channel_type_has_anchors(state->channel_type)) {
state->feerate_per_kw = anchor_feerate;
} else {
state->feerate_per_kw = nonanchor_feerate;
@@ -552,12 +551,7 @@ 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),
feature_negotiated(state->our_features,
state->their_features,
OPT_ANCHORS_ZERO_FEE_HTLC_TX),
channel_type_has(state->channel_type, OPT_ANCHORS_ZERO_FEE_HTLC_TX),
&err_reason)) {
negotiation_failed(state, "%s", err_reason);
return NULL;
@@ -1071,12 +1065,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),
feature_negotiated(state->our_features,
state->their_features,
OPT_ANCHORS_ZERO_FEE_HTLC_TX),
channel_type_has(state->channel_type,
OPT_ANCHORS_ZERO_FEE_HTLC_TX),
&err_reason)) {
negotiation_failed(state, "%s", err_reason);
return NULL;