| 160 | } |
| 161 | |
| 162 | u8 *json_tok_bin_from_hex(const tal_t *ctx, const char *buffer, const jsmntok_t *tok) |
| 163 | { |
| 164 | u8 *result; |
| 165 | size_t hexlen, rawlen; |
| 166 | hexlen = tok->end - tok->start; |
| 167 | rawlen = hex_data_size(hexlen); |
| 168 | |
| 169 | result = tal_arr(ctx, u8, rawlen); |
| 170 | if (!hex_decode(buffer + tok->start, hexlen, result, rawlen)) |
| 171 | return tal_free(result); |
| 172 | |
| 173 | return result; |
| 174 | } |
| 175 | |
| 176 | /* talfmt take a ctx pointer and return NULL or a valid pointer. |
| 177 | * fmt takes the argument, and returns a bool. |
no test coverage detected