@@ -131,6 +131,9 @@ pub(super) struct PendingHTLCInfo {
131
131
/// may overshoot this in either case)
132
132
pub ( super ) outgoing_amt_msat : u64 ,
133
133
pub ( super ) outgoing_cltv_value : u32 ,
134
+ /// The fee being skimmed off the top of this HTLC. If this is a forward, it'll be the fee we are
135
+ /// skimming. If we're receiving this HTLC, it's the fee that our counterparty skimmed.
136
+ pub ( super ) skimmed_fee_msat : Option < u64 > ,
134
137
}
135
138
136
139
#[ derive( Clone ) ] // See Channel::revoke_and_ack for why, tl;dr: Rust bug
@@ -2623,6 +2626,7 @@ where
2623
2626
incoming_amt_msat : Some ( amt_msat) ,
2624
2627
outgoing_amt_msat : hop_data. amt_to_forward ,
2625
2628
outgoing_cltv_value : hop_data. outgoing_cltv_value ,
2629
+ skimmed_fee_msat : None ,
2626
2630
} )
2627
2631
}
2628
2632
@@ -2890,6 +2894,7 @@ where
2890
2894
incoming_amt_msat : Some ( msg. amount_msat ) ,
2891
2895
outgoing_amt_msat : next_hop_data. amt_to_forward ,
2892
2896
outgoing_cltv_value : next_hop_data. outgoing_cltv_value ,
2897
+ skimmed_fee_msat : None ,
2893
2898
} )
2894
2899
}
2895
2900
}
@@ -3527,7 +3532,10 @@ where
3527
3532
} ,
3528
3533
_ => unreachable ! ( ) // Only `PendingHTLCRouting::Forward`s are intercepted
3529
3534
} ;
3535
+ let skimmed_fee_msat =
3536
+ payment. forward_info . outgoing_amt_msat . saturating_sub ( amt_to_forward_msat) ;
3530
3537
let pending_htlc_info = PendingHTLCInfo {
3538
+ skimmed_fee_msat : if skimmed_fee_msat == 0 { None } else { Some ( skimmed_fee_msat) } ,
3531
3539
outgoing_amt_msat : amt_to_forward_msat, routing, ..payment. forward_info
3532
3540
} ;
3533
3541
@@ -3597,7 +3605,7 @@ where
3597
3605
prev_short_channel_id, prev_htlc_id, prev_funding_outpoint, prev_user_channel_id,
3598
3606
forward_info: PendingHTLCInfo {
3599
3607
routing, incoming_shared_secret, payment_hash, outgoing_amt_msat,
3600
- outgoing_cltv_value, incoming_amt_msat : _
3608
+ outgoing_cltv_value, ..
3601
3609
}
3602
3610
} ) => {
3603
3611
macro_rules! failure_handler {
@@ -3710,7 +3718,7 @@ where
3710
3718
prev_short_channel_id, prev_htlc_id, prev_funding_outpoint, prev_user_channel_id : _,
3711
3719
forward_info : PendingHTLCInfo {
3712
3720
incoming_shared_secret, payment_hash, outgoing_amt_msat, outgoing_cltv_value,
3713
- routing : PendingHTLCRouting :: Forward { onion_packet, .. } , incoming_amt_msat : _ ,
3721
+ routing : PendingHTLCRouting :: Forward { onion_packet, .. } , ..
3714
3722
} ,
3715
3723
} ) => {
3716
3724
log_trace ! ( self . logger, "Adding HTLC from short id {} with payment_hash {} to channel with short id {} after delay" , prev_short_channel_id, log_bytes!( payment_hash. 0 ) , short_chan_id) ;
@@ -7508,6 +7516,7 @@ impl_writeable_tlv_based!(PendingHTLCInfo, {
7508
7516
( 6 , outgoing_amt_msat, required) ,
7509
7517
( 8 , outgoing_cltv_value, required) ,
7510
7518
( 9 , incoming_amt_msat, option) ,
7519
+ ( 10 , skimmed_fee_msat, option) ,
7511
7520
} ) ;
7512
7521
7513
7522
0 commit comments