Merge pull request #2417 from tnull/2023-07-max-total-fee
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>
Tue, 26 Sep 2023 20:07:52 +0000 (20:07 +0000)
committerGitHub <noreply@github.com>
Tue, 26 Sep 2023 20:07:52 +0000 (20:07 +0000)
Add config option to set maximum total routing fee

1  2 
lightning/src/ln/channelmanager.rs
lightning/src/ln/functional_test_utils.rs
lightning/src/ln/outbound_payment.rs
lightning/src/ln/payment_tests.rs
lightning/src/routing/router.rs

Simple merge
Simple merge
Simple merge
index 6e5c00e7665a4c04ccab6df38de89bef9ad7e5ba,c680d57a6dc4f05e97d838d038e2e90276f92874..c20ce2e97ee835ca0cf2c77b8c7526c08dba5855
@@@ -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;