| 108 | } |
| 109 | |
| 110 | struct channel_update_timestamps * |
| 111 | decode_channel_update_timestamps(const tal_t *ctx, |
| 112 | const struct tlv_reply_channel_range_tlvs_timestamps_tlv *timestamps_tlv) |
| 113 | { |
| 114 | /* Note that our parser will set this to NULL if there are no elements */ |
| 115 | u8 *encoded = timestamps_tlv->encoded_timestamps; |
| 116 | size_t max = tal_count(encoded); |
| 117 | struct channel_update_timestamps *ts; |
| 118 | |
| 119 | /* FIXME: BOLT #7 should have a requirements like it does for |
| 120 | * query_short_channel_ids_tlvs! */ |
| 121 | switch (timestamps_tlv->encoding_type) { |
| 122 | case ARR_ZLIB_DEPRECATED: |
| 123 | encoded = unzlib(tmpctx, encoded, max); |
| 124 | if (!encoded) |
| 125 | return NULL; |
| 126 | max = tal_count(encoded); |
| 127 | /* fall thru */ |
| 128 | case ARR_UNCOMPRESSED: |
| 129 | ts = tal_arr(ctx, struct channel_update_timestamps, 0); |
| 130 | while (max) { |
| 131 | struct channel_update_timestamps t; |
| 132 | fromwire_channel_update_timestamps |
| 133 | (cast_const2(const u8 **, &encoded), |
| 134 | &max, &t); |
| 135 | /* Sets this to NULL if it fails */ |
| 136 | if (!encoded) |
| 137 | return tal_free(ts); |
| 138 | tal_arr_expand(&ts, t); |
| 139 | } |
| 140 | return ts; |
| 141 | } |
| 142 | return NULL; |
| 143 | } |