Skip to content

Commit e0e9a8c

Browse files
committed
Use RouteParametersConfig to create new RouteParameters
- This finally allow overriding the {Route, Payment} parameters with the RouteParametersConfig value provided by the user.
1 parent e7ae124 commit e0e9a8c

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

lightning/src/ln/outbound_payment.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -863,15 +863,15 @@ impl OutboundPayments {
863863
SP: Fn(SendAlongPathArgs) -> Result<(), APIError>,
864864
{
865865
let payment_hash = invoice.payment_hash();
866-
let max_total_routing_fee_msat;
866+
let params_config;
867867
let retry_strategy;
868868
match self.pending_outbound_payments.lock().unwrap().entry(payment_id) {
869869
hash_map::Entry::Occupied(entry) => match entry.get() {
870870
PendingOutboundPayment::AwaitingInvoice {
871871
retry_strategy: retry, route_params_config, ..
872872
} => {
873873
retry_strategy = *retry;
874-
max_total_routing_fee_msat = route_params_config.max_total_routing_fee_msat;
874+
params_config = *route_params_config;
875875
*entry.into_mut() = PendingOutboundPayment::InvoiceReceived {
876876
payment_hash,
877877
retry_strategy: *retry,
@@ -891,9 +891,9 @@ impl OutboundPayments {
891891
}
892892

893893
let mut route_params = RouteParameters::from_payment_params_and_value(
894-
PaymentParameters::from_bolt12_invoice(&invoice), invoice.amount_msats()
894+
PaymentParameters::from_bolt12_invoice(&invoice).with_user_config(params_config), invoice.amount_msats()
895895
);
896-
if let Some(max_fee_msat) = max_total_routing_fee_msat {
896+
if let Some(max_fee_msat) = params_config.max_total_routing_fee_msat {
897897
route_params.max_total_routing_fee_msat = Some(max_fee_msat);
898898
}
899899
self.send_payment_for_bolt12_invoice_internal(
@@ -1066,7 +1066,7 @@ impl OutboundPayments {
10661066
};
10671067
let keysend_preimage = PaymentPreimage(entropy_source.get_secure_random_bytes());
10681068
let payment_hash = PaymentHash(Sha256::hash(&keysend_preimage.0).to_byte_array());
1069-
let pay_params = PaymentParameters::from_static_invoice(invoice);
1069+
let pay_params = PaymentParameters::from_static_invoice(invoice).with_user_config(*route_params_config);
10701070
let mut route_params = RouteParameters::from_payment_params_and_value(pay_params, amount_msat);
10711071
route_params.max_total_routing_fee_msat = route_params_config.max_total_routing_fee_msat;
10721072

lightning/src/routing/router.rs

+10
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,16 @@ impl PaymentParameters {
943943
}
944944
}
945945

946+
/// Update the parameters with the configuration provided by user.
947+
pub fn with_user_config(self, params_config: RouteParametersConfig) -> Self {
948+
Self {
949+
max_total_cltv_expiry_delta: params_config.max_total_cltv_expiry_delta,
950+
max_path_count: params_config.max_path_count,
951+
max_channel_saturation_power_of_half: params_config.max_channel_saturation_power_of_half,
952+
.. self
953+
}
954+
}
955+
946956
/// Includes the payee's features. Errors if the parameters were not initialized with
947957
/// [`PaymentParameters::from_bolt12_invoice`].
948958
///

0 commit comments

Comments
 (0)