Skip to content

Commit a590bad

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 bcdb67e commit a590bad

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lightning/src/routing/router.rs

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

689+
/// The maximum total number of hops in any returned path, including [`Path::hops`] and
690+
/// [`BlindedTail::hops`].
691+
/// Defaults to [`MAX_PATH_LENGTH_ESTIMATE`].
692+
pub max_path_length: u8,
693+
689694
/// Selects the maximum share of a channel's total capacity which will be sent over a channel,
690695
/// as a power of 1/2. A higher value prefers to send the payment using more MPP parts whereas
691696
/// a lower value prefers to send larger MPP parts, potentially saturating channels and
@@ -732,6 +737,7 @@ impl Writeable for PaymentParameters {
732737
(8, *blinded_hints, optional_vec),
733738
(9, self.payee.final_cltv_expiry_delta(), option),
734739
(11, self.previously_failed_blinded_path_idxs, required_vec),
740+
(13, self.max_path_length, required),
735741
});
736742
Ok(())
737743
}
@@ -751,6 +757,7 @@ impl ReadableArgs<u32> for PaymentParameters {
751757
(8, blinded_route_hints, optional_vec),
752758
(9, final_cltv_expiry_delta, (default_value, default_final_cltv_expiry_delta)),
753759
(11, previously_failed_blinded_path_idxs, optional_vec),
760+
(13, max_path_length, (default_value, MAX_PATH_LENGTH_ESTIMATE)),
754761
});
755762
let blinded_route_hints = blinded_route_hints.unwrap_or(vec![]);
756763
let payee = if blinded_route_hints.len() != 0 {
@@ -775,6 +782,7 @@ impl ReadableArgs<u32> for PaymentParameters {
775782
expiry_time,
776783
previously_failed_channels: previously_failed_channels.unwrap_or(Vec::new()),
777784
previously_failed_blinded_path_idxs: previously_failed_blinded_path_idxs.unwrap_or(Vec::new()),
785+
max_path_length: _init_tlv_based_struct_field!(max_path_length, (default_value, unused)),
778786
})
779787
}
780788
}
@@ -791,6 +799,7 @@ impl PaymentParameters {
791799
expiry_time: None,
792800
max_total_cltv_expiry_delta: DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA,
793801
max_path_count: DEFAULT_MAX_PATH_COUNT,
802+
max_path_length: MAX_PATH_LENGTH_ESTIMATE,
794803
max_channel_saturation_power_of_half: DEFAULT_MAX_CHANNEL_SATURATION_POW_HALF,
795804
previously_failed_channels: Vec::new(),
796805
previously_failed_blinded_path_idxs: Vec::new(),
@@ -830,6 +839,7 @@ impl PaymentParameters {
830839
expiry_time: None,
831840
max_total_cltv_expiry_delta: DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA,
832841
max_path_count: DEFAULT_MAX_PATH_COUNT,
842+
max_path_length: MAX_PATH_LENGTH_ESTIMATE,
833843
max_channel_saturation_power_of_half: DEFAULT_MAX_CHANNEL_SATURATION_POW_HALF,
834844
previously_failed_channels: Vec::new(),
835845
previously_failed_blinded_path_idxs: Vec::new(),

0 commit comments

Comments
 (0)