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