@@ -104,6 +104,9 @@ pub(super) enum PendingHTLCRouting {
104
104
/// The SCID from the onion that we should forward to. This could be a real SCID or a fake one
105
105
/// generated using `get_fake_scid` from the scid_utils::fake_scid module.
106
106
short_channel_id : u64 , // This should be NonZero<u64> eventually when we bump MSRV
107
+ /// The fee we're skimming off the top of this HTLC. See
108
+ /// [`ChannelConfig::accept_underpaying_htlcs`].
109
+ skimmed_fee_msat : Option < u64 > ,
107
110
} ,
108
111
Receive {
109
112
payment_data : msgs:: FinalOnionHopData ,
@@ -2774,6 +2777,7 @@ where
2774
2777
routing : PendingHTLCRouting :: Forward {
2775
2778
onion_packet : outgoing_packet,
2776
2779
short_channel_id,
2780
+ skimmed_fee_msat : None ,
2777
2781
} ,
2778
2782
payment_hash : msg. payment_hash . clone ( ) ,
2779
2783
incoming_shared_secret : shared_secret,
@@ -3410,8 +3414,16 @@ where
3410
3414
} ) ?;
3411
3415
3412
3416
let routing = match payment. forward_info . routing {
3413
- PendingHTLCRouting :: Forward { onion_packet, .. } => {
3414
- PendingHTLCRouting :: Forward { onion_packet, short_channel_id : next_hop_scid }
3417
+ PendingHTLCRouting :: Forward { onion_packet, skimmed_fee_msat, .. } => {
3418
+ debug_assert ! ( skimmed_fee_msat. is_none( ) ) ;
3419
+ PendingHTLCRouting :: Forward {
3420
+ onion_packet,
3421
+ short_channel_id : next_hop_scid,
3422
+ skimmed_fee_msat :
3423
+ // The minuend here must match the expected forward amount generated for the
3424
+ // HTLCIntercepted event.
3425
+ Some ( payment. forward_info . outgoing_amt_msat . saturating_sub ( amt_to_forward_msat) ) ,
3426
+ }
3415
3427
} ,
3416
3428
_ => unreachable ! ( ) // Only `PendingHTLCRouting::Forward`s are intercepted
3417
3429
} ;
@@ -7282,6 +7294,7 @@ impl_writeable_tlv_based!(PhantomRouteHints, {
7282
7294
impl_writeable_tlv_based_enum ! ( PendingHTLCRouting ,
7283
7295
( 0 , Forward ) => {
7284
7296
( 0 , onion_packet, required) ,
7297
+ ( 1 , skimmed_fee_msat, option) ,
7285
7298
( 2 , short_channel_id, required) ,
7286
7299
} ,
7287
7300
( 1 , Receive ) => {
0 commit comments