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

Function wallet_update_channel

lightningd/dual_open_control.c:1217–1295  ·  view source on GitHub ↗

Steals fields from uncommitted_channel: returns NULL if can't generate a * key for this channel (shouldn't happen!). */

Source from the content-addressed store, hash-verified

1215/* Steals fields from uncommitted_channel: returns NULL if can't generate a
1216 * key for this channel (shouldn't happen!). */
1217static struct channel_inflight *
1218wallet_update_channel(struct lightningd *ld,
1219 struct channel *channel,
1220 const struct bitcoin_outpoint *funding,
1221 struct amount_sat total_funding,
1222 struct amount_sat our_funding,
1223 u32 funding_feerate,
1224 struct wally_psbt *psbt STEALS,
1225 const u32 lease_expiry,
1226 struct amount_sat lease_fee,
1227 secp256k1_ecdsa_signature *lease_commit_sig STEALS,
1228 const u32 lease_chan_max_msat,
1229 const u16 lease_chan_max_ppt,
1230 const u32 lease_blockheight_start,
1231 struct amount_sat lease_amt)
1232{
1233 struct amount_msat our_msat, lease_fee_msat;
1234 struct channel_inflight *inflight;
1235
1236 if (!amount_sat_to_msat(&our_msat, our_funding)) {
1237 log_broken(channel->log, "Unable to convert funds");
1238 return NULL;
1239 }
1240
1241 if (!amount_sat_to_msat(&lease_fee_msat, lease_fee)) {
1242 log_broken(channel->log, "Unable to convert 'lease_fee'");
1243 return NULL;
1244 }
1245
1246 assert(channel->unsaved_dbid == 0);
1247 assert(channel->dbid != 0);
1248
1249 channel->funding = *funding;
1250 channel->funding_sats = total_funding;
1251 channel->our_funds = our_funding;
1252 channel->our_msat = our_msat;
1253 channel->push = lease_fee_msat;
1254 channel->msat_to_us_min = our_msat;
1255 channel->msat_to_us_max = our_msat;
1256 channel->lease_expiry = lease_expiry;
1257 channel->htlc_minimum_msat = channel->channel_info.their_config.htlc_minimum;
1258 channel->htlc_maximum_msat = htlc_max_possible_send(channel);
1259
1260 tal_free(channel->lease_commit_sig);
1261 channel->lease_commit_sig = tal_steal(channel, lease_commit_sig);
1262 channel->lease_chan_max_msat = lease_chan_max_msat;
1263 channel->lease_chan_max_ppt = lease_chan_max_ppt;
1264
1265 tal_free(channel->blockheight_states);
1266 channel->blockheight_states = new_height_states(channel,
1267 channel->opener,
1268 &lease_blockheight_start);
1269
1270 /* Update in database */
1271 wallet_channel_save(ld->wallet, channel);
1272
1273 /* Add open attempt to channel's inflights */
1274 inflight = new_inflight(channel,

Callers 1

handle_commit_readyFunction · 0.85

Calls 7

tal_freeFunction · 0.85
new_height_statesFunction · 0.85
wallet_inflight_addFunction · 0.85
htlc_max_possible_sendFunction · 0.70
new_inflightFunction · 0.70
amount_sat_to_msatFunction · 0.50
wallet_channel_saveFunction · 0.50

Tested by

no test coverage detected