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

Function json_splice_init

lightningd/channel_control.c:2375–2486  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2373}
2374
2375static struct command_result *json_splice_init(struct command *cmd,
2376 const char *buffer,
2377 const jsmntok_t *obj UNNEEDED,
2378 const jsmntok_t *params)
2379{
2380 struct channel *channel;
2381 struct splice_command *cc;
2382 struct wally_psbt *initialpsbt;
2383 s64 *relative_amount;
2384 u32 *feerate_per_kw;
2385 u32 last_feerate, next_feerate_min;
2386 bool *force_feerate, *skip_stfu;
2387 u8 *msg;
2388
2389 if (!param_check(cmd, buffer, params,
2390 p_req("channel_id", param_channel_for_splice, &channel),
2391 p_req("relative_amount", param_s64, &relative_amount),
2392 p_opt("initialpsbt", param_psbt, &initialpsbt),
2393 p_opt("feerate_per_kw", param_feerate, &feerate_per_kw),
2394 p_opt_def("force_feerate", param_bool, &force_feerate, false),
2395 p_opt_def("skip_stfu", param_bool, &skip_stfu, false),
2396 NULL))
2397 return command_param_failed();
2398
2399 if (splice_command_for_chan(cmd->ld, channel))
2400 return command_fail(cmd,
2401 SPLICE_BUSY_ERROR,
2402 "Currently waiting on previous splice"
2403 " command to finish.");
2404
2405 /* With a splice pending, channeld sends this as tx_init_rbf.
2406 *
2407 * BOLT #2:
2408 * The sender:
2409 * - MUST set `feerate` greater than or equal to 25/24 times the
2410 * `feerate` of the previously constructed transaction, rounded
2411 * down.
2412 */
2413 last_feerate = channel_last_funding_feerate(channel);
2414 if (!last_feerate)
2415 next_feerate_min = 0;
2416 else if (!next_funding_feerate(last_feerate, &next_feerate_min))
2417 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
2418 "Can't calculate the next feerate: the"
2419 " pending splice's feerate (%u) is out"
2420 " of range",
2421 last_feerate);
2422
2423 if (feerate_per_kw && *feerate_per_kw < next_feerate_min)
2424 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
2425 "Next feerate must be at least 1/24th"
2426 " greater than the pending splice's. Min"
2427 " req %u, you proposed %u",
2428 next_feerate_min, *feerate_per_kw);
2429
2430 if (command_check_only(cmd))
2431 return command_check_done(cmd);
2432

Callers

nothing calls this directly

Calls 15

param_checkFunction · 0.85
splice_command_for_chanFunction · 0.85
next_funding_feerateFunction · 0.85
splice_feerateFunction · 0.85
our_feerate_maxFunction · 0.85
create_psbtFunction · 0.85
validate_psbtFunction · 0.85
psbt_set_versionFunction · 0.85
command_param_failedFunction · 0.70
command_failFunction · 0.70
command_check_onlyFunction · 0.70

Tested by

no test coverage detected