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

Function wallet_commit_channel

lightningd/dual_open_control.c:1158–1304  ·  view source on GitHub ↗

Returns NULL if can't generate a key for this channel (Shouldn't happen) */

Source from the content-addressed store, hash-verified

1156
1157/* Returns NULL if can't generate a key for this channel (Shouldn't happen) */
1158static struct channel_inflight *
1159wallet_commit_channel(struct lightningd *ld,
1160 struct channel *channel,
1161 struct bitcoin_tx *remote_commit,
1162 struct bitcoin_signature *remote_commit_sig,
1163 const struct bitcoin_outpoint *funding,
1164 struct amount_sat total_funding,
1165 struct amount_sat our_funding,
1166 struct channel_info *channel_info,
1167 u32 funding_feerate,
1168 u32 commitment_feerate,
1169 const u8 *our_upfront_shutdown_script,
1170 const u8 *remote_upfront_shutdown_script,
1171 struct wally_psbt *psbt STEALS,
1172 const u32 lease_blockheight_start,
1173 const u32 lease_expiry,
1174 const struct amount_sat lease_fee,
1175 secp256k1_ecdsa_signature *lease_commit_sig STEALS,
1176 const u32 lease_chan_max_msat,
1177 const u16 lease_chan_max_ppt)
1178{
1179 struct amount_msat our_msat, lease_fee_msat;
1180 struct channel_inflight *inflight;
1181 bool any_active = peer_any_active_channel(channel->peer, NULL);
1182
1183 if (!amount_sat_to_msat(&our_msat, our_funding)) {
1184 log_broken(channel->log, "Unable to convert funds");
1185 return NULL;
1186 }
1187
1188 if (!amount_sat_to_msat(&lease_fee_msat, lease_fee)) {
1189 log_broken(channel->log, "Unable to convert lease fee");
1190 return NULL;
1191 }
1192
1193 /* Get a key to use for closing outputs from this tx */
1194 channel->final_key_idx = wallet_get_newindex(ld);
1195 if (channel->final_key_idx == -1) {
1196 log_broken(channel->log, "Can't get final key index");
1197 return NULL;
1198 }
1199
1200 /* This is a new channel_info.their_config so set its ID to 0 */
1201 channel_info->their_config.id = 0;
1202 /* old_remote_per_commit not valid yet, copy valid one. */
1203 channel_info->old_remote_per_commit = channel_info->remote_per_commit;
1204
1205 /* Promote the unsaved_dbid to the dbid */
1206 assert(channel->unsaved_dbid != 0);
1207 channel->dbid = channel->unsaved_dbid;
1208 channel->unsaved_dbid = 0;
1209
1210 channel->funding = *funding;
1211 channel->funding_sats = total_funding;
1212 channel->our_funds = our_funding;
1213 channel->our_msat = our_msat;
1214 channel->push = lease_fee_msat;
1215 channel->msat_to_us_min = our_msat;

Callers 1

handle_commit_receivedFunction · 0.70

Calls 14

wallet_get_newindexFunction · 0.85
new_fee_statesFunction · 0.85
channel_type_dupFunction · 0.85
p2wpkh_for_keyidxFunction · 0.85
tal_freeFunction · 0.85
wallet_channel_insertFunction · 0.85
new_inflightFunction · 0.85
wallet_inflight_addFunction · 0.85
peer_any_active_channelFunction · 0.70
get_block_heightFunction · 0.70
htlc_max_possible_sendFunction · 0.70
try_reconnectFunction · 0.70

Tested by

no test coverage detected