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

Function json_askrene_create_layer

plugins/askrene/askrene.c:1344–1382  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1342}
1343
1344static struct command_result *json_askrene_create_layer(struct command *cmd,
1345 const char *buffer,
1346 const jsmntok_t *params)
1347{
1348 struct askrene *askrene = get_askrene(cmd->plugin);
1349 struct layer *layer;
1350 const char *layername;
1351 struct json_stream *response;
1352 bool *persistent;
1353
1354 if (!param_check(cmd, buffer, params,
1355 p_req("layer", param_string, &layername),
1356 p_opt_def("persistent", param_bool, &persistent, false),
1357 NULL))
1358 return command_param_failed();
1359 plugin_log(cmd->plugin, LOG_TRACE, "%s called: %.*s", __func__,
1360 json_tok_full_len(params), json_tok_full(buffer, params));
1361
1362 if (strstarts(layername, "auto."))
1363 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
1364 "Cannot create auto layer");
1365
1366 /* If it's persistent, creation is a noop if it already exists */
1367 layer = find_layer(askrene, layername);
1368 if (layer && !*persistent) {
1369 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
1370 "Layer already exists");
1371 }
1372
1373 if (command_check_only(cmd))
1374 return command_check_done(cmd);
1375
1376 if (!layer)
1377 layer = new_layer(askrene, layername, *persistent);
1378
1379 response = jsonrpc_stream_success(cmd);
1380 json_add_layers(response, askrene, "layers", layer);
1381 return command_finished(cmd, response);
1382}
1383
1384static struct command_result *json_askrene_remove_layer(struct command *cmd,
1385 const char *buffer,

Callers

nothing calls this directly

Calls 14

get_askreneFunction · 0.85
param_checkFunction · 0.85
find_layerFunction · 0.85
new_layerFunction · 0.85
json_add_layersFunction · 0.85
command_param_failedFunction · 0.50
plugin_logFunction · 0.50
json_tok_full_lenFunction · 0.50
json_tok_fullFunction · 0.50
command_failFunction · 0.50
command_check_onlyFunction · 0.50
command_check_doneFunction · 0.50

Tested by

no test coverage detected