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