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

Function decode_short_ids

common/decode_array.c:7–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5#include <wire/peer_wire.h>
6
7struct short_channel_id *decode_short_ids(const tal_t *ctx, const u8 *encoded)
8{
9 struct short_channel_id *scids;
10 size_t max = tal_count(encoded);
11 enum arr_encode_types type;
12
13 /* BOLT #7:
14 *
15 * The receiver:
16 * - if the first byte of `encoded_short_ids` is not a known encoding
17 * type:
18 * - MAY send a `warning`.
19 * - MAY close the connection.
20 * - if `encoded_short_ids` does not decode into a whole number of
21 * `short_channel_id`:
22 * - MAY send a `warning`.
23 * - MAY close the connection.
24 */
25 type = fromwire_u8(&encoded, &max);
26 switch (type) {
27 case ARR_ZLIB_DEPRECATED:
28 return NULL;
29 case ARR_UNCOMPRESSED:
30 scids = tal_arr(ctx, struct short_channel_id, 0);
31 while (max) {
32 struct short_channel_id scid;
33 scid = fromwire_short_channel_id(&encoded, &max);
34 tal_arr_expand(&scids, scid);
35 }
36
37 /* encoded is set to NULL if we ran over */
38 if (!encoded)
39 return tal_free(scids);
40 return scids;
41 }
42 return NULL;
43}
44
45bigsize_t *decode_scid_query_flags(const tal_t *ctx,
46 const struct tlv_query_short_channel_ids_tlvs_query_flags *qf)

Callers 3

Calls 3

tal_freeFunction · 0.85
fromwire_u8Function · 0.50

Tested by

no test coverage detected