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

Function param_onion_hops

lightningd/onion_message.c:178–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

176};
177
178static struct command_result *param_onion_hops(struct command *cmd,
179 const char *name,
180 const char *buffer,
181 const jsmntok_t *tok,
182 struct onion_hop **hops)
183{
184 size_t i;
185 const jsmntok_t *t;
186
187 if (tok->type != JSMN_ARRAY || tok->size == 0)
188 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
189 "%s must be an (non-empty) array", name);
190
191 *hops = tal_arr(cmd, struct onion_hop, tok->size);
192 json_for_each_arr(i, t, tok) {
193 const char *err;
194
195 err = json_scan(cmd, buffer, t, "{id:%,tlv:%}",
196 JSON_SCAN(json_to_pubkey, &(*hops)[i].node),
197 JSON_SCAN_TAL(tmpctx, json_tok_bin_from_hex,
198 &(*hops)[i].tlv));
199 if (err)
200 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
201 "%s[%zu]: %s", name, i, err);
202 }
203 return NULL;
204}
205
206static struct command_result *json_sendonionmessage(struct command *cmd,
207 const char *buffer,

Callers

nothing calls this directly

Calls 2

command_failFunction · 0.70
json_scanFunction · 0.50

Tested by

no test coverage detected