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

Function param_routehint

common/json_param.c:907–947  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

905}
906
907static struct command_result *param_routehint(struct command *cmd,
908 const char *name,
909 const char *buffer,
910 const jsmntok_t *tok,
911 struct route_info **ri)
912{
913 size_t i;
914 const jsmntok_t *curr;
915 const char *err;
916
917 if (tok->type != JSMN_ARRAY) {
918 return command_fail(
919 cmd, JSONRPC2_INVALID_PARAMS,
920 "Routehint %s (\"%s\") is not an array of hop objects",
921 name, json_strdup(tmpctx, buffer, tok));
922 }
923
924 *ri = tal_arr(cmd, struct route_info, tok->size);
925 json_for_each_arr(i, curr, tok) {
926 struct route_info *e = &(*ri)[i];
927 struct amount_msat temp;
928
929 err = json_scan(tmpctx, buffer, curr,
930 "{id:%,scid:%,feebase:%,feeprop:%,expirydelta:%}",
931 JSON_SCAN(json_to_node_id, &e->pubkey),
932 JSON_SCAN(json_to_short_channel_id, &e->short_channel_id),
933 JSON_SCAN(json_to_msat, &temp),
934 JSON_SCAN(json_to_u32, &e->fee_proportional_millionths),
935 JSON_SCAN(json_to_u16, &e->cltv_expiry_delta)
936 );
937 e->fee_base_msat =
938 temp.millisatoshis; /* Raw: internal conversion. */
939 if (err != NULL) {
940 return command_fail(
941 cmd, JSONRPC2_INVALID_PARAMS,
942 "Error parsing routehint %s[%zu]: %s", name, i,
943 err);
944 }
945 }
946 return NULL;
947}
948
949struct command_result *
950param_routehint_array(struct command *cmd, const char *name, const char *buffer,

Callers 1

param_routehint_arrayFunction · 0.85

Calls 3

json_strdupFunction · 0.70
json_scanFunction · 0.70
command_failFunction · 0.50

Tested by

no test coverage detected