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

Function json_splice_signed

lightningd/channel_control.c:2478–2543  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2476}
2477
2478static struct command_result *json_splice_signed(struct command *cmd,
2479 const char *buffer,
2480 const jsmntok_t *obj UNNEEDED,
2481 const jsmntok_t *params)
2482{
2483 struct channel *channel, **channels;
2484 struct wally_psbt *psbt;
2485 struct channel_id *channel_ids;
2486 struct command_result *result;
2487 bool *sign_first;
2488 bool success;
2489
2490 if (!param_check(cmd, buffer, params,
2491 p_req("psbt", param_psbt, &psbt),
2492 p_opt("channel_id", param_channel_for_splice, &channel),
2493 p_opt_def("sign_first", param_bool, &sign_first, false),
2494 NULL))
2495 return command_param_failed();
2496
2497 if (!validate_psbt(psbt))
2498 return command_fail(cmd, SPLICE_INPUT_ERROR,
2499 "PSBT failed to validate.");
2500
2501 log_debug(cmd->ld->log, "splice_signed input PSBT version %d",
2502 psbt->version);
2503
2504 /* If a single channel is specified, we do that and finish. */
2505 if (channel) {
2506 if (command_check_only(cmd))
2507 return command_check_done(cmd);
2508 return single_splice_signed(cmd, channel, psbt, *sign_first,
2509 NULL);
2510 }
2511
2512 if (!psbt_get_channel_ids(tmpctx, psbt, &channel_ids))
2513 return command_fail(cmd, SPLICE_INPUT_ERROR,
2514 "Unable to find channel_ids in psbt.");
2515
2516 /* We load into channels in a seperate pass to do checks before
2517 * beginning in earnest. */
2518 channels = tal_arr(tmpctx, struct channel*, tal_count(channel_ids));
2519 for (size_t i = 0; i < tal_count(channels); i++) {
2520 result = channel_for_splice(cmd, &channel_ids[i], &channels[i]);
2521 if (result)
2522 return result;
2523 }
2524
2525 if (command_check_only(cmd))
2526 return command_check_done(cmd);
2527
2528 /* Now execute the splice event for each channel */
2529 /* TODO: We need to intelligently choose the order of channel to splice,
2530 * store the signatures received on each run, and pass them to the next
2531 */
2532 for (size_t i = 0; i < tal_count(channels); i++) {
2533 success = false;
2534 result = single_splice_signed(cmd, channels[i], psbt,
2535 *sign_first, &success);

Callers

nothing calls this directly

Calls 9

param_checkFunction · 0.85
validate_psbtFunction · 0.85
single_splice_signedFunction · 0.85
psbt_get_channel_idsFunction · 0.85
channel_for_spliceFunction · 0.85
command_param_failedFunction · 0.70
command_failFunction · 0.70
command_check_onlyFunction · 0.70
command_check_doneFunction · 0.70

Tested by

no test coverage detected