@@ -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
@@ -2616,6 +2619,7 @@ where
2616
2619
incoming_amt_msat : Some ( amt_msat) ,
2617
2620
outgoing_amt_msat : hop_data. amt_to_forward ,
2618
2621
outgoing_cltv_value : hop_data. outgoing_cltv_value ,
2622
+ skimmed_fee_msat : None ,
2619
2623
} )
2620
2624
}
2621
2625
@@ -2885,6 +2889,7 @@ where
2885
2889
incoming_amt_msat : Some ( msg. amount_msat ) ,
2886
2890
outgoing_amt_msat : next_hop_data. amt_to_forward ,
2887
2891
outgoing_cltv_value : next_hop_data. outgoing_cltv_value ,
2892
+ skimmed_fee_msat : None ,
2888
2893
} )
2889
2894
}
2890
2895
}
@@ -3525,7 +3530,10 @@ where
3525
3530
} ,
3526
3531
_ => unreachable ! ( ) // Only `PendingHTLCRouting::Forward`s are intercepted
3527
3532
} ;
3533
+ let skimmed_fee_msat =
3534
+ payment. forward_info . outgoing_amt_msat . saturating_sub ( amt_to_forward_msat) ;
3528
3535
let pending_htlc_info = PendingHTLCInfo {
3536
+ skimmed_fee_msat : if skimmed_fee_msat == 0 { None } else { Some ( skimmed_fee_msat) } ,
3529
3537
outgoing_amt_msat : amt_to_forward_msat, routing, ..payment. forward_info
3530
3538
} ;
3531
3539
@@ -3595,7 +3603,7 @@ where
3595
3603
prev_short_channel_id, prev_htlc_id, prev_funding_outpoint, prev_user_channel_id,
3596
3604
forward_info: PendingHTLCInfo {
3597
3605
routing, incoming_shared_secret, payment_hash, outgoing_amt_msat,
3598
- outgoing_cltv_value, incoming_amt_msat : _
3606
+ outgoing_cltv_value, ..
3599
3607
}
3600
3608
} ) => {
3601
3609
macro_rules! failure_handler {
@@ -3708,7 +3716,7 @@ where
3708
3716
prev_short_channel_id, prev_htlc_id, prev_funding_outpoint, prev_user_channel_id : _,
3709
3717
forward_info : PendingHTLCInfo {
3710
3718
incoming_shared_secret, payment_hash, outgoing_amt_msat, outgoing_cltv_value,
3711
- routing : PendingHTLCRouting :: Forward { onion_packet, .. } , incoming_amt_msat : _ ,
3719
+ routing : PendingHTLCRouting :: Forward { onion_packet, .. } , ..
3712
3720
} ,
3713
3721
} ) => {
3714
3722
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) ;
@@ -7443,6 +7451,7 @@ impl_writeable_tlv_based!(PendingHTLCInfo, {
7443
7451
( 6 , outgoing_amt_msat, required) ,
7444
7452
( 8 , outgoing_cltv_value, required) ,
7445
7453
( 9 , incoming_amt_msat, option) ,
7454
+ ( 10 , skimmed_fee_msat, option) ,
7446
7455
} ) ;
7447
7456
7448
7457
0 commit comments