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

Function json_splice_signed

lightningd/channel_control.c:2578–2643  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2576}
2577
2578static struct command_result *json_splice_signed(struct command *cmd,
2579 const char *buffer,
2580 const jsmntok_t *obj UNNEEDED,
2581 const jsmntok_t *params)
2582{
2583 struct channel *channel, **channels;
2584 struct wally_psbt *psbt;
2585 struct channel_id *channel_ids;
2586 struct command_result *result;
2587 bool *sign_first;
2588 bool success;
2589
2590 if (!param_check(cmd, buffer, params,
2591 p_req("psbt", param_psbt, &psbt),
2592 p_opt("channel_id", param_channel_for_splice, &channel),
2593 p_opt_def("sign_first", param_bool, &sign_first, false),
2594 NULL))
2595 return command_param_failed();
2596
2597 if (!validate_psbt(psbt))
2598 return command_fail(cmd, SPLICE_INPUT_ERROR,
2599 "PSBT failed to validate.");
2600
2601 log_debug(cmd->ld->log, "splice_signed input PSBT version %d",
2602 psbt->version);
2603
2604 /* If a single channel is specified, we do that and finish. */
2605 if (channel) {
2606 if (command_check_only(cmd))
2607 return command_check_done(cmd);
2608 return single_splice_signed(cmd, channel, psbt, *sign_first,
2609 NULL);
2610 }
2611
2612 if (!psbt_get_channel_ids(tmpctx, psbt, &channel_ids))
2613 return command_fail(cmd, SPLICE_INPUT_ERROR,
2614 "Unable to find channel_ids in psbt.");
2615
2616 /* We load into channels in a seperate pass to do checks before
2617 * beginning in earnest. */
2618 channels = tal_arr(tmpctx, struct channel*, tal_count(channel_ids));
2619 for (size_t i = 0; i < tal_count(channels); i++) {
2620 result = channel_for_splice(cmd, &channel_ids[i], &channels[i]);
2621 if (result)
2622 return result;
2623 }
2624
2625 if (command_check_only(cmd))
2626 return command_check_done(cmd);
2627
2628 /* Now execute the splice event for each channel */
2629 /* TODO: We need to intelligently choose the order of channel to splice,
2630 * store the signatures received on each run, and pass them to the next
2631 */
2632 for (size_t i = 0; i < tal_count(channels); i++) {
2633 success = false;
2634 result = single_splice_signed(cmd, channels[i], psbt,
2635 *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