| 2314 | } |
| 2315 | |
| 2316 | static struct command_result *json_splice_init(struct command *cmd, |
| 2317 | const char *buffer, |
| 2318 | const jsmntok_t *obj UNNEEDED, |
| 2319 | const jsmntok_t *params) |
| 2320 | { |
| 2321 | struct channel *channel; |
| 2322 | struct splice_command *cc; |
| 2323 | struct wally_psbt *initialpsbt; |
| 2324 | s64 *relative_amount; |
| 2325 | u32 *feerate_per_kw; |
| 2326 | bool *force_feerate, *skip_stfu; |
| 2327 | u8 *msg; |
| 2328 | |
| 2329 | if (!param_check(cmd, buffer, params, |
| 2330 | p_req("channel_id", param_channel_for_splice, &channel), |
| 2331 | p_req("relative_amount", param_s64, &relative_amount), |
| 2332 | p_opt("initialpsbt", param_psbt, &initialpsbt), |
| 2333 | p_opt("feerate_per_kw", param_feerate, &feerate_per_kw), |
| 2334 | p_opt_def("force_feerate", param_bool, &force_feerate, false), |
| 2335 | p_opt_def("skip_stfu", param_bool, &skip_stfu, false), |
| 2336 | NULL)) |
| 2337 | return command_param_failed(); |
| 2338 | |
| 2339 | if (splice_command_for_chan(cmd->ld, channel)) |
| 2340 | return command_fail(cmd, |
| 2341 | SPLICE_BUSY_ERROR, |
| 2342 | "Currently waiting on previous splice" |
| 2343 | " command to finish."); |
| 2344 | |
| 2345 | if (command_check_only(cmd)) |
| 2346 | return command_check_done(cmd); |
| 2347 | |
| 2348 | if (!feerate_per_kw) { |
| 2349 | feerate_per_kw = tal(cmd, u32); |
| 2350 | *feerate_per_kw = splice_feerate(cmd->ld->topology, cmd->ld); |
| 2351 | } |
| 2352 | |
| 2353 | if (!initialpsbt) |
| 2354 | initialpsbt = create_psbt(cmd, 0, 0, 0); |
| 2355 | if (!validate_psbt(initialpsbt)) |
| 2356 | return command_fail(cmd, |
| 2357 | SPLICE_INPUT_ERROR, |
| 2358 | "PSBT failed to validate."); |
| 2359 | |
| 2360 | log_debug(cmd->ld->log, "splice_init input PSBT version %d," |
| 2361 | " feerate: %u", |
| 2362 | initialpsbt->version, |
| 2363 | *feerate_per_kw); |
| 2364 | |
| 2365 | cc = tal(cmd, struct splice_command); |
| 2366 | |
| 2367 | list_add_tail(&cmd->ld->splice_commands, &cc->list); |
| 2368 | tal_add_destructor(cc, destroy_splice_command); |
| 2369 | |
| 2370 | cc->cmd = cmd; |
| 2371 | cc->channel = channel; |
| 2372 | cc->stfu_req_info = NULL; |
| 2373 | cc->user_psbt_ver = initialpsbt->version; |
nothing calls this directly
no test coverage detected