@@ -962,6 +962,91 @@ impl PaymentParameters {
962962 }
963963}
964964
965+ /// A struct for configuring parameters for routing the payment.
966+ #[ derive( Clone , Copy ) ]
967+ pub struct RouteParametersConfig {
968+ /// The maximum total fees, in millisatoshi, that may accrue during route finding.
969+ ///
970+ /// This limit also applies to the total fees that may arise while retrying failed payment
971+ /// paths.
972+ ///
973+ /// Note that values below a few sats may result in some paths being spuriously ignored.
974+ ///
975+ /// Defaults to 1% of the payment amount + 50 sats
976+ pub max_total_routing_fee_msat : Option < u64 > ,
977+
978+ /// The maximum total CLTV delta we accept for the route.
979+ /// Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`].
980+ pub max_total_cltv_expiry_delta : u32 ,
981+
982+ /// The maximum number of paths that may be used by (MPP) payments.
983+ /// Defaults to [`DEFAULT_MAX_PATH_COUNT`].
984+ pub max_path_count : u8 ,
985+
986+ /// Selects the maximum share of a channel's total capacity which will be sent over a channel,
987+ /// as a power of 1/2. A higher value prefers to send the payment using more MPP parts whereas
988+ /// a lower value prefers to send larger MPP parts, potentially saturating channels and
989+ /// increasing failure probability for those paths.
990+ ///
991+ /// Note that this restriction will be relaxed during pathfinding after paths which meet this
992+ /// restriction have been found. While paths which meet this criteria will be searched for, it
993+ /// is ultimately up to the scorer to select them over other paths.
994+ ///
995+ /// A value of 0 will allow payments up to and including a channel's total announced usable
996+ /// capacity, a value of one will only use up to half its capacity, two 1/4, etc.
997+ ///
998+ /// Default value: 2
999+ pub max_channel_saturation_power_of_half : u8 ,
1000+ }
1001+
1002+ impl_writeable_tlv_based ! ( RouteParametersConfig , {
1003+ ( 1 , max_total_routing_fee_msat, option) ,
1004+ ( 3 , max_total_cltv_expiry_delta, required) ,
1005+ ( 5 , max_path_count, required) ,
1006+ ( 7 , max_channel_saturation_power_of_half, required) ,
1007+ } ) ;
1008+
1009+ impl RouteParametersConfig {
1010+ /// Initates an new set of route parameter configs with default parameters.
1011+ pub fn new ( ) -> Self {
1012+ Self {
1013+ max_total_routing_fee_msat : None ,
1014+ max_total_cltv_expiry_delta : DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA ,
1015+ max_path_count : DEFAULT_MAX_PATH_COUNT ,
1016+ max_channel_saturation_power_of_half : DEFAULT_MAX_CHANNEL_SATURATION_POW_HALF ,
1017+ }
1018+ }
1019+
1020+ /// Set the maximum total fees, in millisatoshi, that may accrue during route finding.
1021+ ///
1022+ /// This is not exported to bindings users since bindings don't support move semantics
1023+ pub fn with_max_total_routing_fee_msat ( self , fee_msat : u64 ) -> Self {
1024+ Self { max_total_routing_fee_msat : Some ( fee_msat) , ..self }
1025+ }
1026+
1027+ /// Includes a limit for the total CLTV expiry delta which is considered during routing
1028+ ///
1029+ /// This is not exported to bindings users since bindings don't support move semantics
1030+ pub fn with_max_total_cltv_expiry_delta ( self , max_total_cltv_expiry_delta : u32 ) -> Self {
1031+ Self { max_total_cltv_expiry_delta, ..self }
1032+ }
1033+
1034+ /// Includes a limit for the maximum number of payment paths that may be used.
1035+ ///
1036+ /// This is not exported to bindings users since bindings don't support move semantics
1037+ pub fn with_max_path_count ( self , max_path_count : u8 ) -> Self {
1038+ Self { max_path_count, ..self }
1039+ }
1040+
1041+ /// Includes a limit for the maximum share of a channel's total capacity that can be sent over, as
1042+ /// a power of 1/2. See [`PaymentParameters::max_channel_saturation_power_of_half`].
1043+ ///
1044+ /// This is not exported to bindings users since bindings don't support move semantics
1045+ pub fn with_max_channel_saturation_power_of_half ( self , max_channel_saturation_power_of_half : u8 ) -> Self {
1046+ Self { max_channel_saturation_power_of_half, ..self }
1047+ }
1048+ }
1049+
9651050/// The recipient of a payment, differing based on whether they've hidden their identity with route
9661051/// blinding.
9671052#[ derive( Clone , Debug , Hash , PartialEq , Eq ) ]
0 commit comments