@@ -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 ,
@@ -2524,6 +2527,7 @@ where
2524
2527
routing : PendingHTLCRouting :: Forward {
2525
2528
onion_packet : outgoing_packet,
2526
2529
short_channel_id,
2530
+ skimmed_fee_msat : None ,
2527
2531
} ,
2528
2532
payment_hash : msg. payment_hash . clone ( ) ,
2529
2533
incoming_shared_secret : shared_secret,
@@ -3275,8 +3279,16 @@ where
3275
3279
} ) ?;
3276
3280
3277
3281
let routing = match payment. forward_info . routing {
3278
- PendingHTLCRouting :: Forward { onion_packet, .. } => {
3279
- PendingHTLCRouting :: Forward { onion_packet, short_channel_id : next_hop_scid }
3282
+ PendingHTLCRouting :: Forward { onion_packet, skimmed_fee_msat, .. } => {
3283
+ debug_assert ! ( skimmed_fee_msat. is_none( ) ) ;
3284
+ PendingHTLCRouting :: Forward {
3285
+ onion_packet,
3286
+ short_channel_id : next_hop_scid,
3287
+ skimmed_fee_msat :
3288
+ // The minuend here must match the expected forward amount generated for the
3289
+ // HTLCIntercepted event.
3290
+ Some ( payment. forward_info . outgoing_amt_msat . saturating_sub ( amt_to_forward_msat) ) ,
3291
+ }
3280
3292
} ,
3281
3293
_ => unreachable ! ( ) // Only `PendingHTLCRouting::Forward`s are intercepted
3282
3294
} ;
@@ -7094,6 +7106,7 @@ impl_writeable_tlv_based!(PhantomRouteHints, {
7094
7106
impl_writeable_tlv_based_enum ! ( PendingHTLCRouting ,
7095
7107
( 0 , Forward ) => {
7096
7108
( 0 , onion_packet, required) ,
7109
+ ( 1 , skimmed_fee_msat, option) ,
7097
7110
( 2 , short_channel_id, required) ,
7098
7111
} ,
7099
7112
( 1 , Receive ) => {
0 commit comments