| 2486 | } |
| 2487 | |
| 2488 | static struct command_result *json_splice_update(struct command *cmd, |
| 2489 | const char *buffer, |
| 2490 | const jsmntok_t *obj UNNEEDED, |
| 2491 | const jsmntok_t *params) |
| 2492 | { |
| 2493 | struct channel *channel; |
| 2494 | struct splice_command *cc; |
| 2495 | struct wally_psbt *psbt; |
| 2496 | |
| 2497 | if (!param(cmd, buffer, params, |
| 2498 | p_req("channel_id", param_channel_for_splice, &channel), |
| 2499 | p_req("psbt", param_psbt, &psbt), |
| 2500 | NULL)) |
| 2501 | return command_param_failed(); |
| 2502 | |
| 2503 | if (splice_command_for_chan(cmd->ld, channel)) |
| 2504 | return command_fail(cmd, |
| 2505 | SPLICE_BUSY_ERROR, |
| 2506 | "Currently waiting on previous splice" |
| 2507 | " command to finish."); |
| 2508 | if (!validate_psbt(psbt)) |
| 2509 | return command_fail(cmd, |
| 2510 | SPLICE_INPUT_ERROR, |
| 2511 | "PSBT failed to validate."); |
| 2512 | |
| 2513 | log_debug(cmd->ld->log, "splice_update input PSBT version %d", |
| 2514 | psbt->version); |
| 2515 | |
| 2516 | cc = tal(cmd, struct splice_command); |
| 2517 | |
| 2518 | list_add_tail(&cmd->ld->splice_commands, &cc->list); |
| 2519 | tal_add_destructor(cc, destroy_splice_command); |
| 2520 | |
| 2521 | cc->cmd = cmd; |
| 2522 | cc->channel = channel; |
| 2523 | cc->stfu_req_info = NULL; |
| 2524 | cc->user_psbt_ver = psbt->version; |
| 2525 | |
| 2526 | if (psbt->version != 2 && !psbt_set_version(psbt, 2)) |
| 2527 | return command_fail(cmd, |
| 2528 | SPLICE_INPUT_ERROR, |
| 2529 | "Splice failed to convert to v2"); |
| 2530 | |
| 2531 | subd_send_msg(channel->owner, |
| 2532 | take(towire_channeld_splice_update(NULL, psbt))); |
| 2533 | return command_still_pending(cmd); |
| 2534 | } |
| 2535 | |
| 2536 | static struct command_result *single_splice_signed(struct command *cmd, |
| 2537 | struct channel *channel, |
nothing calls this directly
no test coverage detected