Steals fields from uncommitted_channel: returns NULL if can't generate a * key for this channel (shouldn't happen!). */
| 1073 | /* Steals fields from uncommitted_channel: returns NULL if can't generate a |
| 1074 | * key for this channel (shouldn't happen!). */ |
| 1075 | static struct channel_inflight * |
| 1076 | wallet_update_channel(struct lightningd *ld, |
| 1077 | struct channel *channel, |
| 1078 | struct bitcoin_tx *remote_commit STEALS, |
| 1079 | struct bitcoin_signature *remote_commit_sig, |
| 1080 | const struct bitcoin_outpoint *funding, |
| 1081 | struct amount_sat total_funding, |
| 1082 | struct amount_sat our_funding, |
| 1083 | u32 funding_feerate, |
| 1084 | struct wally_psbt *psbt STEALS, |
| 1085 | const u32 lease_expiry, |
| 1086 | struct amount_sat lease_fee, |
| 1087 | secp256k1_ecdsa_signature *lease_commit_sig STEALS, |
| 1088 | const u32 lease_chan_max_msat, |
| 1089 | const u16 lease_chan_max_ppt, |
| 1090 | const u32 lease_blockheight_start) |
| 1091 | { |
| 1092 | struct amount_msat our_msat, lease_fee_msat; |
| 1093 | struct channel_inflight *inflight; |
| 1094 | |
| 1095 | if (!amount_sat_to_msat(&our_msat, our_funding)) { |
| 1096 | log_broken(channel->log, "Unable to convert funds"); |
| 1097 | return NULL; |
| 1098 | } |
| 1099 | |
| 1100 | if (!amount_sat_to_msat(&lease_fee_msat, lease_fee)) { |
| 1101 | log_broken(channel->log, "Unable to convert 'lease_fee'"); |
| 1102 | return NULL; |
| 1103 | } |
| 1104 | |
| 1105 | assert(channel->unsaved_dbid == 0); |
| 1106 | assert(channel->dbid != 0); |
| 1107 | |
| 1108 | channel->funding = *funding; |
| 1109 | channel->funding_sats = total_funding; |
| 1110 | channel->our_funds = our_funding; |
| 1111 | channel->our_msat = our_msat; |
| 1112 | channel->push = lease_fee_msat; |
| 1113 | channel->msat_to_us_min = our_msat; |
| 1114 | channel->msat_to_us_max = our_msat; |
| 1115 | channel->lease_expiry = lease_expiry; |
| 1116 | channel->htlc_minimum_msat = channel->channel_info.their_config.htlc_minimum; |
| 1117 | channel->htlc_maximum_msat = htlc_max_possible_send(channel); |
| 1118 | |
| 1119 | tal_free(channel->lease_commit_sig); |
| 1120 | channel->lease_commit_sig = tal_steal(channel, lease_commit_sig); |
| 1121 | channel->lease_chan_max_msat = lease_chan_max_msat; |
| 1122 | channel->lease_chan_max_ppt = lease_chan_max_ppt; |
| 1123 | |
| 1124 | tal_free(channel->blockheight_states); |
| 1125 | channel->blockheight_states = new_height_states(channel, |
| 1126 | channel->opener, |
| 1127 | &lease_blockheight_start); |
| 1128 | |
| 1129 | channel_set_last_tx(channel, |
| 1130 | tal_steal(channel, remote_commit), |
| 1131 | remote_commit_sig, |
| 1132 | TX_CHANNEL_UNILATERAL); |
no test coverage detected