@@ -6190,10 +6190,9 @@ where
61906190 let mut htlc_value_msat = 0;
61916191 for (idx, htlc) in self.context.pending_inbound_htlcs.iter().enumerate() {
61926192 if htlc.htlc_id == htlc_id_arg {
6193- debug_assert_eq!(
6194- htlc.payment_hash,
6195- PaymentHash(Sha256::hash(&payment_preimage_arg.0[..]).to_byte_array())
6196- );
6193+ let expected_hash =
6194+ PaymentHash(Sha256::hash(&payment_preimage_arg.0[..]).to_byte_array());
6195+ debug_assert_eq!(htlc.payment_hash, expected_hash);
61976196 log_debug!(
61986197 logger,
61996198 "Claiming inbound HTLC id {} with payment hash {} with preimage {}",
@@ -6347,10 +6346,8 @@ where
63476346 self.context.latest_monitor_update_id = monitor_update.update_id;
63486347 monitor_update.updates.append(&mut additional_update.updates);
63496348 } else {
6350- let new_mon_id = self
6351- .context
6352- .blocked_monitor_updates
6353- .get(0)
6349+ let blocked_upd = self.context.blocked_monitor_updates.get(0);
6350+ let new_mon_id = blocked_upd
63546351 .map(|upd| upd.update.update_id)
63556352 .unwrap_or(monitor_update.update_id);
63566353 monitor_update.update_id = new_mon_id;
@@ -6682,11 +6679,9 @@ where
66826679 ));
66836680 }
66846681
6685- self.mark_outbound_htlc_removed(
6686- msg.htlc_id,
6687- OutboundHTLCOutcome::Success(msg.payment_preimage),
6688- )
6689- .map(|htlc| (htlc.source.clone(), htlc.amount_msat, htlc.skimmed_fee_msat))
6682+ let outcome = OutboundHTLCOutcome::Success(msg.payment_preimage);
6683+ self.mark_outbound_htlc_removed(msg.htlc_id, outcome)
6684+ .map(|htlc| (htlc.source.clone(), htlc.amount_msat, htlc.skimmed_fee_msat))
66906685 }
66916686
66926687 #[rustfmt::skip]
@@ -7259,10 +7254,10 @@ where
72597254 // `ChannelMonitorUpdate` to the user, making this one redundant, however
72607255 // there's no harm in including the extra `ChannelMonitorUpdateStep` here.
72617256 // We do not bother to track and include `payment_info` here, however.
7257+ let fulfill =
7258+ self.get_update_fulfill_htlc(htlc_id, *payment_preimage, None, logger);
72627259 let mut additional_monitor_update =
7263- if let UpdateFulfillFetch::NewClaim { monitor_update, .. } = self
7264- .get_update_fulfill_htlc(htlc_id, *payment_preimage, None, logger)
7265- {
7260+ if let UpdateFulfillFetch::NewClaim { monitor_update, .. } = fulfill {
72667261 monitor_update
72677262 } else {
72687263 unreachable!()
@@ -12434,12 +12429,8 @@ where
1243412429
1243512430 // Write out the old serialization for shutdown_pubkey for backwards compatibility, if
1243612431 // deserialized from that format.
12437- match self
12438- .context
12439- .shutdown_scriptpubkey
12440- .as_ref()
12441- .and_then(|script| script.as_legacy_pubkey())
12442- {
12432+ let shutdown_scriptpubkey = self.context.shutdown_scriptpubkey.as_ref();
12433+ match shutdown_scriptpubkey.and_then(|script| script.as_legacy_pubkey()) {
1244312434 Some(shutdown_pubkey) => shutdown_pubkey.write(writer)?,
1244412435 None => [0u8; PUBLIC_KEY_SIZE].write(writer)?,
1244512436 }
@@ -12718,11 +12709,11 @@ where
1271812709 // the default, and when `holder_max_htlc_value_in_flight_msat` is configured to be set to
1271912710 // a different percentage of the channel value then 10%, which older versions of LDK used
1272012711 // to set it to before the percentage was made configurable.
12712+ let legacy_reserve_satoshis = get_legacy_default_holder_selected_channel_reserve_satoshis(
12713+ self.funding.get_value_satoshis(),
12714+ );
1272112715 let serialized_holder_selected_reserve =
12722- if self.funding.holder_selected_channel_reserve_satoshis
12723- != get_legacy_default_holder_selected_channel_reserve_satoshis(
12724- self.funding.get_value_satoshis(),
12725- ) {
12716+ if self.funding.holder_selected_channel_reserve_satoshis != legacy_reserve_satoshis {
1272612717 Some(self.funding.holder_selected_channel_reserve_satoshis)
1272712718 } else {
1272812719 None
@@ -12731,12 +12722,12 @@ where
1273112722 let mut old_max_in_flight_percent_config = UserConfig::default().channel_handshake_config;
1273212723 old_max_in_flight_percent_config.max_inbound_htlc_value_in_flight_percent_of_channel =
1273312724 MAX_IN_FLIGHT_PERCENT_LEGACY;
12725+ let max_in_flight_msat = get_holder_max_htlc_value_in_flight_msat(
12726+ self.funding.get_value_satoshis(),
12727+ &old_max_in_flight_percent_config,
12728+ );
1273412729 let serialized_holder_htlc_max_in_flight =
12735- if self.context.holder_max_htlc_value_in_flight_msat
12736- != get_holder_max_htlc_value_in_flight_msat(
12737- self.funding.get_value_satoshis(),
12738- &old_max_in_flight_percent_config,
12739- ) {
12730+ if self.context.holder_max_htlc_value_in_flight_msat != max_in_flight_msat {
1274012731 Some(self.context.holder_max_htlc_value_in_flight_msat)
1274112732 } else {
1274212733 None
@@ -14233,16 +14224,17 @@ mod tests {
1423314224 &logger,
1423414225 )
1423514226 .unwrap();
14227+ let open_channel_msg = &outbound_chan
14228+ .get_open_channel(ChainHash::using_genesis_block(network), &&logger)
14229+ .unwrap();
1423614230 let mut inbound_chan = InboundV1Channel::<&TestKeysInterface>::new(
1423714231 &feeest,
1423814232 &&keys_provider,
1423914233 &&keys_provider,
1424014234 node_b_node_id,
1424114235 &channelmanager::provided_channel_type_features(&config),
1424214236 &features,
14243- &outbound_chan
14244- .get_open_channel(ChainHash::using_genesis_block(network), &&logger)
14245- .unwrap(),
14237+ open_channel_msg,
1424614238 7,
1424714239 &config,
1424814240 0,
0 commit comments