Fix InvalidRoute error to be ChannelUnavailable
authorValentine Wallace <vwallace@protonmail.com>
Wed, 22 Feb 2023 19:09:58 +0000 (14:09 -0500)
committerValentine Wallace <vwallace@protonmail.com>
Thu, 23 Feb 2023 04:05:43 +0000 (23:05 -0500)
InvalidRoute is reserved for malformed routes, not routes where a channel or
its peer is unavailable

lightning/src/ln/channelmanager.rs

index ad942d25dd3ec91ab1dff057d7653395214454bf..39cb9a7b5fe24d543674095fdbda3464b776ec10 100644 (file)
@@ -2386,7 +2386,7 @@ where
 
                        let per_peer_state = self.per_peer_state.read().unwrap();
                        let peer_state_mutex = per_peer_state.get(&counterparty_node_id)
-                               .ok_or_else(|| APIError::InvalidRoute{err: "No peer matching the path's first hop found!" })?;
+                               .ok_or_else(|| APIError::ChannelUnavailable{err: "No peer matching the path's first hop found!".to_owned() })?;
                        let mut peer_state_lock = peer_state_mutex.lock().unwrap();
                        let peer_state = &mut *peer_state_lock;
                        if let hash_map::Entry::Occupied(mut chan) = peer_state.channel_by_id.entry(id) {