@@ -10625,28 +10625,30 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
10625
10625
let is_our_scid = self.short_to_chan_info.read().unwrap().contains_key(&scid);
10626
10626
10627
10627
let mut forward_htlcs = self.forward_htlcs.lock().unwrap();
10628
+ let payment_hash = forward_info.payment_hash;
10629
+ let pending_add = PendingAddHTLCInfo {
10630
+ prev_short_channel_id,
10631
+ prev_counterparty_node_id,
10632
+ prev_funding_outpoint,
10633
+ prev_channel_id,
10634
+ prev_htlc_id,
10635
+ prev_user_channel_id,
10636
+ forward_info,
10637
+ };
10628
10638
match forward_htlcs.entry(scid) {
10629
10639
hash_map::Entry::Occupied(mut entry) => {
10630
- entry.get_mut().push(HTLCForwardInfo::AddHTLC(PendingAddHTLCInfo {
10631
- prev_short_channel_id,
10632
- prev_counterparty_node_id,
10633
- prev_funding_outpoint,
10634
- prev_channel_id,
10635
- prev_htlc_id,
10636
- prev_user_channel_id,
10637
- forward_info,
10638
- }));
10640
+ entry.get_mut().push(HTLCForwardInfo::AddHTLC(pending_add));
10639
10641
},
10640
10642
hash_map::Entry::Vacant(entry) => {
10641
10643
if !is_our_scid
10642
- && forward_info.incoming_amt_msat.is_some()
10644
+ && pending_add. forward_info.incoming_amt_msat.is_some()
10643
10645
&& fake_scid::is_valid_intercept(
10644
10646
&self.fake_scid_rand_bytes,
10645
10647
scid,
10646
10648
&self.chain_hash,
10647
10649
) {
10648
10650
let intercept_id = InterceptId(
10649
- Sha256::hash(&forward_info.incoming_shared_secret)
10651
+ Sha256::hash(&pending_add. forward_info.incoming_shared_secret)
10650
10652
.to_byte_array(),
10651
10653
);
10652
10654
let mut pending_intercepts =
@@ -10656,57 +10658,35 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
10656
10658
new_intercept_events.push_back((
10657
10659
events::Event::HTLCIntercepted {
10658
10660
requested_next_hop_scid: scid,
10659
- payment_hash: forward_info.payment_hash,
10660
- inbound_amount_msat: forward_info
10661
+ payment_hash,
10662
+ inbound_amount_msat: pending_add
10663
+ .forward_info
10661
10664
.incoming_amt_msat
10662
10665
.unwrap(),
10663
- expected_outbound_amount_msat: forward_info
10666
+ expected_outbound_amount_msat: pending_add
10667
+ .forward_info
10664
10668
.outgoing_amt_msat,
10665
10669
intercept_id,
10666
10670
},
10667
10671
None,
10668
10672
));
10669
- entry.insert(PendingAddHTLCInfo {
10670
- prev_short_channel_id,
10671
- prev_counterparty_node_id,
10672
- prev_funding_outpoint,
10673
- prev_channel_id,
10674
- prev_htlc_id,
10675
- prev_user_channel_id,
10676
- forward_info,
10677
- });
10673
+ entry.insert(pending_add);
10678
10674
},
10679
10675
hash_map::Entry::Occupied(_) => {
10680
10676
let logger = WithContext::from(
10681
10677
&self.logger,
10682
10678
None,
10683
10679
Some(prev_channel_id),
10684
- Some(forward_info. payment_hash),
10680
+ Some(payment_hash),
10685
10681
);
10686
10682
log_info!(
10687
10683
logger,
10688
10684
"Failed to forward incoming HTLC: detected duplicate intercepted payment over short channel id {}",
10689
10685
scid
10690
10686
);
10691
- let routing = &forward_info.routing;
10692
- let htlc_source =
10693
- HTLCSource::PreviousHopData(HTLCPreviousHopData {
10694
- short_channel_id: prev_short_channel_id,
10695
- user_channel_id: Some(prev_user_channel_id),
10696
- counterparty_node_id: Some(
10697
- prev_counterparty_node_id,
10698
- ),
10699
- outpoint: prev_funding_outpoint,
10700
- channel_id: prev_channel_id,
10701
- htlc_id: prev_htlc_id,
10702
- incoming_packet_shared_secret: forward_info
10703
- .incoming_shared_secret,
10704
- phantom_shared_secret: None,
10705
- blinded_failure: routing.blinded_failure(),
10706
- cltv_expiry: routing.incoming_cltv_expiry(),
10707
- });
10708
-
10709
- let payment_hash = forward_info.payment_hash;
10687
+ let htlc_source = HTLCSource::PreviousHopData(
10688
+ pending_add.htlc_previous_hop_data(),
10689
+ );
10710
10690
let reason = HTLCFailReason::from_failure_code(
10711
10691
LocalHTLCFailureReason::UnknownNextPeer,
10712
10692
);
@@ -10723,15 +10703,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
10723
10703
},
10724
10704
}
10725
10705
} else {
10726
- entry.insert(vec![HTLCForwardInfo::AddHTLC(PendingAddHTLCInfo {
10727
- prev_short_channel_id,
10728
- prev_counterparty_node_id,
10729
- prev_funding_outpoint,
10730
- prev_channel_id,
10731
- prev_htlc_id,
10732
- prev_user_channel_id,
10733
- forward_info,
10734
- })]);
10706
+ entry.insert(vec![HTLCForwardInfo::AddHTLC(pending_add)]);
10735
10707
}
10736
10708
},
10737
10709
}
0 commit comments