Skip to content

Commit 11d031e

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 45c4b34 commit 11d031e

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
@@ -846,15 +846,15 @@ impl OutboundPayments {
846846
SP: Fn(SendAlongPathArgs) -> Result<(), APIError>,
847847
{
848848
let payment_hash = invoice.payment_hash();
849-
let max_total_routing_fee_msat;
849+
let params_config;
850850
let retry_strategy;
851851
match self.pending_outbound_payments.lock().unwrap().entry(payment_id) {
852852
hash_map::Entry::Occupied(entry) => match entry.get() {
853853
PendingOutboundPayment::AwaitingInvoice {
854854
retry_strategy: retry, route_params_config, ..
855855
} => {
856856
retry_strategy = *retry;
857-
max_total_routing_fee_msat = route_params_config.max_total_routing_fee_msat;
857+
params_config = *route_params_config;
858858
*entry.into_mut() = PendingOutboundPayment::InvoiceReceived {
859859
payment_hash,
860860
retry_strategy: *retry,
@@ -874,9 +874,9 @@ impl OutboundPayments {
874874
}
875875

876876
let mut route_params = RouteParameters::from_payment_params_and_value(
877-
PaymentParameters::from_bolt12_invoice(&invoice), invoice.amount_msats()
877+
PaymentParameters::from_bolt12_invoice(&invoice).with_user_config(params_config), invoice.amount_msats()
878878
);
879-
if let Some(max_fee_msat) = max_total_routing_fee_msat {
879+
if let Some(max_fee_msat) = params_config.max_total_routing_fee_msat {
880880
route_params.max_total_routing_fee_msat = Some(max_fee_msat);
881881
}
882882
self.send_payment_for_bolt12_invoice_internal(
@@ -1049,7 +1049,7 @@ impl OutboundPayments {
10491049
};
10501050
let keysend_preimage = PaymentPreimage(entropy_source.get_secure_random_bytes());
10511051
let payment_hash = PaymentHash(Sha256::hash(&keysend_preimage.0).to_byte_array());
1052-
let pay_params = PaymentParameters::from_static_invoice(invoice);
1052+
let pay_params = PaymentParameters::from_static_invoice(invoice).with_user_config(*route_params_config);
10531053
let mut route_params = RouteParameters::from_payment_params_and_value(pay_params, amount_msat);
10541054
route_params.max_total_routing_fee_msat = route_params_config.max_total_routing_fee_msat;
10551055

lightning/src/routing/router.rs

+10
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,16 @@ impl PaymentParameters {
948948
}
949949
}
950950

951+
/// Update the parameters with the configuration provided by user.
952+
pub fn with_user_config(self, params_config: RouteParametersConfig) -> Self {
953+
Self {
954+
max_total_cltv_expiry_delta: params_config.max_total_cltv_expiry_delta,
955+
max_path_count: params_config.max_path_count,
956+
max_channel_saturation_power_of_half: params_config.max_channel_saturation_power_of_half,
957+
.. self
958+
}
959+
}
960+
951961
/// Includes the payee's features. Errors if the parameters were not initialized with
952962
/// [`PaymentParameters::from_bolt12_invoice`].
953963
///

0 commit comments

Comments
 (0)