Merge pull request #14 from TheBlueMatt/main
[ldk-c-bindings] / lightning-c-bindings / src / lightning / routing / router.rs
1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
3 //
4 // This file is licensed under the license available in the LICENSE or LICENSE.md
5 // file in the root of this repository or, if no such file exists, the same
6 // license as that which applies to the original source files from which this
7 // source was automatically generated.
8
9 //! The top-level routing/network map tracking logic lives here.
10 //!
11 //! You probably want to create a NetGraphMsgHandler and use that as your RoutingMessageHandler and then
12 //! interrogate it to get routes for your own payments.
13
14 use std::ffi::c_void;
15 use bitcoin::hashes::Hash;
16 use crate::c_types::*;
17
18
19 use lightning::routing::router::RouteHop as nativeRouteHopImport;
20 type nativeRouteHop = nativeRouteHopImport;
21
22 /// A hop in a route
23 #[must_use]
24 #[repr(C)]
25 pub struct RouteHop {
26         /// A pointer to the opaque Rust object.
27
28         /// Nearly everywhere, inner must be non-null, however in places where
29         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
30         pub inner: *mut nativeRouteHop,
31         /// Indicates that this is the only struct which contains the same pointer.
32
33         /// Rust functions which take ownership of an object provided via an argument require
34         /// this to be true and invalidate the object pointed to by inner.
35         pub is_owned: bool,
36 }
37
38 impl Drop for RouteHop {
39         fn drop(&mut self) {
40                 if self.is_owned && !<*mut nativeRouteHop>::is_null(self.inner) {
41                         let _ = unsafe { Box::from_raw(self.inner) };
42                 }
43         }
44 }
45 /// Frees any resources used by the RouteHop, if is_owned is set and inner is non-NULL.
46 #[no_mangle]
47 pub extern "C" fn RouteHop_free(this_obj: RouteHop) { }
48 #[allow(unused)]
49 /// Used only if an object of this type is returned as a trait impl by a method
50 extern "C" fn RouteHop_free_void(this_ptr: *mut c_void) {
51         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRouteHop); }
52 }
53 #[allow(unused)]
54 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
55 impl RouteHop {
56         pub(crate) fn take_inner(mut self) -> *mut nativeRouteHop {
57                 assert!(self.is_owned);
58                 let ret = self.inner;
59                 self.inner = std::ptr::null_mut();
60                 ret
61         }
62 }
63 /// The node_id of the node at this hop.
64 #[no_mangle]
65 pub extern "C" fn RouteHop_get_pubkey(this_ptr: &RouteHop) -> crate::c_types::PublicKey {
66         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.pubkey;
67         crate::c_types::PublicKey::from_rust(&(*inner_val))
68 }
69 /// The node_id of the node at this hop.
70 #[no_mangle]
71 pub extern "C" fn RouteHop_set_pubkey(this_ptr: &mut RouteHop, mut val: crate::c_types::PublicKey) {
72         unsafe { &mut *this_ptr.inner }.pubkey = val.into_rust();
73 }
74 /// The node_announcement features of the node at this hop. For the last hop, these may be
75 /// amended to match the features present in the invoice this node generated.
76 #[no_mangle]
77 pub extern "C" fn RouteHop_get_node_features(this_ptr: &RouteHop) -> crate::lightning::ln::features::NodeFeatures {
78         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_features;
79         crate::lightning::ln::features::NodeFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
80 }
81 /// The node_announcement features of the node at this hop. For the last hop, these may be
82 /// amended to match the features present in the invoice this node generated.
83 #[no_mangle]
84 pub extern "C" fn RouteHop_set_node_features(this_ptr: &mut RouteHop, mut val: crate::lightning::ln::features::NodeFeatures) {
85         unsafe { &mut *this_ptr.inner }.node_features = *unsafe { Box::from_raw(val.take_inner()) };
86 }
87 /// The channel that should be used from the previous hop to reach this node.
88 #[no_mangle]
89 pub extern "C" fn RouteHop_get_short_channel_id(this_ptr: &RouteHop) -> u64 {
90         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
91         (*inner_val)
92 }
93 /// The channel that should be used from the previous hop to reach this node.
94 #[no_mangle]
95 pub extern "C" fn RouteHop_set_short_channel_id(this_ptr: &mut RouteHop, mut val: u64) {
96         unsafe { &mut *this_ptr.inner }.short_channel_id = val;
97 }
98 /// The channel_announcement features of the channel that should be used from the previous hop
99 /// to reach this node.
100 #[no_mangle]
101 pub extern "C" fn RouteHop_get_channel_features(this_ptr: &RouteHop) -> crate::lightning::ln::features::ChannelFeatures {
102         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_features;
103         crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
104 }
105 /// The channel_announcement features of the channel that should be used from the previous hop
106 /// to reach this node.
107 #[no_mangle]
108 pub extern "C" fn RouteHop_set_channel_features(this_ptr: &mut RouteHop, mut val: crate::lightning::ln::features::ChannelFeatures) {
109         unsafe { &mut *this_ptr.inner }.channel_features = *unsafe { Box::from_raw(val.take_inner()) };
110 }
111 /// The fee taken on this hop (for paying for the use of the *next* channel in the path).
112 /// For the last hop, this should be the full value of the payment (might be more than
113 /// requested if we had to match htlc_minimum_msat).
114 #[no_mangle]
115 pub extern "C" fn RouteHop_get_fee_msat(this_ptr: &RouteHop) -> u64 {
116         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_msat;
117         (*inner_val)
118 }
119 /// The fee taken on this hop (for paying for the use of the *next* channel in the path).
120 /// For the last hop, this should be the full value of the payment (might be more than
121 /// requested if we had to match htlc_minimum_msat).
122 #[no_mangle]
123 pub extern "C" fn RouteHop_set_fee_msat(this_ptr: &mut RouteHop, mut val: u64) {
124         unsafe { &mut *this_ptr.inner }.fee_msat = val;
125 }
126 /// The CLTV delta added for this hop. For the last hop, this should be the full CLTV value
127 /// expected at the destination, in excess of the current block height.
128 #[no_mangle]
129 pub extern "C" fn RouteHop_get_cltv_expiry_delta(this_ptr: &RouteHop) -> u32 {
130         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry_delta;
131         (*inner_val)
132 }
133 /// The CLTV delta added for this hop. For the last hop, this should be the full CLTV value
134 /// expected at the destination, in excess of the current block height.
135 #[no_mangle]
136 pub extern "C" fn RouteHop_set_cltv_expiry_delta(this_ptr: &mut RouteHop, mut val: u32) {
137         unsafe { &mut *this_ptr.inner }.cltv_expiry_delta = val;
138 }
139 /// Constructs a new RouteHop given each field
140 #[must_use]
141 #[no_mangle]
142 pub extern "C" fn RouteHop_new(mut pubkey_arg: crate::c_types::PublicKey, mut node_features_arg: crate::lightning::ln::features::NodeFeatures, mut short_channel_id_arg: u64, mut channel_features_arg: crate::lightning::ln::features::ChannelFeatures, mut fee_msat_arg: u64, mut cltv_expiry_delta_arg: u32) -> RouteHop {
143         RouteHop { inner: Box::into_raw(Box::new(nativeRouteHop {
144                 pubkey: pubkey_arg.into_rust(),
145                 node_features: *unsafe { Box::from_raw(node_features_arg.take_inner()) },
146                 short_channel_id: short_channel_id_arg,
147                 channel_features: *unsafe { Box::from_raw(channel_features_arg.take_inner()) },
148                 fee_msat: fee_msat_arg,
149                 cltv_expiry_delta: cltv_expiry_delta_arg,
150         })), is_owned: true }
151 }
152 impl Clone for RouteHop {
153         fn clone(&self) -> Self {
154                 Self {
155                         inner: if <*mut nativeRouteHop>::is_null(self.inner) { std::ptr::null_mut() } else {
156                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
157                         is_owned: true,
158                 }
159         }
160 }
161 #[allow(unused)]
162 /// Used only if an object of this type is returned as a trait impl by a method
163 pub(crate) extern "C" fn RouteHop_clone_void(this_ptr: *const c_void) -> *mut c_void {
164         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRouteHop)).clone() })) as *mut c_void
165 }
166 #[no_mangle]
167 /// Creates a copy of the RouteHop
168 pub extern "C" fn RouteHop_clone(orig: &RouteHop) -> RouteHop {
169         orig.clone()
170 }
171
172 use lightning::routing::router::Route as nativeRouteImport;
173 type nativeRoute = nativeRouteImport;
174
175 /// A route directs a payment from the sender (us) to the recipient. If the recipient supports MPP,
176 /// it can take multiple paths. Each path is composed of one or more hops through the network.
177 #[must_use]
178 #[repr(C)]
179 pub struct Route {
180         /// A pointer to the opaque Rust object.
181
182         /// Nearly everywhere, inner must be non-null, however in places where
183         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
184         pub inner: *mut nativeRoute,
185         /// Indicates that this is the only struct which contains the same pointer.
186
187         /// Rust functions which take ownership of an object provided via an argument require
188         /// this to be true and invalidate the object pointed to by inner.
189         pub is_owned: bool,
190 }
191
192 impl Drop for Route {
193         fn drop(&mut self) {
194                 if self.is_owned && !<*mut nativeRoute>::is_null(self.inner) {
195                         let _ = unsafe { Box::from_raw(self.inner) };
196                 }
197         }
198 }
199 /// Frees any resources used by the Route, if is_owned is set and inner is non-NULL.
200 #[no_mangle]
201 pub extern "C" fn Route_free(this_obj: Route) { }
202 #[allow(unused)]
203 /// Used only if an object of this type is returned as a trait impl by a method
204 extern "C" fn Route_free_void(this_ptr: *mut c_void) {
205         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRoute); }
206 }
207 #[allow(unused)]
208 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
209 impl Route {
210         pub(crate) fn take_inner(mut self) -> *mut nativeRoute {
211                 assert!(self.is_owned);
212                 let ret = self.inner;
213                 self.inner = std::ptr::null_mut();
214                 ret
215         }
216 }
217 /// The list of routes taken for a single (potentially-)multi-part payment. The pubkey of the
218 /// last RouteHop in each path must be the same.
219 /// Each entry represents a list of hops, NOT INCLUDING our own, where the last hop is the
220 /// destination. Thus, this must always be at least length one. While the maximum length of any
221 /// given path is variable, keeping the length of any path to less than 20 should currently
222 /// ensure it is viable.
223 #[no_mangle]
224 pub extern "C" fn Route_set_paths(this_ptr: &mut Route, mut val: crate::c_types::derived::CVec_CVec_RouteHopZZ) {
225         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { let mut local_val_0 = Vec::new(); for mut item in item.into_rust().drain(..) { local_val_0.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; local_val_0 }); };
226         unsafe { &mut *this_ptr.inner }.paths = local_val;
227 }
228 /// Constructs a new Route given each field
229 #[must_use]
230 #[no_mangle]
231 pub extern "C" fn Route_new(mut paths_arg: crate::c_types::derived::CVec_CVec_RouteHopZZ) -> Route {
232         let mut local_paths_arg = Vec::new(); for mut item in paths_arg.into_rust().drain(..) { local_paths_arg.push( { let mut local_paths_arg_0 = Vec::new(); for mut item in item.into_rust().drain(..) { local_paths_arg_0.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; local_paths_arg_0 }); };
233         Route { inner: Box::into_raw(Box::new(nativeRoute {
234                 paths: local_paths_arg,
235         })), is_owned: true }
236 }
237 impl Clone for Route {
238         fn clone(&self) -> Self {
239                 Self {
240                         inner: if <*mut nativeRoute>::is_null(self.inner) { std::ptr::null_mut() } else {
241                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
242                         is_owned: true,
243                 }
244         }
245 }
246 #[allow(unused)]
247 /// Used only if an object of this type is returned as a trait impl by a method
248 pub(crate) extern "C" fn Route_clone_void(this_ptr: *const c_void) -> *mut c_void {
249         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRoute)).clone() })) as *mut c_void
250 }
251 #[no_mangle]
252 /// Creates a copy of the Route
253 pub extern "C" fn Route_clone(orig: &Route) -> Route {
254         orig.clone()
255 }
256 #[no_mangle]
257 /// Serialize the Route object into a byte array which can be read by Route_read
258 pub extern "C" fn Route_write(obj: &Route) -> crate::c_types::derived::CVec_u8Z {
259         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
260 }
261 #[no_mangle]
262 pub(crate) extern "C" fn Route_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
263         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRoute) })
264 }
265 #[no_mangle]
266 /// Read a Route from a byte array, created by Route_write
267 pub extern "C" fn Route_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RouteDecodeErrorZ {
268         let res = crate::c_types::deserialize_obj(ser);
269         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::Route { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
270         local_res
271 }
272
273 use lightning::routing::router::RouteHintHop as nativeRouteHintHopImport;
274 type nativeRouteHintHop = nativeRouteHintHopImport;
275
276 /// A channel descriptor which provides a last-hop route to get_route
277 #[must_use]
278 #[repr(C)]
279 pub struct RouteHintHop {
280         /// A pointer to the opaque Rust object.
281
282         /// Nearly everywhere, inner must be non-null, however in places where
283         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
284         pub inner: *mut nativeRouteHintHop,
285         /// Indicates that this is the only struct which contains the same pointer.
286
287         /// Rust functions which take ownership of an object provided via an argument require
288         /// this to be true and invalidate the object pointed to by inner.
289         pub is_owned: bool,
290 }
291
292 impl Drop for RouteHintHop {
293         fn drop(&mut self) {
294                 if self.is_owned && !<*mut nativeRouteHintHop>::is_null(self.inner) {
295                         let _ = unsafe { Box::from_raw(self.inner) };
296                 }
297         }
298 }
299 /// Frees any resources used by the RouteHintHop, if is_owned is set and inner is non-NULL.
300 #[no_mangle]
301 pub extern "C" fn RouteHintHop_free(this_obj: RouteHintHop) { }
302 #[allow(unused)]
303 /// Used only if an object of this type is returned as a trait impl by a method
304 extern "C" fn RouteHintHop_free_void(this_ptr: *mut c_void) {
305         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRouteHintHop); }
306 }
307 #[allow(unused)]
308 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
309 impl RouteHintHop {
310         pub(crate) fn take_inner(mut self) -> *mut nativeRouteHintHop {
311                 assert!(self.is_owned);
312                 let ret = self.inner;
313                 self.inner = std::ptr::null_mut();
314                 ret
315         }
316 }
317 /// The node_id of the non-target end of the route
318 #[no_mangle]
319 pub extern "C" fn RouteHintHop_get_src_node_id(this_ptr: &RouteHintHop) -> crate::c_types::PublicKey {
320         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.src_node_id;
321         crate::c_types::PublicKey::from_rust(&(*inner_val))
322 }
323 /// The node_id of the non-target end of the route
324 #[no_mangle]
325 pub extern "C" fn RouteHintHop_set_src_node_id(this_ptr: &mut RouteHintHop, mut val: crate::c_types::PublicKey) {
326         unsafe { &mut *this_ptr.inner }.src_node_id = val.into_rust();
327 }
328 /// The short_channel_id of this channel
329 #[no_mangle]
330 pub extern "C" fn RouteHintHop_get_short_channel_id(this_ptr: &RouteHintHop) -> u64 {
331         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
332         (*inner_val)
333 }
334 /// The short_channel_id of this channel
335 #[no_mangle]
336 pub extern "C" fn RouteHintHop_set_short_channel_id(this_ptr: &mut RouteHintHop, mut val: u64) {
337         unsafe { &mut *this_ptr.inner }.short_channel_id = val;
338 }
339 /// The fees which must be paid to use this channel
340 #[no_mangle]
341 pub extern "C" fn RouteHintHop_get_fees(this_ptr: &RouteHintHop) -> crate::lightning::routing::network_graph::RoutingFees {
342         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fees;
343         crate::lightning::routing::network_graph::RoutingFees { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
344 }
345 /// The fees which must be paid to use this channel
346 #[no_mangle]
347 pub extern "C" fn RouteHintHop_set_fees(this_ptr: &mut RouteHintHop, mut val: crate::lightning::routing::network_graph::RoutingFees) {
348         unsafe { &mut *this_ptr.inner }.fees = *unsafe { Box::from_raw(val.take_inner()) };
349 }
350 /// The difference in CLTV values between this node and the next node.
351 #[no_mangle]
352 pub extern "C" fn RouteHintHop_get_cltv_expiry_delta(this_ptr: &RouteHintHop) -> u16 {
353         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry_delta;
354         (*inner_val)
355 }
356 /// The difference in CLTV values between this node and the next node.
357 #[no_mangle]
358 pub extern "C" fn RouteHintHop_set_cltv_expiry_delta(this_ptr: &mut RouteHintHop, mut val: u16) {
359         unsafe { &mut *this_ptr.inner }.cltv_expiry_delta = val;
360 }
361 /// The minimum value, in msat, which must be relayed to the next hop.
362 #[no_mangle]
363 pub extern "C" fn RouteHintHop_get_htlc_minimum_msat(this_ptr: &RouteHintHop) -> crate::c_types::derived::COption_u64Z {
364         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat;
365         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else {  { crate::c_types::derived::COption_u64Z::Some(inner_val.unwrap()) } };
366         local_inner_val
367 }
368 /// The minimum value, in msat, which must be relayed to the next hop.
369 #[no_mangle]
370 pub extern "C" fn RouteHintHop_set_htlc_minimum_msat(this_ptr: &mut RouteHintHop, mut val: crate::c_types::derived::COption_u64Z) {
371         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
372         unsafe { &mut *this_ptr.inner }.htlc_minimum_msat = local_val;
373 }
374 /// The maximum value in msat available for routing with a single HTLC.
375 #[no_mangle]
376 pub extern "C" fn RouteHintHop_get_htlc_maximum_msat(this_ptr: &RouteHintHop) -> crate::c_types::derived::COption_u64Z {
377         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_maximum_msat;
378         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else {  { crate::c_types::derived::COption_u64Z::Some(inner_val.unwrap()) } };
379         local_inner_val
380 }
381 /// The maximum value in msat available for routing with a single HTLC.
382 #[no_mangle]
383 pub extern "C" fn RouteHintHop_set_htlc_maximum_msat(this_ptr: &mut RouteHintHop, mut val: crate::c_types::derived::COption_u64Z) {
384         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
385         unsafe { &mut *this_ptr.inner }.htlc_maximum_msat = local_val;
386 }
387 /// Constructs a new RouteHintHop given each field
388 #[must_use]
389 #[no_mangle]
390 pub extern "C" fn RouteHintHop_new(mut src_node_id_arg: crate::c_types::PublicKey, mut short_channel_id_arg: u64, mut fees_arg: crate::lightning::routing::network_graph::RoutingFees, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: crate::c_types::derived::COption_u64Z, mut htlc_maximum_msat_arg: crate::c_types::derived::COption_u64Z) -> RouteHintHop {
391         let mut local_htlc_minimum_msat_arg = if htlc_minimum_msat_arg.is_some() { Some( { htlc_minimum_msat_arg.take() }) } else { None };
392         let mut local_htlc_maximum_msat_arg = if htlc_maximum_msat_arg.is_some() { Some( { htlc_maximum_msat_arg.take() }) } else { None };
393         RouteHintHop { inner: Box::into_raw(Box::new(nativeRouteHintHop {
394                 src_node_id: src_node_id_arg.into_rust(),
395                 short_channel_id: short_channel_id_arg,
396                 fees: *unsafe { Box::from_raw(fees_arg.take_inner()) },
397                 cltv_expiry_delta: cltv_expiry_delta_arg,
398                 htlc_minimum_msat: local_htlc_minimum_msat_arg,
399                 htlc_maximum_msat: local_htlc_maximum_msat_arg,
400         })), is_owned: true }
401 }
402 impl Clone for RouteHintHop {
403         fn clone(&self) -> Self {
404                 Self {
405                         inner: if <*mut nativeRouteHintHop>::is_null(self.inner) { std::ptr::null_mut() } else {
406                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
407                         is_owned: true,
408                 }
409         }
410 }
411 #[allow(unused)]
412 /// Used only if an object of this type is returned as a trait impl by a method
413 pub(crate) extern "C" fn RouteHintHop_clone_void(this_ptr: *const c_void) -> *mut c_void {
414         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRouteHintHop)).clone() })) as *mut c_void
415 }
416 #[no_mangle]
417 /// Creates a copy of the RouteHintHop
418 pub extern "C" fn RouteHintHop_clone(orig: &RouteHintHop) -> RouteHintHop {
419         orig.clone()
420 }
421 /// Gets a route from us (payer) to the given target node (payee).
422 ///
423 /// If the payee provided features in their invoice, they should be provided via payee_features.
424 /// Without this, MPP will only be used if the payee's features are available in the network graph.
425 ///
426 /// Extra routing hops between known nodes and the target will be used if they are included in
427 /// last_hops.
428 ///
429 /// If some channels aren't announced, it may be useful to fill in a first_hops with the
430 /// results from a local ChannelManager::list_usable_channels() call. If it is filled in, our
431 /// view of our local channels (from net_graph_msg_handler) will be ignored, and only those
432 /// in first_hops will be used.
433 ///
434 /// Panics if first_hops contains channels without short_channel_ids
435 /// (ChannelManager::list_usable_channels will never include such channels).
436 ///
437 /// The fees on channels from us to next-hops are ignored (as they are assumed to all be
438 /// equal), however the enabled/disabled bit on such channels as well as the
439 /// htlc_minimum_msat/htlc_maximum_msat *are* checked as they may change based on the receiving node.
440 #[no_mangle]
441 pub extern "C" fn get_route(mut our_node_id: crate::c_types::PublicKey, network: &crate::lightning::routing::network_graph::NetworkGraph, mut payee: crate::c_types::PublicKey, mut payee_features: crate::lightning::ln::features::InvoiceFeatures, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, mut last_hops: crate::c_types::derived::CVec_RouteHintHopZ, mut final_value_msat: u64, mut final_cltv: u32, mut logger: crate::lightning::util::logger::Logger) -> crate::c_types::derived::CResult_RouteLightningErrorZ {
442         let mut local_payee_features = if payee_features.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(payee_features.take_inner()) } }) };
443         let mut local_first_hops_base = if first_hops == std::ptr::null_mut() { None } else { Some( { let mut local_first_hops_0 = Vec::new(); for mut item in unsafe { &mut *first_hops }.as_slice().iter() { local_first_hops_0.push( { unsafe { &*item.inner } }); }; local_first_hops_0 }) }; let mut local_first_hops = local_first_hops_base.as_ref().map(|a| &a[..]);
444         let mut local_last_hops = Vec::new(); for mut item in last_hops.as_slice().iter() { local_last_hops.push( { unsafe { &*item.inner } }); };
445         let mut ret = lightning::routing::router::get_route(&our_node_id.into_rust(), unsafe { &*network.inner }, &payee.into_rust(), local_payee_features, local_first_hops, &local_last_hops[..], final_value_msat, final_cltv, logger);
446         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::Route { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
447         local_ret
448 }
449