| 137 | } |
| 138 | |
| 139 | u8 *json_tok_bin_from_hex(const tal_t *ctx, const char *buffer, const jsmntok_t *tok) |
| 140 | { |
| 141 | u8 *result; |
| 142 | size_t hexlen, rawlen; |
| 143 | hexlen = tok->end - tok->start; |
| 144 | rawlen = hex_data_size(hexlen); |
| 145 | |
| 146 | result = tal_arr(ctx, u8, rawlen); |
| 147 | if (!hex_decode(buffer + tok->start, hexlen, result, rawlen)) |
| 148 | return tal_free(result); |
| 149 | |
| 150 | return result; |
| 151 | } |
| 152 | |
| 153 | /* talfmt take a ctx pointer and return NULL or a valid pointer. |
| 154 | * fmt takes the argument, and returns a bool. |
no test coverage detected