X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=sidebyside;f=lightning%2Fsrc%2Fln%2Foutbound_payment.rs;h=5270ed35d8835d6f240e8ae0fcd90b12e0851685;hb=b13163426ac3451118f3e25398afe240c12f32b6;hp=18763685f8f9ff58aa81b7927379578e71605802;hpb=d5b05e54c32cd53e0534849b57242c65747738b1;p=rust-lightning diff --git a/lightning/src/ln/outbound_payment.rs b/lightning/src/ln/outbound_payment.rs index 18763685..5270ed35 100644 --- a/lightning/src/ln/outbound_payment.rs +++ b/lightning/src/ln/outbound_payment.rs @@ -719,7 +719,7 @@ impl OutboundPayments { }; for path in route.paths.iter() { if path.hops.len() == 0 { - log_error!(logger, "length-0 path in route"); + log_error!(logger, "Unusable path in route (path.hops.len() must be at least 1"); self.abandon_payment(payment_id, PaymentFailureReason::UnexpectedError, pending_events); return } @@ -895,7 +895,7 @@ impl OutboundPayments { let payment_hash = probing_cookie_from_id(&payment_id, probing_cookie_secret); - if path.hops.len() < 2 { + if path.hops.len() < 2 && path.blinded_tail.is_none() { return Err(PaymentSendFailure::ParameterError(APIError::APIMisuseError { err: "No need probing a path with less than two hops".to_string() })) @@ -1000,8 +1000,14 @@ impl OutboundPayments { path_errs.push(Err(APIError::InvalidRoute{err: "Path didn't go anywhere/had bogus size".to_owned()})); continue 'path_check; } + if path.blinded_tail.is_some() { + path_errs.push(Err(APIError::InvalidRoute{err: "Sending to blinded paths isn't supported yet".to_owned()})); + continue 'path_check; + } + let dest_hop_idx = if path.blinded_tail.is_some() && path.blinded_tail.as_ref().unwrap().hops.len() > 1 { + usize::max_value() } else { path.hops.len() - 1 }; for (idx, hop) in path.hops.iter().enumerate() { - if idx != path.hops.len() - 1 && hop.pubkey == our_node_id { + if idx != dest_hop_idx && hop.pubkey == our_node_id { path_errs.push(Err(APIError::InvalidRoute{err: "Path went through us but wasn't a simple rebalance loop to us".to_owned()})); continue 'path_check; } @@ -1552,7 +1558,7 @@ mod tests { channel_features: ChannelFeatures::empty(), fee_msat: 0, cltv_expiry_delta: 0, - }]}], + }], blinded_tail: None }], payment_params: Some(payment_params), }; router.expect_find_route(route_params.clone(), Ok(route.clone()));