Skip to content

Commit bc66e4f

Browse files
Add max path length knob to PaymentParameters.
Will be used so the outbound_payment module can calculate the maximum path length with knowledge of any custom TLVs or payment metadata present.
1 parent 8f75caf commit bc66e4f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lightning/src/routing/router.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,10 @@ pub struct PaymentParameters {
686686
/// Defaults to [`DEFAULT_MAX_PATH_COUNT`].
687687
pub max_path_count: u8,
688688

689+
/// The maximum number of [`Path::hops`] in any returned path, not counting the recipient hop.
690+
/// Defaults to [`MAX_PATH_LENGTH_ESTIMATE`].
691+
pub max_intermediate_hops: u8,
692+
689693
/// Selects the maximum share of a channel's total capacity which will be sent over a channel,
690694
/// as a power of 1/2. A higher value prefers to send the payment using more MPP parts whereas
691695
/// a lower value prefers to send larger MPP parts, potentially saturating channels and
@@ -732,6 +736,7 @@ impl Writeable for PaymentParameters {
732736
(8, *blinded_hints, optional_vec),
733737
(9, self.payee.final_cltv_expiry_delta(), option),
734738
(11, self.previously_failed_blinded_path_idxs, required_vec),
739+
(13, self.max_intermediate_hops, required),
735740
});
736741
Ok(())
737742
}
@@ -751,6 +756,7 @@ impl ReadableArgs<u32> for PaymentParameters {
751756
(8, blinded_route_hints, optional_vec),
752757
(9, final_cltv_expiry_delta, (default_value, default_final_cltv_expiry_delta)),
753758
(11, previously_failed_blinded_path_idxs, optional_vec),
759+
(13, max_intermediate_hops, (default_value, MAX_PATH_LENGTH_ESTIMATE)),
754760
});
755761
let blinded_route_hints = blinded_route_hints.unwrap_or(vec![]);
756762
let payee = if blinded_route_hints.len() != 0 {
@@ -775,6 +781,7 @@ impl ReadableArgs<u32> for PaymentParameters {
775781
expiry_time,
776782
previously_failed_channels: previously_failed_channels.unwrap_or(Vec::new()),
777783
previously_failed_blinded_path_idxs: previously_failed_blinded_path_idxs.unwrap_or(Vec::new()),
784+
max_intermediate_hops: _init_tlv_based_struct_field!(max_intermediate_hops, (default_value, unused)),
778785
})
779786
}
780787
}
@@ -791,6 +798,7 @@ impl PaymentParameters {
791798
expiry_time: None,
792799
max_total_cltv_expiry_delta: DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA,
793800
max_path_count: DEFAULT_MAX_PATH_COUNT,
801+
max_intermediate_hops: MAX_PATH_LENGTH_ESTIMATE,
794802
max_channel_saturation_power_of_half: DEFAULT_MAX_CHANNEL_SATURATION_POW_HALF,
795803
previously_failed_channels: Vec::new(),
796804
previously_failed_blinded_path_idxs: Vec::new(),
@@ -830,6 +838,7 @@ impl PaymentParameters {
830838
expiry_time: None,
831839
max_total_cltv_expiry_delta: DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA,
832840
max_path_count: DEFAULT_MAX_PATH_COUNT,
841+
max_intermediate_hops: MAX_PATH_LENGTH_ESTIMATE,
833842
max_channel_saturation_power_of_half: DEFAULT_MAX_CHANNEL_SATURATION_POW_HALF,
834843
previously_failed_channels: Vec::new(),
835844
previously_failed_blinded_path_idxs: Vec::new(),

0 commit comments

Comments
 (0)