Skip to content

Commit 423a7ff

Browse files
committed
Introduce ManualRoutingParameters
With the current architecture, `pay_for_offer` only allows setting `max_total_routing_fee_msat` as a route parameter. However, it doesn't provide users the flexibility to set other important parameters. This commit introduces a new struct, `ManualRoutingParameters`, that optionally allows users to set additional routing parameters. In later commits, this struct will be utilized when paying BOLT12 invoices.
1 parent ad19d93 commit 423a7ff

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

lightning/src/routing/router.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,43 @@ impl PaymentParameters {
962962
}
963963
}
964964

965+
/// Information manually provided by the user to route the payment
966+
#[derive(Clone, Copy)]
967+
pub struct ManualRoutingParameters {
968+
/// Same as [`RouteParameters::max_total_routing_fee_msat`]
969+
pub max_total_routing_fee_msat: Option<u64>,
970+
/// Same as [`PaymentParameters::max_total_cltv_expiry_delta`]
971+
pub max_total_cltv_expiry_delta: Option<u32>,
972+
/// Same as [`PaymentParameters::max_path_count`]
973+
pub max_path_count: Option<u8>,
974+
/// Same as [`PaymentParameters::max_channel_saturation_power_of_half`]
975+
pub max_channel_saturation_power_of_half: Option<u8>,
976+
}
977+
978+
impl_writeable_tlv_based!(ManualRoutingParameters, {
979+
(1, max_total_routing_fee_msat, option),
980+
(3, max_total_cltv_expiry_delta, option),
981+
(5, max_path_count, option),
982+
(7, max_channel_saturation_power_of_half, option),
983+
});
984+
985+
impl ManualRoutingParameters {
986+
/// Initates an empty set of [`ManualRoutingParameters`]
987+
pub fn new() -> Self {
988+
Self {
989+
max_total_routing_fee_msat: None,
990+
max_total_cltv_expiry_delta: None,
991+
max_path_count: None,
992+
max_channel_saturation_power_of_half: None,
993+
}
994+
}
995+
996+
/// Creates a new set of [`ManualRoutingParameters`] with the updated `max_total_routing_fee_msat`.
997+
pub fn with_max_total_routing_fee_msat(self, fee_msat: u64) -> Self {
998+
Self { max_total_routing_fee_msat: Some(fee_msat), ..self }
999+
}
1000+
}
1001+
9651002
/// The recipient of a payment, differing based on whether they've hidden their identity with route
9661003
/// blinding.
9671004
#[derive(Clone, Debug, Hash, PartialEq, Eq)]

0 commit comments

Comments
 (0)