MCPcopy Create free account
hub / github.com/ElementsProject/lightning / param_extra_tlvs

Function param_extra_tlvs

common/json_param.c:866–905  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

864}
865
866struct command_result *param_extra_tlvs(struct command *cmd, const char *name,
867 const char *buffer,
868 const jsmntok_t *tok,
869 struct tlv_field **fields)
870{
871 size_t i;
872 const jsmntok_t *curr;
873 struct tlv_field *f, *temp;
874
875 if (tok->type != JSMN_OBJECT) {
876 return command_fail(
877 cmd, JSONRPC2_INVALID_PARAMS,
878 "Could not decode the TLV object from %s: "
879 "\"%s\" is not a valid JSON object.",
880 name, json_strdup(tmpctx, buffer, tok));
881 }
882
883 temp = tal_arr(cmd, struct tlv_field, tok->size);
884 json_for_each_obj(i, curr, tok) {
885 f = &temp[i];
886 if (!json_to_u64(buffer, curr, &f->numtype)) {
887 return command_fail(
888 cmd, JSONRPC2_INVALID_PARAMS,
889 "\"%s\" is not a valid numeric TLV type.",
890 json_strdup(tmpctx, buffer, curr));
891 }
892 f->value = json_tok_bin_from_hex(temp, buffer, curr + 1);
893
894 if (f->value == NULL) {
895 return command_fail(
896 cmd, JSONRPC2_INVALID_PARAMS,
897 "\"%s\" is not a valid hex encoded TLV value.",
898 json_strdup(tmpctx, buffer, curr));
899 }
900 f->length = tal_bytelen(f->value);
901 f->meta = NULL;
902 }
903 *fields = temp;
904 return NULL;
905}
906
907static struct command_result *param_routehint(struct command *cmd,
908 const char *name,

Callers

nothing calls this directly

Calls 5

tal_bytelenFunction · 0.85
json_strdupFunction · 0.70
json_to_u64Function · 0.70
json_tok_bin_from_hexFunction · 0.70
command_failFunction · 0.50

Tested by

no test coverage detected