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

Function crc32_of_update

devtools/mkgossip.c:101–121  ·  view source on GitHub ↗

BOLT #7: * * The checksum of a `channel_update` is the CRC32C checksum as specified in * [RFC3720](https://tools.ietf.org/html/rfc3720#appendix-B.4) of this * `channel_update` without its `signature` and `timestamp` fields. */

Source from the content-addressed store, hash-verified

99 * `channel_update` without its `signature` and `timestamp` fields.
100 */
101static u32 crc32_of_update(const u8 *channel_update)
102{
103 u32 sum;
104
105 /* BOLT #7:
106 *
107 * 1. type: 258 (`channel_update`)
108 * 2. data:
109 * * [`signature`:`signature`]
110 * * [`chain_hash`:`chain_hash`]
111 * * [`short_channel_id`:`short_channel_id`]
112 * * [`u32`:`timestamp`]
113 *...
114 */
115 /* We already checked it's valid before accepting */
116 assert(tal_count(channel_update) > 2 + 64 + 32 + 8 + 4);
117 sum = crc32c(0, channel_update + 2 + 64, 32 + 8);
118 sum = crc32c(sum, channel_update + 2 + 64 + 32 + 8 + 4,
119 tal_count(channel_update) - (64 + 2 + 32 + 8 + 4));
120 return sum;
121}
122
123static void print_update(const struct bitcoin_blkid *chainhash,
124 const struct short_channel_id *scid,

Callers 1

print_updateFunction · 0.70

Calls 1

crc32cFunction · 0.85

Tested by

no test coverage detected