@@ -6177,10 +6177,9 @@ where
61776177 let mut htlc_value_msat = 0;
61786178 for (idx, htlc) in self.context.pending_inbound_htlcs.iter().enumerate() {
61796179 if htlc.htlc_id == htlc_id_arg {
6180- debug_assert_eq!(
6181- htlc.payment_hash,
6182- PaymentHash(Sha256::hash(&payment_preimage_arg.0[..]).to_byte_array())
6183- );
6180+ let expected_hash =
6181+ PaymentHash(Sha256::hash(&payment_preimage_arg.0[..]).to_byte_array());
6182+ debug_assert_eq!(htlc.payment_hash, expected_hash);
61846183 log_debug!(
61856184 logger,
61866185 "Claiming inbound HTLC id {} with payment hash {} with preimage {}",
@@ -6334,10 +6333,8 @@ where
63346333 self.context.latest_monitor_update_id = monitor_update.update_id;
63356334 monitor_update.updates.append(&mut additional_update.updates);
63366335 } else {
6337- let new_mon_id = self
6338- .context
6339- .blocked_monitor_updates
6340- .get(0)
6336+ let blocked_upd = self.context.blocked_monitor_updates.get(0);
6337+ let new_mon_id = blocked_upd
63416338 .map(|upd| upd.update.update_id)
63426339 .unwrap_or(monitor_update.update_id);
63436340 monitor_update.update_id = new_mon_id;
@@ -6669,11 +6666,9 @@ where
66696666 ));
66706667 }
66716668
6672- self.mark_outbound_htlc_removed(
6673- msg.htlc_id,
6674- OutboundHTLCOutcome::Success(msg.payment_preimage),
6675- )
6676- .map(|htlc| (htlc.source.clone(), htlc.amount_msat, htlc.skimmed_fee_msat))
6669+ let outcome = OutboundHTLCOutcome::Success(msg.payment_preimage);
6670+ self.mark_outbound_htlc_removed(msg.htlc_id, outcome)
6671+ .map(|htlc| (htlc.source.clone(), htlc.amount_msat, htlc.skimmed_fee_msat))
66776672 }
66786673
66796674 #[rustfmt::skip]
@@ -7244,10 +7239,10 @@ where
72447239 // `ChannelMonitorUpdate` to the user, making this one redundant, however
72457240 // there's no harm in including the extra `ChannelMonitorUpdateStep` here.
72467241 // We do not bother to track and include `payment_info` here, however.
7242+ let fulfill =
7243+ self.get_update_fulfill_htlc(htlc_id, *payment_preimage, None, logger);
72477244 let mut additional_monitor_update =
7248- if let UpdateFulfillFetch::NewClaim { monitor_update, .. } = self
7249- .get_update_fulfill_htlc(htlc_id, *payment_preimage, None, logger)
7250- {
7245+ if let UpdateFulfillFetch::NewClaim { monitor_update, .. } = fulfill {
72517246 monitor_update
72527247 } else {
72537248 unreachable!()
@@ -12404,12 +12399,8 @@ where
1240412399
1240512400 // Write out the old serialization for shutdown_pubkey for backwards compatibility, if
1240612401 // deserialized from that format.
12407- match self
12408- .context
12409- .shutdown_scriptpubkey
12410- .as_ref()
12411- .and_then(|script| script.as_legacy_pubkey())
12412- {
12402+ let shutdown_scriptpubkey = self.context.shutdown_scriptpubkey.as_ref();
12403+ match shutdown_scriptpubkey.and_then(|script| script.as_legacy_pubkey()) {
1241312404 Some(shutdown_pubkey) => shutdown_pubkey.write(writer)?,
1241412405 None => [0u8; PUBLIC_KEY_SIZE].write(writer)?,
1241512406 }
@@ -12688,11 +12679,11 @@ where
1268812679 // the default, and when `holder_max_htlc_value_in_flight_msat` is configured to be set to
1268912680 // a different percentage of the channel value then 10%, which older versions of LDK used
1269012681 // to set it to before the percentage was made configurable.
12682+ let legacy_reserve_satoshis = get_legacy_default_holder_selected_channel_reserve_satoshis(
12683+ self.funding.get_value_satoshis(),
12684+ );
1269112685 let serialized_holder_selected_reserve =
12692- if self.funding.holder_selected_channel_reserve_satoshis
12693- != get_legacy_default_holder_selected_channel_reserve_satoshis(
12694- self.funding.get_value_satoshis(),
12695- ) {
12686+ if self.funding.holder_selected_channel_reserve_satoshis != legacy_reserve_satoshis {
1269612687 Some(self.funding.holder_selected_channel_reserve_satoshis)
1269712688 } else {
1269812689 None
@@ -12701,12 +12692,12 @@ where
1270112692 let mut old_max_in_flight_percent_config = UserConfig::default().channel_handshake_config;
1270212693 old_max_in_flight_percent_config.max_inbound_htlc_value_in_flight_percent_of_channel =
1270312694 MAX_IN_FLIGHT_PERCENT_LEGACY;
12695+ let max_in_flight_msat = get_holder_max_htlc_value_in_flight_msat(
12696+ self.funding.get_value_satoshis(),
12697+ &old_max_in_flight_percent_config,
12698+ );
1270412699 let serialized_holder_htlc_max_in_flight =
12705- if self.context.holder_max_htlc_value_in_flight_msat
12706- != get_holder_max_htlc_value_in_flight_msat(
12707- self.funding.get_value_satoshis(),
12708- &old_max_in_flight_percent_config,
12709- ) {
12700+ if self.context.holder_max_htlc_value_in_flight_msat != max_in_flight_msat {
1271012701 Some(self.context.holder_max_htlc_value_in_flight_msat)
1271112702 } else {
1271212703 None
@@ -14203,16 +14194,17 @@ mod tests {
1420314194 &logger,
1420414195 )
1420514196 .unwrap();
14197+ let open_channel_msg = &outbound_chan
14198+ .get_open_channel(ChainHash::using_genesis_block(network), &&logger)
14199+ .unwrap();
1420614200 let mut inbound_chan = InboundV1Channel::<&TestKeysInterface>::new(
1420714201 &feeest,
1420814202 &&keys_provider,
1420914203 &&keys_provider,
1421014204 node_b_node_id,
1421114205 &channelmanager::provided_channel_type_features(&config),
1421214206 &features,
14213- &outbound_chan
14214- .get_open_channel(ChainHash::using_genesis_block(network), &&logger)
14215- .unwrap(),
14207+ open_channel_msg,
1421614208 7,
1421714209 &config,
1421814210 0,
0 commit comments