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

Function funder_channel_start

openingd/openingd.c:323–568  ·  view source on GitHub ↗

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 */

Source from the content-addressed store, hash-verified

321/* We start the 'open a channel' negotation with the supplied peer, but
322 * stop when we get to the part where we need the funding txid */
323static u8 *funder_channel_start(struct state *state, u8 channel_flags)
324{
325 u8 *msg;
326 u8 *funding_output_script;
327 struct channel_id id_in;
328 struct tlv_open_channel_tlvs *open_tlvs;
329 struct tlv_accept_channel_tlvs *accept_tlvs;
330 char *err_reason;
331 u32 their_mindepth;
332
333 status_debug("funder_channel_start");
334 if (!setup_channel_funder(state))
335 return NULL;
336
337 /* If we have a reserve override we use that, otherwise we'll
338 * use our default of 1% of the funding value. */
339 if (state->reserve != NULL) {
340 set_reserve_absolute(state, state->localconf.dust_limit,
341 *state->reserve);
342 } else {
343 set_reserve(state, state->localconf.dust_limit);
344 }
345
346 if (!state->upfront_shutdown_script[LOCAL])
347 state->upfront_shutdown_script[LOCAL]
348 = no_upfront_shutdown_script(state,
349 state->our_features,
350 state->their_features);
351
352 state->channel_type = default_channel_type(state,
353 state->our_features,
354 state->their_features);
355
356 open_tlvs = tlv_open_channel_tlvs_new(tmpctx);
357 open_tlvs->upfront_shutdown_script
358 = state->upfront_shutdown_script[LOCAL];
359
360 /* BOLT #2:
361 * - if it includes `channel_type`:
362 * - MUST set it to a defined type representing the type it wants.
363 * - MUST use the smallest bitmap possible to represent the channel
364 * type.
365 * - SHOULD NOT set it to a type containing a feature which was not
366 * negotiated.
367 */
368 open_tlvs->channel_type = state->channel_type->features;
369
370 msg = towire_open_channel(NULL,
371 &chainparams->genesis_blockhash,
372 &state->channel_id,
373 state->funding_sats,
374 state->push_msat,
375 state->localconf.dust_limit,
376 state->localconf.max_htlc_value_in_flight,
377 state->localconf.channel_reserve,
378 state->localconf.htlc_minimum,
379 state->feerate_per_kw,
380 state->localconf.to_self_delay,

Callers 1

handle_master_inFunction · 0.85

Calls 15

setup_channel_funderFunction · 0.85
set_reserve_absoluteFunction · 0.85
default_channel_typeFunction · 0.85
peer_writeFunction · 0.85
peer_failed_errFunction · 0.85
tal_hexFunction · 0.85
featurebits_eqFunction · 0.85
fmt_featurebitsFunction · 0.85
amount_sat_greaterFunction · 0.85
amount_sat_mulFunction · 0.85

Tested by

no test coverage detected