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