BOLT #7: * * - MUST set `features` based on what features were negotiated for this channel, according to [BOLT #9](09-features.md#assigned-features-flags) * - MUST set `len` to the minimum length required to hold the `features` bits * it sets. */
| 300 | * it sets. |
| 301 | */ |
| 302 | u8 *get_agreed_channelfeatures(const tal_t *ctx, |
| 303 | const struct feature_set *our_features, |
| 304 | const u8 *their_features) |
| 305 | { |
| 306 | u8 *f = tal_dup_talarr(ctx, u8, our_features->bits[CHANNEL_FEATURE]); |
| 307 | size_t max_len = 0; |
| 308 | |
| 309 | /* Clear any features which they didn't offer too */ |
| 310 | for (size_t i = 0; i < 8 * tal_count(f); i += 2) { |
| 311 | if (!feature_offered(f, i)) |
| 312 | continue; |
| 313 | if (!feature_offered(their_features, i)) { |
| 314 | clear_feature_bit(f, COMPULSORY_FEATURE(i)); |
| 315 | clear_feature_bit(f, OPTIONAL_FEATURE(i)); |
| 316 | trim_features(&f); |
| 317 | continue; |
| 318 | } |
| 319 | max_len = (i / 8) + 1; |
| 320 | } |
| 321 | |
| 322 | /* Trim to length (unless it's already NULL). */ |
| 323 | if (f) |
| 324 | tal_resize(&f, max_len); |
| 325 | return f; |
| 326 | } |
| 327 | |
| 328 | bool feature_is_set(const u8 *features, size_t bit) |
| 329 | { |
no test coverage detected