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

Function funder_finalize_channel_setup

openingd/openingd.c:544–781  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

542}
543
544static bool funder_finalize_channel_setup(struct state *state,
545 struct amount_msat local_msat,
546 struct bitcoin_signature *sig,
547 struct bitcoin_tx **tx,
548 struct penalty_base **pbase)
549{
550 u8 *msg;
551 struct channel_id id_in;
552 const u8 *wscript;
553 struct channel_id cid;
554 char *err_reason;
555 struct wally_tx_output *direct_outputs[NUM_SIDES];
556
557 /*~ Channel is ready; Report the channel parameters to the signer. */
558 msg = towire_hsmd_setup_channel(NULL,
559 true, /* is_outbound */
560 state->funding_sats,
561 state->push_msat,
562 &state->funding.txid,
563 state->funding.n,
564 state->localconf.to_self_delay,
565 state->upfront_shutdown_script[LOCAL],
566 state->local_upfront_shutdown_wallet_index,
567 &state->their_points,
568 &state->their_funding_pubkey,
569 state->remoteconf.to_self_delay,
570 state->upfront_shutdown_script[REMOTE],
571 state->channel_type);
572 wire_sync_write(HSM_FD, take(msg));
573 msg = wire_sync_read(tmpctx, HSM_FD);
574 if (!fromwire_hsmd_setup_channel_reply(msg))
575 status_failed(STATUS_FAIL_HSM_IO, "Bad setup_channel_reply %s",
576 tal_hex(tmpctx, msg));
577
578 /*~ Now we can initialize the `struct channel`. This represents
579 * the current channel state and is how we can generate the current
580 * commitment transaction.
581 *
582 * The routines to support `struct channel` are split into a common
583 * part (common/initial_channel) which doesn't support HTLCs and is
584 * enough for us here, and the complete channel support required by
585 * `channeld` which lives in channeld/full_channel. */
586 derive_channel_id(&cid, &state->funding);
587
588 state->channel = new_initial_channel(state,
589 &cid,
590 &state->funding,
591 state->minimum_depth,
592 NULL, 0, /* No channel lease */
593 state->funding_sats,
594 local_msat,
595 take(new_fee_states(NULL, LOCAL,
596 &state->feerate_per_kw)),
597 &state->localconf,
598 &state->remoteconf,
599 &state->our_points,
600 &state->their_points,
601 &state->our_funding_pubkey,

Callers 1

funder_channel_completeFunction · 0.85

Calls 15

tal_hexFunction · 0.85
derive_channel_idFunction · 0.85
new_initial_channelFunction · 0.85
new_fee_statesFunction · 0.85
initial_channel_txFunction · 0.85
penalty_base_newFunction · 0.85
fmt_bitcoin_signatureFunction · 0.85
fmt_bitcoin_txFunction · 0.85
fmt_pubkeyFunction · 0.85
peer_writeFunction · 0.85

Tested by

no test coverage detected