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

Function reckless_call

plugins/recklessrpc.c:214–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212}
213
214static struct command_result *reckless_call(struct command *cmd,
215 const char *subcommand,
216 const char *target,
217 const char *target2)
218{
219 if (!subcommand || !target)
220 return command_fail(cmd, PLUGIN_ERROR, "invalid reckless call");
221 char **my_call;
222 my_call = tal_arrz(tmpctx, char *, 0);
223 tal_arr_expand(&my_call, "reckless");
224 tal_arr_expand(&my_call, "-v");
225 tal_arr_expand(&my_call, "--json");
226 tal_arr_expand(&my_call, "-l");
227 tal_arr_expand(&my_call, lconfig.lightningdir);
228 tal_arr_expand(&my_call, "--network");
229 tal_arr_expand(&my_call, lconfig.network);
230 if (lconfig.config) {
231 tal_arr_expand(&my_call, "--conf");
232 tal_arr_expand(&my_call, lconfig.config);
233 }
234 tal_arr_expand(&my_call, (char *) subcommand);
235 tal_arr_expand(&my_call, (char *) target);
236 if (target2)
237 tal_arr_expand(&my_call, (char *) target2);
238 tal_arr_expand(&my_call, NULL);
239 struct reckless *reckless;
240 reckless = tal(NULL, struct reckless);
241 reckless->cmd = cmd;
242 reckless->stdoutbuf = tal_arrz(reckless, char, 4096);
243 reckless->stderrbuf = tal_arrz(reckless, char, 4096);
244 reckless->stdout_read = 0;
245 reckless->stdout_new = 0;
246 reckless->stderr_read = 0;
247 reckless->stderr_new = 0;
248 reckless->process_failed = NULL;
249 char * full_cmd;
250 full_cmd = tal_fmt(tmpctx, "calling:");
251 for (int i=0; i<tal_count(my_call); i++)
252 tal_append_fmt(&full_cmd, " %s", my_call[i]);
253 plugin_log(plugin, LOG_DBG, "%s", full_cmd);
254 tal_free(full_cmd);
255
256 reckless->pid = pipecmdarr(&reckless->stdinfd, &reckless->stdoutfd,
257 &reckless->stderrfd, my_call);
258
259 if (reckless->pid < 0) {
260 return command_fail(cmd, LIGHTNINGD, "reckless failed: %s",
261 strerror(errno));
262 }
263
264 io_new_conn(reckless, reckless->stdoutfd, conn_init, reckless);
265 io_new_conn(reckless, reckless->stderrfd, stderr_conn_init, reckless);
266 tal_free(my_call);
267 return command_still_pending(cmd);
268}
269
270static struct command_result *json_reckless(struct command *cmd,
271 const char *buf,

Callers 1

json_recklessFunction · 0.85

Calls 6

tal_append_fmtFunction · 0.85
tal_freeFunction · 0.85
pipecmdarrFunction · 0.85
command_failFunction · 0.70
plugin_logFunction · 0.70
command_still_pendingFunction · 0.70

Tested by

no test coverage detected