mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
gossmap: function to get channel features bitmap.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -1140,6 +1140,22 @@ int gossmap_chan_get_feature(const struct gossmap *map,
|
|||||||
c->cann_off + feature_len_off + 2, feature_len);
|
c->cann_off + feature_len_off + 2, feature_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u8 *gossmap_chan_get_features(const tal_t *ctx,
|
||||||
|
const struct gossmap *map,
|
||||||
|
const struct gossmap_chan *c)
|
||||||
|
{
|
||||||
|
u8 *ret;
|
||||||
|
/* Note that first two bytes are message type */
|
||||||
|
const size_t feature_len_off = 2 + (64 + 64 + 64 + 64);
|
||||||
|
size_t feature_len;
|
||||||
|
|
||||||
|
feature_len = map_be16(map, c->cann_off + feature_len_off);
|
||||||
|
ret = tal_arr(ctx, u8, feature_len);
|
||||||
|
|
||||||
|
map_copy(map, c->cann_off + feature_len_off + 2, ret, feature_len);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/* BOLT #7:
|
/* BOLT #7:
|
||||||
* 1. type: 258 (`channel_update`)
|
* 1. type: 258 (`channel_update`)
|
||||||
* 2. data:
|
* 2. data:
|
||||||
|
|||||||
@@ -134,6 +134,11 @@ int gossmap_chan_get_feature(const struct gossmap *map,
|
|||||||
const struct gossmap_chan *c,
|
const struct gossmap_chan *c,
|
||||||
int fbit);
|
int fbit);
|
||||||
|
|
||||||
|
/* Return the feature bitmap */
|
||||||
|
u8 *gossmap_chan_get_features(const tal_t *ctx,
|
||||||
|
const struct gossmap *map,
|
||||||
|
const struct gossmap_chan *c);
|
||||||
|
|
||||||
/* Return the feature bit (odd or even), or -1 if neither (or no announcement) */
|
/* Return the feature bit (odd or even), or -1 if neither (or no announcement) */
|
||||||
int gossmap_node_get_feature(const struct gossmap *map,
|
int gossmap_node_get_feature(const struct gossmap *map,
|
||||||
const struct gossmap_node *n,
|
const struct gossmap_node *n,
|
||||||
|
|||||||
@@ -402,6 +402,11 @@ int main(int argc, char *argv[])
|
|||||||
assert(amount_msat_eq(htlc_minimum_msat, AMOUNT_MSAT(0)));
|
assert(amount_msat_eq(htlc_minimum_msat, AMOUNT_MSAT(0)));
|
||||||
assert(amount_msat_eq(htlc_maximum_msat, AMOUNT_MSAT(990000000)));
|
assert(amount_msat_eq(htlc_maximum_msat, AMOUNT_MSAT(990000000)));
|
||||||
|
|
||||||
|
assert(tal_bytelen(gossmap_chan_get_features(tmpctx, map,
|
||||||
|
gossmap_find_chan(map, &scid12))) == 0);
|
||||||
|
assert(tal_bytelen(gossmap_chan_get_features(tmpctx, map,
|
||||||
|
gossmap_find_chan(map, &scid23))) == 0);
|
||||||
|
|
||||||
/* Now, let's add a new channel l1 -> l4. */
|
/* Now, let's add a new channel l1 -> l4. */
|
||||||
mods = gossmap_localmods_new(tmpctx);
|
mods = gossmap_localmods_new(tmpctx);
|
||||||
assert(node_id_from_hexstr("0382ce59ebf18be7d84677c2e35f23294b9992ceca95491fcf8a56c6cb2d9de199", 66, &l4));
|
assert(node_id_from_hexstr("0382ce59ebf18be7d84677c2e35f23294b9992ceca95491fcf8a56c6cb2d9de199", 66, &l4));
|
||||||
|
|||||||
Reference in New Issue
Block a user