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

Function json_fundchannel_start

lightningd/opening_control.c:1284–1508  ·  view source on GitHub ↗

* json_fundchannel_start - Entrypoint for funding a channel */

Source from the content-addressed store, hash-verified

1282 * json_fundchannel_start - Entrypoint for funding a channel
1283 */
1284static struct command_result *json_fundchannel_start(struct command *cmd,
1285 const char *buffer,
1286 const jsmntok_t *obj UNNEEDED,
1287 const jsmntok_t *params)
1288{
1289 struct funding_channel * fc = tal(cmd, struct funding_channel);
1290 struct node_id *id;
1291 struct peer *peer;
1292 bool *announce_channel;
1293 u32 *feerate_non_anchor, feerate_anchor, *mindepth;
1294 struct amount_sat *amount, *reserve;
1295 struct amount_msat *push_msat;
1296 u32 *upfront_shutdown_script_wallet_index;
1297 struct channel_id tmp_channel_id;
1298 struct channel_type *ctype;
1299
1300 fc->cmd = cmd;
1301 fc->cancels = tal_arr(fc, struct command *, 0);
1302 fc->uc = NULL;
1303 fc->inflight = false;
1304 fc->funding_scriptpubkey = NULL;
1305
1306 if (!param_check(fc->cmd, buffer, params,
1307 p_req("id", param_node_id, &id),
1308 p_req("amount", param_sat, &amount),
1309 p_opt("feerate", param_feerate, &feerate_non_anchor),
1310 p_opt_def("announce", param_bool, &announce_channel, true),
1311 p_opt("close_to", param_bitcoin_address, &fc->our_upfront_shutdown_script),
1312 p_opt("push_msat", param_msat, &push_msat),
1313 p_opt("mindepth", param_u32, &mindepth),
1314 p_opt("reserve", param_sat, &reserve),
1315 p_opt("channel_type", param_channel_type, &ctype),
1316 NULL))
1317 return command_param_failed();
1318
1319 if (ctype) {
1320 fc->channel_type = tal_steal(fc, ctype);
1321 if (!cmd->ld->dev_any_channel_type &&
1322 !channel_type_accept(tmpctx,
1323 ctype->features,
1324 cmd->ld->our_features)) {
1325 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
1326 "channel_type not supported");
1327 }
1328 /* BOLT #2:
1329 *
1330 * The sender:
1331 * - if `channel_type` includes `option_zeroconf`:
1332 * - MUST set `minimum_depth` to zero.
1333 * - otherwise:
1334 * - SHOULD set `minimum_depth` to a number of blocks it
1335 * considers reasonable to avoid double-spending of the
1336 * funding transaction.
1337 */
1338 if (channel_type_has(ctype, OPT_ZEROCONF)) {
1339 if (mindepth && *mindepth != 0) {
1340 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
1341 "Cannot set non-zero mindepth for zero-conf channel_type");

Callers

nothing calls this directly

Calls 15

param_checkFunction · 0.85
channel_type_acceptFunction · 0.85
channel_type_hasFunction · 0.85
amount_msat_greater_satFunction · 0.85
feature_offeredFunction · 0.85
peer_by_idFunction · 0.85
feature_negotiatedFunction · 0.85
amount_sat_greaterFunction · 0.85
desired_channel_typeFunction · 0.85
log_infoClass · 0.85
fmt_node_idFunction · 0.85
wallet_can_spendFunction · 0.85

Tested by

no test coverage detected