From: Matt Corallo <649246+TheBlueMatt@users.noreply.github.com> Date: Tue, 26 Sep 2023 20:07:52 +0000 (+0000) Subject: Merge pull request #2417 from tnull/2023-07-max-total-fee X-Git-Tag: v0.0.117-alpha2~5 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=1ac53ed02bf26520d3b1a2c3c0e90c8691c83099;p=rust-lightning Merge pull request #2417 from tnull/2023-07-max-total-fee Add config option to set maximum total routing fee --- 1ac53ed02bf26520d3b1a2c3c0e90c8691c83099 diff --cc lightning/src/routing/router.rs index 6e5c00e76,c680d57a6..c20ce2e97 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@@ -5239,11 -5269,23 +5270,23 @@@ mod tests } else { panic!(); } } + { + // Attempt to route while setting max_total_routing_fee_msat to 149_999 results in a failure. + let route_params = RouteParameters { payment_params: payment_params.clone(), final_value_msat: 200_000, + max_total_routing_fee_msat: Some(149_999) }; + if let Err(LightningError{err, action: ErrorAction::IgnoreError}) = get_route( + &our_id, &route_params, &network_graph.read_only(), None, Arc::clone(&logger), + &scorer, &(), &random_seed_bytes) { + assert_eq!(err, "Failed to find a sufficient route to the given destination"); + } else { panic!(); } + } + { // Now, attempt to route 200 sats (exact amount we can route). - let route_params = RouteParameters::from_payment_params_and_value(payment_params, 200_000); + let route_params = RouteParameters { payment_params: payment_params.clone(), final_value_msat: 200_000, + max_total_routing_fee_msat: Some(150_000) }; let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 2); let mut total_amount_paid_msat = 0;