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

Function initial_channel_tx

common/initial_channel.c:88–155  ·  view source on GitHub ↗

FIXME: We could cache this. */

Source from the content-addressed store, hash-verified

86
87/* FIXME: We could cache this. */
88struct bitcoin_tx *initial_channel_tx(const tal_t *ctx,
89 const u8 **wscript,
90 const struct channel *channel,
91 const struct pubkey *per_commitment_point,
92 enum side side,
93 struct wally_tx_output *direct_outputs[NUM_SIDES],
94 char** err_reason)
95{
96 struct keyset keyset;
97 struct bitcoin_tx *init_tx;
98 u32 csv_lock;
99
100 /* This assumes no HTLCs! */
101 assert(!channel->htlcs);
102
103 if (!derive_keyset(per_commitment_point,
104 &channel->basepoints[side],
105 &channel->basepoints[!side],
106 channel_has(channel, OPT_STATIC_REMOTEKEY),
107 &keyset)) {
108 *err_reason = "Cannot derive keyset";
109 return NULL;
110 }
111
112 /* Figure out the csv_lock (if there's a lease) */
113 if (channel->lease_expiry == 0)
114 csv_lock = 1;
115 else
116 /* For the initial commitment, starts max lease */
117 csv_lock = channel->lease_expiry
118 - get_blockheight(channel->blockheight_states,
119 channel->opener,
120 side);
121
122 init_tx = initial_commit_tx(ctx, &channel->funding,
123 channel->funding_sats,
124 channel->funding_pubkey,
125 channel->opener,
126 /* They specify our to_self_delay and v.v. */
127 channel->config[!side].to_self_delay,
128 &keyset,
129 channel_feerate(channel, side),
130 channel->config[side].dust_limit,
131 channel->view[side].owed[side],
132 channel->view[side].owed[!side],
133 channel->config[!side].channel_reserve,
134 0 ^ channel->commitment_number_obscurer,
135 direct_outputs,
136 side, csv_lock,
137 channel_has(channel, OPT_ANCHOR_OUTPUTS_DEPRECATED),
138 channel_has(channel, OPT_ANCHORS_ZERO_FEE_HTLC_TX),
139 err_reason);
140
141 if (init_tx) {
142 psbt_input_add_pubkey(init_tx->psbt, 0,
143 &channel->funding_pubkey[side], false /* is_taproot */);
144 psbt_input_add_pubkey(init_tx->psbt, 0,
145 &channel->funding_pubkey[!side], false /* is_taproot */);

Callers 5

handle_initFunction · 0.85
fundee_channelFunction · 0.85
msg_for_remote_commitFunction · 0.85

Calls 7

get_blockheightFunction · 0.85
initial_commit_txFunction · 0.85
channel_feerateFunction · 0.85
psbt_input_add_pubkeyFunction · 0.85
bitcoin_redeem_2of2Function · 0.85
derive_keysetFunction · 0.70
channel_hasFunction · 0.70

Tested by

no test coverage detected