| 979 | } |
| 980 | |
| 981 | struct command_result *param_extra_tlvs(struct command *cmd, const char *name, |
| 982 | const char *buffer, |
| 983 | const jsmntok_t *tok, |
| 984 | struct tlv_field **fields) |
| 985 | { |
| 986 | size_t i; |
| 987 | const jsmntok_t *curr; |
| 988 | struct tlv_field *f, *temp; |
| 989 | |
| 990 | if (tok->type != JSMN_OBJECT) { |
| 991 | return command_fail( |
| 992 | cmd, JSONRPC2_INVALID_PARAMS, |
| 993 | "Could not decode the TLV object from %s: " |
| 994 | "\"%s\" is not a valid JSON object.", |
| 995 | name, json_strdup(tmpctx, buffer, tok)); |
| 996 | } |
| 997 | |
| 998 | temp = tal_arr(cmd, struct tlv_field, tok->size); |
| 999 | json_for_each_obj(i, curr, tok) { |
| 1000 | f = &temp[i]; |
| 1001 | /* Accept either bare ints as keys (not spec |
| 1002 | * compliant, but simpler), or ints in strings, which |
| 1003 | * are JSON spec compliant. */ |
| 1004 | if (!json_to_u64(buffer, curr, &f->numtype)) { |
| 1005 | return command_fail( |
| 1006 | cmd, JSONRPC2_INVALID_PARAMS, |
| 1007 | "\"%s\" is not a valid numeric TLV type.", |
| 1008 | json_strdup(tmpctx, buffer, curr)); |
| 1009 | } |
| 1010 | f->value = json_tok_bin_from_hex(temp, buffer, curr + 1); |
| 1011 | |
| 1012 | if (f->value == NULL) { |
| 1013 | return command_fail( |
| 1014 | cmd, JSONRPC2_INVALID_PARAMS, |
| 1015 | "\"%s\" is not a valid hex encoded TLV value.", |
| 1016 | json_strdup(tmpctx, buffer, curr)); |
| 1017 | } |
| 1018 | f->length = tal_bytelen(f->value); |
| 1019 | f->meta = NULL; |
| 1020 | } |
| 1021 | *fields = temp; |
| 1022 | return NULL; |
| 1023 | } |
| 1024 | |
| 1025 | static struct command_result *param_routehint(struct command *cmd, |
| 1026 | const char *name, |
nothing calls this directly
no test coverage detected