@@ -6220,10 +6220,9 @@ where
62206220 let mut htlc_value_msat = 0;
62216221 for (idx, htlc) in self.context.pending_inbound_htlcs.iter().enumerate() {
62226222 if htlc.htlc_id == htlc_id_arg {
6223- debug_assert_eq!(
6224- htlc.payment_hash,
6225- PaymentHash(Sha256::hash(&payment_preimage_arg.0[..]).to_byte_array())
6226- );
6223+ let expected_hash =
6224+ PaymentHash(Sha256::hash(&payment_preimage_arg.0[..]).to_byte_array());
6225+ debug_assert_eq!(htlc.payment_hash, expected_hash);
62276226 log_debug!(
62286227 logger,
62296228 "Claiming inbound HTLC id {} with payment hash {} with preimage {}",
@@ -6377,10 +6376,8 @@ where
63776376 self.context.latest_monitor_update_id = monitor_update.update_id;
63786377 monitor_update.updates.append(&mut additional_update.updates);
63796378 } else {
6380- let new_mon_id = self
6381- .context
6382- .blocked_monitor_updates
6383- .get(0)
6379+ let blocked_upd = self.context.blocked_monitor_updates.get(0);
6380+ let new_mon_id = blocked_upd
63846381 .map(|upd| upd.update.update_id)
63856382 .unwrap_or(monitor_update.update_id);
63866383 monitor_update.update_id = new_mon_id;
@@ -6712,11 +6709,9 @@ where
67126709 ));
67136710 }
67146711
6715- self.mark_outbound_htlc_removed(
6716- msg.htlc_id,
6717- OutboundHTLCOutcome::Success(msg.payment_preimage),
6718- )
6719- .map(|htlc| (htlc.source.clone(), htlc.amount_msat, htlc.skimmed_fee_msat))
6712+ let outcome = OutboundHTLCOutcome::Success(msg.payment_preimage);
6713+ self.mark_outbound_htlc_removed(msg.htlc_id, outcome)
6714+ .map(|htlc| (htlc.source.clone(), htlc.amount_msat, htlc.skimmed_fee_msat))
67206715 }
67216716
67226717 #[rustfmt::skip]
@@ -12465,12 +12460,8 @@ where
1246512460
1246612461 // Write out the old serialization for shutdown_pubkey for backwards compatibility, if
1246712462 // deserialized from that format.
12468- match self
12469- .context
12470- .shutdown_scriptpubkey
12471- .as_ref()
12472- .and_then(|script| script.as_legacy_pubkey())
12473- {
12463+ let shutdown_scriptpubkey = self.context.shutdown_scriptpubkey.as_ref();
12464+ match shutdown_scriptpubkey.and_then(|script| script.as_legacy_pubkey()) {
1247412465 Some(shutdown_pubkey) => shutdown_pubkey.write(writer)?,
1247512466 None => [0u8; PUBLIC_KEY_SIZE].write(writer)?,
1247612467 }
@@ -12749,11 +12740,11 @@ where
1274912740 // the default, and when `holder_max_htlc_value_in_flight_msat` is configured to be set to
1275012741 // a different percentage of the channel value then 10%, which older versions of LDK used
1275112742 // to set it to before the percentage was made configurable.
12743+ let legacy_reserve_satoshis = get_legacy_default_holder_selected_channel_reserve_satoshis(
12744+ self.funding.get_value_satoshis(),
12745+ );
1275212746 let serialized_holder_selected_reserve =
12753- if self.funding.holder_selected_channel_reserve_satoshis
12754- != get_legacy_default_holder_selected_channel_reserve_satoshis(
12755- self.funding.get_value_satoshis(),
12756- ) {
12747+ if self.funding.holder_selected_channel_reserve_satoshis != legacy_reserve_satoshis {
1275712748 Some(self.funding.holder_selected_channel_reserve_satoshis)
1275812749 } else {
1275912750 None
@@ -12762,12 +12753,12 @@ where
1276212753 let mut old_max_in_flight_percent_config = UserConfig::default().channel_handshake_config;
1276312754 old_max_in_flight_percent_config.max_inbound_htlc_value_in_flight_percent_of_channel =
1276412755 MAX_IN_FLIGHT_PERCENT_LEGACY;
12756+ let max_in_flight_msat = get_holder_max_htlc_value_in_flight_msat(
12757+ self.funding.get_value_satoshis(),
12758+ &old_max_in_flight_percent_config,
12759+ );
1276512760 let serialized_holder_htlc_max_in_flight =
12766- if self.context.holder_max_htlc_value_in_flight_msat
12767- != get_holder_max_htlc_value_in_flight_msat(
12768- self.funding.get_value_satoshis(),
12769- &old_max_in_flight_percent_config,
12770- ) {
12761+ if self.context.holder_max_htlc_value_in_flight_msat != max_in_flight_msat {
1277112762 Some(self.context.holder_max_htlc_value_in_flight_msat)
1277212763 } else {
1277312764 None
@@ -14262,16 +14253,17 @@ mod tests {
1426214253 &logger,
1426314254 )
1426414255 .unwrap();
14256+ let open_channel_msg = &outbound_chan
14257+ .get_open_channel(ChainHash::using_genesis_block(network), &&logger)
14258+ .unwrap();
1426514259 let mut inbound_chan = InboundV1Channel::<&TestKeysInterface>::new(
1426614260 &feeest,
1426714261 &&keys_provider,
1426814262 &&keys_provider,
1426914263 node_b_node_id,
1427014264 &channelmanager::provided_channel_type_features(&config),
1427114265 &features,
14272- &outbound_chan
14273- .get_open_channel(ChainHash::using_genesis_block(network), &&logger)
14274- .unwrap(),
14266+ open_channel_msg,
1427514267 7,
1427614268 &config,
1427714269 0,
0 commit comments