* json_fundchannel_start - Entrypoint for funding a channel */
| 1282 | * json_fundchannel_start - Entrypoint for funding a channel |
| 1283 | */ |
| 1284 | static 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"); |
nothing calls this directly
no test coverage detected