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

Function funder_finalize_channel_setup

openingd/openingd.c:546–783  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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