You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Validate the Router is meeting MPP and max-fee limitations given
When `OutboundPayments` calls the provided `Router` to fetch a
`Route` it passes a `RouteParameters` with a specific max-fee. Here
we validate that the `Route` returned sticks to the limits
provided, and also that it meets the MPP rules of not having any
single MPP part which can be removed while still meeting the
desired payment amount.
let err = format!("Router returned an attempt to pay with a higher fee ({total_fee}msat) than we allowed ({max_total_fee}msat). Your router is critically buggy!");
699
+
debug_assert!(false,"{}", err);
700
+
log_error!(logger,"{}", err);
701
+
returnErr(());
702
+
}
703
+
}
704
+
705
+
// Test that we don't contain any "extra" MPP parts - while we're allowed to overshoot
706
+
// the `final_value_msat` specified in the `route_params`, we aren't allowed to have
707
+
// any MPP parts which aren't needed to meet `route_params.final_value_msat`.
708
+
let min_mpp_part = self.paths.iter().map(|h| h.final_value_msat()).min().unwrap_or(0);
"Router returned an attempt to include more MPP parts than needed. The smallest MPP part ({min_mpp_part}msat) was not needed for a payment of {}msat. Your router is critically buggy!",
712
+
route_params.final_value_msat
713
+
);
714
+
debug_assert!(false,"{}", err);
715
+
log_error!(logger,"{}", err);
716
+
returnErr(());
717
+
}
718
+
719
+
ifself.paths.is_empty(){
720
+
let err = "Selected route had no paths. Your router is buggy!";
721
+
debug_assert!(false,"{}", err);
722
+
log_error!(logger,"{}", err);
723
+
returnErr(());
724
+
}
725
+
726
+
for path inself.paths.iter(){
727
+
if path.hops.is_empty(){
728
+
let err = "Unusable path in route (path.hops.len() must be at least 1)";
729
+
debug_assert!(false,"{}", err);
730
+
log_error!(logger,"{}", err);
731
+
returnErr(());
732
+
}
733
+
734
+
if path.hops.len() > route_params.payment_params.max_path_length.into(){
735
+
let err = format!(
736
+
"Path had a length of {}, which is greater than the maximum we're allowed ({})",
737
+
path.hops.len(),
738
+
route_params.payment_params.max_path_length,
739
+
);
740
+
#[cfg(any(test, feature = "_test_utils"))]
741
+
debug_assert!(false,"{}", err);
742
+
log_error!(logger,"{}", err);
743
+
// This is a bug, but there's not a material safety risk to making this
0 commit comments