diff --git a/common/features.c b/common/features.c index 14c0a3914..5040c39ac 100644 --- a/common/features.c +++ b/common/features.c @@ -516,6 +516,17 @@ u8 *featurebits_or(const tal_t *ctx, const u8 *f1 TAKES, const u8 *f2 TAKES) return result; } +void featurebits_unset(u8 **ptr, size_t bit) +{ + size_t len = tal_count(*ptr); + if (bit / 8 >= len) + return; + + (*ptr)[len - 1 - bit / 8] &= (0 << (bit % 8)); + + trim_features(ptr); +} + bool featurebits_eq(const u8 *f1, const u8 *f2) { size_t len = tal_bytelen(f1); diff --git a/common/features.h b/common/features.h index 58b57c48f..d5da02fdf 100644 --- a/common/features.h +++ b/common/features.h @@ -73,6 +73,8 @@ void set_feature_bit(u8 **ptr, u32 bit); /* Given two featurebit vectors, combine them by applying a logical OR. */ u8 *featurebits_or(const tal_t *ctx, const u8 *f1 TAKES, const u8 *f2 TAKES); +/* Unset a given bit in a featurebits string */ +void featurebits_unset(u8 **ptr, size_t bit); /* Are these two feature bitsets functionally equal (one may have * trailing zeroes)? */