Update auto-generated bindings
[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 P2PGossipSync and use that as your RoutingMessageHandler and then
12 //! interrogate it to get routes for your own payments.
13
14 use alloc::str::FromStr;
15 use core::ffi::c_void;
16 use core::convert::Infallible;
17 use bitcoin::hashes::Hash;
18 use crate::c_types::*;
19 #[cfg(feature="no-std")]
20 use alloc::{vec::Vec, boxed::Box};
21
22
23 use lightning::routing::router::RouteHop as nativeRouteHopImport;
24 pub(crate) type nativeRouteHop = nativeRouteHopImport;
25
26 /// A hop in a route
27 #[must_use]
28 #[repr(C)]
29 pub struct RouteHop {
30         /// A pointer to the opaque Rust object.
31
32         /// Nearly everywhere, inner must be non-null, however in places where
33         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
34         pub inner: *mut nativeRouteHop,
35         /// Indicates that this is the only struct which contains the same pointer.
36
37         /// Rust functions which take ownership of an object provided via an argument require
38         /// this to be true and invalidate the object pointed to by inner.
39         pub is_owned: bool,
40 }
41
42 impl Drop for RouteHop {
43         fn drop(&mut self) {
44                 if self.is_owned && !<*mut nativeRouteHop>::is_null(self.inner) {
45                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
46                 }
47         }
48 }
49 /// Frees any resources used by the RouteHop, if is_owned is set and inner is non-NULL.
50 #[no_mangle]
51 pub extern "C" fn RouteHop_free(this_obj: RouteHop) { }
52 #[allow(unused)]
53 /// Used only if an object of this type is returned as a trait impl by a method
54 pub(crate) extern "C" fn RouteHop_free_void(this_ptr: *mut c_void) {
55         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRouteHop); }
56 }
57 #[allow(unused)]
58 impl RouteHop {
59         pub(crate) fn get_native_ref(&self) -> &'static nativeRouteHop {
60                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
61         }
62         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRouteHop {
63                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
64         }
65         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
66         pub(crate) fn take_inner(mut self) -> *mut nativeRouteHop {
67                 assert!(self.is_owned);
68                 let ret = ObjOps::untweak_ptr(self.inner);
69                 self.inner = core::ptr::null_mut();
70                 ret
71         }
72 }
73 /// The node_id of the node at this hop.
74 #[no_mangle]
75 pub extern "C" fn RouteHop_get_pubkey(this_ptr: &RouteHop) -> crate::c_types::PublicKey {
76         let mut inner_val = &mut this_ptr.get_native_mut_ref().pubkey;
77         crate::c_types::PublicKey::from_rust(&inner_val)
78 }
79 /// The node_id of the node at this hop.
80 #[no_mangle]
81 pub extern "C" fn RouteHop_set_pubkey(this_ptr: &mut RouteHop, mut val: crate::c_types::PublicKey) {
82         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.pubkey = val.into_rust();
83 }
84 /// The node_announcement features of the node at this hop. For the last hop, these may be
85 /// amended to match the features present in the invoice this node generated.
86 #[no_mangle]
87 pub extern "C" fn RouteHop_get_node_features(this_ptr: &RouteHop) -> crate::lightning::ln::features::NodeFeatures {
88         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_features;
89         crate::lightning::ln::features::NodeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::NodeFeatures<>) as *mut _) }, is_owned: false }
90 }
91 /// The node_announcement features of the node at this hop. For the last hop, these may be
92 /// amended to match the features present in the invoice this node generated.
93 #[no_mangle]
94 pub extern "C" fn RouteHop_set_node_features(this_ptr: &mut RouteHop, mut val: crate::lightning::ln::features::NodeFeatures) {
95         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_features = *unsafe { Box::from_raw(val.take_inner()) };
96 }
97 /// The channel that should be used from the previous hop to reach this node.
98 #[no_mangle]
99 pub extern "C" fn RouteHop_get_short_channel_id(this_ptr: &RouteHop) -> u64 {
100         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
101         *inner_val
102 }
103 /// The channel that should be used from the previous hop to reach this node.
104 #[no_mangle]
105 pub extern "C" fn RouteHop_set_short_channel_id(this_ptr: &mut RouteHop, mut val: u64) {
106         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
107 }
108 /// The channel_announcement features of the channel that should be used from the previous hop
109 /// to reach this node.
110 #[no_mangle]
111 pub extern "C" fn RouteHop_get_channel_features(this_ptr: &RouteHop) -> crate::lightning::ln::features::ChannelFeatures {
112         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_features;
113         crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::ChannelFeatures<>) as *mut _) }, is_owned: false }
114 }
115 /// The channel_announcement features of the channel that should be used from the previous hop
116 /// to reach this node.
117 #[no_mangle]
118 pub extern "C" fn RouteHop_set_channel_features(this_ptr: &mut RouteHop, mut val: crate::lightning::ln::features::ChannelFeatures) {
119         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_features = *unsafe { Box::from_raw(val.take_inner()) };
120 }
121 /// The fee taken on this hop (for paying for the use of the *next* channel in the path).
122 /// For the last hop, this should be the full value of the payment (might be more than
123 /// requested if we had to match htlc_minimum_msat).
124 #[no_mangle]
125 pub extern "C" fn RouteHop_get_fee_msat(this_ptr: &RouteHop) -> u64 {
126         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_msat;
127         *inner_val
128 }
129 /// The fee taken on this hop (for paying for the use of the *next* channel in the path).
130 /// For the last hop, this should be the full value of the payment (might be more than
131 /// requested if we had to match htlc_minimum_msat).
132 #[no_mangle]
133 pub extern "C" fn RouteHop_set_fee_msat(this_ptr: &mut RouteHop, mut val: u64) {
134         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_msat = val;
135 }
136 /// The CLTV delta added for this hop. For the last hop, this should be the full CLTV value
137 /// expected at the destination, in excess of the current block height.
138 #[no_mangle]
139 pub extern "C" fn RouteHop_get_cltv_expiry_delta(this_ptr: &RouteHop) -> u32 {
140         let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
141         *inner_val
142 }
143 /// The CLTV delta added for this hop. For the last hop, this should be the full CLTV value
144 /// expected at the destination, in excess of the current block height.
145 #[no_mangle]
146 pub extern "C" fn RouteHop_set_cltv_expiry_delta(this_ptr: &mut RouteHop, mut val: u32) {
147         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
148 }
149 /// Constructs a new RouteHop given each field
150 #[must_use]
151 #[no_mangle]
152 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 {
153         RouteHop { inner: ObjOps::heap_alloc(nativeRouteHop {
154                 pubkey: pubkey_arg.into_rust(),
155                 node_features: *unsafe { Box::from_raw(node_features_arg.take_inner()) },
156                 short_channel_id: short_channel_id_arg,
157                 channel_features: *unsafe { Box::from_raw(channel_features_arg.take_inner()) },
158                 fee_msat: fee_msat_arg,
159                 cltv_expiry_delta: cltv_expiry_delta_arg,
160         }), is_owned: true }
161 }
162 impl Clone for RouteHop {
163         fn clone(&self) -> Self {
164                 Self {
165                         inner: if <*mut nativeRouteHop>::is_null(self.inner) { core::ptr::null_mut() } else {
166                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
167                         is_owned: true,
168                 }
169         }
170 }
171 #[allow(unused)]
172 /// Used only if an object of this type is returned as a trait impl by a method
173 pub(crate) extern "C" fn RouteHop_clone_void(this_ptr: *const c_void) -> *mut c_void {
174         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRouteHop)).clone() })) as *mut c_void
175 }
176 #[no_mangle]
177 /// Creates a copy of the RouteHop
178 pub extern "C" fn RouteHop_clone(orig: &RouteHop) -> RouteHop {
179         orig.clone()
180 }
181 /// Checks if two RouteHops contain equal inner contents.
182 #[no_mangle]
183 pub extern "C" fn RouteHop_hash(o: &RouteHop) -> u64 {
184         if o.inner.is_null() { return 0; }
185         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
186         #[allow(deprecated)]
187         let mut hasher = core::hash::SipHasher::new();
188         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
189         core::hash::Hasher::finish(&hasher)
190 }
191 /// Checks if two RouteHops contain equal inner contents.
192 /// This ignores pointers and is_owned flags and looks at the values in fields.
193 /// Two objects with NULL inner values will be considered "equal" here.
194 #[no_mangle]
195 pub extern "C" fn RouteHop_eq(a: &RouteHop, b: &RouteHop) -> bool {
196         if a.inner == b.inner { return true; }
197         if a.inner.is_null() || b.inner.is_null() { return false; }
198         if a.get_native_ref() == b.get_native_ref() { true } else { false }
199 }
200 #[no_mangle]
201 /// Serialize the RouteHop object into a byte array which can be read by RouteHop_read
202 pub extern "C" fn RouteHop_write(obj: &crate::lightning::routing::router::RouteHop) -> crate::c_types::derived::CVec_u8Z {
203         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
204 }
205 #[no_mangle]
206 pub(crate) extern "C" fn RouteHop_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
207         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRouteHop) })
208 }
209 #[no_mangle]
210 /// Read a RouteHop from a byte array, created by RouteHop_write
211 pub extern "C" fn RouteHop_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RouteHopDecodeErrorZ {
212         let res: Result<lightning::routing::router::RouteHop, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
213         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::RouteHop { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
214         local_res
215 }
216
217 use lightning::routing::router::Route as nativeRouteImport;
218 pub(crate) type nativeRoute = nativeRouteImport;
219
220 /// A route directs a payment from the sender (us) to the recipient. If the recipient supports MPP,
221 /// it can take multiple paths. Each path is composed of one or more hops through the network.
222 #[must_use]
223 #[repr(C)]
224 pub struct Route {
225         /// A pointer to the opaque Rust object.
226
227         /// Nearly everywhere, inner must be non-null, however in places where
228         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
229         pub inner: *mut nativeRoute,
230         /// Indicates that this is the only struct which contains the same pointer.
231
232         /// Rust functions which take ownership of an object provided via an argument require
233         /// this to be true and invalidate the object pointed to by inner.
234         pub is_owned: bool,
235 }
236
237 impl Drop for Route {
238         fn drop(&mut self) {
239                 if self.is_owned && !<*mut nativeRoute>::is_null(self.inner) {
240                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
241                 }
242         }
243 }
244 /// Frees any resources used by the Route, if is_owned is set and inner is non-NULL.
245 #[no_mangle]
246 pub extern "C" fn Route_free(this_obj: Route) { }
247 #[allow(unused)]
248 /// Used only if an object of this type is returned as a trait impl by a method
249 pub(crate) extern "C" fn Route_free_void(this_ptr: *mut c_void) {
250         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRoute); }
251 }
252 #[allow(unused)]
253 impl Route {
254         pub(crate) fn get_native_ref(&self) -> &'static nativeRoute {
255                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
256         }
257         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRoute {
258                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
259         }
260         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
261         pub(crate) fn take_inner(mut self) -> *mut nativeRoute {
262                 assert!(self.is_owned);
263                 let ret = ObjOps::untweak_ptr(self.inner);
264                 self.inner = core::ptr::null_mut();
265                 ret
266         }
267 }
268 /// The list of routes taken for a single (potentially-)multi-part payment. The pubkey of the
269 /// last RouteHop in each path must be the same. Each entry represents a list of hops, NOT
270 /// INCLUDING our own, where the last hop is the destination. Thus, this must always be at
271 /// least length one. While the maximum length of any given path is variable, keeping the length
272 /// of any path less or equal to 19 should currently ensure it is viable.
273 #[no_mangle]
274 pub extern "C" fn Route_get_paths(this_ptr: &Route) -> crate::c_types::derived::CVec_CVec_RouteHopZZ {
275         let mut inner_val = &mut this_ptr.get_native_mut_ref().paths;
276         let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { let mut local_inner_val_0 = Vec::new(); for item in item.iter() { local_inner_val_0.push( { crate::lightning::routing::router::RouteHop { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::routing::router::RouteHop<>) as *mut _) }, is_owned: false } }); }; local_inner_val_0.into() }); };
277         local_inner_val.into()
278 }
279 /// The list of routes taken for a single (potentially-)multi-part payment. The pubkey of the
280 /// last RouteHop in each path must be the same. Each entry represents a list of hops, NOT
281 /// INCLUDING our own, where the last hop is the destination. Thus, this must always be at
282 /// least length one. While the maximum length of any given path is variable, keeping the length
283 /// of any path less or equal to 19 should currently ensure it is viable.
284 #[no_mangle]
285 pub extern "C" fn Route_set_paths(this_ptr: &mut Route, mut val: crate::c_types::derived::CVec_CVec_RouteHopZZ) {
286         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 }); };
287         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.paths = local_val;
288 }
289 /// The `payment_params` parameter passed to [`find_route`].
290 /// This is used by `ChannelManager` to track information which may be required for retries,
291 /// provided back to you via [`Event::PaymentPathFailed`].
292 ///
293 /// [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed
294 ///
295 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
296 #[no_mangle]
297 pub extern "C" fn Route_get_payment_params(this_ptr: &Route) -> crate::lightning::routing::router::PaymentParameters {
298         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_params;
299         let mut local_inner_val = crate::lightning::routing::router::PaymentParameters { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::routing::router::PaymentParameters<>) as *mut _ }, is_owned: false };
300         local_inner_val
301 }
302 /// The `payment_params` parameter passed to [`find_route`].
303 /// This is used by `ChannelManager` to track information which may be required for retries,
304 /// provided back to you via [`Event::PaymentPathFailed`].
305 ///
306 /// [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed
307 ///
308 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
309 #[no_mangle]
310 pub extern "C" fn Route_set_payment_params(this_ptr: &mut Route, mut val: crate::lightning::routing::router::PaymentParameters) {
311         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
312         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_params = local_val;
313 }
314 /// Constructs a new Route given each field
315 #[must_use]
316 #[no_mangle]
317 pub extern "C" fn Route_new(mut paths_arg: crate::c_types::derived::CVec_CVec_RouteHopZZ, mut payment_params_arg: crate::lightning::routing::router::PaymentParameters) -> Route {
318         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 }); };
319         let mut local_payment_params_arg = if payment_params_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(payment_params_arg.take_inner()) } }) };
320         Route { inner: ObjOps::heap_alloc(nativeRoute {
321                 paths: local_paths_arg,
322                 payment_params: local_payment_params_arg,
323         }), is_owned: true }
324 }
325 impl Clone for Route {
326         fn clone(&self) -> Self {
327                 Self {
328                         inner: if <*mut nativeRoute>::is_null(self.inner) { core::ptr::null_mut() } else {
329                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
330                         is_owned: true,
331                 }
332         }
333 }
334 #[allow(unused)]
335 /// Used only if an object of this type is returned as a trait impl by a method
336 pub(crate) extern "C" fn Route_clone_void(this_ptr: *const c_void) -> *mut c_void {
337         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRoute)).clone() })) as *mut c_void
338 }
339 #[no_mangle]
340 /// Creates a copy of the Route
341 pub extern "C" fn Route_clone(orig: &Route) -> Route {
342         orig.clone()
343 }
344 /// Checks if two Routes contain equal inner contents.
345 #[no_mangle]
346 pub extern "C" fn Route_hash(o: &Route) -> u64 {
347         if o.inner.is_null() { return 0; }
348         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
349         #[allow(deprecated)]
350         let mut hasher = core::hash::SipHasher::new();
351         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
352         core::hash::Hasher::finish(&hasher)
353 }
354 /// Checks if two Routes contain equal inner contents.
355 /// This ignores pointers and is_owned flags and looks at the values in fields.
356 /// Two objects with NULL inner values will be considered "equal" here.
357 #[no_mangle]
358 pub extern "C" fn Route_eq(a: &Route, b: &Route) -> bool {
359         if a.inner == b.inner { return true; }
360         if a.inner.is_null() || b.inner.is_null() { return false; }
361         if a.get_native_ref() == b.get_native_ref() { true } else { false }
362 }
363 /// Returns the total amount of fees paid on this [`Route`].
364 ///
365 /// This doesn't include any extra payment made to the recipient, which can happen in excess of
366 /// the amount passed to [`find_route`]'s `params.final_value_msat`.
367 #[must_use]
368 #[no_mangle]
369 pub extern "C" fn Route_get_total_fees(this_arg: &crate::lightning::routing::router::Route) -> u64 {
370         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_total_fees();
371         ret
372 }
373
374 /// Returns the total amount paid on this [`Route`], excluding the fees.
375 #[must_use]
376 #[no_mangle]
377 pub extern "C" fn Route_get_total_amount(this_arg: &crate::lightning::routing::router::Route) -> u64 {
378         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_total_amount();
379         ret
380 }
381
382 #[no_mangle]
383 /// Serialize the Route object into a byte array which can be read by Route_read
384 pub extern "C" fn Route_write(obj: &crate::lightning::routing::router::Route) -> crate::c_types::derived::CVec_u8Z {
385         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
386 }
387 #[no_mangle]
388 pub(crate) extern "C" fn Route_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
389         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRoute) })
390 }
391 #[no_mangle]
392 /// Read a Route from a byte array, created by Route_write
393 pub extern "C" fn Route_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RouteDecodeErrorZ {
394         let res: Result<lightning::routing::router::Route, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
395         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::Route { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
396         local_res
397 }
398
399 use lightning::routing::router::RouteParameters as nativeRouteParametersImport;
400 pub(crate) type nativeRouteParameters = nativeRouteParametersImport;
401
402 /// Parameters needed to find a [`Route`].
403 ///
404 /// Passed to [`find_route`] and [`build_route_from_hops`], but also provided in
405 /// [`Event::PaymentPathFailed`] for retrying a failed payment path.
406 ///
407 /// [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed
408 #[must_use]
409 #[repr(C)]
410 pub struct RouteParameters {
411         /// A pointer to the opaque Rust object.
412
413         /// Nearly everywhere, inner must be non-null, however in places where
414         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
415         pub inner: *mut nativeRouteParameters,
416         /// Indicates that this is the only struct which contains the same pointer.
417
418         /// Rust functions which take ownership of an object provided via an argument require
419         /// this to be true and invalidate the object pointed to by inner.
420         pub is_owned: bool,
421 }
422
423 impl Drop for RouteParameters {
424         fn drop(&mut self) {
425                 if self.is_owned && !<*mut nativeRouteParameters>::is_null(self.inner) {
426                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
427                 }
428         }
429 }
430 /// Frees any resources used by the RouteParameters, if is_owned is set and inner is non-NULL.
431 #[no_mangle]
432 pub extern "C" fn RouteParameters_free(this_obj: RouteParameters) { }
433 #[allow(unused)]
434 /// Used only if an object of this type is returned as a trait impl by a method
435 pub(crate) extern "C" fn RouteParameters_free_void(this_ptr: *mut c_void) {
436         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRouteParameters); }
437 }
438 #[allow(unused)]
439 impl RouteParameters {
440         pub(crate) fn get_native_ref(&self) -> &'static nativeRouteParameters {
441                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
442         }
443         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRouteParameters {
444                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
445         }
446         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
447         pub(crate) fn take_inner(mut self) -> *mut nativeRouteParameters {
448                 assert!(self.is_owned);
449                 let ret = ObjOps::untweak_ptr(self.inner);
450                 self.inner = core::ptr::null_mut();
451                 ret
452         }
453 }
454 /// The parameters of the failed payment path.
455 #[no_mangle]
456 pub extern "C" fn RouteParameters_get_payment_params(this_ptr: &RouteParameters) -> crate::lightning::routing::router::PaymentParameters {
457         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_params;
458         crate::lightning::routing::router::PaymentParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::router::PaymentParameters<>) as *mut _) }, is_owned: false }
459 }
460 /// The parameters of the failed payment path.
461 #[no_mangle]
462 pub extern "C" fn RouteParameters_set_payment_params(this_ptr: &mut RouteParameters, mut val: crate::lightning::routing::router::PaymentParameters) {
463         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_params = *unsafe { Box::from_raw(val.take_inner()) };
464 }
465 /// The amount in msats sent on the failed payment path.
466 #[no_mangle]
467 pub extern "C" fn RouteParameters_get_final_value_msat(this_ptr: &RouteParameters) -> u64 {
468         let mut inner_val = &mut this_ptr.get_native_mut_ref().final_value_msat;
469         *inner_val
470 }
471 /// The amount in msats sent on the failed payment path.
472 #[no_mangle]
473 pub extern "C" fn RouteParameters_set_final_value_msat(this_ptr: &mut RouteParameters, mut val: u64) {
474         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.final_value_msat = val;
475 }
476 /// The CLTV on the final hop of the failed payment path.
477 #[no_mangle]
478 pub extern "C" fn RouteParameters_get_final_cltv_expiry_delta(this_ptr: &RouteParameters) -> u32 {
479         let mut inner_val = &mut this_ptr.get_native_mut_ref().final_cltv_expiry_delta;
480         *inner_val
481 }
482 /// The CLTV on the final hop of the failed payment path.
483 #[no_mangle]
484 pub extern "C" fn RouteParameters_set_final_cltv_expiry_delta(this_ptr: &mut RouteParameters, mut val: u32) {
485         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.final_cltv_expiry_delta = val;
486 }
487 /// Constructs a new RouteParameters given each field
488 #[must_use]
489 #[no_mangle]
490 pub extern "C" fn RouteParameters_new(mut payment_params_arg: crate::lightning::routing::router::PaymentParameters, mut final_value_msat_arg: u64, mut final_cltv_expiry_delta_arg: u32) -> RouteParameters {
491         RouteParameters { inner: ObjOps::heap_alloc(nativeRouteParameters {
492                 payment_params: *unsafe { Box::from_raw(payment_params_arg.take_inner()) },
493                 final_value_msat: final_value_msat_arg,
494                 final_cltv_expiry_delta: final_cltv_expiry_delta_arg,
495         }), is_owned: true }
496 }
497 impl Clone for RouteParameters {
498         fn clone(&self) -> Self {
499                 Self {
500                         inner: if <*mut nativeRouteParameters>::is_null(self.inner) { core::ptr::null_mut() } else {
501                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
502                         is_owned: true,
503                 }
504         }
505 }
506 #[allow(unused)]
507 /// Used only if an object of this type is returned as a trait impl by a method
508 pub(crate) extern "C" fn RouteParameters_clone_void(this_ptr: *const c_void) -> *mut c_void {
509         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRouteParameters)).clone() })) as *mut c_void
510 }
511 #[no_mangle]
512 /// Creates a copy of the RouteParameters
513 pub extern "C" fn RouteParameters_clone(orig: &RouteParameters) -> RouteParameters {
514         orig.clone()
515 }
516 #[no_mangle]
517 /// Serialize the RouteParameters object into a byte array which can be read by RouteParameters_read
518 pub extern "C" fn RouteParameters_write(obj: &crate::lightning::routing::router::RouteParameters) -> crate::c_types::derived::CVec_u8Z {
519         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
520 }
521 #[no_mangle]
522 pub(crate) extern "C" fn RouteParameters_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
523         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRouteParameters) })
524 }
525 #[no_mangle]
526 /// Read a RouteParameters from a byte array, created by RouteParameters_write
527 pub extern "C" fn RouteParameters_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RouteParametersDecodeErrorZ {
528         let res: Result<lightning::routing::router::RouteParameters, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
529         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::RouteParameters { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
530         local_res
531 }
532 /// Maximum total CTLV difference we allow for a full payment path.
533
534 #[no_mangle]
535 pub static DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA: u32 = lightning::routing::router::DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA;
536 /// Maximum number of paths we allow an (MPP) payment to have.
537
538 #[no_mangle]
539 pub static DEFAULT_MAX_PATH_COUNT: u8 = lightning::routing::router::DEFAULT_MAX_PATH_COUNT;
540
541 use lightning::routing::router::PaymentParameters as nativePaymentParametersImport;
542 pub(crate) type nativePaymentParameters = nativePaymentParametersImport;
543
544 /// The recipient of a payment.
545 #[must_use]
546 #[repr(C)]
547 pub struct PaymentParameters {
548         /// A pointer to the opaque Rust object.
549
550         /// Nearly everywhere, inner must be non-null, however in places where
551         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
552         pub inner: *mut nativePaymentParameters,
553         /// Indicates that this is the only struct which contains the same pointer.
554
555         /// Rust functions which take ownership of an object provided via an argument require
556         /// this to be true and invalidate the object pointed to by inner.
557         pub is_owned: bool,
558 }
559
560 impl Drop for PaymentParameters {
561         fn drop(&mut self) {
562                 if self.is_owned && !<*mut nativePaymentParameters>::is_null(self.inner) {
563                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
564                 }
565         }
566 }
567 /// Frees any resources used by the PaymentParameters, if is_owned is set and inner is non-NULL.
568 #[no_mangle]
569 pub extern "C" fn PaymentParameters_free(this_obj: PaymentParameters) { }
570 #[allow(unused)]
571 /// Used only if an object of this type is returned as a trait impl by a method
572 pub(crate) extern "C" fn PaymentParameters_free_void(this_ptr: *mut c_void) {
573         unsafe { let _ = Box::from_raw(this_ptr as *mut nativePaymentParameters); }
574 }
575 #[allow(unused)]
576 impl PaymentParameters {
577         pub(crate) fn get_native_ref(&self) -> &'static nativePaymentParameters {
578                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
579         }
580         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePaymentParameters {
581                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
582         }
583         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
584         pub(crate) fn take_inner(mut self) -> *mut nativePaymentParameters {
585                 assert!(self.is_owned);
586                 let ret = ObjOps::untweak_ptr(self.inner);
587                 self.inner = core::ptr::null_mut();
588                 ret
589         }
590 }
591 /// The node id of the payee.
592 #[no_mangle]
593 pub extern "C" fn PaymentParameters_get_payee_pubkey(this_ptr: &PaymentParameters) -> crate::c_types::PublicKey {
594         let mut inner_val = &mut this_ptr.get_native_mut_ref().payee_pubkey;
595         crate::c_types::PublicKey::from_rust(&inner_val)
596 }
597 /// The node id of the payee.
598 #[no_mangle]
599 pub extern "C" fn PaymentParameters_set_payee_pubkey(this_ptr: &mut PaymentParameters, mut val: crate::c_types::PublicKey) {
600         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payee_pubkey = val.into_rust();
601 }
602 /// Features supported by the payee.
603 ///
604 /// May be set from the payee's invoice or via [`for_keysend`]. May be `None` if the invoice
605 /// does not contain any features.
606 ///
607 /// [`for_keysend`]: Self::for_keysend
608 ///
609 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
610 #[no_mangle]
611 pub extern "C" fn PaymentParameters_get_features(this_ptr: &PaymentParameters) -> crate::lightning::ln::features::InvoiceFeatures {
612         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
613         let mut local_inner_val = crate::lightning::ln::features::InvoiceFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::InvoiceFeatures<>) as *mut _ }, is_owned: false };
614         local_inner_val
615 }
616 /// Features supported by the payee.
617 ///
618 /// May be set from the payee's invoice or via [`for_keysend`]. May be `None` if the invoice
619 /// does not contain any features.
620 ///
621 /// [`for_keysend`]: Self::for_keysend
622 ///
623 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
624 #[no_mangle]
625 pub extern "C" fn PaymentParameters_set_features(this_ptr: &mut PaymentParameters, mut val: crate::lightning::ln::features::InvoiceFeatures) {
626         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
627         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = local_val;
628 }
629 /// Hints for routing to the payee, containing channels connecting the payee to public nodes.
630 #[no_mangle]
631 pub extern "C" fn PaymentParameters_get_route_hints(this_ptr: &PaymentParameters) -> crate::c_types::derived::CVec_RouteHintZ {
632         let mut inner_val = &mut this_ptr.get_native_mut_ref().route_hints;
633         let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::routing::router::RouteHint { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::routing::router::RouteHint<>) as *mut _) }, is_owned: false } }); };
634         local_inner_val.into()
635 }
636 /// Hints for routing to the payee, containing channels connecting the payee to public nodes.
637 #[no_mangle]
638 pub extern "C" fn PaymentParameters_set_route_hints(this_ptr: &mut PaymentParameters, mut val: crate::c_types::derived::CVec_RouteHintZ) {
639         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
640         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.route_hints = local_val;
641 }
642 /// Expiration of a payment to the payee, in seconds relative to the UNIX epoch.
643 #[no_mangle]
644 pub extern "C" fn PaymentParameters_get_expiry_time(this_ptr: &PaymentParameters) -> crate::c_types::derived::COption_u64Z {
645         let mut inner_val = &mut this_ptr.get_native_mut_ref().expiry_time;
646         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() }) };
647         local_inner_val
648 }
649 /// Expiration of a payment to the payee, in seconds relative to the UNIX epoch.
650 #[no_mangle]
651 pub extern "C" fn PaymentParameters_set_expiry_time(this_ptr: &mut PaymentParameters, mut val: crate::c_types::derived::COption_u64Z) {
652         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
653         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.expiry_time = local_val;
654 }
655 /// The maximum total CLTV delta we accept for the route.
656 /// Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`].
657 #[no_mangle]
658 pub extern "C" fn PaymentParameters_get_max_total_cltv_expiry_delta(this_ptr: &PaymentParameters) -> u32 {
659         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_total_cltv_expiry_delta;
660         *inner_val
661 }
662 /// The maximum total CLTV delta we accept for the route.
663 /// Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`].
664 #[no_mangle]
665 pub extern "C" fn PaymentParameters_set_max_total_cltv_expiry_delta(this_ptr: &mut PaymentParameters, mut val: u32) {
666         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_total_cltv_expiry_delta = val;
667 }
668 /// The maximum number of paths that may be used by (MPP) payments.
669 /// Defaults to [`DEFAULT_MAX_PATH_COUNT`].
670 #[no_mangle]
671 pub extern "C" fn PaymentParameters_get_max_path_count(this_ptr: &PaymentParameters) -> u8 {
672         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_path_count;
673         *inner_val
674 }
675 /// The maximum number of paths that may be used by (MPP) payments.
676 /// Defaults to [`DEFAULT_MAX_PATH_COUNT`].
677 #[no_mangle]
678 pub extern "C" fn PaymentParameters_set_max_path_count(this_ptr: &mut PaymentParameters, mut val: u8) {
679         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_path_count = val;
680 }
681 /// Selects the maximum share of a channel's total capacity which will be sent over a channel,
682 /// as a power of 1/2. A higher value prefers to send the payment using more MPP parts whereas
683 /// a lower value prefers to send larger MPP parts, potentially saturating channels and
684 /// increasing failure probability for those paths.
685 ///
686 /// Note that this restriction will be relaxed during pathfinding after paths which meet this
687 /// restriction have been found. While paths which meet this criteria will be searched for, it
688 /// is ultimately up to the scorer to select them over other paths.
689 ///
690 /// A value of 0 will allow payments up to and including a channel's total announced usable
691 /// capacity, a value of one will only use up to half its capacity, two 1/4, etc.
692 ///
693 /// Default value: 2
694 #[no_mangle]
695 pub extern "C" fn PaymentParameters_get_max_channel_saturation_power_of_half(this_ptr: &PaymentParameters) -> u8 {
696         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_channel_saturation_power_of_half;
697         *inner_val
698 }
699 /// Selects the maximum share of a channel's total capacity which will be sent over a channel,
700 /// as a power of 1/2. A higher value prefers to send the payment using more MPP parts whereas
701 /// a lower value prefers to send larger MPP parts, potentially saturating channels and
702 /// increasing failure probability for those paths.
703 ///
704 /// Note that this restriction will be relaxed during pathfinding after paths which meet this
705 /// restriction have been found. While paths which meet this criteria will be searched for, it
706 /// is ultimately up to the scorer to select them over other paths.
707 ///
708 /// A value of 0 will allow payments up to and including a channel's total announced usable
709 /// capacity, a value of one will only use up to half its capacity, two 1/4, etc.
710 ///
711 /// Default value: 2
712 #[no_mangle]
713 pub extern "C" fn PaymentParameters_set_max_channel_saturation_power_of_half(this_ptr: &mut PaymentParameters, mut val: u8) {
714         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_channel_saturation_power_of_half = val;
715 }
716 /// A list of SCIDs which this payment was previously attempted over and which caused the
717 /// payment to fail. Future attempts for the same payment shouldn't be relayed through any of
718 /// these SCIDs.
719 ///
720 /// Returns a copy of the field.
721 #[no_mangle]
722 pub extern "C" fn PaymentParameters_get_previously_failed_channels(this_ptr: &PaymentParameters) -> crate::c_types::derived::CVec_u64Z {
723         let mut inner_val = this_ptr.get_native_mut_ref().previously_failed_channels.clone();
724         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
725         local_inner_val.into()
726 }
727 /// A list of SCIDs which this payment was previously attempted over and which caused the
728 /// payment to fail. Future attempts for the same payment shouldn't be relayed through any of
729 /// these SCIDs.
730 #[no_mangle]
731 pub extern "C" fn PaymentParameters_set_previously_failed_channels(this_ptr: &mut PaymentParameters, mut val: crate::c_types::derived::CVec_u64Z) {
732         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
733         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.previously_failed_channels = local_val;
734 }
735 /// Constructs a new PaymentParameters given each field
736 #[must_use]
737 #[no_mangle]
738 pub extern "C" fn PaymentParameters_new(mut payee_pubkey_arg: crate::c_types::PublicKey, mut features_arg: crate::lightning::ln::features::InvoiceFeatures, mut route_hints_arg: crate::c_types::derived::CVec_RouteHintZ, mut expiry_time_arg: crate::c_types::derived::COption_u64Z, mut max_total_cltv_expiry_delta_arg: u32, mut max_path_count_arg: u8, mut max_channel_saturation_power_of_half_arg: u8, mut previously_failed_channels_arg: crate::c_types::derived::CVec_u64Z) -> PaymentParameters {
739         let mut local_features_arg = if features_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(features_arg.take_inner()) } }) };
740         let mut local_route_hints_arg = Vec::new(); for mut item in route_hints_arg.into_rust().drain(..) { local_route_hints_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
741         let mut local_expiry_time_arg = if expiry_time_arg.is_some() { Some( { expiry_time_arg.take() }) } else { None };
742         let mut local_previously_failed_channels_arg = Vec::new(); for mut item in previously_failed_channels_arg.into_rust().drain(..) { local_previously_failed_channels_arg.push( { item }); };
743         PaymentParameters { inner: ObjOps::heap_alloc(nativePaymentParameters {
744                 payee_pubkey: payee_pubkey_arg.into_rust(),
745                 features: local_features_arg,
746                 route_hints: local_route_hints_arg,
747                 expiry_time: local_expiry_time_arg,
748                 max_total_cltv_expiry_delta: max_total_cltv_expiry_delta_arg,
749                 max_path_count: max_path_count_arg,
750                 max_channel_saturation_power_of_half: max_channel_saturation_power_of_half_arg,
751                 previously_failed_channels: local_previously_failed_channels_arg,
752         }), is_owned: true }
753 }
754 impl Clone for PaymentParameters {
755         fn clone(&self) -> Self {
756                 Self {
757                         inner: if <*mut nativePaymentParameters>::is_null(self.inner) { core::ptr::null_mut() } else {
758                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
759                         is_owned: true,
760                 }
761         }
762 }
763 #[allow(unused)]
764 /// Used only if an object of this type is returned as a trait impl by a method
765 pub(crate) extern "C" fn PaymentParameters_clone_void(this_ptr: *const c_void) -> *mut c_void {
766         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePaymentParameters)).clone() })) as *mut c_void
767 }
768 #[no_mangle]
769 /// Creates a copy of the PaymentParameters
770 pub extern "C" fn PaymentParameters_clone(orig: &PaymentParameters) -> PaymentParameters {
771         orig.clone()
772 }
773 /// Checks if two PaymentParameterss contain equal inner contents.
774 #[no_mangle]
775 pub extern "C" fn PaymentParameters_hash(o: &PaymentParameters) -> u64 {
776         if o.inner.is_null() { return 0; }
777         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
778         #[allow(deprecated)]
779         let mut hasher = core::hash::SipHasher::new();
780         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
781         core::hash::Hasher::finish(&hasher)
782 }
783 /// Checks if two PaymentParameterss contain equal inner contents.
784 /// This ignores pointers and is_owned flags and looks at the values in fields.
785 /// Two objects with NULL inner values will be considered "equal" here.
786 #[no_mangle]
787 pub extern "C" fn PaymentParameters_eq(a: &PaymentParameters, b: &PaymentParameters) -> bool {
788         if a.inner == b.inner { return true; }
789         if a.inner.is_null() || b.inner.is_null() { return false; }
790         if a.get_native_ref() == b.get_native_ref() { true } else { false }
791 }
792 #[no_mangle]
793 /// Serialize the PaymentParameters object into a byte array which can be read by PaymentParameters_read
794 pub extern "C" fn PaymentParameters_write(obj: &crate::lightning::routing::router::PaymentParameters) -> crate::c_types::derived::CVec_u8Z {
795         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
796 }
797 #[no_mangle]
798 pub(crate) extern "C" fn PaymentParameters_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
799         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePaymentParameters) })
800 }
801 #[no_mangle]
802 /// Read a PaymentParameters from a byte array, created by PaymentParameters_write
803 pub extern "C" fn PaymentParameters_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PaymentParametersDecodeErrorZ {
804         let res: Result<lightning::routing::router::PaymentParameters, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
805         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::PaymentParameters { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
806         local_res
807 }
808 /// Creates a payee with the node id of the given `pubkey`.
809 #[must_use]
810 #[no_mangle]
811 pub extern "C" fn PaymentParameters_from_node_id(mut payee_pubkey: crate::c_types::PublicKey) -> crate::lightning::routing::router::PaymentParameters {
812         let mut ret = lightning::routing::router::PaymentParameters::from_node_id(payee_pubkey.into_rust());
813         crate::lightning::routing::router::PaymentParameters { inner: ObjOps::heap_alloc(ret), is_owned: true }
814 }
815
816 /// Creates a payee with the node id of the given `pubkey` to use for keysend payments.
817 #[must_use]
818 #[no_mangle]
819 pub extern "C" fn PaymentParameters_for_keysend(mut payee_pubkey: crate::c_types::PublicKey) -> crate::lightning::routing::router::PaymentParameters {
820         let mut ret = lightning::routing::router::PaymentParameters::for_keysend(payee_pubkey.into_rust());
821         crate::lightning::routing::router::PaymentParameters { inner: ObjOps::heap_alloc(ret), is_owned: true }
822 }
823
824
825 use lightning::routing::router::RouteHint as nativeRouteHintImport;
826 pub(crate) type nativeRouteHint = nativeRouteHintImport;
827
828 /// A list of hops along a payment path terminating with a channel to the recipient.
829 #[must_use]
830 #[repr(C)]
831 pub struct RouteHint {
832         /// A pointer to the opaque Rust object.
833
834         /// Nearly everywhere, inner must be non-null, however in places where
835         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
836         pub inner: *mut nativeRouteHint,
837         /// Indicates that this is the only struct which contains the same pointer.
838
839         /// Rust functions which take ownership of an object provided via an argument require
840         /// this to be true and invalidate the object pointed to by inner.
841         pub is_owned: bool,
842 }
843
844 impl Drop for RouteHint {
845         fn drop(&mut self) {
846                 if self.is_owned && !<*mut nativeRouteHint>::is_null(self.inner) {
847                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
848                 }
849         }
850 }
851 /// Frees any resources used by the RouteHint, if is_owned is set and inner is non-NULL.
852 #[no_mangle]
853 pub extern "C" fn RouteHint_free(this_obj: RouteHint) { }
854 #[allow(unused)]
855 /// Used only if an object of this type is returned as a trait impl by a method
856 pub(crate) extern "C" fn RouteHint_free_void(this_ptr: *mut c_void) {
857         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRouteHint); }
858 }
859 #[allow(unused)]
860 impl RouteHint {
861         pub(crate) fn get_native_ref(&self) -> &'static nativeRouteHint {
862                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
863         }
864         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRouteHint {
865                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
866         }
867         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
868         pub(crate) fn take_inner(mut self) -> *mut nativeRouteHint {
869                 assert!(self.is_owned);
870                 let ret = ObjOps::untweak_ptr(self.inner);
871                 self.inner = core::ptr::null_mut();
872                 ret
873         }
874 }
875 #[no_mangle]
876 pub extern "C" fn RouteHint_get_a(this_ptr: &RouteHint) -> crate::c_types::derived::CVec_RouteHintHopZ {
877         let mut inner_val = &mut this_ptr.get_native_mut_ref().0;
878         let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::routing::router::RouteHintHop { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::routing::router::RouteHintHop<>) as *mut _) }, is_owned: false } }); };
879         local_inner_val.into()
880 }
881 #[no_mangle]
882 pub extern "C" fn RouteHint_set_a(this_ptr: &mut RouteHint, mut val: crate::c_types::derived::CVec_RouteHintHopZ) {
883         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
884         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.0 = local_val;
885 }
886 /// Constructs a new RouteHint given each field
887 #[must_use]
888 #[no_mangle]
889 pub extern "C" fn RouteHint_new(mut a_arg: crate::c_types::derived::CVec_RouteHintHopZ) -> RouteHint {
890         let mut local_a_arg = Vec::new(); for mut item in a_arg.into_rust().drain(..) { local_a_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
891         RouteHint { inner: ObjOps::heap_alloc(lightning::routing::router::RouteHint (
892                 local_a_arg,
893         )), is_owned: true }
894 }
895 impl Clone for RouteHint {
896         fn clone(&self) -> Self {
897                 Self {
898                         inner: if <*mut nativeRouteHint>::is_null(self.inner) { core::ptr::null_mut() } else {
899                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
900                         is_owned: true,
901                 }
902         }
903 }
904 #[allow(unused)]
905 /// Used only if an object of this type is returned as a trait impl by a method
906 pub(crate) extern "C" fn RouteHint_clone_void(this_ptr: *const c_void) -> *mut c_void {
907         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRouteHint)).clone() })) as *mut c_void
908 }
909 #[no_mangle]
910 /// Creates a copy of the RouteHint
911 pub extern "C" fn RouteHint_clone(orig: &RouteHint) -> RouteHint {
912         orig.clone()
913 }
914 /// Checks if two RouteHints contain equal inner contents.
915 #[no_mangle]
916 pub extern "C" fn RouteHint_hash(o: &RouteHint) -> u64 {
917         if o.inner.is_null() { return 0; }
918         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
919         #[allow(deprecated)]
920         let mut hasher = core::hash::SipHasher::new();
921         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
922         core::hash::Hasher::finish(&hasher)
923 }
924 /// Checks if two RouteHints contain equal inner contents.
925 /// This ignores pointers and is_owned flags and looks at the values in fields.
926 /// Two objects with NULL inner values will be considered "equal" here.
927 #[no_mangle]
928 pub extern "C" fn RouteHint_eq(a: &RouteHint, b: &RouteHint) -> bool {
929         if a.inner == b.inner { return true; }
930         if a.inner.is_null() || b.inner.is_null() { return false; }
931         if a.get_native_ref() == b.get_native_ref() { true } else { false }
932 }
933 #[no_mangle]
934 /// Serialize the RouteHint object into a byte array which can be read by RouteHint_read
935 pub extern "C" fn RouteHint_write(obj: &crate::lightning::routing::router::RouteHint) -> crate::c_types::derived::CVec_u8Z {
936         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
937 }
938 #[no_mangle]
939 pub(crate) extern "C" fn RouteHint_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
940         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRouteHint) })
941 }
942 #[no_mangle]
943 /// Read a RouteHint from a byte array, created by RouteHint_write
944 pub extern "C" fn RouteHint_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RouteHintDecodeErrorZ {
945         let res: Result<lightning::routing::router::RouteHint, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
946         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::RouteHint { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
947         local_res
948 }
949
950 use lightning::routing::router::RouteHintHop as nativeRouteHintHopImport;
951 pub(crate) type nativeRouteHintHop = nativeRouteHintHopImport;
952
953 /// A channel descriptor for a hop along a payment path.
954 #[must_use]
955 #[repr(C)]
956 pub struct RouteHintHop {
957         /// A pointer to the opaque Rust object.
958
959         /// Nearly everywhere, inner must be non-null, however in places where
960         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
961         pub inner: *mut nativeRouteHintHop,
962         /// Indicates that this is the only struct which contains the same pointer.
963
964         /// Rust functions which take ownership of an object provided via an argument require
965         /// this to be true and invalidate the object pointed to by inner.
966         pub is_owned: bool,
967 }
968
969 impl Drop for RouteHintHop {
970         fn drop(&mut self) {
971                 if self.is_owned && !<*mut nativeRouteHintHop>::is_null(self.inner) {
972                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
973                 }
974         }
975 }
976 /// Frees any resources used by the RouteHintHop, if is_owned is set and inner is non-NULL.
977 #[no_mangle]
978 pub extern "C" fn RouteHintHop_free(this_obj: RouteHintHop) { }
979 #[allow(unused)]
980 /// Used only if an object of this type is returned as a trait impl by a method
981 pub(crate) extern "C" fn RouteHintHop_free_void(this_ptr: *mut c_void) {
982         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRouteHintHop); }
983 }
984 #[allow(unused)]
985 impl RouteHintHop {
986         pub(crate) fn get_native_ref(&self) -> &'static nativeRouteHintHop {
987                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
988         }
989         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRouteHintHop {
990                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
991         }
992         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
993         pub(crate) fn take_inner(mut self) -> *mut nativeRouteHintHop {
994                 assert!(self.is_owned);
995                 let ret = ObjOps::untweak_ptr(self.inner);
996                 self.inner = core::ptr::null_mut();
997                 ret
998         }
999 }
1000 /// The node_id of the non-target end of the route
1001 #[no_mangle]
1002 pub extern "C" fn RouteHintHop_get_src_node_id(this_ptr: &RouteHintHop) -> crate::c_types::PublicKey {
1003         let mut inner_val = &mut this_ptr.get_native_mut_ref().src_node_id;
1004         crate::c_types::PublicKey::from_rust(&inner_val)
1005 }
1006 /// The node_id of the non-target end of the route
1007 #[no_mangle]
1008 pub extern "C" fn RouteHintHop_set_src_node_id(this_ptr: &mut RouteHintHop, mut val: crate::c_types::PublicKey) {
1009         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.src_node_id = val.into_rust();
1010 }
1011 /// The short_channel_id of this channel
1012 #[no_mangle]
1013 pub extern "C" fn RouteHintHop_get_short_channel_id(this_ptr: &RouteHintHop) -> u64 {
1014         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
1015         *inner_val
1016 }
1017 /// The short_channel_id of this channel
1018 #[no_mangle]
1019 pub extern "C" fn RouteHintHop_set_short_channel_id(this_ptr: &mut RouteHintHop, mut val: u64) {
1020         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
1021 }
1022 /// The fees which must be paid to use this channel
1023 #[no_mangle]
1024 pub extern "C" fn RouteHintHop_get_fees(this_ptr: &RouteHintHop) -> crate::lightning::routing::gossip::RoutingFees {
1025         let mut inner_val = &mut this_ptr.get_native_mut_ref().fees;
1026         crate::lightning::routing::gossip::RoutingFees { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::RoutingFees<>) as *mut _) }, is_owned: false }
1027 }
1028 /// The fees which must be paid to use this channel
1029 #[no_mangle]
1030 pub extern "C" fn RouteHintHop_set_fees(this_ptr: &mut RouteHintHop, mut val: crate::lightning::routing::gossip::RoutingFees) {
1031         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fees = *unsafe { Box::from_raw(val.take_inner()) };
1032 }
1033 /// The difference in CLTV values between this node and the next node.
1034 #[no_mangle]
1035 pub extern "C" fn RouteHintHop_get_cltv_expiry_delta(this_ptr: &RouteHintHop) -> u16 {
1036         let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
1037         *inner_val
1038 }
1039 /// The difference in CLTV values between this node and the next node.
1040 #[no_mangle]
1041 pub extern "C" fn RouteHintHop_set_cltv_expiry_delta(this_ptr: &mut RouteHintHop, mut val: u16) {
1042         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
1043 }
1044 /// The minimum value, in msat, which must be relayed to the next hop.
1045 #[no_mangle]
1046 pub extern "C" fn RouteHintHop_get_htlc_minimum_msat(this_ptr: &RouteHintHop) -> crate::c_types::derived::COption_u64Z {
1047         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1048         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() }) };
1049         local_inner_val
1050 }
1051 /// The minimum value, in msat, which must be relayed to the next hop.
1052 #[no_mangle]
1053 pub extern "C" fn RouteHintHop_set_htlc_minimum_msat(this_ptr: &mut RouteHintHop, mut val: crate::c_types::derived::COption_u64Z) {
1054         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1055         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = local_val;
1056 }
1057 /// The maximum value in msat available for routing with a single HTLC.
1058 #[no_mangle]
1059 pub extern "C" fn RouteHintHop_get_htlc_maximum_msat(this_ptr: &RouteHintHop) -> crate::c_types::derived::COption_u64Z {
1060         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat;
1061         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() }) };
1062         local_inner_val
1063 }
1064 /// The maximum value in msat available for routing with a single HTLC.
1065 #[no_mangle]
1066 pub extern "C" fn RouteHintHop_set_htlc_maximum_msat(this_ptr: &mut RouteHintHop, mut val: crate::c_types::derived::COption_u64Z) {
1067         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1068         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = local_val;
1069 }
1070 /// Constructs a new RouteHintHop given each field
1071 #[must_use]
1072 #[no_mangle]
1073 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::gossip::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 {
1074         let mut local_htlc_minimum_msat_arg = if htlc_minimum_msat_arg.is_some() { Some( { htlc_minimum_msat_arg.take() }) } else { None };
1075         let mut local_htlc_maximum_msat_arg = if htlc_maximum_msat_arg.is_some() { Some( { htlc_maximum_msat_arg.take() }) } else { None };
1076         RouteHintHop { inner: ObjOps::heap_alloc(nativeRouteHintHop {
1077                 src_node_id: src_node_id_arg.into_rust(),
1078                 short_channel_id: short_channel_id_arg,
1079                 fees: *unsafe { Box::from_raw(fees_arg.take_inner()) },
1080                 cltv_expiry_delta: cltv_expiry_delta_arg,
1081                 htlc_minimum_msat: local_htlc_minimum_msat_arg,
1082                 htlc_maximum_msat: local_htlc_maximum_msat_arg,
1083         }), is_owned: true }
1084 }
1085 impl Clone for RouteHintHop {
1086         fn clone(&self) -> Self {
1087                 Self {
1088                         inner: if <*mut nativeRouteHintHop>::is_null(self.inner) { core::ptr::null_mut() } else {
1089                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1090                         is_owned: true,
1091                 }
1092         }
1093 }
1094 #[allow(unused)]
1095 /// Used only if an object of this type is returned as a trait impl by a method
1096 pub(crate) extern "C" fn RouteHintHop_clone_void(this_ptr: *const c_void) -> *mut c_void {
1097         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRouteHintHop)).clone() })) as *mut c_void
1098 }
1099 #[no_mangle]
1100 /// Creates a copy of the RouteHintHop
1101 pub extern "C" fn RouteHintHop_clone(orig: &RouteHintHop) -> RouteHintHop {
1102         orig.clone()
1103 }
1104 /// Checks if two RouteHintHops contain equal inner contents.
1105 #[no_mangle]
1106 pub extern "C" fn RouteHintHop_hash(o: &RouteHintHop) -> u64 {
1107         if o.inner.is_null() { return 0; }
1108         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1109         #[allow(deprecated)]
1110         let mut hasher = core::hash::SipHasher::new();
1111         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1112         core::hash::Hasher::finish(&hasher)
1113 }
1114 /// Checks if two RouteHintHops contain equal inner contents.
1115 /// This ignores pointers and is_owned flags and looks at the values in fields.
1116 /// Two objects with NULL inner values will be considered "equal" here.
1117 #[no_mangle]
1118 pub extern "C" fn RouteHintHop_eq(a: &RouteHintHop, b: &RouteHintHop) -> bool {
1119         if a.inner == b.inner { return true; }
1120         if a.inner.is_null() || b.inner.is_null() { return false; }
1121         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1122 }
1123 #[no_mangle]
1124 /// Serialize the RouteHintHop object into a byte array which can be read by RouteHintHop_read
1125 pub extern "C" fn RouteHintHop_write(obj: &crate::lightning::routing::router::RouteHintHop) -> crate::c_types::derived::CVec_u8Z {
1126         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1127 }
1128 #[no_mangle]
1129 pub(crate) extern "C" fn RouteHintHop_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1130         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRouteHintHop) })
1131 }
1132 #[no_mangle]
1133 /// Read a RouteHintHop from a byte array, created by RouteHintHop_write
1134 pub extern "C" fn RouteHintHop_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RouteHintHopDecodeErrorZ {
1135         let res: Result<lightning::routing::router::RouteHintHop, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
1136         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::RouteHintHop { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
1137         local_res
1138 }
1139 /// Finds a route from us (payer) to the given target node (payee).
1140 ///
1141 /// If the payee provided features in their invoice, they should be provided via `params.payee`.
1142 /// Without this, MPP will only be used if the payee's features are available in the network graph.
1143 ///
1144 /// Private routing paths between a public node and the target may be included in `params.payee`.
1145 ///
1146 /// If some channels aren't announced, it may be useful to fill in `first_hops` with the results
1147 /// from [`ChannelManager::list_usable_channels`]. If it is filled in, the view of these channels
1148 /// from `network_graph` will be ignored, and only those in `first_hops` will be used.
1149 ///
1150 /// The fees on channels from us to the next hop are ignored as they are assumed to all be equal.
1151 /// However, the enabled/disabled bit on such channels as well as the `htlc_minimum_msat` /
1152 /// `htlc_maximum_msat` *are* checked as they may change based on the receiving node.
1153 ///
1154 /// # Note
1155 ///
1156 /// May be used to re-compute a [`Route`] when handling a [`Event::PaymentPathFailed`]. Any
1157 /// adjustments to the [`NetworkGraph`] and channel scores should be made prior to calling this
1158 /// function.
1159 ///
1160 /// # Panics
1161 ///
1162 /// Panics if first_hops contains channels without short_channel_ids;
1163 /// [`ChannelManager::list_usable_channels`] will never include such channels.
1164 ///
1165 /// [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels
1166 /// [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed
1167 /// [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
1168 ///
1169 /// Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None
1170 #[no_mangle]
1171 pub extern "C" fn find_route(mut our_node_pubkey: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, network_graph: &crate::lightning::routing::gossip::NetworkGraph, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, mut logger: crate::lightning::util::logger::Logger, scorer: &crate::lightning::routing::scoring::Score, random_seed_bytes: *const [u8; 32]) -> crate::c_types::derived::CResult_RouteLightningErrorZ {
1172         let mut local_first_hops_base = if first_hops == core::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( { item.get_native_ref() }); }; local_first_hops_0 }) }; let mut local_first_hops = local_first_hops_base.as_ref().map(|a| &a[..]);
1173         let mut ret = lightning::routing::router::find_route::<crate::lightning::util::logger::Logger, crate::lightning::util::logger::Logger, crate::lightning::routing::scoring::Score>(&our_node_pubkey.into_rust(), route_params.get_native_ref(), network_graph.get_native_ref(), local_first_hops, logger, scorer, unsafe { &*random_seed_bytes});
1174         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::Route { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
1175         local_ret
1176 }
1177
1178 /// Construct a route from us (payer) to the target node (payee) via the given hops (which should
1179 /// exclude the payer, but include the payee). This may be useful, e.g., for probing the chosen path.
1180 ///
1181 /// Re-uses logic from `find_route`, so the restrictions described there also apply here.
1182 #[no_mangle]
1183 pub extern "C" fn build_route_from_hops(mut our_node_pubkey: crate::c_types::PublicKey, mut hops: crate::c_types::derived::CVec_PublicKeyZ, route_params: &crate::lightning::routing::router::RouteParameters, network_graph: &crate::lightning::routing::gossip::NetworkGraph, mut logger: crate::lightning::util::logger::Logger, random_seed_bytes: *const [u8; 32]) -> crate::c_types::derived::CResult_RouteLightningErrorZ {
1184         let mut local_hops = Vec::new(); for mut item in hops.into_rust().drain(..) { local_hops.push( { item.into_rust() }); };
1185         let mut ret = lightning::routing::router::build_route_from_hops::<crate::lightning::util::logger::Logger, crate::lightning::util::logger::Logger>(&our_node_pubkey.into_rust(), &local_hops[..], route_params.get_native_ref(), network_graph.get_native_ref(), logger, unsafe { &*random_seed_bytes});
1186         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::Route { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
1187         local_ret
1188 }
1189