diff --git a/common/channel_type.c b/common/channel_type.c index ba4126388..546b21a90 100644 --- a/common/channel_type.c +++ b/common/channel_type.c @@ -55,6 +55,17 @@ void channel_type_set_scid_alias(struct channel_type *type) COMPULSORY_FEATURE(OPT_SCID_ALIAS)); } +struct channel_type *channel_type_anchors_zero_fee_htlc(const tal_t *ctx) +{ + struct channel_type *type = channel_type_none(ctx); + + set_feature_bit(&type->features, + COMPULSORY_FEATURE(OPT_ANCHORS_ZERO_FEE_HTLC_TX)); + set_feature_bit(&type->features, + COMPULSORY_FEATURE(OPT_STATIC_REMOTEKEY)); + return type; +} + struct channel_type *default_channel_type(const tal_t *ctx, const struct feature_set *our_features, const u8 *their_features) @@ -64,12 +75,15 @@ struct channel_type *default_channel_type(const tal_t *ctx, * - if `channel_type` was present in both `open_channel` and `accept_channel`: * - This is the `channel_type` (they must be equal, required above) * - otherwise: + * - if `option_anchors_zero_fee_htlc_tx` was negotiated: + * - the `channel_type` is `option_anchors_zero_fee_htlc_tx` and `option_static_remotekey` (bits 22 and 12) + * - otherwise, if `option_anchor_outputs` was negotiated: + * - the `channel_type` is `option_anchor_outputs` and + * `option_static_remotekey` (bits 20 and 12) */ - /* BOLT #2: - * - otherwise, if `option_anchor_outputs` was negotiated: - * - the `channel_type` is `option_anchor_outputs` and - * `option_static_remotekey` (bits 20 and 12) - */ + if (feature_negotiated(our_features, their_features, + OPT_ANCHORS_ZERO_FEE_HTLC_TX)) + return channel_type_anchors_zero_fee_htlc(ctx); if (feature_negotiated(our_features, their_features, OPT_ANCHOR_OUTPUTS)) return channel_type_anchor_outputs(ctx); @@ -137,6 +151,7 @@ struct channel_type *channel_type_accept(const tal_t *ctx, static const size_t feats[] = { OPT_ANCHOR_OUTPUTS, + OPT_ANCHORS_ZERO_FEE_HTLC_TX, OPT_STATIC_REMOTEKEY, OPT_SCID_ALIAS, OPT_ZEROCONF, @@ -185,6 +200,8 @@ struct channel_type *channel_type_accept(const tal_t *ctx, if (channel_type_eq(&proposed, channel_type_none(tmpctx)) || channel_type_eq(&proposed, channel_type_static_remotekey(tmpctx)) || + channel_type_eq(&proposed, + channel_type_anchors_zero_fee_htlc(tmpctx)) || channel_type_eq(&proposed, channel_type_anchor_outputs(tmpctx))) { /* At this point we know it matches, and maybe has * a couple of extra options. So let's just reply diff --git a/common/channel_type.h b/common/channel_type.h index 14f5bfa4b..eb22244eb 100644 --- a/common/channel_type.h +++ b/common/channel_type.h @@ -9,6 +9,7 @@ struct channel_type *channel_type_none(const tal_t *ctx); struct channel_type *channel_type_static_remotekey(const tal_t *ctx); struct channel_type *channel_type_anchor_outputs(const tal_t *ctx); +struct channel_type *channel_type_anchors_zero_fee_htlc(const tal_t *ctx); /* channel_type variants */ void channel_type_set_zeroconf(struct channel_type *channel_type); diff --git a/common/initial_channel.c b/common/initial_channel.c index 46728b017..ec7817c08 100644 --- a/common/initial_channel.c +++ b/common/initial_channel.c @@ -169,6 +169,10 @@ struct channel_type *channel_upgradable_type(const tal_t *ctx, struct channel_type *channel_desired_type(const tal_t *ctx, const struct channel *channel) { + /* We don't actually want to downgrade anchors! */ + if (channel_has(channel, OPT_ANCHORS_ZERO_FEE_HTLC_TX)) + return channel_type_anchors_zero_fee_htlc(ctx); + /* We don't actually want to downgrade anchors! */ if (channel_has(channel, OPT_ANCHOR_OUTPUTS)) return channel_type_anchor_outputs(ctx); diff --git a/doc/lightning-listpeerchannels.7.md b/doc/lightning-listpeerchannels.7.md index 47c7db1fa..643303356 100644 --- a/doc/lightning-listpeerchannels.7.md +++ b/doc/lightning-listpeerchannels.7.md @@ -29,7 +29,7 @@ On success, an object containing **channels** is returned. It is an array of ob - **state** (string): the channel state, in particular "CHANNELD\_NORMAL" means the channel can be used normally (one of "OPENINGD", "CHANNELD\_AWAITING\_LOCKIN", "CHANNELD\_NORMAL", "CHANNELD\_SHUTTING\_DOWN", "CLOSINGD\_SIGEXCHANGE", "CLOSINGD\_COMPLETE", "AWAITING\_UNILATERAL", "FUNDING\_SPEND\_SEEN", "ONCHAIN", "DUALOPEND\_OPEN\_INIT", "DUALOPEND\_AWAITING\_LOCKIN") - **opener** (string): Who initiated the channel (one of "local", "remote") - **features** (array of strings): - - BOLT #9 features which apply to this channel (one of "option\_static\_remotekey", "option\_anchor\_outputs", "option\_scid\_alias", "option\_zeroconf") + - BOLT #9 features which apply to this channel (one of "option\_static\_remotekey", "option\_anchor\_outputs", "option\_anchors\_zero\_fee\_htlc\_tx", "option\_scid\_alias", "option\_zeroconf") - **scratch\_txid** (txid, optional): The txid we would use if we went onchain now - **channel\_type** (object, optional): channel\_type as negotiated with peer *(added v23.05)*: - **bits** (array of u32s): Each bit set in this channel\_type: @@ -194,4 +194,4 @@ Main web site: Lightning RFC site (BOLT \#9): -[comment]: # ( SHA256STAMP:005c109a25f91eabf18e2003a4c83e305ca6b4a604999ceeef6ca3f0ee4b0006) +[comment]: # ( SHA256STAMP:f5103dae3b20a7d2a4112a368e753f1dd0518a269bd34c2fd17657c9f90596d7) diff --git a/doc/schemas/listpeerchannels.schema.json b/doc/schemas/listpeerchannels.schema.json index a780faa94..d1dd71761 100644 --- a/doc/schemas/listpeerchannels.schema.json +++ b/doc/schemas/listpeerchannels.schema.json @@ -212,6 +212,7 @@ "enum": [ "option_static_remotekey", "option_anchor_outputs", + "option_anchors_zero_fee_htlc_tx", "option_scid_alias", "option_zeroconf" ],