| 23 | } |
| 24 | |
| 25 | struct short_channel_id *decode_short_ids(const tal_t *ctx, const u8 *encoded) |
| 26 | { |
| 27 | struct short_channel_id *scids; |
| 28 | size_t max = tal_count(encoded); |
| 29 | enum arr_encode_types type; |
| 30 | |
| 31 | /* BOLT #7: |
| 32 | * |
| 33 | * The receiver: |
| 34 | * - if the first byte of `encoded_short_ids` is not a known encoding |
| 35 | * type: |
| 36 | * - MAY send a `warning`. |
| 37 | * - MAY close the connection. |
| 38 | * - if `encoded_short_ids` does not decode into a whole number of |
| 39 | * `short_channel_id`: |
| 40 | * - MAY send a `warning`. |
| 41 | * - MAY close the connection. |
| 42 | */ |
| 43 | type = fromwire_u8(&encoded, &max); |
| 44 | switch (type) { |
| 45 | case ARR_ZLIB_DEPRECATED: |
| 46 | encoded = unzlib(tmpctx, encoded, max); |
| 47 | if (!encoded) |
| 48 | return NULL; |
| 49 | max = tal_count(encoded); |
| 50 | /* fall thru */ |
| 51 | case ARR_UNCOMPRESSED: |
| 52 | scids = tal_arr(ctx, struct short_channel_id, 0); |
| 53 | while (max) { |
| 54 | struct short_channel_id scid; |
| 55 | fromwire_short_channel_id(&encoded, &max, &scid); |
| 56 | tal_arr_expand(&scids, scid); |
| 57 | } |
| 58 | |
| 59 | /* encoded is set to NULL if we ran over */ |
| 60 | if (!encoded) |
| 61 | return tal_free(scids); |
| 62 | return scids; |
| 63 | } |
| 64 | return NULL; |
| 65 | } |
| 66 | |
| 67 | bigsize_t *decode_scid_query_flags(const tal_t *ctx, |
| 68 | const struct tlv_query_short_channel_ids_tlvs_query_flags *qf) |
no test coverage detected