MCPcopy Create free account
hub / github.com/ElementsProject/lightning / gossmap_chan_get_update_details

Function gossmap_chan_get_update_details

common/gossmap.c:1222–1262  ·  view source on GitHub ↗

BOLT #7: * 1. type: 258 (`channel_update`) * 2. data: * * [`signature`:`signature`] * * [`chain_hash`:`chain_hash`] * * [`short_channel_id`:`short_channel_id`] * * [`u32`:`timestamp`] * * [`byte`:`message_flags`] * * [`byte`:`channel_flags`] * * [`u16`:`cltv_expiry_delta`] * * [`u64`:`htlc_minimum_msat`] * * [`u32`:`fee_base_msat`] * * [`u32`:`fe

Source from the content-addressed store, hash-verified

1220 * * [`u64`:`htlc_maximum_msat`]
1221 */
1222void gossmap_chan_get_update_details(const struct gossmap *map,
1223 const struct gossmap_chan *chan,
1224 int dir,
1225 u32 *timestamp,
1226 u8 *message_flags,
1227 u8 *channel_flags,
1228 u32 *fee_base_msat,
1229 u32 *fee_proportional_millionths,
1230 struct amount_msat *htlc_minimum_msat,
1231 struct amount_msat *htlc_maximum_msat)
1232{
1233 /* Note that first two bytes are message type */
1234 const size_t scid_off = chan->cupdate_off[dir] + 2 + (64 + 32);
1235 const size_t timestamp_off = scid_off + 8;
1236 const size_t message_flags_off = timestamp_off + 4;
1237 const size_t channel_flags_off = message_flags_off + 1;
1238 const size_t cltv_expiry_delta_off = channel_flags_off + 1;
1239 const size_t htlc_minimum_off = cltv_expiry_delta_off + 2;
1240 const size_t fee_base_off = htlc_minimum_off + 8;
1241 const size_t fee_prop_off = fee_base_off + 4;
1242 const size_t htlc_maximum_off = fee_prop_off + 4;
1243
1244 assert(gossmap_chan_set(chan, dir));
1245
1246 if (timestamp)
1247 *timestamp = map_be32(map, timestamp_off);
1248 if (channel_flags)
1249 *channel_flags = map_u8(map, channel_flags_off);
1250 if (message_flags)
1251 *message_flags = map_u8(map, message_flags_off);
1252 if (fee_base_msat)
1253 *fee_base_msat = map_be32(map, fee_base_off);
1254 if (fee_proportional_millionths)
1255 *fee_proportional_millionths = map_be32(map, fee_prop_off);
1256 if (htlc_minimum_msat)
1257 *htlc_minimum_msat
1258 = amount_msat(map_be64(map, htlc_minimum_off));
1259 if (htlc_maximum_msat)
1260 *htlc_maximum_msat
1261 = amount_msat(map_be64(map, htlc_maximum_off));
1262}
1263
1264/* BOLT #7:
1265 * 1. type: 257 (`node_announcement`)

Callers 3

mainFunction · 0.85
mainFunction · 0.85
json_add_halfchanFunction · 0.85

Calls 5

gossmap_chan_setFunction · 0.85
map_be32Function · 0.85
map_u8Function · 0.85
map_be64Function · 0.85
amount_msatClass · 0.70

Tested by 2

mainFunction · 0.68
mainFunction · 0.68