File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -1625,7 +1625,15 @@ impl ChannelMessageHandler for ChannelManager {
1625
1625
hmac : next_hop_data. hmac . clone ( ) ,
1626
1626
} ;
1627
1627
1628
- //TODO: Check amt_to_forward and outgoing_cltv_value are within acceptable ranges!
1628
+ let channel_state = self . channel_state . lock ( ) . unwrap ( ) ;
1629
+ let chan = channel_state. by_id . get ( & msg. channel_id ) . unwrap ( ) ;
1630
+ let fee = chan. get_our_fee_base_msat ( & * self . fee_estimator ) + ( next_hop_data. data . amt_to_forward * self . fee_proportional_millionths as u64 / 1000000 ) as u32 ;
1631
+ if msg. amount_msat - fee as u64 >= next_hop_data. data . amt_to_forward {
1632
+ return_err ! ( "Prior hop has deviated from specified parameters" , 0x1000 | 12 , & [ 0 ; 0 ] ) ;
1633
+ }
1634
+ if msg. cltv_expiry - CLTV_EXPIRY_DELTA as u32 >= next_hop_data. data . outgoing_cltv_value {
1635
+ return_err ! ( "Forwarding node has tampered with the intended HTLC values or origin node has an obsolete cltv_expiry_delta" , 0x1000 | 13 , & [ 0 ; 0 ] ) ;
1636
+ }
1629
1637
1630
1638
PendingForwardHTLCInfo {
1631
1639
onion_packet : Some ( outgoing_packet) ,
You can’t perform that action at this time.
0 commit comments