@@ -1030,6 +1030,91 @@ impl PaymentParameters {
10301030 }
10311031}
10321032
1033+ /// A struct for configuring parameters for routing the payment.
1034+ #[ derive( Clone , Copy ) ]
1035+ pub struct RouteParametersConfig {
1036+ /// The maximum total fees, in millisatoshi, that may accrue during route finding.
1037+ ///
1038+ /// This limit also applies to the total fees that may arise while retrying failed payment
1039+ /// paths.
1040+ ///
1041+ /// Note that values below a few sats may result in some paths being spuriously ignored.
1042+ ///
1043+ /// Defaults to 1% of the payment amount + 50 sats
1044+ pub max_total_routing_fee_msat : Option < u64 > ,
1045+
1046+ /// The maximum total CLTV delta we accept for the route.
1047+ /// Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`].
1048+ pub max_total_cltv_expiry_delta : u32 ,
1049+
1050+ /// The maximum number of paths that may be used by (MPP) payments.
1051+ /// Defaults to [`DEFAULT_MAX_PATH_COUNT`].
1052+ pub max_path_count : u8 ,
1053+
1054+ /// Selects the maximum share of a channel's total capacity which will be sent over a channel,
1055+ /// as a power of 1/2. A higher value prefers to send the payment using more MPP parts whereas
1056+ /// a lower value prefers to send larger MPP parts, potentially saturating channels and
1057+ /// increasing failure probability for those paths.
1058+ ///
1059+ /// Note that this restriction will be relaxed during pathfinding after paths which meet this
1060+ /// restriction have been found. While paths which meet this criteria will be searched for, it
1061+ /// is ultimately up to the scorer to select them over other paths.
1062+ ///
1063+ /// A value of 0 will allow payments up to and including a channel's total announced usable
1064+ /// capacity, a value of one will only use up to half its capacity, two 1/4, etc.
1065+ ///
1066+ /// Default value: 2
1067+ pub max_channel_saturation_power_of_half : u8 ,
1068+ }
1069+
1070+ impl_writeable_tlv_based ! ( RouteParametersConfig , {
1071+ ( 1 , max_total_routing_fee_msat, option) ,
1072+ ( 3 , max_total_cltv_expiry_delta, required) ,
1073+ ( 5 , max_path_count, required) ,
1074+ ( 7 , max_channel_saturation_power_of_half, required) ,
1075+ } ) ;
1076+
1077+ impl RouteParametersConfig {
1078+ /// Initates an new set of route parameter configs with default parameters.
1079+ pub fn new ( ) -> Self {
1080+ Self {
1081+ max_total_routing_fee_msat : None ,
1082+ max_total_cltv_expiry_delta : DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA ,
1083+ max_path_count : DEFAULT_MAX_PATH_COUNT ,
1084+ max_channel_saturation_power_of_half : DEFAULT_MAX_CHANNEL_SATURATION_POW_HALF ,
1085+ }
1086+ }
1087+
1088+ /// Set the maximum total fees, in millisatoshi, that may accrue during route finding.
1089+ ///
1090+ /// This is not exported to bindings users since bindings don't support move semantics
1091+ pub fn with_max_total_routing_fee_msat ( self , fee_msat : u64 ) -> Self {
1092+ Self { max_total_routing_fee_msat : Some ( fee_msat) , ..self }
1093+ }
1094+
1095+ /// Includes a limit for the total CLTV expiry delta which is considered during routing
1096+ ///
1097+ /// This is not exported to bindings users since bindings don't support move semantics
1098+ pub fn with_max_total_cltv_expiry_delta ( self , max_total_cltv_expiry_delta : u32 ) -> Self {
1099+ Self { max_total_cltv_expiry_delta, ..self }
1100+ }
1101+
1102+ /// Includes a limit for the maximum number of payment paths that may be used.
1103+ ///
1104+ /// This is not exported to bindings users since bindings don't support move semantics
1105+ pub fn with_max_path_count ( self , max_path_count : u8 ) -> Self {
1106+ Self { max_path_count, ..self }
1107+ }
1108+
1109+ /// Includes a limit for the maximum share of a channel's total capacity that can be sent over, as
1110+ /// a power of 1/2. See [`PaymentParameters::max_channel_saturation_power_of_half`].
1111+ ///
1112+ /// This is not exported to bindings users since bindings don't support move semantics
1113+ pub fn with_max_channel_saturation_power_of_half ( self , max_channel_saturation_power_of_half : u8 ) -> Self {
1114+ Self { max_channel_saturation_power_of_half, ..self }
1115+ }
1116+ }
1117+
10331118/// The recipient of a payment, differing based on whether they've hidden their identity with route
10341119/// blinding.
10351120#[ derive( Clone , Debug , Hash , PartialEq , Eq ) ]
0 commit comments