We start the 'open a channel' negotation with the supplied peer, but * stop when we get to the part where we need the funding txid */
| 268 | /* We start the 'open a channel' negotation with the supplied peer, but |
| 269 | * stop when we get to the part where we need the funding txid */ |
| 270 | static u8 *funder_channel_start(struct state *state, u8 channel_flags, |
| 271 | u32 nonanchor_feerate, u32 anchor_feerate, |
| 272 | const struct channel_type *ctype TAKES) |
| 273 | { |
| 274 | u8 *msg; |
| 275 | u8 *funding_output_script; |
| 276 | struct channel_id id_in; |
| 277 | struct tlv_open_channel_tlvs *open_tlvs; |
| 278 | struct tlv_accept_channel_tlvs *accept_tlvs; |
| 279 | char *err_reason; |
| 280 | u32 their_mindepth; |
| 281 | |
| 282 | status_debug("funder_channel_start"); |
| 283 | if (!setup_channel_funder(state)) |
| 284 | return NULL; |
| 285 | |
| 286 | /* If we have a reserve override we use that, otherwise we'll |
| 287 | * use our default of 1% of the funding value. */ |
| 288 | if (state->reserve != NULL) { |
| 289 | set_reserve_absolute(state, state->localconf.dust_limit, |
| 290 | *state->reserve); |
| 291 | } else { |
| 292 | set_reserve(state, state->localconf.dust_limit); |
| 293 | } |
| 294 | |
| 295 | if (!state->upfront_shutdown_script[LOCAL]) |
| 296 | state->upfront_shutdown_script[LOCAL] |
| 297 | = no_upfront_shutdown_script(state, state->developer, |
| 298 | state->our_features, |
| 299 | state->their_features); |
| 300 | |
| 301 | state->channel_type = channel_type_dup(state, ctype); |
| 302 | /* We set scid alias if we're not announcing */ |
| 303 | if (feature_negotiated(state->our_features, state->their_features, |
| 304 | OPT_SCID_ALIAS) |
| 305 | && !(channel_flags & CHANNEL_FLAGS_ANNOUNCE_CHANNEL)) { |
| 306 | channel_type_set_scid_alias(state->channel_type); |
| 307 | } |
| 308 | |
| 309 | /* Which feerate do we use? (We can lowball fees if using anchors!) */ |
| 310 | if (channel_type_has_anchors(state->channel_type)) { |
| 311 | state->feerate_per_kw = anchor_feerate; |
| 312 | } else { |
| 313 | state->feerate_per_kw = nonanchor_feerate; |
| 314 | } |
| 315 | |
| 316 | /* If they use the same settings as us, would we fail? If so, do that now. */ |
| 317 | if (!check_config_bounds(tmpctx, state->funding_sats, |
| 318 | state->feerate_per_kw, |
| 319 | state->max_to_self_delay, |
| 320 | state->min_effective_htlc_capacity, |
| 321 | &state->localconf, |
| 322 | &state->localconf, |
| 323 | channel_type_has(state->channel_type, OPT_ANCHORS_ZERO_FEE_HTLC_TX), |
| 324 | &err_reason)) { |
| 325 | negotiation_aborted(state, |
| 326 | tal_fmt(tmpctx, "Not opening because if they used the same setting as us %s", |
| 327 | err_reason)); |
no test coverage detected