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

Function json_splice

plugins/spender/splice.c:2147–2217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2145}
2146
2147static struct command_result *
2148json_splice(struct command *cmd, const char *buf, const jsmntok_t *params)
2149{
2150 struct out_req *req;
2151 const char *script;
2152 const jsmntok_t *json;
2153 struct wally_psbt *psbt;
2154 bool *dryrun, *force_feerate, *debug_log, *wetrun;
2155 struct str_or_arr *str_or_arr;
2156
2157 if (!param(cmd, buf, params,
2158 p_opt("script_or_json", param_string_or_array, &str_or_arr),
2159 p_opt_def("dryrun", param_bool, &dryrun, false),
2160 p_opt_def("force_feerate", param_bool, &force_feerate,
2161 false),
2162 p_opt_def("debug_log", param_bool, &debug_log, false),
2163 p_opt_dev("dev-wetrun", param_bool, &wetrun, false),
2164 NULL))
2165 return command_param_failed();
2166
2167 if (!str_or_arr)
2168 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
2169 "Must pass 'script_or_json'");
2170
2171 script = str_or_arr->str;
2172 json = str_or_arr->arr;
2173
2174 psbt = create_psbt(cmd, 0, 0, 0);
2175
2176 struct splice_cmd *splice_cmd = tal(cmd, struct splice_cmd);
2177
2178 splice_cmd->cmd = cmd;
2179 splice_cmd->script = tal_steal(splice_cmd, script);
2180 splice_cmd->psbt = tal_steal(splice_cmd, psbt);
2181 splice_cmd->dryrun = *dryrun;
2182 splice_cmd->wetrun = *wetrun;
2183 splice_cmd->feerate_per_kw = 0;
2184 splice_cmd->force_feerate = *force_feerate;
2185 splice_cmd->wallet_inputs_to_signed = 0;
2186 splice_cmd->fee_calculated = false;
2187 splice_cmd->initial_funds = AMOUNT_SAT(0);
2188 splice_cmd->emergency_sat = AMOUNT_SAT(0);
2189 splice_cmd->debug_log = *debug_log ? tal_strdup(splice_cmd, "") : NULL;
2190 splice_cmd->debug_counter = 0;
2191 splice_cmd->needed_funds = AMOUNT_SAT(0);
2192 memset(&splice_cmd->final_txid, 0, sizeof(splice_cmd->final_txid));
2193
2194 /* If script validates as json, parse it as json instead */
2195 if (json) {
2196 if (!json_to_splice(splice_cmd, buf, json,
2197 &splice_cmd->actions))
2198 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
2199 "splice json failed validation");
2200
2201 splice_cmd->states = tal_arr(splice_cmd,
2202 struct splice_cmd_action_state*,
2203 tal_count(splice_cmd->actions));
2204

Callers

nothing calls this directly

Calls 6

create_psbtFunction · 0.85
json_to_spliceFunction · 0.85
paramFunction · 0.50
command_param_failedFunction · 0.50
command_failFunction · 0.50
send_outreqFunction · 0.50

Tested by

no test coverage detected