@@ -6177,10 +6177,9 @@ where
6177
6177
let mut htlc_value_msat = 0;
6178
6178
for (idx, htlc) in self.context.pending_inbound_htlcs.iter().enumerate() {
6179
6179
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);
6184
6183
log_debug!(
6185
6184
logger,
6186
6185
"Claiming inbound HTLC id {} with payment hash {} with preimage {}",
@@ -6334,10 +6333,8 @@ where
6334
6333
self.context.latest_monitor_update_id = monitor_update.update_id;
6335
6334
monitor_update.updates.append(&mut additional_update.updates);
6336
6335
} 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
6341
6338
.map(|upd| upd.update.update_id)
6342
6339
.unwrap_or(monitor_update.update_id);
6343
6340
monitor_update.update_id = new_mon_id;
@@ -6669,11 +6666,9 @@ where
6669
6666
));
6670
6667
}
6671
6668
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))
6677
6672
}
6678
6673
6679
6674
#[rustfmt::skip]
@@ -7244,10 +7239,10 @@ where
7244
7239
// `ChannelMonitorUpdate` to the user, making this one redundant, however
7245
7240
// there's no harm in including the extra `ChannelMonitorUpdateStep` here.
7246
7241
// 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);
7247
7244
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 {
7251
7246
monitor_update
7252
7247
} else {
7253
7248
unreachable!()
@@ -12404,12 +12399,8 @@ where
12404
12399
12405
12400
// Write out the old serialization for shutdown_pubkey for backwards compatibility, if
12406
12401
// 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()) {
12413
12404
Some(shutdown_pubkey) => shutdown_pubkey.write(writer)?,
12414
12405
None => [0u8; PUBLIC_KEY_SIZE].write(writer)?,
12415
12406
}
@@ -12688,11 +12679,11 @@ where
12688
12679
// the default, and when `holder_max_htlc_value_in_flight_msat` is configured to be set to
12689
12680
// a different percentage of the channel value then 10%, which older versions of LDK used
12690
12681
// 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
+ );
12691
12685
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 {
12696
12687
Some(self.funding.holder_selected_channel_reserve_satoshis)
12697
12688
} else {
12698
12689
None
@@ -12701,12 +12692,12 @@ where
12701
12692
let mut old_max_in_flight_percent_config = UserConfig::default().channel_handshake_config;
12702
12693
old_max_in_flight_percent_config.max_inbound_htlc_value_in_flight_percent_of_channel =
12703
12694
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
+ );
12704
12699
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 {
12710
12701
Some(self.context.holder_max_htlc_value_in_flight_msat)
12711
12702
} else {
12712
12703
None
@@ -14203,16 +14194,17 @@ mod tests {
14203
14194
&logger,
14204
14195
)
14205
14196
.unwrap();
14197
+ let open_channel_msg = &outbound_chan
14198
+ .get_open_channel(ChainHash::using_genesis_block(network), &&logger)
14199
+ .unwrap();
14206
14200
let mut inbound_chan = InboundV1Channel::<&TestKeysInterface>::new(
14207
14201
&feeest,
14208
14202
&&keys_provider,
14209
14203
&&keys_provider,
14210
14204
node_b_node_id,
14211
14205
&channelmanager::provided_channel_type_features(&config),
14212
14206
&features,
14213
- &outbound_chan
14214
- .get_open_channel(ChainHash::using_genesis_block(network), &&logger)
14215
- .unwrap(),
14207
+ open_channel_msg,
14216
14208
7,
14217
14209
&config,
14218
14210
0,
0 commit comments