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