Skip to content
9 changes: 3 additions & 6 deletions lightning-invoice/src/payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,7 @@ fn pay_invoice_using_amount<P: Deref>(
if let Some(features) = invoice.features() {
payment_params = payment_params.with_bolt11_features(features.clone()).unwrap();
}
let route_params = RouteParameters {
payment_params,
final_value_msat: amount_msats,
};
let route_params = RouteParameters::from_payment_params_and_value(payment_params, amount_msats);

payer.send_payment(payment_hash, recipient_onion, payment_id, route_params, retry_strategy)
}
Expand Down Expand Up @@ -148,7 +145,7 @@ pub fn preflight_probe_invoice<C: AChannelManager>(
if let Some(features) = invoice.features() {
payment_params = payment_params.with_bolt11_features(features.clone()).unwrap();
}
let route_params = RouteParameters { payment_params, final_value_msat: amount_msat };
let route_params = RouteParameters::from_payment_params_and_value(payment_params, amount_msat);

channelmanager.get_cm().send_preflight_probes(route_params, liquidity_limit_multiplier)
.map_err(ProbingError::Sending)
Expand Down Expand Up @@ -178,7 +175,7 @@ pub fn preflight_probe_zero_value_invoice<C: AChannelManager>(
if let Some(features) = invoice.features() {
payment_params = payment_params.with_bolt11_features(features.clone()).unwrap();
}
let route_params = RouteParameters { payment_params, final_value_msat: amount_msat };
let route_params = RouteParameters::from_payment_params_and_value(payment_params, amount_msat);

channelmanager.get_cm().send_preflight_probes(route_params, liquidity_limit_multiplier)
.map_err(ProbingError::Sending)
Expand Down
16 changes: 8 additions & 8 deletions lightning/src/ln/blinded_payment_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ fn do_one_hop_blinded_path(success: bool) {
nodes[1].node.get_our_node_id(), payee_tlvs, &chanmon_cfgs[1].keys_manager, &secp_ctx
).unwrap();

let route_params = RouteParameters {
payment_params: PaymentParameters::blinded(vec![blinded_path]),
final_value_msat: amt_msat
};
let route_params = RouteParameters::from_payment_params_and_value(
PaymentParameters::blinded(vec![blinded_path]),
amt_msat,
);
nodes[0].node.send_payment(payment_hash, RecipientOnionFields::spontaneous_empty(),
PaymentId(payment_hash.0), route_params, Retry::Attempts(0)).unwrap();
check_added_monitors(&nodes[0], 1);
Expand Down Expand Up @@ -90,11 +90,11 @@ fn mpp_to_one_hop_blinded_path() {

let bolt12_features: Bolt12InvoiceFeatures =
channelmanager::provided_invoice_features(&UserConfig::default()).to_context();
let route_params = RouteParameters {
payment_params: PaymentParameters::blinded(vec![blinded_path])
let route_params = RouteParameters::from_payment_params_and_value(
PaymentParameters::blinded(vec![blinded_path])
.with_bolt12_features(bolt12_features).unwrap(),
final_value_msat: amt_msat,
};
amt_msat,
);
nodes[0].node.send_payment(payment_hash, RecipientOnionFields::spontaneous_empty(), PaymentId(payment_hash.0), route_params, Retry::Attempts(0)).unwrap();
check_added_monitors(&nodes[0], 2);

Expand Down
3 changes: 2 additions & 1 deletion lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3570,7 +3570,7 @@ where
let payment_params =
PaymentParameters::from_node_id(node_id, final_cltv_expiry_delta);

let route_params = RouteParameters { payment_params, final_value_msat: amount_msat };
let route_params = RouteParameters::from_payment_params_and_value(payment_params, amount_msat);

self.send_preflight_probes(route_params, liquidity_limit_multiplier)
}
Expand Down Expand Up @@ -9559,6 +9559,7 @@ where
pending_fee_msat: Some(path_fee),
total_msat: path_amt,
starting_block_height: best_block_height,
remaining_max_total_routing_fee_msat: None, // only used for retries, and we'll never retry on startup
});
log_info!(args.logger, "Added a pending payment for {} msat with payment hash {} for path with session priv {}",
path_amt, &htlc.payment_hash, log_bytes!(session_priv_bytes));
Expand Down
6 changes: 5 additions & 1 deletion lightning/src/ln/functional_test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1878,7 +1878,11 @@ macro_rules! get_route_and_payment_hash {
$crate::get_route_and_payment_hash!($send_node, $recv_node, payment_params, $recv_value)
}};
($send_node: expr, $recv_node: expr, $payment_params: expr, $recv_value: expr) => {{
let route_params = $crate::routing::router::RouteParameters::from_payment_params_and_value($payment_params, $recv_value);
$crate::get_route_and_payment_hash!($send_node, $recv_node, $payment_params, $recv_value, None)
}};
($send_node: expr, $recv_node: expr, $payment_params: expr, $recv_value: expr, $max_total_routing_fee_msat: expr) => {{
let mut route_params = $crate::routing::router::RouteParameters::from_payment_params_and_value($payment_params, $recv_value);
route_params.max_total_routing_fee_msat = $max_total_routing_fee_msat;
let (payment_preimage, payment_hash, payment_secret) =
$crate::ln::functional_test_utils::get_payment_preimage_hash(&$recv_node, Some($recv_value), None);
let route = $crate::ln::functional_test_utils::get_route(&$send_node, &route_params);
Expand Down
Loading