@@ -6195,10 +6195,9 @@ where
61956195 let mut htlc_value_msat = 0;
61966196 for (idx, htlc) in self.context.pending_inbound_htlcs.iter().enumerate() {
61976197 if htlc.htlc_id == htlc_id_arg {
6198- debug_assert_eq!(
6199- htlc.payment_hash,
6200- PaymentHash(Sha256::hash(&payment_preimage_arg.0[..]).to_byte_array())
6201- );
6198+ let expected_hash =
6199+ PaymentHash(Sha256::hash(&payment_preimage_arg.0[..]).to_byte_array());
6200+ debug_assert_eq!(htlc.payment_hash, expected_hash);
62026201 log_debug!(
62036202 logger,
62046203 "Claiming inbound HTLC id {} with payment hash {} with preimage {}",
@@ -6352,10 +6351,8 @@ where
63526351 self.context.latest_monitor_update_id = monitor_update.update_id;
63536352 monitor_update.updates.append(&mut additional_update.updates);
63546353 } else {
6355- let new_mon_id = self
6356- .context
6357- .blocked_monitor_updates
6358- .get(0)
6354+ let blocked_upd = self.context.blocked_monitor_updates.get(0);
6355+ let new_mon_id = blocked_upd
63596356 .map(|upd| upd.update.update_id)
63606357 .unwrap_or(monitor_update.update_id);
63616358 monitor_update.update_id = new_mon_id;
@@ -6687,11 +6684,9 @@ where
66876684 ));
66886685 }
66896686
6690- self.mark_outbound_htlc_removed(
6691- msg.htlc_id,
6692- OutboundHTLCOutcome::Success(msg.payment_preimage),
6693- )
6694- .map(|htlc| (htlc.source.clone(), htlc.amount_msat, htlc.skimmed_fee_msat))
6687+ let outcome = OutboundHTLCOutcome::Success(msg.payment_preimage);
6688+ self.mark_outbound_htlc_removed(msg.htlc_id, outcome)
6689+ .map(|htlc| (htlc.source.clone(), htlc.amount_msat, htlc.skimmed_fee_msat))
66956690 }
66966691
66976692 #[rustfmt::skip]
@@ -7262,10 +7257,10 @@ where
72627257 // `ChannelMonitorUpdate` to the user, making this one redundant, however
72637258 // there's no harm in including the extra `ChannelMonitorUpdateStep` here.
72647259 // We do not bother to track and include `payment_info` here, however.
7260+ let fulfill =
7261+ self.get_update_fulfill_htlc(htlc_id, *payment_preimage, None, logger);
72657262 let mut additional_monitor_update =
7266- if let UpdateFulfillFetch::NewClaim { monitor_update, .. } = self
7267- .get_update_fulfill_htlc(htlc_id, *payment_preimage, None, logger)
7268- {
7263+ if let UpdateFulfillFetch::NewClaim { monitor_update, .. } = fulfill {
72697264 monitor_update
72707265 } else {
72717266 unreachable!()
@@ -12429,12 +12424,8 @@ where
1242912424
1243012425 // Write out the old serialization for shutdown_pubkey for backwards compatibility, if
1243112426 // deserialized from that format.
12432- match self
12433- .context
12434- .shutdown_scriptpubkey
12435- .as_ref()
12436- .and_then(|script| script.as_legacy_pubkey())
12437- {
12427+ let shutdown_scriptpubkey = self.context.shutdown_scriptpubkey.as_ref();
12428+ match shutdown_scriptpubkey.and_then(|script| script.as_legacy_pubkey()) {
1243812429 Some(shutdown_pubkey) => shutdown_pubkey.write(writer)?,
1243912430 None => [0u8; PUBLIC_KEY_SIZE].write(writer)?,
1244012431 }
@@ -12713,11 +12704,11 @@ where
1271312704 // the default, and when `holder_max_htlc_value_in_flight_msat` is configured to be set to
1271412705 // a different percentage of the channel value then 10%, which older versions of LDK used
1271512706 // to set it to before the percentage was made configurable.
12707+ let legacy_reserve_satoshis = get_legacy_default_holder_selected_channel_reserve_satoshis(
12708+ self.funding.get_value_satoshis(),
12709+ );
1271612710 let serialized_holder_selected_reserve =
12717- if self.funding.holder_selected_channel_reserve_satoshis
12718- != get_legacy_default_holder_selected_channel_reserve_satoshis(
12719- self.funding.get_value_satoshis(),
12720- ) {
12711+ if self.funding.holder_selected_channel_reserve_satoshis != legacy_reserve_satoshis {
1272112712 Some(self.funding.holder_selected_channel_reserve_satoshis)
1272212713 } else {
1272312714 None
@@ -12726,12 +12717,12 @@ where
1272612717 let mut old_max_in_flight_percent_config = UserConfig::default().channel_handshake_config;
1272712718 old_max_in_flight_percent_config.max_inbound_htlc_value_in_flight_percent_of_channel =
1272812719 MAX_IN_FLIGHT_PERCENT_LEGACY;
12720+ let max_in_flight_msat = get_holder_max_htlc_value_in_flight_msat(
12721+ self.funding.get_value_satoshis(),
12722+ &old_max_in_flight_percent_config,
12723+ );
1272912724 let serialized_holder_htlc_max_in_flight =
12730- if self.context.holder_max_htlc_value_in_flight_msat
12731- != get_holder_max_htlc_value_in_flight_msat(
12732- self.funding.get_value_satoshis(),
12733- &old_max_in_flight_percent_config,
12734- ) {
12725+ if self.context.holder_max_htlc_value_in_flight_msat != max_in_flight_msat {
1273512726 Some(self.context.holder_max_htlc_value_in_flight_msat)
1273612727 } else {
1273712728 None
@@ -14228,16 +14219,17 @@ mod tests {
1422814219 &logger,
1422914220 )
1423014221 .unwrap();
14222+ let open_channel_msg = &outbound_chan
14223+ .get_open_channel(ChainHash::using_genesis_block(network), &&logger)
14224+ .unwrap();
1423114225 let mut inbound_chan = InboundV1Channel::<&TestKeysInterface>::new(
1423214226 &feeest,
1423314227 &&keys_provider,
1423414228 &&keys_provider,
1423514229 node_b_node_id,
1423614230 &channelmanager::provided_channel_type_features(&config),
1423714231 &features,
14238- &outbound_chan
14239- .get_open_channel(ChainHash::using_genesis_block(network), &&logger)
14240- .unwrap(),
14232+ open_channel_msg,
1424114233 7,
1424214234 &config,
1424314235 0,
0 commit comments