@@ -374,8 +374,8 @@ fn filter_channels(channels: Vec<ChannelDetails>, min_inbound_capacity_msat: Opt
374
374
proportional_millionths: forwarding_info. fee_proportional_millionths,
375
375
} ,
376
376
cltv_expiry_delta: forwarding_info. cltv_expiry_delta,
377
- htlc_minimum_msat: None ,
378
- htlc_maximum_msat: None , } ] )
377
+ htlc_minimum_msat: Some ( channel . inbound_htlc_minimum_msat ) ,
378
+ htlc_maximum_msat: channel . inbound_htlc_maximum_msat , } ] )
379
379
} ;
380
380
// If all channels are private, return the route hint for the highest inbound capacity channel
381
381
// per counterparty node. If channels with an higher inbound capacity than the
@@ -497,10 +497,13 @@ mod test {
497
497
498
498
// Invoice SCIDs should always use inbound SCID aliases over the real channel ID, if one is
499
499
// available.
500
+ let chan = & nodes[ 1 ] . node . list_usable_channels ( ) [ 0 ] ;
500
501
assert_eq ! ( invoice. route_hints( ) . len( ) , 1 ) ;
501
502
assert_eq ! ( invoice. route_hints( ) [ 0 ] . 0 . len( ) , 1 ) ;
502
- assert_eq ! ( invoice. route_hints( ) [ 0 ] . 0 [ 0 ] . short_channel_id,
503
- nodes[ 1 ] . node. list_usable_channels( ) [ 0 ] . inbound_scid_alias. unwrap( ) ) ;
503
+ assert_eq ! ( invoice. route_hints( ) [ 0 ] . 0 [ 0 ] . short_channel_id, chan. inbound_scid_alias. unwrap( ) ) ;
504
+
505
+ assert_eq ! ( invoice. route_hints( ) [ 0 ] . 0 [ 0 ] . htlc_minimum_msat, Some ( chan. inbound_htlc_minimum_msat) ) ;
506
+ assert_eq ! ( invoice. route_hints( ) [ 0 ] . 0 [ 0 ] . htlc_maximum_msat, chan. inbound_htlc_maximum_msat) ;
504
507
505
508
let payment_params = PaymentParameters :: from_node_id ( invoice. recover_payee_pub_key ( ) )
506
509
. with_features ( invoice. features ( ) . unwrap ( ) . clone ( ) )
@@ -839,6 +842,40 @@ mod test {
839
842
}
840
843
}
841
844
845
+ #[ test]
846
+ #[ cfg( feature = "std" ) ]
847
+ fn test_multi_node_hints_has_htlc_min_max_values ( ) {
848
+ let mut chanmon_cfgs = create_chanmon_cfgs ( 3 ) ;
849
+ let seed_1 = [ 42 as u8 ; 32 ] ;
850
+ let seed_2 = [ 43 as u8 ; 32 ] ;
851
+ let cross_node_seed = [ 44 as u8 ; 32 ] ;
852
+ chanmon_cfgs[ 1 ] . keys_manager . backing = PhantomKeysManager :: new ( & seed_1, 43 , 44 , & cross_node_seed) ;
853
+ chanmon_cfgs[ 2 ] . keys_manager . backing = PhantomKeysManager :: new ( & seed_2, 43 , 44 , & cross_node_seed) ;
854
+ let node_cfgs = create_node_cfgs ( 3 , & chanmon_cfgs) ;
855
+ let node_chanmgrs = create_node_chanmgrs ( 3 , & node_cfgs, & [ None , None , None ] ) ;
856
+ let nodes = create_network ( 3 , & node_cfgs, & node_chanmgrs) ;
857
+
858
+ create_unannounced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 100000 , 10001 , InitFeatures :: known ( ) , InitFeatures :: known ( ) ) ;
859
+ create_unannounced_chan_between_nodes_with_value ( & nodes, 0 , 2 , 100000 , 10001 , InitFeatures :: known ( ) , InitFeatures :: known ( ) ) ;
860
+
861
+ let payment_amt = 20_000 ;
862
+ let ( payment_hash, payment_secret) = nodes[ 1 ] . node . create_inbound_payment ( Some ( payment_amt) , 3600 ) . unwrap ( ) ;
863
+ let route_hints = vec ! [
864
+ nodes[ 1 ] . node. get_phantom_route_hints( ) ,
865
+ nodes[ 2 ] . node. get_phantom_route_hints( ) ,
866
+ ] ;
867
+
868
+ let invoice = :: utils:: create_phantom_invoice :: < EnforcingSigner , & test_utils:: TestKeysInterface > ( Some ( payment_amt) , "test" . to_string ( ) , payment_hash, payment_secret, route_hints, & nodes[ 1 ] . keys_manager , Currency :: BitcoinTestnet ) . unwrap ( ) ;
869
+
870
+ let chan_0_1 = & nodes[ 1 ] . node . list_usable_channels ( ) [ 0 ] ;
871
+ assert_eq ! ( invoice. route_hints( ) [ 0 ] . 0 [ 0 ] . htlc_minimum_msat, Some ( chan_0_1. inbound_htlc_minimum_msat) ) ;
872
+ assert_eq ! ( invoice. route_hints( ) [ 0 ] . 0 [ 0 ] . htlc_maximum_msat, chan_0_1. inbound_htlc_maximum_msat) ;
873
+
874
+ let chan_0_2 = & nodes[ 2 ] . node . list_usable_channels ( ) [ 0 ] ;
875
+ assert_eq ! ( invoice. route_hints( ) [ 1 ] . 0 [ 0 ] . htlc_minimum_msat, Some ( chan_0_2. inbound_htlc_minimum_msat) ) ;
876
+ assert_eq ! ( invoice. route_hints( ) [ 1 ] . 0 [ 0 ] . htlc_maximum_msat, chan_0_2. inbound_htlc_maximum_msat) ;
877
+ }
878
+
842
879
#[ test]
843
880
#[ cfg( feature = "std" ) ]
844
881
fn create_phantom_invoice_with_description_hash ( ) {
0 commit comments