@@ -554,6 +554,8 @@ impl<T: SimNetwork, C: Clock> SimNode<T, C> {
554554 /// The [`lightning::routing::router::build_route_from_hops`] function can be used to build the route to be passed here.
555555 ///
556556 /// **Note:** The payment hash passed in here should be used in track_payment to track the payment outcome.
557+ ///
558+ /// **Note:** The route passed in here must contain only one path.
557559 pub async fn send_to_route (
558560 & mut self ,
559561 route : Route ,
@@ -562,6 +564,12 @@ impl<T: SimNetwork, C: Clock> SimNode<T, C> {
562564 ) -> Result < ( ) , LightningError > {
563565 let ( sender, receiver) = channel ( ) ;
564566
567+ if route. paths . len ( ) != 1 {
568+ return Err ( LightningError :: SendPaymentError (
569+ "Route must contain exactly one path for this operation." . to_string ( ) ,
570+ ) ) ;
571+ }
572+
565573 // Check for payment hash collision, failing the payment if we happen to repeat one.
566574 match self . in_flight . lock ( ) . await . entry ( payment_hash) {
567575 Entry :: Occupied ( _) => {
@@ -700,6 +708,12 @@ impl<T: SimNetwork, C: Clock> LightningNode for SimNode<T, C> {
700708 } ,
701709 } ;
702710
711+ if route. paths . len ( ) != 1 {
712+ return Err ( LightningError :: SendPaymentError (
713+ "Route must contain exactly one path for this operation." . to_string ( ) ,
714+ ) ) ;
715+ }
716+
703717 entry. insert ( InFlightPayment {
704718 track_payment_receiver : receiver,
705719 path : Some ( route. paths [ 0 ] . clone ( ) ) , // TODO: how to handle non-MPP support (where would we do
@@ -1174,7 +1188,12 @@ impl SimNetwork for SimGraph {
11741188 payment_hash : PaymentHash ,
11751189 sender : Sender < Result < PaymentResult , LightningError > > ,
11761190 ) {
1177- // Expect at least one path (right now), with the intention to support multiple in future.
1191+ // Expect only one path (right now), with the intention to support multiple in future.
1192+ if route. paths . len ( ) != 1 {
1193+ log:: error!( "Route must contain exactly one path for this operation." ) ;
1194+ return ;
1195+ }
1196+
11781197 let path = match route. paths . first ( ) {
11791198 Some ( p) => p,
11801199 None => {
0 commit comments