common: simple helpers to test for either anchor feature.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2023-06-26 08:37:21 +09:30
parent 0587cf324e
commit e036080fc5
4 changed files with 18 additions and 0 deletions

View file

@ -97,6 +97,12 @@ bool channel_type_has(const struct channel_type *type, int feature)
return feature_offered(type->features, feature);
}
bool channel_type_has_anchors(const struct channel_type *type)
{
return feature_offered(type->features, OPT_ANCHOR_OUTPUTS)
|| feature_offered(type->features, OPT_ANCHORS_ZERO_FEE_HTLC_TX);
}
bool channel_type_eq(const struct channel_type *a,
const struct channel_type *b)
{

View file

@ -30,6 +30,9 @@ struct channel_type *default_channel_type(const tal_t *ctx,
/* Does this type include this feature? */
bool channel_type_has(const struct channel_type *type, int feature);
/* Convenience for querying either anchor_outputs or anchors_zero_fee_htlc_tx */
bool channel_type_has_anchors(const struct channel_type *type);
/* Are these two channel_types equivalent? */
bool channel_type_eq(const struct channel_type *a,
const struct channel_type *b);

View file

@ -182,6 +182,11 @@ bool channel_has(const struct channel *channel, int feature)
return channel_type_has(channel->type, feature);
}
bool channel_has_anchors(const struct channel *channel)
{
return channel_type_has_anchors(channel->type);
}
static char *fmt_channel_view(const tal_t *ctx, const struct channel_view *view)
{
return tal_fmt(ctx, "{ owed_local=%s,"

View file

@ -159,4 +159,8 @@ struct channel_type *channel_desired_type(const tal_t *ctx,
/* Convenience for querying channel->type */
bool channel_has(const struct channel *channel, int feature);
/* Convenience for querying either anchor_outputs or anchors_zero_fee_htlc_tx */
bool channel_has_anchors(const struct channel *channel);
#endif /* LIGHTNING_COMMON_INITIAL_CHANNEL_H */