Update CI/Cargo.toml references to 0.0.122
[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 router finds paths within a [`NetworkGraph`] for a payment.
10
11 use alloc::str::FromStr;
12 use alloc::string::String;
13 use core::ffi::c_void;
14 use core::convert::Infallible;
15 use bitcoin::hashes::Hash;
16 use crate::c_types::*;
17 #[cfg(feature="no-std")]
18 use alloc::{vec::Vec, boxed::Box};
19
20
21 use lightning::routing::router::DefaultRouter as nativeDefaultRouterImport;
22 pub(crate) type nativeDefaultRouter = nativeDefaultRouterImport<&'static lightning::routing::gossip::NetworkGraph<crate::lightning::util::logger::Logger>, crate::lightning::util::logger::Logger, crate::lightning::sign::EntropySource, crate::lightning::routing::scoring::LockableScore>;
23
24 /// A [`Router`] implemented using [`find_route`].
25 #[must_use]
26 #[repr(C)]
27 pub struct DefaultRouter {
28         /// A pointer to the opaque Rust object.
29
30         /// Nearly everywhere, inner must be non-null, however in places where
31         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
32         pub inner: *mut nativeDefaultRouter,
33         /// Indicates that this is the only struct which contains the same pointer.
34
35         /// Rust functions which take ownership of an object provided via an argument require
36         /// this to be true and invalidate the object pointed to by inner.
37         pub is_owned: bool,
38 }
39
40 impl Drop for DefaultRouter {
41         fn drop(&mut self) {
42                 if self.is_owned && !<*mut nativeDefaultRouter>::is_null(self.inner) {
43                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
44                 }
45         }
46 }
47 /// Frees any resources used by the DefaultRouter, if is_owned is set and inner is non-NULL.
48 #[no_mangle]
49 pub extern "C" fn DefaultRouter_free(this_obj: DefaultRouter) { }
50 #[allow(unused)]
51 /// Used only if an object of this type is returned as a trait impl by a method
52 pub(crate) extern "C" fn DefaultRouter_free_void(this_ptr: *mut c_void) {
53         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeDefaultRouter) };
54 }
55 #[allow(unused)]
56 impl DefaultRouter {
57         pub(crate) fn get_native_ref(&self) -> &'static nativeDefaultRouter {
58                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
59         }
60         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeDefaultRouter {
61                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
62         }
63         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
64         pub(crate) fn take_inner(mut self) -> *mut nativeDefaultRouter {
65                 assert!(self.is_owned);
66                 let ret = ObjOps::untweak_ptr(self.inner);
67                 self.inner = core::ptr::null_mut();
68                 ret
69         }
70 }
71 /// Creates a new router.
72 #[must_use]
73 #[no_mangle]
74 pub extern "C" fn DefaultRouter_new(network_graph: &crate::lightning::routing::gossip::NetworkGraph, mut logger: crate::lightning::util::logger::Logger, mut entropy_source: crate::lightning::sign::EntropySource, mut scorer: crate::lightning::routing::scoring::LockableScore, mut score_params: crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters) -> crate::lightning::routing::router::DefaultRouter {
75         let mut ret = lightning::routing::router::DefaultRouter::new(network_graph.get_native_ref(), logger, entropy_source, scorer, *unsafe { Box::from_raw(score_params.take_inner()) });
76         crate::lightning::routing::router::DefaultRouter { inner: ObjOps::heap_alloc(ret), is_owned: true }
77 }
78
79 impl From<nativeDefaultRouter> for crate::lightning::routing::router::Router {
80         fn from(obj: nativeDefaultRouter) -> Self {
81                 let rust_obj = crate::lightning::routing::router::DefaultRouter { inner: ObjOps::heap_alloc(obj), is_owned: true };
82                 let mut ret = DefaultRouter_as_Router(&rust_obj);
83                 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn
84                 core::mem::forget(rust_obj);
85                 ret.free = Some(DefaultRouter_free_void);
86                 ret
87         }
88 }
89 /// Constructs a new Router which calls the relevant methods on this_arg.
90 /// This copies the `inner` pointer in this_arg and thus the returned Router must be freed before this_arg is
91 #[no_mangle]
92 pub extern "C" fn DefaultRouter_as_Router(this_arg: &DefaultRouter) -> crate::lightning::routing::router::Router {
93         crate::lightning::routing::router::Router {
94                 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
95                 free: None,
96                 find_route: DefaultRouter_Router_find_route,
97                 find_route_with_id: DefaultRouter_Router_find_route_with_id,
98                 create_blinded_payment_paths: DefaultRouter_Router_create_blinded_payment_paths,
99                 MessageRouter: crate::lightning::onion_message::messenger::MessageRouter {
100                         this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
101                         free: None,
102                         find_path: DefaultRouter_MessageRouter_find_path,
103                         create_blinded_paths: DefaultRouter_MessageRouter_create_blinded_paths,
104                 },
105         }
106 }
107
108 #[must_use]
109 extern "C" fn DefaultRouter_Router_find_route(this_arg: *const c_void, mut payer: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, mut inflight_htlcs: crate::lightning::routing::router::InFlightHtlcs) -> crate::c_types::derived::CResult_RouteLightningErrorZ {
110         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[..]);
111         let mut ret = <nativeDefaultRouter as lightning::routing::router::Router<>>::find_route(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, &payer.into_rust(), route_params.get_native_ref(), local_first_hops, *unsafe { Box::from_raw(inflight_htlcs.take_inner()) });
112         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() };
113         local_ret
114 }
115 #[must_use]
116 extern "C" fn DefaultRouter_Router_find_route_with_id(this_arg: *const c_void, mut payer: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, mut inflight_htlcs: crate::lightning::routing::router::InFlightHtlcs, mut _payment_hash: crate::c_types::ThirtyTwoBytes, mut _payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_RouteLightningErrorZ {
117         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[..]);
118         let mut ret = <nativeDefaultRouter as lightning::routing::router::Router<>>::find_route_with_id(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, &payer.into_rust(), route_params.get_native_ref(), local_first_hops, *unsafe { Box::from_raw(inflight_htlcs.take_inner()) }, ::lightning::ln::PaymentHash(_payment_hash.data), ::lightning::ln::channelmanager::PaymentId(_payment_id.data));
119         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() };
120         local_ret
121 }
122 #[must_use]
123 extern "C" fn DefaultRouter_Router_create_blinded_payment_paths(this_arg: *const c_void, mut recipient: crate::c_types::PublicKey, mut first_hops: crate::c_types::derived::CVec_ChannelDetailsZ, mut tlvs: crate::lightning::blinded_path::payment::ReceiveTlvs, mut amount_msats: u64) -> crate::c_types::derived::CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ {
124         let mut local_first_hops = Vec::new(); for mut item in first_hops.into_rust().drain(..) { local_first_hops.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
125         let mut ret = <nativeDefaultRouter as lightning::routing::router::Router<>>::create_blinded_payment_paths(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, recipient.into_rust(), local_first_hops, *unsafe { Box::from_raw(tlvs.take_inner()) }, amount_msats, secp256k1::global::SECP256K1);
126         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { let (mut orig_ret_0_0_0, mut orig_ret_0_0_1) = item; let mut local_ret_0_0 = (crate::lightning::offers::invoice::BlindedPayInfo { inner: ObjOps::heap_alloc(orig_ret_0_0_0), is_owned: true }, crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(orig_ret_0_0_1), is_owned: true }).into(); local_ret_0_0 }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
127         local_ret
128 }
129
130 impl From<nativeDefaultRouter> for crate::lightning::onion_message::messenger::MessageRouter {
131         fn from(obj: nativeDefaultRouter) -> Self {
132                 let rust_obj = crate::lightning::routing::router::DefaultRouter { inner: ObjOps::heap_alloc(obj), is_owned: true };
133                 let mut ret = DefaultRouter_as_MessageRouter(&rust_obj);
134                 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn
135                 core::mem::forget(rust_obj);
136                 ret.free = Some(DefaultRouter_free_void);
137                 ret
138         }
139 }
140 /// Constructs a new MessageRouter which calls the relevant methods on this_arg.
141 /// This copies the `inner` pointer in this_arg and thus the returned MessageRouter must be freed before this_arg is
142 #[no_mangle]
143 pub extern "C" fn DefaultRouter_as_MessageRouter(this_arg: &DefaultRouter) -> crate::lightning::onion_message::messenger::MessageRouter {
144         crate::lightning::onion_message::messenger::MessageRouter {
145                 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
146                 free: None,
147                 find_path: DefaultRouter_MessageRouter_find_path,
148                 create_blinded_paths: DefaultRouter_MessageRouter_create_blinded_paths,
149         }
150 }
151
152 #[must_use]
153 extern "C" fn DefaultRouter_MessageRouter_find_path(this_arg: *const c_void, mut sender: crate::c_types::PublicKey, mut peers: crate::c_types::derived::CVec_PublicKeyZ, mut destination: crate::lightning::onion_message::messenger::Destination) -> crate::c_types::derived::CResult_OnionMessagePathNoneZ {
154         let mut local_peers = Vec::new(); for mut item in peers.into_rust().drain(..) { local_peers.push( { item.into_rust() }); };
155         let mut ret = <nativeDefaultRouter as lightning::onion_message::messenger::MessageRouter<>>::find_path(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, sender.into_rust(), local_peers, destination.into_native());
156         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::onion_message::messenger::OnionMessagePath { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
157         local_ret
158 }
159 #[must_use]
160 extern "C" fn DefaultRouter_MessageRouter_create_blinded_paths(this_arg: *const c_void, mut recipient: crate::c_types::PublicKey, mut peers: crate::c_types::derived::CVec_PublicKeyZ) -> crate::c_types::derived::CResult_CVec_BlindedPathZNoneZ {
161         let mut local_peers = Vec::new(); for mut item in peers.into_rust().drain(..) { local_peers.push( { item.into_rust() }); };
162         let mut ret = <nativeDefaultRouter as lightning::onion_message::messenger::MessageRouter<>>::create_blinded_paths(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, recipient.into_rust(), local_peers, secp256k1::global::SECP256K1);
163         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
164         local_ret
165 }
166
167 /// A trait defining behavior for routing a payment.
168 #[repr(C)]
169 pub struct Router {
170         /// An opaque pointer which is passed to your function implementations as an argument.
171         /// This has no meaning in the LDK, and can be NULL or any other value.
172         pub this_arg: *mut c_void,
173         /// Finds a [`Route`] for a payment between the given `payer` and a payee.
174         ///
175         /// The `payee` and the payment's value are given in [`RouteParameters::payment_params`]
176         /// and [`RouteParameters::final_value_msat`], respectively.
177         ///
178         /// Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None
179         pub find_route: extern "C" fn (this_arg: *const c_void, payer: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, inflight_htlcs: crate::lightning::routing::router::InFlightHtlcs) -> crate::c_types::derived::CResult_RouteLightningErrorZ,
180         /// Finds a [`Route`] for a payment between the given `payer` and a payee.
181         ///
182         /// The `payee` and the payment's value are given in [`RouteParameters::payment_params`]
183         /// and [`RouteParameters::final_value_msat`], respectively.
184         ///
185         /// Includes a [`PaymentHash`] and a [`PaymentId`] to be able to correlate the request with a specific
186         /// payment.
187         ///
188         /// Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None
189         pub find_route_with_id: extern "C" fn (this_arg: *const c_void, payer: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, inflight_htlcs: crate::lightning::routing::router::InFlightHtlcs, _payment_hash: crate::c_types::ThirtyTwoBytes, _payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_RouteLightningErrorZ,
190         /// Creates [`BlindedPath`]s for payment to the `recipient` node. The channels in `first_hops`
191         /// are assumed to be with the `recipient`'s peers. The payment secret and any constraints are
192         /// given in `tlvs`.
193         pub create_blinded_payment_paths: extern "C" fn (this_arg: *const c_void, recipient: crate::c_types::PublicKey, first_hops: crate::c_types::derived::CVec_ChannelDetailsZ, tlvs: crate::lightning::blinded_path::payment::ReceiveTlvs, amount_msats: u64) -> crate::c_types::derived::CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ,
194         /// Implementation of MessageRouter for this object.
195         pub MessageRouter: crate::lightning::onion_message::messenger::MessageRouter,
196         /// Frees any resources associated with this object given its this_arg pointer.
197         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
198         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
199 }
200 unsafe impl Send for Router {}
201 unsafe impl Sync for Router {}
202 #[allow(unused)]
203 pub(crate) fn Router_clone_fields(orig: &Router) -> Router {
204         Router {
205                 this_arg: orig.this_arg,
206                 find_route: Clone::clone(&orig.find_route),
207                 find_route_with_id: Clone::clone(&orig.find_route_with_id),
208                 create_blinded_payment_paths: Clone::clone(&orig.create_blinded_payment_paths),
209                 MessageRouter: crate::lightning::onion_message::messenger::MessageRouter_clone_fields(&orig.MessageRouter),
210                 free: Clone::clone(&orig.free),
211         }
212 }
213 impl lightning::onion_message::messenger::MessageRouter for Router {
214         fn find_path(&self, mut sender: bitcoin::secp256k1::PublicKey, mut peers: Vec<bitcoin::secp256k1::PublicKey>, mut destination: lightning::onion_message::messenger::Destination) -> Result<lightning::onion_message::messenger::OnionMessagePath, ()> {
215                 let mut local_peers = Vec::new(); for mut item in peers.drain(..) { local_peers.push( { crate::c_types::PublicKey::from_rust(&item) }); };
216                 let mut ret = (self.MessageRouter.find_path)(self.MessageRouter.this_arg, crate::c_types::PublicKey::from_rust(&sender), local_peers.into(), crate::lightning::onion_message::messenger::Destination::native_into(destination));
217                 let mut local_ret = match ret.result_ok { true => Ok( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).take_inner()) } }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
218                 local_ret
219         }
220         fn create_blinded_paths<T:bitcoin::secp256k1::Signing + bitcoin::secp256k1::Verification>(&self, mut recipient: bitcoin::secp256k1::PublicKey, mut peers: Vec<bitcoin::secp256k1::PublicKey>, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> Result<Vec<lightning::blinded_path::BlindedPath>, ()> {
221                 let mut local_peers = Vec::new(); for mut item in peers.drain(..) { local_peers.push( { crate::c_types::PublicKey::from_rust(&item) }); };
222                 let mut ret = (self.MessageRouter.create_blinded_paths)(self.MessageRouter.this_arg, crate::c_types::PublicKey::from_rust(&recipient), local_peers.into());
223                 let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = Vec::new(); for mut item in (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust().drain(..) { local_ret_0.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
224                 local_ret
225         }
226 }
227
228 use lightning::routing::router::Router as rustRouter;
229 impl rustRouter for Router {
230         fn find_route(&self, mut payer: &bitcoin::secp256k1::PublicKey, mut route_params: &lightning::routing::router::RouteParameters, mut first_hops: Option<&[&lightning::ln::channelmanager::ChannelDetails]>, mut inflight_htlcs: lightning::routing::router::InFlightHtlcs) -> Result<lightning::routing::router::Route, lightning::ln::msgs::LightningError> {
231                 let mut local_first_hops_base = if first_hops.is_none() { SmartPtr::null() } else { SmartPtr::from_obj( { let mut local_first_hops_0 = Vec::new(); for item in (first_hops.unwrap()).iter() { local_first_hops_0.push( { crate::lightning::ln::channelmanager::ChannelDetails { inner: unsafe { ObjOps::nonnull_ptr_to_inner(((*item) as *const lightning::ln::channelmanager::ChannelDetails<>) as *mut _) }, is_owned: false } }); }; local_first_hops_0.into() }) }; let mut local_first_hops = *local_first_hops_base;
232                 let mut ret = (self.find_route)(self.this_arg, crate::c_types::PublicKey::from_rust(&payer), &crate::lightning::routing::router::RouteParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((route_params as *const lightning::routing::router::RouteParameters<>) as *mut _) }, is_owned: false }, local_first_hops, crate::lightning::routing::router::InFlightHtlcs { inner: ObjOps::heap_alloc(inflight_htlcs), is_owned: true });
233                 let mut local_ret = match ret.result_ok { true => Ok( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).take_inner()) } }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
234                 local_ret
235         }
236         fn find_route_with_id(&self, mut payer: &bitcoin::secp256k1::PublicKey, mut route_params: &lightning::routing::router::RouteParameters, mut first_hops: Option<&[&lightning::ln::channelmanager::ChannelDetails]>, mut inflight_htlcs: lightning::routing::router::InFlightHtlcs, mut _payment_hash: lightning::ln::PaymentHash, mut _payment_id: lightning::ln::channelmanager::PaymentId) -> Result<lightning::routing::router::Route, lightning::ln::msgs::LightningError> {
237                 let mut local_first_hops_base = if first_hops.is_none() { SmartPtr::null() } else { SmartPtr::from_obj( { let mut local_first_hops_0 = Vec::new(); for item in (first_hops.unwrap()).iter() { local_first_hops_0.push( { crate::lightning::ln::channelmanager::ChannelDetails { inner: unsafe { ObjOps::nonnull_ptr_to_inner(((*item) as *const lightning::ln::channelmanager::ChannelDetails<>) as *mut _) }, is_owned: false } }); }; local_first_hops_0.into() }) }; let mut local_first_hops = *local_first_hops_base;
238                 let mut ret = (self.find_route_with_id)(self.this_arg, crate::c_types::PublicKey::from_rust(&payer), &crate::lightning::routing::router::RouteParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((route_params as *const lightning::routing::router::RouteParameters<>) as *mut _) }, is_owned: false }, local_first_hops, crate::lightning::routing::router::InFlightHtlcs { inner: ObjOps::heap_alloc(inflight_htlcs), is_owned: true }, crate::c_types::ThirtyTwoBytes { data: _payment_hash.0 }, crate::c_types::ThirtyTwoBytes { data: _payment_id.0 });
239                 let mut local_ret = match ret.result_ok { true => Ok( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).take_inner()) } }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
240                 local_ret
241         }
242         fn create_blinded_payment_paths<T:bitcoin::secp256k1::Signing + bitcoin::secp256k1::Verification>(&self, mut recipient: bitcoin::secp256k1::PublicKey, mut first_hops: Vec<lightning::ln::channelmanager::ChannelDetails>, mut tlvs: lightning::blinded_path::payment::ReceiveTlvs, mut amount_msats: u64, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> Result<Vec<(lightning::offers::invoice::BlindedPayInfo, lightning::blinded_path::BlindedPath)>, ()> {
243                 let mut local_first_hops = Vec::new(); for mut item in first_hops.drain(..) { local_first_hops.push( { crate::lightning::ln::channelmanager::ChannelDetails { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
244                 let mut ret = (self.create_blinded_payment_paths)(self.this_arg, crate::c_types::PublicKey::from_rust(&recipient), local_first_hops.into(), crate::lightning::blinded_path::payment::ReceiveTlvs { inner: ObjOps::heap_alloc(tlvs), is_owned: true }, amount_msats);
245                 let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = Vec::new(); for mut item in (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust().drain(..) { local_ret_0.push( { let (mut orig_ret_0_0_0, mut orig_ret_0_0_1) = item.to_rust(); let mut local_ret_0_0 = (*unsafe { Box::from_raw(orig_ret_0_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_ret_0_0_1.take_inner()) }); local_ret_0_0 }); }; local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
246                 local_ret
247         }
248 }
249
250 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
251 // directly as a Deref trait in higher-level structs:
252 impl core::ops::Deref for Router {
253         type Target = Self;
254         fn deref(&self) -> &Self {
255                 self
256         }
257 }
258 impl core::ops::DerefMut for Router {
259         fn deref_mut(&mut self) -> &mut Self {
260                 self
261         }
262 }
263 /// Calls the free function if one is set
264 #[no_mangle]
265 pub extern "C" fn Router_free(this_ptr: Router) { }
266 impl Drop for Router {
267         fn drop(&mut self) {
268                 if let Some(f) = self.free {
269                         f(self.this_arg);
270                 }
271         }
272 }
273
274 use lightning::routing::router::ScorerAccountingForInFlightHtlcs as nativeScorerAccountingForInFlightHtlcsImport;
275 pub(crate) type nativeScorerAccountingForInFlightHtlcs = nativeScorerAccountingForInFlightHtlcsImport<'static, crate::lightning::routing::scoring::ScoreLookUp>;
276
277 /// [`ScoreLookUp`] implementation that factors in in-flight HTLC liquidity.
278 ///
279 /// Useful for custom [`Router`] implementations to wrap their [`ScoreLookUp`] on-the-fly when calling
280 /// [`find_route`].
281 ///
282 /// [`ScoreLookUp`]: crate::routing::scoring::ScoreLookUp
283 #[must_use]
284 #[repr(C)]
285 pub struct ScorerAccountingForInFlightHtlcs {
286         /// A pointer to the opaque Rust object.
287
288         /// Nearly everywhere, inner must be non-null, however in places where
289         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
290         pub inner: *mut nativeScorerAccountingForInFlightHtlcs,
291         /// Indicates that this is the only struct which contains the same pointer.
292
293         /// Rust functions which take ownership of an object provided via an argument require
294         /// this to be true and invalidate the object pointed to by inner.
295         pub is_owned: bool,
296 }
297
298 impl Drop for ScorerAccountingForInFlightHtlcs {
299         fn drop(&mut self) {
300                 if self.is_owned && !<*mut nativeScorerAccountingForInFlightHtlcs>::is_null(self.inner) {
301                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
302                 }
303         }
304 }
305 /// Frees any resources used by the ScorerAccountingForInFlightHtlcs, if is_owned is set and inner is non-NULL.
306 #[no_mangle]
307 pub extern "C" fn ScorerAccountingForInFlightHtlcs_free(this_obj: ScorerAccountingForInFlightHtlcs) { }
308 #[allow(unused)]
309 /// Used only if an object of this type is returned as a trait impl by a method
310 pub(crate) extern "C" fn ScorerAccountingForInFlightHtlcs_free_void(this_ptr: *mut c_void) {
311         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeScorerAccountingForInFlightHtlcs) };
312 }
313 #[allow(unused)]
314 impl ScorerAccountingForInFlightHtlcs {
315         pub(crate) fn get_native_ref(&self) -> &'static nativeScorerAccountingForInFlightHtlcs {
316                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
317         }
318         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeScorerAccountingForInFlightHtlcs {
319                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
320         }
321         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
322         pub(crate) fn take_inner(mut self) -> *mut nativeScorerAccountingForInFlightHtlcs {
323                 assert!(self.is_owned);
324                 let ret = ObjOps::untweak_ptr(self.inner);
325                 self.inner = core::ptr::null_mut();
326                 ret
327         }
328 }
329 /// Initialize a new `ScorerAccountingForInFlightHtlcs`.
330 #[must_use]
331 #[no_mangle]
332 pub extern "C" fn ScorerAccountingForInFlightHtlcs_new(mut scorer: crate::lightning::routing::scoring::ScoreLookUp, inflight_htlcs: &crate::lightning::routing::router::InFlightHtlcs) -> crate::lightning::routing::router::ScorerAccountingForInFlightHtlcs {
333         let mut ret = lightning::routing::router::ScorerAccountingForInFlightHtlcs::new(scorer, inflight_htlcs.get_native_ref());
334         crate::lightning::routing::router::ScorerAccountingForInFlightHtlcs { inner: ObjOps::heap_alloc(ret), is_owned: true }
335 }
336
337 impl From<nativeScorerAccountingForInFlightHtlcs> for crate::lightning::routing::scoring::ScoreLookUp {
338         fn from(obj: nativeScorerAccountingForInFlightHtlcs) -> Self {
339                 let rust_obj = crate::lightning::routing::router::ScorerAccountingForInFlightHtlcs { inner: ObjOps::heap_alloc(obj), is_owned: true };
340                 let mut ret = ScorerAccountingForInFlightHtlcs_as_ScoreLookUp(&rust_obj);
341                 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn
342                 core::mem::forget(rust_obj);
343                 ret.free = Some(ScorerAccountingForInFlightHtlcs_free_void);
344                 ret
345         }
346 }
347 /// Constructs a new ScoreLookUp which calls the relevant methods on this_arg.
348 /// This copies the `inner` pointer in this_arg and thus the returned ScoreLookUp must be freed before this_arg is
349 #[no_mangle]
350 pub extern "C" fn ScorerAccountingForInFlightHtlcs_as_ScoreLookUp(this_arg: &ScorerAccountingForInFlightHtlcs) -> crate::lightning::routing::scoring::ScoreLookUp {
351         crate::lightning::routing::scoring::ScoreLookUp {
352                 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
353                 free: None,
354                 channel_penalty_msat: ScorerAccountingForInFlightHtlcs_ScoreLookUp_channel_penalty_msat,
355         }
356 }
357
358 #[must_use]
359 extern "C" fn ScorerAccountingForInFlightHtlcs_ScoreLookUp_channel_penalty_msat(this_arg: *const c_void, candidate: &crate::lightning::routing::router::CandidateRouteHop, mut usage: crate::lightning::routing::scoring::ChannelUsage, score_params: &crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters) -> u64 {
360         let mut ret = <nativeScorerAccountingForInFlightHtlcs as lightning::routing::scoring::ScoreLookUp<>>::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeScorerAccountingForInFlightHtlcs) }, &candidate.to_native(), *unsafe { Box::from_raw(usage.take_inner()) }, score_params.get_native_ref());
361         ret
362 }
363
364
365 use lightning::routing::router::InFlightHtlcs as nativeInFlightHtlcsImport;
366 pub(crate) type nativeInFlightHtlcs = nativeInFlightHtlcsImport;
367
368 /// A data structure for tracking in-flight HTLCs. May be used during pathfinding to account for
369 /// in-use channel liquidity.
370 #[must_use]
371 #[repr(C)]
372 pub struct InFlightHtlcs {
373         /// A pointer to the opaque Rust object.
374
375         /// Nearly everywhere, inner must be non-null, however in places where
376         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
377         pub inner: *mut nativeInFlightHtlcs,
378         /// Indicates that this is the only struct which contains the same pointer.
379
380         /// Rust functions which take ownership of an object provided via an argument require
381         /// this to be true and invalidate the object pointed to by inner.
382         pub is_owned: bool,
383 }
384
385 impl Drop for InFlightHtlcs {
386         fn drop(&mut self) {
387                 if self.is_owned && !<*mut nativeInFlightHtlcs>::is_null(self.inner) {
388                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
389                 }
390         }
391 }
392 /// Frees any resources used by the InFlightHtlcs, if is_owned is set and inner is non-NULL.
393 #[no_mangle]
394 pub extern "C" fn InFlightHtlcs_free(this_obj: InFlightHtlcs) { }
395 #[allow(unused)]
396 /// Used only if an object of this type is returned as a trait impl by a method
397 pub(crate) extern "C" fn InFlightHtlcs_free_void(this_ptr: *mut c_void) {
398         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInFlightHtlcs) };
399 }
400 #[allow(unused)]
401 impl InFlightHtlcs {
402         pub(crate) fn get_native_ref(&self) -> &'static nativeInFlightHtlcs {
403                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
404         }
405         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInFlightHtlcs {
406                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
407         }
408         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
409         pub(crate) fn take_inner(mut self) -> *mut nativeInFlightHtlcs {
410                 assert!(self.is_owned);
411                 let ret = ObjOps::untweak_ptr(self.inner);
412                 self.inner = core::ptr::null_mut();
413                 ret
414         }
415 }
416 impl Clone for InFlightHtlcs {
417         fn clone(&self) -> Self {
418                 Self {
419                         inner: if <*mut nativeInFlightHtlcs>::is_null(self.inner) { core::ptr::null_mut() } else {
420                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
421                         is_owned: true,
422                 }
423         }
424 }
425 #[allow(unused)]
426 /// Used only if an object of this type is returned as a trait impl by a method
427 pub(crate) extern "C" fn InFlightHtlcs_clone_void(this_ptr: *const c_void) -> *mut c_void {
428         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeInFlightHtlcs)).clone() })) as *mut c_void
429 }
430 #[no_mangle]
431 /// Creates a copy of the InFlightHtlcs
432 pub extern "C" fn InFlightHtlcs_clone(orig: &InFlightHtlcs) -> InFlightHtlcs {
433         orig.clone()
434 }
435 /// Constructs an empty `InFlightHtlcs`.
436 #[must_use]
437 #[no_mangle]
438 pub extern "C" fn InFlightHtlcs_new() -> crate::lightning::routing::router::InFlightHtlcs {
439         let mut ret = lightning::routing::router::InFlightHtlcs::new();
440         crate::lightning::routing::router::InFlightHtlcs { inner: ObjOps::heap_alloc(ret), is_owned: true }
441 }
442
443 /// Takes in a path with payer's node id and adds the path's details to `InFlightHtlcs`.
444 #[no_mangle]
445 pub extern "C" fn InFlightHtlcs_process_path(this_arg: &mut crate::lightning::routing::router::InFlightHtlcs, path: &crate::lightning::routing::router::Path, mut payer_node_id: crate::c_types::PublicKey) {
446         unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::router::nativeInFlightHtlcs)) }.process_path(path.get_native_ref(), payer_node_id.into_rust())
447 }
448
449 /// Adds a known HTLC given the public key of the HTLC source, target, and short channel
450 /// id.
451 #[no_mangle]
452 pub extern "C" fn InFlightHtlcs_add_inflight_htlc(this_arg: &mut crate::lightning::routing::router::InFlightHtlcs, source: &crate::lightning::routing::gossip::NodeId, target: &crate::lightning::routing::gossip::NodeId, mut channel_scid: u64, mut used_msat: u64) {
453         unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::router::nativeInFlightHtlcs)) }.add_inflight_htlc(source.get_native_ref(), target.get_native_ref(), channel_scid, used_msat)
454 }
455
456 /// Returns liquidity in msat given the public key of the HTLC source, target, and short channel
457 /// id.
458 #[must_use]
459 #[no_mangle]
460 pub extern "C" fn InFlightHtlcs_used_liquidity_msat(this_arg: &crate::lightning::routing::router::InFlightHtlcs, source: &crate::lightning::routing::gossip::NodeId, target: &crate::lightning::routing::gossip::NodeId, mut channel_scid: u64) -> crate::c_types::derived::COption_u64Z {
461         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.used_liquidity_msat(source.get_native_ref(), target.get_native_ref(), channel_scid);
462         let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap() }) };
463         local_ret
464 }
465
466 #[no_mangle]
467 /// Serialize the InFlightHtlcs object into a byte array which can be read by InFlightHtlcs_read
468 pub extern "C" fn InFlightHtlcs_write(obj: &crate::lightning::routing::router::InFlightHtlcs) -> crate::c_types::derived::CVec_u8Z {
469         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
470 }
471 #[allow(unused)]
472 pub(crate) extern "C" fn InFlightHtlcs_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
473         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInFlightHtlcs) })
474 }
475 #[no_mangle]
476 /// Read a InFlightHtlcs from a byte array, created by InFlightHtlcs_write
477 pub extern "C" fn InFlightHtlcs_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InFlightHtlcsDecodeErrorZ {
478         let res: Result<lightning::routing::router::InFlightHtlcs, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
479         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::InFlightHtlcs { 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() };
480         local_res
481 }
482
483 use lightning::routing::router::RouteHop as nativeRouteHopImport;
484 pub(crate) type nativeRouteHop = nativeRouteHopImport;
485
486 /// A hop in a route, and additional metadata about it. \"Hop\" is defined as a node and the channel
487 /// that leads to it.
488 #[must_use]
489 #[repr(C)]
490 pub struct RouteHop {
491         /// A pointer to the opaque Rust object.
492
493         /// Nearly everywhere, inner must be non-null, however in places where
494         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
495         pub inner: *mut nativeRouteHop,
496         /// Indicates that this is the only struct which contains the same pointer.
497
498         /// Rust functions which take ownership of an object provided via an argument require
499         /// this to be true and invalidate the object pointed to by inner.
500         pub is_owned: bool,
501 }
502
503 impl Drop for RouteHop {
504         fn drop(&mut self) {
505                 if self.is_owned && !<*mut nativeRouteHop>::is_null(self.inner) {
506                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
507                 }
508         }
509 }
510 /// Frees any resources used by the RouteHop, if is_owned is set and inner is non-NULL.
511 #[no_mangle]
512 pub extern "C" fn RouteHop_free(this_obj: RouteHop) { }
513 #[allow(unused)]
514 /// Used only if an object of this type is returned as a trait impl by a method
515 pub(crate) extern "C" fn RouteHop_free_void(this_ptr: *mut c_void) {
516         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRouteHop) };
517 }
518 #[allow(unused)]
519 impl RouteHop {
520         pub(crate) fn get_native_ref(&self) -> &'static nativeRouteHop {
521                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
522         }
523         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRouteHop {
524                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
525         }
526         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
527         pub(crate) fn take_inner(mut self) -> *mut nativeRouteHop {
528                 assert!(self.is_owned);
529                 let ret = ObjOps::untweak_ptr(self.inner);
530                 self.inner = core::ptr::null_mut();
531                 ret
532         }
533 }
534 /// The node_id of the node at this hop.
535 #[no_mangle]
536 pub extern "C" fn RouteHop_get_pubkey(this_ptr: &RouteHop) -> crate::c_types::PublicKey {
537         let mut inner_val = &mut this_ptr.get_native_mut_ref().pubkey;
538         crate::c_types::PublicKey::from_rust(&inner_val)
539 }
540 /// The node_id of the node at this hop.
541 #[no_mangle]
542 pub extern "C" fn RouteHop_set_pubkey(this_ptr: &mut RouteHop, mut val: crate::c_types::PublicKey) {
543         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.pubkey = val.into_rust();
544 }
545 /// The node_announcement features of the node at this hop. For the last hop, these may be
546 /// amended to match the features present in the invoice this node generated.
547 #[no_mangle]
548 pub extern "C" fn RouteHop_get_node_features(this_ptr: &RouteHop) -> crate::lightning::ln::features::NodeFeatures {
549         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_features;
550         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 }
551 }
552 /// The node_announcement features of the node at this hop. For the last hop, these may be
553 /// amended to match the features present in the invoice this node generated.
554 #[no_mangle]
555 pub extern "C" fn RouteHop_set_node_features(this_ptr: &mut RouteHop, mut val: crate::lightning::ln::features::NodeFeatures) {
556         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_features = *unsafe { Box::from_raw(val.take_inner()) };
557 }
558 /// The channel that should be used from the previous hop to reach this node.
559 #[no_mangle]
560 pub extern "C" fn RouteHop_get_short_channel_id(this_ptr: &RouteHop) -> u64 {
561         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
562         *inner_val
563 }
564 /// The channel that should be used from the previous hop to reach this node.
565 #[no_mangle]
566 pub extern "C" fn RouteHop_set_short_channel_id(this_ptr: &mut RouteHop, mut val: u64) {
567         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
568 }
569 /// The channel_announcement features of the channel that should be used from the previous hop
570 /// to reach this node.
571 #[no_mangle]
572 pub extern "C" fn RouteHop_get_channel_features(this_ptr: &RouteHop) -> crate::lightning::ln::features::ChannelFeatures {
573         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_features;
574         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 }
575 }
576 /// The channel_announcement features of the channel that should be used from the previous hop
577 /// to reach this node.
578 #[no_mangle]
579 pub extern "C" fn RouteHop_set_channel_features(this_ptr: &mut RouteHop, mut val: crate::lightning::ln::features::ChannelFeatures) {
580         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_features = *unsafe { Box::from_raw(val.take_inner()) };
581 }
582 /// The fee taken on this hop (for paying for the use of the *next* channel in the path).
583 /// If this is the last hop in [`Path::hops`]:
584 /// * if we're sending to a [`BlindedPath`], this is the fee paid for use of the entire blinded path
585 /// * otherwise, this is the full value of this [`Path`]'s part of the payment
586 ///
587 /// [`BlindedPath`]: crate::blinded_path::BlindedPath
588 #[no_mangle]
589 pub extern "C" fn RouteHop_get_fee_msat(this_ptr: &RouteHop) -> u64 {
590         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_msat;
591         *inner_val
592 }
593 /// The fee taken on this hop (for paying for the use of the *next* channel in the path).
594 /// If this is the last hop in [`Path::hops`]:
595 /// * if we're sending to a [`BlindedPath`], this is the fee paid for use of the entire blinded path
596 /// * otherwise, this is the full value of this [`Path`]'s part of the payment
597 ///
598 /// [`BlindedPath`]: crate::blinded_path::BlindedPath
599 #[no_mangle]
600 pub extern "C" fn RouteHop_set_fee_msat(this_ptr: &mut RouteHop, mut val: u64) {
601         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_msat = val;
602 }
603 /// The CLTV delta added for this hop.
604 /// If this is the last hop in [`Path::hops`]:
605 /// * if we're sending to a [`BlindedPath`], this is the CLTV delta for the entire blinded path
606 /// * otherwise, this is the CLTV delta expected at the destination
607 ///
608 /// [`BlindedPath`]: crate::blinded_path::BlindedPath
609 #[no_mangle]
610 pub extern "C" fn RouteHop_get_cltv_expiry_delta(this_ptr: &RouteHop) -> u32 {
611         let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
612         *inner_val
613 }
614 /// The CLTV delta added for this hop.
615 /// If this is the last hop in [`Path::hops`]:
616 /// * if we're sending to a [`BlindedPath`], this is the CLTV delta for the entire blinded path
617 /// * otherwise, this is the CLTV delta expected at the destination
618 ///
619 /// [`BlindedPath`]: crate::blinded_path::BlindedPath
620 #[no_mangle]
621 pub extern "C" fn RouteHop_set_cltv_expiry_delta(this_ptr: &mut RouteHop, mut val: u32) {
622         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
623 }
624 /// Indicates whether this hop is possibly announced in the public network graph.
625 ///
626 /// Will be `true` if there is a possibility that the channel is publicly known, i.e., if we
627 /// either know for sure it's announced in the public graph, or if any public channels exist
628 /// for which the given `short_channel_id` could be an alias for. Will be `false` if we believe
629 /// the channel to be unannounced.
630 ///
631 /// Will be `true` for objects serialized with LDK version 0.0.116 and before.
632 #[no_mangle]
633 pub extern "C" fn RouteHop_get_maybe_announced_channel(this_ptr: &RouteHop) -> bool {
634         let mut inner_val = &mut this_ptr.get_native_mut_ref().maybe_announced_channel;
635         *inner_val
636 }
637 /// Indicates whether this hop is possibly announced in the public network graph.
638 ///
639 /// Will be `true` if there is a possibility that the channel is publicly known, i.e., if we
640 /// either know for sure it's announced in the public graph, or if any public channels exist
641 /// for which the given `short_channel_id` could be an alias for. Will be `false` if we believe
642 /// the channel to be unannounced.
643 ///
644 /// Will be `true` for objects serialized with LDK version 0.0.116 and before.
645 #[no_mangle]
646 pub extern "C" fn RouteHop_set_maybe_announced_channel(this_ptr: &mut RouteHop, mut val: bool) {
647         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.maybe_announced_channel = val;
648 }
649 /// Constructs a new RouteHop given each field
650 #[must_use]
651 #[no_mangle]
652 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, mut maybe_announced_channel_arg: bool) -> RouteHop {
653         RouteHop { inner: ObjOps::heap_alloc(nativeRouteHop {
654                 pubkey: pubkey_arg.into_rust(),
655                 node_features: *unsafe { Box::from_raw(node_features_arg.take_inner()) },
656                 short_channel_id: short_channel_id_arg,
657                 channel_features: *unsafe { Box::from_raw(channel_features_arg.take_inner()) },
658                 fee_msat: fee_msat_arg,
659                 cltv_expiry_delta: cltv_expiry_delta_arg,
660                 maybe_announced_channel: maybe_announced_channel_arg,
661         }), is_owned: true }
662 }
663 impl Clone for RouteHop {
664         fn clone(&self) -> Self {
665                 Self {
666                         inner: if <*mut nativeRouteHop>::is_null(self.inner) { core::ptr::null_mut() } else {
667                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
668                         is_owned: true,
669                 }
670         }
671 }
672 #[allow(unused)]
673 /// Used only if an object of this type is returned as a trait impl by a method
674 pub(crate) extern "C" fn RouteHop_clone_void(this_ptr: *const c_void) -> *mut c_void {
675         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRouteHop)).clone() })) as *mut c_void
676 }
677 #[no_mangle]
678 /// Creates a copy of the RouteHop
679 pub extern "C" fn RouteHop_clone(orig: &RouteHop) -> RouteHop {
680         orig.clone()
681 }
682 /// Get a string which allows debug introspection of a RouteHop object
683 pub extern "C" fn RouteHop_debug_str_void(o: *const c_void) -> Str {
684         alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::router::RouteHop }).into()}
685 /// Generates a non-cryptographic 64-bit hash of the RouteHop.
686 #[no_mangle]
687 pub extern "C" fn RouteHop_hash(o: &RouteHop) -> u64 {
688         if o.inner.is_null() { return 0; }
689         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
690         #[allow(deprecated)]
691         let mut hasher = core::hash::SipHasher::new();
692         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
693         core::hash::Hasher::finish(&hasher)
694 }
695 /// Checks if two RouteHops contain equal inner contents.
696 /// This ignores pointers and is_owned flags and looks at the values in fields.
697 /// Two objects with NULL inner values will be considered "equal" here.
698 #[no_mangle]
699 pub extern "C" fn RouteHop_eq(a: &RouteHop, b: &RouteHop) -> bool {
700         if a.inner == b.inner { return true; }
701         if a.inner.is_null() || b.inner.is_null() { return false; }
702         if a.get_native_ref() == b.get_native_ref() { true } else { false }
703 }
704 #[no_mangle]
705 /// Serialize the RouteHop object into a byte array which can be read by RouteHop_read
706 pub extern "C" fn RouteHop_write(obj: &crate::lightning::routing::router::RouteHop) -> crate::c_types::derived::CVec_u8Z {
707         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
708 }
709 #[allow(unused)]
710 pub(crate) extern "C" fn RouteHop_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
711         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRouteHop) })
712 }
713 #[no_mangle]
714 /// Read a RouteHop from a byte array, created by RouteHop_write
715 pub extern "C" fn RouteHop_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RouteHopDecodeErrorZ {
716         let res: Result<lightning::routing::router::RouteHop, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
717         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() };
718         local_res
719 }
720
721 use lightning::routing::router::BlindedTail as nativeBlindedTailImport;
722 pub(crate) type nativeBlindedTail = nativeBlindedTailImport;
723
724 /// The blinded portion of a [`Path`], if we're routing to a recipient who provided blinded paths in
725 /// their [`Bolt12Invoice`].
726 ///
727 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
728 #[must_use]
729 #[repr(C)]
730 pub struct BlindedTail {
731         /// A pointer to the opaque Rust object.
732
733         /// Nearly everywhere, inner must be non-null, however in places where
734         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
735         pub inner: *mut nativeBlindedTail,
736         /// Indicates that this is the only struct which contains the same pointer.
737
738         /// Rust functions which take ownership of an object provided via an argument require
739         /// this to be true and invalidate the object pointed to by inner.
740         pub is_owned: bool,
741 }
742
743 impl Drop for BlindedTail {
744         fn drop(&mut self) {
745                 if self.is_owned && !<*mut nativeBlindedTail>::is_null(self.inner) {
746                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
747                 }
748         }
749 }
750 /// Frees any resources used by the BlindedTail, if is_owned is set and inner is non-NULL.
751 #[no_mangle]
752 pub extern "C" fn BlindedTail_free(this_obj: BlindedTail) { }
753 #[allow(unused)]
754 /// Used only if an object of this type is returned as a trait impl by a method
755 pub(crate) extern "C" fn BlindedTail_free_void(this_ptr: *mut c_void) {
756         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBlindedTail) };
757 }
758 #[allow(unused)]
759 impl BlindedTail {
760         pub(crate) fn get_native_ref(&self) -> &'static nativeBlindedTail {
761                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
762         }
763         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBlindedTail {
764                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
765         }
766         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
767         pub(crate) fn take_inner(mut self) -> *mut nativeBlindedTail {
768                 assert!(self.is_owned);
769                 let ret = ObjOps::untweak_ptr(self.inner);
770                 self.inner = core::ptr::null_mut();
771                 ret
772         }
773 }
774 /// The hops of the [`BlindedPath`] provided by the recipient.
775 ///
776 /// [`BlindedPath`]: crate::blinded_path::BlindedPath
777 #[no_mangle]
778 pub extern "C" fn BlindedTail_get_hops(this_ptr: &BlindedTail) -> crate::c_types::derived::CVec_BlindedHopZ {
779         let mut inner_val = &mut this_ptr.get_native_mut_ref().hops;
780         let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::blinded_path::BlindedHop { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::blinded_path::BlindedHop<>) as *mut _) }, is_owned: false } }); };
781         local_inner_val.into()
782 }
783 /// The hops of the [`BlindedPath`] provided by the recipient.
784 ///
785 /// [`BlindedPath`]: crate::blinded_path::BlindedPath
786 #[no_mangle]
787 pub extern "C" fn BlindedTail_set_hops(this_ptr: &mut BlindedTail, mut val: crate::c_types::derived::CVec_BlindedHopZ) {
788         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
789         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.hops = local_val;
790 }
791 /// The blinding point of the [`BlindedPath`] provided by the recipient.
792 ///
793 /// [`BlindedPath`]: crate::blinded_path::BlindedPath
794 #[no_mangle]
795 pub extern "C" fn BlindedTail_get_blinding_point(this_ptr: &BlindedTail) -> crate::c_types::PublicKey {
796         let mut inner_val = &mut this_ptr.get_native_mut_ref().blinding_point;
797         crate::c_types::PublicKey::from_rust(&inner_val)
798 }
799 /// The blinding point of the [`BlindedPath`] provided by the recipient.
800 ///
801 /// [`BlindedPath`]: crate::blinded_path::BlindedPath
802 #[no_mangle]
803 pub extern "C" fn BlindedTail_set_blinding_point(this_ptr: &mut BlindedTail, mut val: crate::c_types::PublicKey) {
804         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinding_point = val.into_rust();
805 }
806 /// Excess CLTV delta added to the recipient's CLTV expiry to deter intermediate nodes from
807 /// inferring the destination. May be 0.
808 #[no_mangle]
809 pub extern "C" fn BlindedTail_get_excess_final_cltv_expiry_delta(this_ptr: &BlindedTail) -> u32 {
810         let mut inner_val = &mut this_ptr.get_native_mut_ref().excess_final_cltv_expiry_delta;
811         *inner_val
812 }
813 /// Excess CLTV delta added to the recipient's CLTV expiry to deter intermediate nodes from
814 /// inferring the destination. May be 0.
815 #[no_mangle]
816 pub extern "C" fn BlindedTail_set_excess_final_cltv_expiry_delta(this_ptr: &mut BlindedTail, mut val: u32) {
817         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_final_cltv_expiry_delta = val;
818 }
819 /// The total amount paid on this [`Path`], excluding the fees.
820 #[no_mangle]
821 pub extern "C" fn BlindedTail_get_final_value_msat(this_ptr: &BlindedTail) -> u64 {
822         let mut inner_val = &mut this_ptr.get_native_mut_ref().final_value_msat;
823         *inner_val
824 }
825 /// The total amount paid on this [`Path`], excluding the fees.
826 #[no_mangle]
827 pub extern "C" fn BlindedTail_set_final_value_msat(this_ptr: &mut BlindedTail, mut val: u64) {
828         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.final_value_msat = val;
829 }
830 /// Constructs a new BlindedTail given each field
831 #[must_use]
832 #[no_mangle]
833 pub extern "C" fn BlindedTail_new(mut hops_arg: crate::c_types::derived::CVec_BlindedHopZ, mut blinding_point_arg: crate::c_types::PublicKey, mut excess_final_cltv_expiry_delta_arg: u32, mut final_value_msat_arg: u64) -> BlindedTail {
834         let mut local_hops_arg = Vec::new(); for mut item in hops_arg.into_rust().drain(..) { local_hops_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
835         BlindedTail { inner: ObjOps::heap_alloc(nativeBlindedTail {
836                 hops: local_hops_arg,
837                 blinding_point: blinding_point_arg.into_rust(),
838                 excess_final_cltv_expiry_delta: excess_final_cltv_expiry_delta_arg,
839                 final_value_msat: final_value_msat_arg,
840         }), is_owned: true }
841 }
842 impl Clone for BlindedTail {
843         fn clone(&self) -> Self {
844                 Self {
845                         inner: if <*mut nativeBlindedTail>::is_null(self.inner) { core::ptr::null_mut() } else {
846                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
847                         is_owned: true,
848                 }
849         }
850 }
851 #[allow(unused)]
852 /// Used only if an object of this type is returned as a trait impl by a method
853 pub(crate) extern "C" fn BlindedTail_clone_void(this_ptr: *const c_void) -> *mut c_void {
854         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBlindedTail)).clone() })) as *mut c_void
855 }
856 #[no_mangle]
857 /// Creates a copy of the BlindedTail
858 pub extern "C" fn BlindedTail_clone(orig: &BlindedTail) -> BlindedTail {
859         orig.clone()
860 }
861 /// Get a string which allows debug introspection of a BlindedTail object
862 pub extern "C" fn BlindedTail_debug_str_void(o: *const c_void) -> Str {
863         alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::router::BlindedTail }).into()}
864 /// Generates a non-cryptographic 64-bit hash of the BlindedTail.
865 #[no_mangle]
866 pub extern "C" fn BlindedTail_hash(o: &BlindedTail) -> u64 {
867         if o.inner.is_null() { return 0; }
868         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
869         #[allow(deprecated)]
870         let mut hasher = core::hash::SipHasher::new();
871         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
872         core::hash::Hasher::finish(&hasher)
873 }
874 /// Checks if two BlindedTails contain equal inner contents.
875 /// This ignores pointers and is_owned flags and looks at the values in fields.
876 /// Two objects with NULL inner values will be considered "equal" here.
877 #[no_mangle]
878 pub extern "C" fn BlindedTail_eq(a: &BlindedTail, b: &BlindedTail) -> bool {
879         if a.inner == b.inner { return true; }
880         if a.inner.is_null() || b.inner.is_null() { return false; }
881         if a.get_native_ref() == b.get_native_ref() { true } else { false }
882 }
883 #[no_mangle]
884 /// Serialize the BlindedTail object into a byte array which can be read by BlindedTail_read
885 pub extern "C" fn BlindedTail_write(obj: &crate::lightning::routing::router::BlindedTail) -> crate::c_types::derived::CVec_u8Z {
886         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
887 }
888 #[allow(unused)]
889 pub(crate) extern "C" fn BlindedTail_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
890         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBlindedTail) })
891 }
892 #[no_mangle]
893 /// Read a BlindedTail from a byte array, created by BlindedTail_write
894 pub extern "C" fn BlindedTail_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BlindedTailDecodeErrorZ {
895         let res: Result<lightning::routing::router::BlindedTail, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
896         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::BlindedTail { 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() };
897         local_res
898 }
899
900 use lightning::routing::router::Path as nativePathImport;
901 pub(crate) type nativePath = nativePathImport;
902
903 /// A path in a [`Route`] to the payment recipient. Must always be at least length one.
904 /// If no [`Path::blinded_tail`] is present, then [`Path::hops`] length may be up to 19.
905 #[must_use]
906 #[repr(C)]
907 pub struct Path {
908         /// A pointer to the opaque Rust object.
909
910         /// Nearly everywhere, inner must be non-null, however in places where
911         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
912         pub inner: *mut nativePath,
913         /// Indicates that this is the only struct which contains the same pointer.
914
915         /// Rust functions which take ownership of an object provided via an argument require
916         /// this to be true and invalidate the object pointed to by inner.
917         pub is_owned: bool,
918 }
919
920 impl Drop for Path {
921         fn drop(&mut self) {
922                 if self.is_owned && !<*mut nativePath>::is_null(self.inner) {
923                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
924                 }
925         }
926 }
927 /// Frees any resources used by the Path, if is_owned is set and inner is non-NULL.
928 #[no_mangle]
929 pub extern "C" fn Path_free(this_obj: Path) { }
930 #[allow(unused)]
931 /// Used only if an object of this type is returned as a trait impl by a method
932 pub(crate) extern "C" fn Path_free_void(this_ptr: *mut c_void) {
933         let _ = unsafe { Box::from_raw(this_ptr as *mut nativePath) };
934 }
935 #[allow(unused)]
936 impl Path {
937         pub(crate) fn get_native_ref(&self) -> &'static nativePath {
938                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
939         }
940         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePath {
941                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
942         }
943         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
944         pub(crate) fn take_inner(mut self) -> *mut nativePath {
945                 assert!(self.is_owned);
946                 let ret = ObjOps::untweak_ptr(self.inner);
947                 self.inner = core::ptr::null_mut();
948                 ret
949         }
950 }
951 /// The list of unblinded hops in this [`Path`]. Must be at least length one.
952 #[no_mangle]
953 pub extern "C" fn Path_get_hops(this_ptr: &Path) -> crate::c_types::derived::CVec_RouteHopZ {
954         let mut inner_val = &mut this_ptr.get_native_mut_ref().hops;
955         let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.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 } }); };
956         local_inner_val.into()
957 }
958 /// The list of unblinded hops in this [`Path`]. Must be at least length one.
959 #[no_mangle]
960 pub extern "C" fn Path_set_hops(this_ptr: &mut Path, mut val: crate::c_types::derived::CVec_RouteHopZ) {
961         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
962         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.hops = local_val;
963 }
964 /// The blinded path at which this path terminates, if we're sending to one, and its metadata.
965 ///
966 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
967 #[no_mangle]
968 pub extern "C" fn Path_get_blinded_tail(this_ptr: &Path) -> crate::lightning::routing::router::BlindedTail {
969         let mut inner_val = &mut this_ptr.get_native_mut_ref().blinded_tail;
970         let mut local_inner_val = crate::lightning::routing::router::BlindedTail { 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::BlindedTail<>) as *mut _ }, is_owned: false };
971         local_inner_val
972 }
973 /// The blinded path at which this path terminates, if we're sending to one, and its metadata.
974 ///
975 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
976 #[no_mangle]
977 pub extern "C" fn Path_set_blinded_tail(this_ptr: &mut Path, mut val: crate::lightning::routing::router::BlindedTail) {
978         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
979         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinded_tail = local_val;
980 }
981 /// Constructs a new Path given each field
982 ///
983 /// Note that blinded_tail_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
984 #[must_use]
985 #[no_mangle]
986 pub extern "C" fn Path_new(mut hops_arg: crate::c_types::derived::CVec_RouteHopZ, mut blinded_tail_arg: crate::lightning::routing::router::BlindedTail) -> Path {
987         let mut local_hops_arg = Vec::new(); for mut item in hops_arg.into_rust().drain(..) { local_hops_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
988         let mut local_blinded_tail_arg = if blinded_tail_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(blinded_tail_arg.take_inner()) } }) };
989         Path { inner: ObjOps::heap_alloc(nativePath {
990                 hops: local_hops_arg,
991                 blinded_tail: local_blinded_tail_arg,
992         }), is_owned: true }
993 }
994 impl Clone for Path {
995         fn clone(&self) -> Self {
996                 Self {
997                         inner: if <*mut nativePath>::is_null(self.inner) { core::ptr::null_mut() } else {
998                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
999                         is_owned: true,
1000                 }
1001         }
1002 }
1003 #[allow(unused)]
1004 /// Used only if an object of this type is returned as a trait impl by a method
1005 pub(crate) extern "C" fn Path_clone_void(this_ptr: *const c_void) -> *mut c_void {
1006         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePath)).clone() })) as *mut c_void
1007 }
1008 #[no_mangle]
1009 /// Creates a copy of the Path
1010 pub extern "C" fn Path_clone(orig: &Path) -> Path {
1011         orig.clone()
1012 }
1013 /// Get a string which allows debug introspection of a Path object
1014 pub extern "C" fn Path_debug_str_void(o: *const c_void) -> Str {
1015         alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::router::Path }).into()}
1016 /// Generates a non-cryptographic 64-bit hash of the Path.
1017 #[no_mangle]
1018 pub extern "C" fn Path_hash(o: &Path) -> u64 {
1019         if o.inner.is_null() { return 0; }
1020         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1021         #[allow(deprecated)]
1022         let mut hasher = core::hash::SipHasher::new();
1023         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1024         core::hash::Hasher::finish(&hasher)
1025 }
1026 /// Checks if two Paths contain equal inner contents.
1027 /// This ignores pointers and is_owned flags and looks at the values in fields.
1028 /// Two objects with NULL inner values will be considered "equal" here.
1029 #[no_mangle]
1030 pub extern "C" fn Path_eq(a: &Path, b: &Path) -> bool {
1031         if a.inner == b.inner { return true; }
1032         if a.inner.is_null() || b.inner.is_null() { return false; }
1033         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1034 }
1035 /// Gets the fees for a given path, excluding any excess paid to the recipient.
1036 #[must_use]
1037 #[no_mangle]
1038 pub extern "C" fn Path_fee_msat(this_arg: &crate::lightning::routing::router::Path) -> u64 {
1039         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fee_msat();
1040         ret
1041 }
1042
1043 /// Gets the total amount paid on this [`Path`], excluding the fees.
1044 #[must_use]
1045 #[no_mangle]
1046 pub extern "C" fn Path_final_value_msat(this_arg: &crate::lightning::routing::router::Path) -> u64 {
1047         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.final_value_msat();
1048         ret
1049 }
1050
1051 /// Gets the final hop's CLTV expiry delta.
1052 #[must_use]
1053 #[no_mangle]
1054 pub extern "C" fn Path_final_cltv_expiry_delta(this_arg: &crate::lightning::routing::router::Path) -> crate::c_types::derived::COption_u32Z {
1055         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.final_cltv_expiry_delta();
1056         let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { ret.unwrap() }) };
1057         local_ret
1058 }
1059
1060
1061 use lightning::routing::router::Route as nativeRouteImport;
1062 pub(crate) type nativeRoute = nativeRouteImport;
1063
1064 /// A route directs a payment from the sender (us) to the recipient. If the recipient supports MPP,
1065 /// it can take multiple paths. Each path is composed of one or more hops through the network.
1066 #[must_use]
1067 #[repr(C)]
1068 pub struct Route {
1069         /// A pointer to the opaque Rust object.
1070
1071         /// Nearly everywhere, inner must be non-null, however in places where
1072         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1073         pub inner: *mut nativeRoute,
1074         /// Indicates that this is the only struct which contains the same pointer.
1075
1076         /// Rust functions which take ownership of an object provided via an argument require
1077         /// this to be true and invalidate the object pointed to by inner.
1078         pub is_owned: bool,
1079 }
1080
1081 impl Drop for Route {
1082         fn drop(&mut self) {
1083                 if self.is_owned && !<*mut nativeRoute>::is_null(self.inner) {
1084                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1085                 }
1086         }
1087 }
1088 /// Frees any resources used by the Route, if is_owned is set and inner is non-NULL.
1089 #[no_mangle]
1090 pub extern "C" fn Route_free(this_obj: Route) { }
1091 #[allow(unused)]
1092 /// Used only if an object of this type is returned as a trait impl by a method
1093 pub(crate) extern "C" fn Route_free_void(this_ptr: *mut c_void) {
1094         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRoute) };
1095 }
1096 #[allow(unused)]
1097 impl Route {
1098         pub(crate) fn get_native_ref(&self) -> &'static nativeRoute {
1099                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1100         }
1101         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRoute {
1102                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1103         }
1104         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1105         pub(crate) fn take_inner(mut self) -> *mut nativeRoute {
1106                 assert!(self.is_owned);
1107                 let ret = ObjOps::untweak_ptr(self.inner);
1108                 self.inner = core::ptr::null_mut();
1109                 ret
1110         }
1111 }
1112 /// The list of [`Path`]s taken for a single (potentially-)multi-part payment. If no
1113 /// [`BlindedTail`]s are present, then the pubkey of the last [`RouteHop`] in each path must be
1114 /// the same.
1115 #[no_mangle]
1116 pub extern "C" fn Route_get_paths(this_ptr: &Route) -> crate::c_types::derived::CVec_PathZ {
1117         let mut inner_val = &mut this_ptr.get_native_mut_ref().paths;
1118         let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::routing::router::Path { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::routing::router::Path<>) as *mut _) }, is_owned: false } }); };
1119         local_inner_val.into()
1120 }
1121 /// The list of [`Path`]s taken for a single (potentially-)multi-part payment. If no
1122 /// [`BlindedTail`]s are present, then the pubkey of the last [`RouteHop`] in each path must be
1123 /// the same.
1124 #[no_mangle]
1125 pub extern "C" fn Route_set_paths(this_ptr: &mut Route, mut val: crate::c_types::derived::CVec_PathZ) {
1126         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
1127         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.paths = local_val;
1128 }
1129 /// The `route_params` parameter passed to [`find_route`].
1130 ///
1131 /// This is used by `ChannelManager` to track information which may be required for retries.
1132 ///
1133 /// Will be `None` for objects serialized with LDK versions prior to 0.0.117.
1134 ///
1135 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1136 #[no_mangle]
1137 pub extern "C" fn Route_get_route_params(this_ptr: &Route) -> crate::lightning::routing::router::RouteParameters {
1138         let mut inner_val = &mut this_ptr.get_native_mut_ref().route_params;
1139         let mut local_inner_val = crate::lightning::routing::router::RouteParameters { 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::RouteParameters<>) as *mut _ }, is_owned: false };
1140         local_inner_val
1141 }
1142 /// The `route_params` parameter passed to [`find_route`].
1143 ///
1144 /// This is used by `ChannelManager` to track information which may be required for retries.
1145 ///
1146 /// Will be `None` for objects serialized with LDK versions prior to 0.0.117.
1147 ///
1148 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1149 #[no_mangle]
1150 pub extern "C" fn Route_set_route_params(this_ptr: &mut Route, mut val: crate::lightning::routing::router::RouteParameters) {
1151         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1152         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.route_params = local_val;
1153 }
1154 /// Constructs a new Route given each field
1155 ///
1156 /// Note that route_params_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1157 #[must_use]
1158 #[no_mangle]
1159 pub extern "C" fn Route_new(mut paths_arg: crate::c_types::derived::CVec_PathZ, mut route_params_arg: crate::lightning::routing::router::RouteParameters) -> Route {
1160         let mut local_paths_arg = Vec::new(); for mut item in paths_arg.into_rust().drain(..) { local_paths_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
1161         let mut local_route_params_arg = if route_params_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(route_params_arg.take_inner()) } }) };
1162         Route { inner: ObjOps::heap_alloc(nativeRoute {
1163                 paths: local_paths_arg,
1164                 route_params: local_route_params_arg,
1165         }), is_owned: true }
1166 }
1167 impl Clone for Route {
1168         fn clone(&self) -> Self {
1169                 Self {
1170                         inner: if <*mut nativeRoute>::is_null(self.inner) { core::ptr::null_mut() } else {
1171                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1172                         is_owned: true,
1173                 }
1174         }
1175 }
1176 #[allow(unused)]
1177 /// Used only if an object of this type is returned as a trait impl by a method
1178 pub(crate) extern "C" fn Route_clone_void(this_ptr: *const c_void) -> *mut c_void {
1179         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRoute)).clone() })) as *mut c_void
1180 }
1181 #[no_mangle]
1182 /// Creates a copy of the Route
1183 pub extern "C" fn Route_clone(orig: &Route) -> Route {
1184         orig.clone()
1185 }
1186 /// Get a string which allows debug introspection of a Route object
1187 pub extern "C" fn Route_debug_str_void(o: *const c_void) -> Str {
1188         alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::router::Route }).into()}
1189 /// Generates a non-cryptographic 64-bit hash of the Route.
1190 #[no_mangle]
1191 pub extern "C" fn Route_hash(o: &Route) -> u64 {
1192         if o.inner.is_null() { return 0; }
1193         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1194         #[allow(deprecated)]
1195         let mut hasher = core::hash::SipHasher::new();
1196         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1197         core::hash::Hasher::finish(&hasher)
1198 }
1199 /// Checks if two Routes contain equal inner contents.
1200 /// This ignores pointers and is_owned flags and looks at the values in fields.
1201 /// Two objects with NULL inner values will be considered "equal" here.
1202 #[no_mangle]
1203 pub extern "C" fn Route_eq(a: &Route, b: &Route) -> bool {
1204         if a.inner == b.inner { return true; }
1205         if a.inner.is_null() || b.inner.is_null() { return false; }
1206         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1207 }
1208 /// Returns the total amount of fees paid on this [`Route`].
1209 ///
1210 /// For objects serialized with LDK 0.0.117 and after, this includes any extra payment made to
1211 /// the recipient, which can happen in excess of the amount passed to [`find_route`] via
1212 /// [`RouteParameters::final_value_msat`], if we had to reach the [`htlc_minimum_msat`] limits.
1213 ///
1214 /// [`htlc_minimum_msat`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
1215 #[must_use]
1216 #[no_mangle]
1217 pub extern "C" fn Route_get_total_fees(this_arg: &crate::lightning::routing::router::Route) -> u64 {
1218         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_total_fees();
1219         ret
1220 }
1221
1222 /// Returns the total amount paid on this [`Route`], excluding the fees.
1223 ///
1224 /// Might be more than requested as part of the given [`RouteParameters::final_value_msat`] if
1225 /// we had to reach the [`htlc_minimum_msat`] limits.
1226 ///
1227 /// [`htlc_minimum_msat`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
1228 #[must_use]
1229 #[no_mangle]
1230 pub extern "C" fn Route_get_total_amount(this_arg: &crate::lightning::routing::router::Route) -> u64 {
1231         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_total_amount();
1232         ret
1233 }
1234
1235 #[no_mangle]
1236 /// Serialize the Route object into a byte array which can be read by Route_read
1237 pub extern "C" fn Route_write(obj: &crate::lightning::routing::router::Route) -> crate::c_types::derived::CVec_u8Z {
1238         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1239 }
1240 #[allow(unused)]
1241 pub(crate) extern "C" fn Route_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1242         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRoute) })
1243 }
1244 #[no_mangle]
1245 /// Read a Route from a byte array, created by Route_write
1246 pub extern "C" fn Route_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RouteDecodeErrorZ {
1247         let res: Result<lightning::routing::router::Route, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
1248         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() };
1249         local_res
1250 }
1251
1252 use lightning::routing::router::RouteParameters as nativeRouteParametersImport;
1253 pub(crate) type nativeRouteParameters = nativeRouteParametersImport;
1254
1255 /// Parameters needed to find a [`Route`].
1256 ///
1257 /// Passed to [`find_route`] and [`build_route_from_hops`].
1258 #[must_use]
1259 #[repr(C)]
1260 pub struct RouteParameters {
1261         /// A pointer to the opaque Rust object.
1262
1263         /// Nearly everywhere, inner must be non-null, however in places where
1264         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1265         pub inner: *mut nativeRouteParameters,
1266         /// Indicates that this is the only struct which contains the same pointer.
1267
1268         /// Rust functions which take ownership of an object provided via an argument require
1269         /// this to be true and invalidate the object pointed to by inner.
1270         pub is_owned: bool,
1271 }
1272
1273 impl Drop for RouteParameters {
1274         fn drop(&mut self) {
1275                 if self.is_owned && !<*mut nativeRouteParameters>::is_null(self.inner) {
1276                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1277                 }
1278         }
1279 }
1280 /// Frees any resources used by the RouteParameters, if is_owned is set and inner is non-NULL.
1281 #[no_mangle]
1282 pub extern "C" fn RouteParameters_free(this_obj: RouteParameters) { }
1283 #[allow(unused)]
1284 /// Used only if an object of this type is returned as a trait impl by a method
1285 pub(crate) extern "C" fn RouteParameters_free_void(this_ptr: *mut c_void) {
1286         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRouteParameters) };
1287 }
1288 #[allow(unused)]
1289 impl RouteParameters {
1290         pub(crate) fn get_native_ref(&self) -> &'static nativeRouteParameters {
1291                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1292         }
1293         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRouteParameters {
1294                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1295         }
1296         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1297         pub(crate) fn take_inner(mut self) -> *mut nativeRouteParameters {
1298                 assert!(self.is_owned);
1299                 let ret = ObjOps::untweak_ptr(self.inner);
1300                 self.inner = core::ptr::null_mut();
1301                 ret
1302         }
1303 }
1304 /// The parameters of the failed payment path.
1305 #[no_mangle]
1306 pub extern "C" fn RouteParameters_get_payment_params(this_ptr: &RouteParameters) -> crate::lightning::routing::router::PaymentParameters {
1307         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_params;
1308         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 }
1309 }
1310 /// The parameters of the failed payment path.
1311 #[no_mangle]
1312 pub extern "C" fn RouteParameters_set_payment_params(this_ptr: &mut RouteParameters, mut val: crate::lightning::routing::router::PaymentParameters) {
1313         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_params = *unsafe { Box::from_raw(val.take_inner()) };
1314 }
1315 /// The amount in msats sent on the failed payment path.
1316 #[no_mangle]
1317 pub extern "C" fn RouteParameters_get_final_value_msat(this_ptr: &RouteParameters) -> u64 {
1318         let mut inner_val = &mut this_ptr.get_native_mut_ref().final_value_msat;
1319         *inner_val
1320 }
1321 /// The amount in msats sent on the failed payment path.
1322 #[no_mangle]
1323 pub extern "C" fn RouteParameters_set_final_value_msat(this_ptr: &mut RouteParameters, mut val: u64) {
1324         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.final_value_msat = val;
1325 }
1326 /// The maximum total fees, in millisatoshi, that may accrue during route finding.
1327 ///
1328 /// This limit also applies to the total fees that may arise while retrying failed payment
1329 /// paths.
1330 ///
1331 /// Note that values below a few sats may result in some paths being spuriously ignored.
1332 #[no_mangle]
1333 pub extern "C" fn RouteParameters_get_max_total_routing_fee_msat(this_ptr: &RouteParameters) -> crate::c_types::derived::COption_u64Z {
1334         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_total_routing_fee_msat;
1335         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() }) };
1336         local_inner_val
1337 }
1338 /// The maximum total fees, in millisatoshi, that may accrue during route finding.
1339 ///
1340 /// This limit also applies to the total fees that may arise while retrying failed payment
1341 /// paths.
1342 ///
1343 /// Note that values below a few sats may result in some paths being spuriously ignored.
1344 #[no_mangle]
1345 pub extern "C" fn RouteParameters_set_max_total_routing_fee_msat(this_ptr: &mut RouteParameters, mut val: crate::c_types::derived::COption_u64Z) {
1346         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1347         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_total_routing_fee_msat = local_val;
1348 }
1349 /// Constructs a new RouteParameters given each field
1350 #[must_use]
1351 #[no_mangle]
1352 pub extern "C" fn RouteParameters_new(mut payment_params_arg: crate::lightning::routing::router::PaymentParameters, mut final_value_msat_arg: u64, mut max_total_routing_fee_msat_arg: crate::c_types::derived::COption_u64Z) -> RouteParameters {
1353         let mut local_max_total_routing_fee_msat_arg = if max_total_routing_fee_msat_arg.is_some() { Some( { max_total_routing_fee_msat_arg.take() }) } else { None };
1354         RouteParameters { inner: ObjOps::heap_alloc(nativeRouteParameters {
1355                 payment_params: *unsafe { Box::from_raw(payment_params_arg.take_inner()) },
1356                 final_value_msat: final_value_msat_arg,
1357                 max_total_routing_fee_msat: local_max_total_routing_fee_msat_arg,
1358         }), is_owned: true }
1359 }
1360 impl Clone for RouteParameters {
1361         fn clone(&self) -> Self {
1362                 Self {
1363                         inner: if <*mut nativeRouteParameters>::is_null(self.inner) { core::ptr::null_mut() } else {
1364                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1365                         is_owned: true,
1366                 }
1367         }
1368 }
1369 #[allow(unused)]
1370 /// Used only if an object of this type is returned as a trait impl by a method
1371 pub(crate) extern "C" fn RouteParameters_clone_void(this_ptr: *const c_void) -> *mut c_void {
1372         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRouteParameters)).clone() })) as *mut c_void
1373 }
1374 #[no_mangle]
1375 /// Creates a copy of the RouteParameters
1376 pub extern "C" fn RouteParameters_clone(orig: &RouteParameters) -> RouteParameters {
1377         orig.clone()
1378 }
1379 /// Get a string which allows debug introspection of a RouteParameters object
1380 pub extern "C" fn RouteParameters_debug_str_void(o: *const c_void) -> Str {
1381         alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::router::RouteParameters }).into()}
1382 /// Generates a non-cryptographic 64-bit hash of the RouteParameters.
1383 #[no_mangle]
1384 pub extern "C" fn RouteParameters_hash(o: &RouteParameters) -> u64 {
1385         if o.inner.is_null() { return 0; }
1386         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1387         #[allow(deprecated)]
1388         let mut hasher = core::hash::SipHasher::new();
1389         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1390         core::hash::Hasher::finish(&hasher)
1391 }
1392 /// Checks if two RouteParameterss contain equal inner contents.
1393 /// This ignores pointers and is_owned flags and looks at the values in fields.
1394 /// Two objects with NULL inner values will be considered "equal" here.
1395 #[no_mangle]
1396 pub extern "C" fn RouteParameters_eq(a: &RouteParameters, b: &RouteParameters) -> bool {
1397         if a.inner == b.inner { return true; }
1398         if a.inner.is_null() || b.inner.is_null() { return false; }
1399         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1400 }
1401 /// Constructs [`RouteParameters`] from the given [`PaymentParameters`] and a payment amount.
1402 ///
1403 /// [`Self::max_total_routing_fee_msat`] defaults to 1% of the payment amount + 50 sats
1404 #[must_use]
1405 #[no_mangle]
1406 pub extern "C" fn RouteParameters_from_payment_params_and_value(mut payment_params: crate::lightning::routing::router::PaymentParameters, mut final_value_msat: u64) -> crate::lightning::routing::router::RouteParameters {
1407         let mut ret = lightning::routing::router::RouteParameters::from_payment_params_and_value(*unsafe { Box::from_raw(payment_params.take_inner()) }, final_value_msat);
1408         crate::lightning::routing::router::RouteParameters { inner: ObjOps::heap_alloc(ret), is_owned: true }
1409 }
1410
1411 #[no_mangle]
1412 /// Serialize the RouteParameters object into a byte array which can be read by RouteParameters_read
1413 pub extern "C" fn RouteParameters_write(obj: &crate::lightning::routing::router::RouteParameters) -> crate::c_types::derived::CVec_u8Z {
1414         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1415 }
1416 #[allow(unused)]
1417 pub(crate) extern "C" fn RouteParameters_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1418         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRouteParameters) })
1419 }
1420 #[no_mangle]
1421 /// Read a RouteParameters from a byte array, created by RouteParameters_write
1422 pub extern "C" fn RouteParameters_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RouteParametersDecodeErrorZ {
1423         let res: Result<lightning::routing::router::RouteParameters, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
1424         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() };
1425         local_res
1426 }
1427 /// Maximum total CTLV difference we allow for a full payment path.
1428
1429 #[no_mangle]
1430 pub static DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA: u32 = lightning::routing::router::DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA;
1431 /// Maximum number of paths we allow an (MPP) payment to have.
1432
1433 #[no_mangle]
1434 pub static DEFAULT_MAX_PATH_COUNT: u8 = lightning::routing::router::DEFAULT_MAX_PATH_COUNT;
1435
1436 use lightning::routing::router::PaymentParameters as nativePaymentParametersImport;
1437 pub(crate) type nativePaymentParameters = nativePaymentParametersImport;
1438
1439 /// Information used to route a payment.
1440 #[must_use]
1441 #[repr(C)]
1442 pub struct PaymentParameters {
1443         /// A pointer to the opaque Rust object.
1444
1445         /// Nearly everywhere, inner must be non-null, however in places where
1446         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1447         pub inner: *mut nativePaymentParameters,
1448         /// Indicates that this is the only struct which contains the same pointer.
1449
1450         /// Rust functions which take ownership of an object provided via an argument require
1451         /// this to be true and invalidate the object pointed to by inner.
1452         pub is_owned: bool,
1453 }
1454
1455 impl Drop for PaymentParameters {
1456         fn drop(&mut self) {
1457                 if self.is_owned && !<*mut nativePaymentParameters>::is_null(self.inner) {
1458                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1459                 }
1460         }
1461 }
1462 /// Frees any resources used by the PaymentParameters, if is_owned is set and inner is non-NULL.
1463 #[no_mangle]
1464 pub extern "C" fn PaymentParameters_free(this_obj: PaymentParameters) { }
1465 #[allow(unused)]
1466 /// Used only if an object of this type is returned as a trait impl by a method
1467 pub(crate) extern "C" fn PaymentParameters_free_void(this_ptr: *mut c_void) {
1468         let _ = unsafe { Box::from_raw(this_ptr as *mut nativePaymentParameters) };
1469 }
1470 #[allow(unused)]
1471 impl PaymentParameters {
1472         pub(crate) fn get_native_ref(&self) -> &'static nativePaymentParameters {
1473                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1474         }
1475         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePaymentParameters {
1476                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1477         }
1478         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1479         pub(crate) fn take_inner(mut self) -> *mut nativePaymentParameters {
1480                 assert!(self.is_owned);
1481                 let ret = ObjOps::untweak_ptr(self.inner);
1482                 self.inner = core::ptr::null_mut();
1483                 ret
1484         }
1485 }
1486 /// Information about the payee, such as their features and route hints for their channels.
1487 #[no_mangle]
1488 pub extern "C" fn PaymentParameters_get_payee(this_ptr: &PaymentParameters) -> crate::lightning::routing::router::Payee {
1489         let mut inner_val = &mut this_ptr.get_native_mut_ref().payee;
1490         crate::lightning::routing::router::Payee::from_native(inner_val)
1491 }
1492 /// Information about the payee, such as their features and route hints for their channels.
1493 #[no_mangle]
1494 pub extern "C" fn PaymentParameters_set_payee(this_ptr: &mut PaymentParameters, mut val: crate::lightning::routing::router::Payee) {
1495         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payee = val.into_native();
1496 }
1497 /// Expiration of a payment to the payee, in seconds relative to the UNIX epoch.
1498 #[no_mangle]
1499 pub extern "C" fn PaymentParameters_get_expiry_time(this_ptr: &PaymentParameters) -> crate::c_types::derived::COption_u64Z {
1500         let mut inner_val = &mut this_ptr.get_native_mut_ref().expiry_time;
1501         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() }) };
1502         local_inner_val
1503 }
1504 /// Expiration of a payment to the payee, in seconds relative to the UNIX epoch.
1505 #[no_mangle]
1506 pub extern "C" fn PaymentParameters_set_expiry_time(this_ptr: &mut PaymentParameters, mut val: crate::c_types::derived::COption_u64Z) {
1507         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1508         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.expiry_time = local_val;
1509 }
1510 /// The maximum total CLTV delta we accept for the route.
1511 /// Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`].
1512 #[no_mangle]
1513 pub extern "C" fn PaymentParameters_get_max_total_cltv_expiry_delta(this_ptr: &PaymentParameters) -> u32 {
1514         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_total_cltv_expiry_delta;
1515         *inner_val
1516 }
1517 /// The maximum total CLTV delta we accept for the route.
1518 /// Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`].
1519 #[no_mangle]
1520 pub extern "C" fn PaymentParameters_set_max_total_cltv_expiry_delta(this_ptr: &mut PaymentParameters, mut val: u32) {
1521         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_total_cltv_expiry_delta = val;
1522 }
1523 /// The maximum number of paths that may be used by (MPP) payments.
1524 /// Defaults to [`DEFAULT_MAX_PATH_COUNT`].
1525 #[no_mangle]
1526 pub extern "C" fn PaymentParameters_get_max_path_count(this_ptr: &PaymentParameters) -> u8 {
1527         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_path_count;
1528         *inner_val
1529 }
1530 /// The maximum number of paths that may be used by (MPP) payments.
1531 /// Defaults to [`DEFAULT_MAX_PATH_COUNT`].
1532 #[no_mangle]
1533 pub extern "C" fn PaymentParameters_set_max_path_count(this_ptr: &mut PaymentParameters, mut val: u8) {
1534         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_path_count = val;
1535 }
1536 /// Selects the maximum share of a channel's total capacity which will be sent over a channel,
1537 /// as a power of 1/2. A higher value prefers to send the payment using more MPP parts whereas
1538 /// a lower value prefers to send larger MPP parts, potentially saturating channels and
1539 /// increasing failure probability for those paths.
1540 ///
1541 /// Note that this restriction will be relaxed during pathfinding after paths which meet this
1542 /// restriction have been found. While paths which meet this criteria will be searched for, it
1543 /// is ultimately up to the scorer to select them over other paths.
1544 ///
1545 /// A value of 0 will allow payments up to and including a channel's total announced usable
1546 /// capacity, a value of one will only use up to half its capacity, two 1/4, etc.
1547 ///
1548 /// Default value: 2
1549 #[no_mangle]
1550 pub extern "C" fn PaymentParameters_get_max_channel_saturation_power_of_half(this_ptr: &PaymentParameters) -> u8 {
1551         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_channel_saturation_power_of_half;
1552         *inner_val
1553 }
1554 /// Selects the maximum share of a channel's total capacity which will be sent over a channel,
1555 /// as a power of 1/2. A higher value prefers to send the payment using more MPP parts whereas
1556 /// a lower value prefers to send larger MPP parts, potentially saturating channels and
1557 /// increasing failure probability for those paths.
1558 ///
1559 /// Note that this restriction will be relaxed during pathfinding after paths which meet this
1560 /// restriction have been found. While paths which meet this criteria will be searched for, it
1561 /// is ultimately up to the scorer to select them over other paths.
1562 ///
1563 /// A value of 0 will allow payments up to and including a channel's total announced usable
1564 /// capacity, a value of one will only use up to half its capacity, two 1/4, etc.
1565 ///
1566 /// Default value: 2
1567 #[no_mangle]
1568 pub extern "C" fn PaymentParameters_set_max_channel_saturation_power_of_half(this_ptr: &mut PaymentParameters, mut val: u8) {
1569         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_channel_saturation_power_of_half = val;
1570 }
1571 /// A list of SCIDs which this payment was previously attempted over and which caused the
1572 /// payment to fail. Future attempts for the same payment shouldn't be relayed through any of
1573 /// these SCIDs.
1574 ///
1575 /// Returns a copy of the field.
1576 #[no_mangle]
1577 pub extern "C" fn PaymentParameters_get_previously_failed_channels(this_ptr: &PaymentParameters) -> crate::c_types::derived::CVec_u64Z {
1578         let mut inner_val = this_ptr.get_native_mut_ref().previously_failed_channels.clone();
1579         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
1580         local_inner_val.into()
1581 }
1582 /// A list of SCIDs which this payment was previously attempted over and which caused the
1583 /// payment to fail. Future attempts for the same payment shouldn't be relayed through any of
1584 /// these SCIDs.
1585 #[no_mangle]
1586 pub extern "C" fn PaymentParameters_set_previously_failed_channels(this_ptr: &mut PaymentParameters, mut val: crate::c_types::derived::CVec_u64Z) {
1587         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
1588         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.previously_failed_channels = local_val;
1589 }
1590 /// A list of indices corresponding to blinded paths in [`Payee::Blinded::route_hints`] which this
1591 /// payment was previously attempted over and which caused the payment to fail. Future attempts
1592 /// for the same payment shouldn't be relayed through any of these blinded paths.
1593 ///
1594 /// Returns a copy of the field.
1595 #[no_mangle]
1596 pub extern "C" fn PaymentParameters_get_previously_failed_blinded_path_idxs(this_ptr: &PaymentParameters) -> crate::c_types::derived::CVec_u64Z {
1597         let mut inner_val = this_ptr.get_native_mut_ref().previously_failed_blinded_path_idxs.clone();
1598         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
1599         local_inner_val.into()
1600 }
1601 /// A list of indices corresponding to blinded paths in [`Payee::Blinded::route_hints`] which this
1602 /// payment was previously attempted over and which caused the payment to fail. Future attempts
1603 /// for the same payment shouldn't be relayed through any of these blinded paths.
1604 #[no_mangle]
1605 pub extern "C" fn PaymentParameters_set_previously_failed_blinded_path_idxs(this_ptr: &mut PaymentParameters, mut val: crate::c_types::derived::CVec_u64Z) {
1606         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
1607         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.previously_failed_blinded_path_idxs = local_val;
1608 }
1609 /// Constructs a new PaymentParameters given each field
1610 #[must_use]
1611 #[no_mangle]
1612 pub extern "C" fn PaymentParameters_new(mut payee_arg: crate::lightning::routing::router::Payee, 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, mut previously_failed_blinded_path_idxs_arg: crate::c_types::derived::CVec_u64Z) -> PaymentParameters {
1613         let mut local_expiry_time_arg = if expiry_time_arg.is_some() { Some( { expiry_time_arg.take() }) } else { None };
1614         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 }); };
1615         let mut local_previously_failed_blinded_path_idxs_arg = Vec::new(); for mut item in previously_failed_blinded_path_idxs_arg.into_rust().drain(..) { local_previously_failed_blinded_path_idxs_arg.push( { item }); };
1616         PaymentParameters { inner: ObjOps::heap_alloc(nativePaymentParameters {
1617                 payee: payee_arg.into_native(),
1618                 expiry_time: local_expiry_time_arg,
1619                 max_total_cltv_expiry_delta: max_total_cltv_expiry_delta_arg,
1620                 max_path_count: max_path_count_arg,
1621                 max_channel_saturation_power_of_half: max_channel_saturation_power_of_half_arg,
1622                 previously_failed_channels: local_previously_failed_channels_arg,
1623                 previously_failed_blinded_path_idxs: local_previously_failed_blinded_path_idxs_arg,
1624         }), is_owned: true }
1625 }
1626 impl Clone for PaymentParameters {
1627         fn clone(&self) -> Self {
1628                 Self {
1629                         inner: if <*mut nativePaymentParameters>::is_null(self.inner) { core::ptr::null_mut() } else {
1630                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1631                         is_owned: true,
1632                 }
1633         }
1634 }
1635 #[allow(unused)]
1636 /// Used only if an object of this type is returned as a trait impl by a method
1637 pub(crate) extern "C" fn PaymentParameters_clone_void(this_ptr: *const c_void) -> *mut c_void {
1638         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePaymentParameters)).clone() })) as *mut c_void
1639 }
1640 #[no_mangle]
1641 /// Creates a copy of the PaymentParameters
1642 pub extern "C" fn PaymentParameters_clone(orig: &PaymentParameters) -> PaymentParameters {
1643         orig.clone()
1644 }
1645 /// Get a string which allows debug introspection of a PaymentParameters object
1646 pub extern "C" fn PaymentParameters_debug_str_void(o: *const c_void) -> Str {
1647         alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::router::PaymentParameters }).into()}
1648 /// Generates a non-cryptographic 64-bit hash of the PaymentParameters.
1649 #[no_mangle]
1650 pub extern "C" fn PaymentParameters_hash(o: &PaymentParameters) -> u64 {
1651         if o.inner.is_null() { return 0; }
1652         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1653         #[allow(deprecated)]
1654         let mut hasher = core::hash::SipHasher::new();
1655         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1656         core::hash::Hasher::finish(&hasher)
1657 }
1658 /// Checks if two PaymentParameterss contain equal inner contents.
1659 /// This ignores pointers and is_owned flags and looks at the values in fields.
1660 /// Two objects with NULL inner values will be considered "equal" here.
1661 #[no_mangle]
1662 pub extern "C" fn PaymentParameters_eq(a: &PaymentParameters, b: &PaymentParameters) -> bool {
1663         if a.inner == b.inner { return true; }
1664         if a.inner.is_null() || b.inner.is_null() { return false; }
1665         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1666 }
1667 #[no_mangle]
1668 /// Serialize the PaymentParameters object into a byte array which can be read by PaymentParameters_read
1669 pub extern "C" fn PaymentParameters_write(obj: &crate::lightning::routing::router::PaymentParameters) -> crate::c_types::derived::CVec_u8Z {
1670         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1671 }
1672 #[allow(unused)]
1673 pub(crate) extern "C" fn PaymentParameters_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1674         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePaymentParameters) })
1675 }
1676 #[no_mangle]
1677 /// Read a PaymentParameters from a byte array, created by PaymentParameters_write
1678 pub extern "C" fn PaymentParameters_read(ser: crate::c_types::u8slice, arg: u32) -> crate::c_types::derived::CResult_PaymentParametersDecodeErrorZ {
1679         let arg_conv = arg;
1680         let res: Result<lightning::routing::router::PaymentParameters, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj_arg(ser, arg_conv);
1681         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() };
1682         local_res
1683 }
1684 /// Creates a payee with the node id of the given `pubkey`.
1685 ///
1686 /// The `final_cltv_expiry_delta` should match the expected final CLTV delta the recipient has
1687 /// provided.
1688 #[must_use]
1689 #[no_mangle]
1690 pub extern "C" fn PaymentParameters_from_node_id(mut payee_pubkey: crate::c_types::PublicKey, mut final_cltv_expiry_delta: u32) -> crate::lightning::routing::router::PaymentParameters {
1691         let mut ret = lightning::routing::router::PaymentParameters::from_node_id(payee_pubkey.into_rust(), final_cltv_expiry_delta);
1692         crate::lightning::routing::router::PaymentParameters { inner: ObjOps::heap_alloc(ret), is_owned: true }
1693 }
1694
1695 /// Creates a payee with the node id of the given `pubkey` to use for keysend payments.
1696 ///
1697 /// The `final_cltv_expiry_delta` should match the expected final CLTV delta the recipient has
1698 /// provided.
1699 ///
1700 /// Note that MPP keysend is not widely supported yet. The `allow_mpp` lets you choose
1701 /// whether your router will be allowed to find a multi-part route for this payment. If you
1702 /// set `allow_mpp` to true, you should ensure a payment secret is set on send, likely via
1703 /// [`RecipientOnionFields::secret_only`].
1704 ///
1705 /// [`RecipientOnionFields::secret_only`]: crate::ln::channelmanager::RecipientOnionFields::secret_only
1706 #[must_use]
1707 #[no_mangle]
1708 pub extern "C" fn PaymentParameters_for_keysend(mut payee_pubkey: crate::c_types::PublicKey, mut final_cltv_expiry_delta: u32, mut allow_mpp: bool) -> crate::lightning::routing::router::PaymentParameters {
1709         let mut ret = lightning::routing::router::PaymentParameters::for_keysend(payee_pubkey.into_rust(), final_cltv_expiry_delta, allow_mpp);
1710         crate::lightning::routing::router::PaymentParameters { inner: ObjOps::heap_alloc(ret), is_owned: true }
1711 }
1712
1713 /// Creates parameters for paying to a blinded payee from the provided invoice. Sets
1714 /// [`Payee::Blinded::route_hints`], [`Payee::Blinded::features`], and
1715 /// [`PaymentParameters::expiry_time`].
1716 #[must_use]
1717 #[no_mangle]
1718 pub extern "C" fn PaymentParameters_from_bolt12_invoice(invoice: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::routing::router::PaymentParameters {
1719         let mut ret = lightning::routing::router::PaymentParameters::from_bolt12_invoice(invoice.get_native_ref());
1720         crate::lightning::routing::router::PaymentParameters { inner: ObjOps::heap_alloc(ret), is_owned: true }
1721 }
1722
1723 /// Creates parameters for paying to a blinded payee from the provided blinded route hints.
1724 #[must_use]
1725 #[no_mangle]
1726 pub extern "C" fn PaymentParameters_blinded(mut blinded_route_hints: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ) -> crate::lightning::routing::router::PaymentParameters {
1727         let mut local_blinded_route_hints = Vec::new(); for mut item in blinded_route_hints.into_rust().drain(..) { local_blinded_route_hints.push( { let (mut orig_blinded_route_hints_0_0, mut orig_blinded_route_hints_0_1) = item.to_rust(); let mut local_blinded_route_hints_0 = (*unsafe { Box::from_raw(orig_blinded_route_hints_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_blinded_route_hints_0_1.take_inner()) }); local_blinded_route_hints_0 }); };
1728         let mut ret = lightning::routing::router::PaymentParameters::blinded(local_blinded_route_hints);
1729         crate::lightning::routing::router::PaymentParameters { inner: ObjOps::heap_alloc(ret), is_owned: true }
1730 }
1731
1732 /// The recipient of a payment, differing based on whether they've hidden their identity with route
1733 /// blinding.
1734 #[derive(Clone)]
1735 #[must_use]
1736 #[repr(C)]
1737 pub enum Payee {
1738         /// The recipient provided blinded paths and payinfo to reach them. The blinded paths themselves
1739         /// will be included in the final [`Route`].
1740         Blinded {
1741                 /// Aggregated routing info and blinded paths, for routing to the payee without knowing their
1742                 /// node id.
1743                 route_hints: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ,
1744                 /// Features supported by the payee.
1745                 ///
1746                 /// May be set from the payee's invoice. May be `None` if the invoice does not contain any
1747                 /// features.
1748                 ///
1749                 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
1750                 features: crate::lightning::ln::features::Bolt12InvoiceFeatures,
1751         },
1752         /// The recipient included these route hints in their BOLT11 invoice.
1753         Clear {
1754                 /// The node id of the payee.
1755                 node_id: crate::c_types::PublicKey,
1756                 /// Hints for routing to the payee, containing channels connecting the payee to public nodes.
1757                 route_hints: crate::c_types::derived::CVec_RouteHintZ,
1758                 /// Features supported by the payee.
1759                 ///
1760                 /// May be set from the payee's invoice or via [`for_keysend`]. May be `None` if the invoice
1761                 /// does not contain any features.
1762                 ///
1763                 /// [`for_keysend`]: PaymentParameters::for_keysend
1764                 ///
1765                 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
1766                 features: crate::lightning::ln::features::Bolt11InvoiceFeatures,
1767                 /// The minimum CLTV delta at the end of the route. This value must not be zero.
1768                 final_cltv_expiry_delta: u32,
1769         },
1770 }
1771 use lightning::routing::router::Payee as PayeeImport;
1772 pub(crate) type nativePayee = PayeeImport;
1773
1774 impl Payee {
1775         #[allow(unused)]
1776         pub(crate) fn to_native(&self) -> nativePayee {
1777                 match self {
1778                         Payee::Blinded {ref route_hints, ref features, } => {
1779                                 let mut route_hints_nonref = Clone::clone(route_hints);
1780                                 let mut local_route_hints_nonref = Vec::new(); for mut item in route_hints_nonref.into_rust().drain(..) { local_route_hints_nonref.push( { let (mut orig_route_hints_nonref_0_0, mut orig_route_hints_nonref_0_1) = item.to_rust(); let mut local_route_hints_nonref_0 = (*unsafe { Box::from_raw(orig_route_hints_nonref_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_route_hints_nonref_0_1.take_inner()) }); local_route_hints_nonref_0 }); };
1781                                 let mut features_nonref = Clone::clone(features);
1782                                 let mut local_features_nonref = if features_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(features_nonref.take_inner()) } }) };
1783                                 nativePayee::Blinded {
1784                                         route_hints: local_route_hints_nonref,
1785                                         features: local_features_nonref,
1786                                 }
1787                         },
1788                         Payee::Clear {ref node_id, ref route_hints, ref features, ref final_cltv_expiry_delta, } => {
1789                                 let mut node_id_nonref = Clone::clone(node_id);
1790                                 let mut route_hints_nonref = Clone::clone(route_hints);
1791                                 let mut local_route_hints_nonref = Vec::new(); for mut item in route_hints_nonref.into_rust().drain(..) { local_route_hints_nonref.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
1792                                 let mut features_nonref = Clone::clone(features);
1793                                 let mut local_features_nonref = if features_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(features_nonref.take_inner()) } }) };
1794                                 let mut final_cltv_expiry_delta_nonref = Clone::clone(final_cltv_expiry_delta);
1795                                 nativePayee::Clear {
1796                                         node_id: node_id_nonref.into_rust(),
1797                                         route_hints: local_route_hints_nonref,
1798                                         features: local_features_nonref,
1799                                         final_cltv_expiry_delta: final_cltv_expiry_delta_nonref,
1800                                 }
1801                         },
1802                 }
1803         }
1804         #[allow(unused)]
1805         pub(crate) fn into_native(self) -> nativePayee {
1806                 match self {
1807                         Payee::Blinded {mut route_hints, mut features, } => {
1808                                 let mut local_route_hints = Vec::new(); for mut item in route_hints.into_rust().drain(..) { local_route_hints.push( { let (mut orig_route_hints_0_0, mut orig_route_hints_0_1) = item.to_rust(); let mut local_route_hints_0 = (*unsafe { Box::from_raw(orig_route_hints_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_route_hints_0_1.take_inner()) }); local_route_hints_0 }); };
1809                                 let mut local_features = if features.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(features.take_inner()) } }) };
1810                                 nativePayee::Blinded {
1811                                         route_hints: local_route_hints,
1812                                         features: local_features,
1813                                 }
1814                         },
1815                         Payee::Clear {mut node_id, mut route_hints, mut features, mut final_cltv_expiry_delta, } => {
1816                                 let mut local_route_hints = Vec::new(); for mut item in route_hints.into_rust().drain(..) { local_route_hints.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
1817                                 let mut local_features = if features.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(features.take_inner()) } }) };
1818                                 nativePayee::Clear {
1819                                         node_id: node_id.into_rust(),
1820                                         route_hints: local_route_hints,
1821                                         features: local_features,
1822                                         final_cltv_expiry_delta: final_cltv_expiry_delta,
1823                                 }
1824                         },
1825                 }
1826         }
1827         #[allow(unused)]
1828         pub(crate) fn from_native(native: &PayeeImport) -> Self {
1829                 let native = unsafe { &*(native as *const _ as *const c_void as *const nativePayee) };
1830                 match native {
1831                         nativePayee::Blinded {ref route_hints, ref features, } => {
1832                                 let mut route_hints_nonref = Clone::clone(route_hints);
1833                                 let mut local_route_hints_nonref = Vec::new(); for mut item in route_hints_nonref.drain(..) { local_route_hints_nonref.push( { let (mut orig_route_hints_nonref_0_0, mut orig_route_hints_nonref_0_1) = item; let mut local_route_hints_nonref_0 = (crate::lightning::offers::invoice::BlindedPayInfo { inner: ObjOps::heap_alloc(orig_route_hints_nonref_0_0), is_owned: true }, crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(orig_route_hints_nonref_0_1), is_owned: true }).into(); local_route_hints_nonref_0 }); };
1834                                 let mut features_nonref = Clone::clone(features);
1835                                 let mut local_features_nonref = crate::lightning::ln::features::Bolt12InvoiceFeatures { inner: if features_nonref.is_none() { core::ptr::null_mut() } else {  { ObjOps::heap_alloc((features_nonref.unwrap())) } }, is_owned: true };
1836                                 Payee::Blinded {
1837                                         route_hints: local_route_hints_nonref.into(),
1838                                         features: local_features_nonref,
1839                                 }
1840                         },
1841                         nativePayee::Clear {ref node_id, ref route_hints, ref features, ref final_cltv_expiry_delta, } => {
1842                                 let mut node_id_nonref = Clone::clone(node_id);
1843                                 let mut route_hints_nonref = Clone::clone(route_hints);
1844                                 let mut local_route_hints_nonref = Vec::new(); for mut item in route_hints_nonref.drain(..) { local_route_hints_nonref.push( { crate::lightning::routing::router::RouteHint { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
1845                                 let mut features_nonref = Clone::clone(features);
1846                                 let mut local_features_nonref = crate::lightning::ln::features::Bolt11InvoiceFeatures { inner: if features_nonref.is_none() { core::ptr::null_mut() } else {  { ObjOps::heap_alloc((features_nonref.unwrap())) } }, is_owned: true };
1847                                 let mut final_cltv_expiry_delta_nonref = Clone::clone(final_cltv_expiry_delta);
1848                                 Payee::Clear {
1849                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
1850                                         route_hints: local_route_hints_nonref.into(),
1851                                         features: local_features_nonref,
1852                                         final_cltv_expiry_delta: final_cltv_expiry_delta_nonref,
1853                                 }
1854                         },
1855                 }
1856         }
1857         #[allow(unused)]
1858         pub(crate) fn native_into(native: nativePayee) -> Self {
1859                 match native {
1860                         nativePayee::Blinded {mut route_hints, mut features, } => {
1861                                 let mut local_route_hints = Vec::new(); for mut item in route_hints.drain(..) { local_route_hints.push( { let (mut orig_route_hints_0_0, mut orig_route_hints_0_1) = item; let mut local_route_hints_0 = (crate::lightning::offers::invoice::BlindedPayInfo { inner: ObjOps::heap_alloc(orig_route_hints_0_0), is_owned: true }, crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(orig_route_hints_0_1), is_owned: true }).into(); local_route_hints_0 }); };
1862                                 let mut local_features = crate::lightning::ln::features::Bolt12InvoiceFeatures { inner: if features.is_none() { core::ptr::null_mut() } else {  { ObjOps::heap_alloc((features.unwrap())) } }, is_owned: true };
1863                                 Payee::Blinded {
1864                                         route_hints: local_route_hints.into(),
1865                                         features: local_features,
1866                                 }
1867                         },
1868                         nativePayee::Clear {mut node_id, mut route_hints, mut features, mut final_cltv_expiry_delta, } => {
1869                                 let mut local_route_hints = Vec::new(); for mut item in route_hints.drain(..) { local_route_hints.push( { crate::lightning::routing::router::RouteHint { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
1870                                 let mut local_features = crate::lightning::ln::features::Bolt11InvoiceFeatures { inner: if features.is_none() { core::ptr::null_mut() } else {  { ObjOps::heap_alloc((features.unwrap())) } }, is_owned: true };
1871                                 Payee::Clear {
1872                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
1873                                         route_hints: local_route_hints.into(),
1874                                         features: local_features,
1875                                         final_cltv_expiry_delta: final_cltv_expiry_delta,
1876                                 }
1877                         },
1878                 }
1879         }
1880 }
1881 /// Frees any resources used by the Payee
1882 #[no_mangle]
1883 pub extern "C" fn Payee_free(this_ptr: Payee) { }
1884 /// Creates a copy of the Payee
1885 #[no_mangle]
1886 pub extern "C" fn Payee_clone(orig: &Payee) -> Payee {
1887         orig.clone()
1888 }
1889 #[allow(unused)]
1890 /// Used only if an object of this type is returned as a trait impl by a method
1891 pub(crate) extern "C" fn Payee_clone_void(this_ptr: *const c_void) -> *mut c_void {
1892         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const Payee)).clone() })) as *mut c_void
1893 }
1894 #[allow(unused)]
1895 /// Used only if an object of this type is returned as a trait impl by a method
1896 pub(crate) extern "C" fn Payee_free_void(this_ptr: *mut c_void) {
1897         let _ = unsafe { Box::from_raw(this_ptr as *mut Payee) };
1898 }
1899 #[no_mangle]
1900 /// Utility method to constructs a new Blinded-variant Payee
1901 pub extern "C" fn Payee_blinded(route_hints: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ, features: crate::lightning::ln::features::Bolt12InvoiceFeatures) -> Payee {
1902         Payee::Blinded {
1903                 route_hints,
1904                 features,
1905         }
1906 }
1907 #[no_mangle]
1908 /// Utility method to constructs a new Clear-variant Payee
1909 pub extern "C" fn Payee_clear(node_id: crate::c_types::PublicKey, route_hints: crate::c_types::derived::CVec_RouteHintZ, features: crate::lightning::ln::features::Bolt11InvoiceFeatures, final_cltv_expiry_delta: u32) -> Payee {
1910         Payee::Clear {
1911                 node_id,
1912                 route_hints,
1913                 features,
1914                 final_cltv_expiry_delta,
1915         }
1916 }
1917 /// Get a string which allows debug introspection of a Payee object
1918 pub extern "C" fn Payee_debug_str_void(o: *const c_void) -> Str {
1919         alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::router::Payee }).into()}
1920 /// Generates a non-cryptographic 64-bit hash of the Payee.
1921 #[no_mangle]
1922 pub extern "C" fn Payee_hash(o: &Payee) -> u64 {
1923         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1924         #[allow(deprecated)]
1925         let mut hasher = core::hash::SipHasher::new();
1926         core::hash::Hash::hash(&o.to_native(), &mut hasher);
1927         core::hash::Hasher::finish(&hasher)
1928 }
1929 /// Checks if two Payees contain equal inner contents.
1930 /// This ignores pointers and is_owned flags and looks at the values in fields.
1931 #[no_mangle]
1932 pub extern "C" fn Payee_eq(a: &Payee, b: &Payee) -> bool {
1933         if &a.to_native() == &b.to_native() { true } else { false }
1934 }
1935
1936 use lightning::routing::router::RouteHint as nativeRouteHintImport;
1937 pub(crate) type nativeRouteHint = nativeRouteHintImport;
1938
1939 /// A list of hops along a payment path terminating with a channel to the recipient.
1940 #[must_use]
1941 #[repr(C)]
1942 pub struct RouteHint {
1943         /// A pointer to the opaque Rust object.
1944
1945         /// Nearly everywhere, inner must be non-null, however in places where
1946         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1947         pub inner: *mut nativeRouteHint,
1948         /// Indicates that this is the only struct which contains the same pointer.
1949
1950         /// Rust functions which take ownership of an object provided via an argument require
1951         /// this to be true and invalidate the object pointed to by inner.
1952         pub is_owned: bool,
1953 }
1954
1955 impl Drop for RouteHint {
1956         fn drop(&mut self) {
1957                 if self.is_owned && !<*mut nativeRouteHint>::is_null(self.inner) {
1958                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1959                 }
1960         }
1961 }
1962 /// Frees any resources used by the RouteHint, if is_owned is set and inner is non-NULL.
1963 #[no_mangle]
1964 pub extern "C" fn RouteHint_free(this_obj: RouteHint) { }
1965 #[allow(unused)]
1966 /// Used only if an object of this type is returned as a trait impl by a method
1967 pub(crate) extern "C" fn RouteHint_free_void(this_ptr: *mut c_void) {
1968         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRouteHint) };
1969 }
1970 #[allow(unused)]
1971 impl RouteHint {
1972         pub(crate) fn get_native_ref(&self) -> &'static nativeRouteHint {
1973                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1974         }
1975         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRouteHint {
1976                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1977         }
1978         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1979         pub(crate) fn take_inner(mut self) -> *mut nativeRouteHint {
1980                 assert!(self.is_owned);
1981                 let ret = ObjOps::untweak_ptr(self.inner);
1982                 self.inner = core::ptr::null_mut();
1983                 ret
1984         }
1985 }
1986 #[no_mangle]
1987 pub extern "C" fn RouteHint_get_a(this_ptr: &RouteHint) -> crate::c_types::derived::CVec_RouteHintHopZ {
1988         let mut inner_val = &mut this_ptr.get_native_mut_ref().0;
1989         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 } }); };
1990         local_inner_val.into()
1991 }
1992 #[no_mangle]
1993 pub extern "C" fn RouteHint_set_a(this_ptr: &mut RouteHint, mut val: crate::c_types::derived::CVec_RouteHintHopZ) {
1994         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
1995         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.0 = local_val;
1996 }
1997 /// Constructs a new RouteHint given each field
1998 #[must_use]
1999 #[no_mangle]
2000 pub extern "C" fn RouteHint_new(mut a_arg: crate::c_types::derived::CVec_RouteHintHopZ) -> RouteHint {
2001         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()) } }); };
2002         RouteHint { inner: ObjOps::heap_alloc(lightning::routing::router::RouteHint (
2003                 local_a_arg,
2004         )), is_owned: true }
2005 }
2006 impl Clone for RouteHint {
2007         fn clone(&self) -> Self {
2008                 Self {
2009                         inner: if <*mut nativeRouteHint>::is_null(self.inner) { core::ptr::null_mut() } else {
2010                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2011                         is_owned: true,
2012                 }
2013         }
2014 }
2015 #[allow(unused)]
2016 /// Used only if an object of this type is returned as a trait impl by a method
2017 pub(crate) extern "C" fn RouteHint_clone_void(this_ptr: *const c_void) -> *mut c_void {
2018         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRouteHint)).clone() })) as *mut c_void
2019 }
2020 #[no_mangle]
2021 /// Creates a copy of the RouteHint
2022 pub extern "C" fn RouteHint_clone(orig: &RouteHint) -> RouteHint {
2023         orig.clone()
2024 }
2025 /// Get a string which allows debug introspection of a RouteHint object
2026 pub extern "C" fn RouteHint_debug_str_void(o: *const c_void) -> Str {
2027         alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::router::RouteHint }).into()}
2028 /// Generates a non-cryptographic 64-bit hash of the RouteHint.
2029 #[no_mangle]
2030 pub extern "C" fn RouteHint_hash(o: &RouteHint) -> u64 {
2031         if o.inner.is_null() { return 0; }
2032         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
2033         #[allow(deprecated)]
2034         let mut hasher = core::hash::SipHasher::new();
2035         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
2036         core::hash::Hasher::finish(&hasher)
2037 }
2038 /// Checks if two RouteHints contain equal inner contents.
2039 /// This ignores pointers and is_owned flags and looks at the values in fields.
2040 /// Two objects with NULL inner values will be considered "equal" here.
2041 #[no_mangle]
2042 pub extern "C" fn RouteHint_eq(a: &RouteHint, b: &RouteHint) -> bool {
2043         if a.inner == b.inner { return true; }
2044         if a.inner.is_null() || b.inner.is_null() { return false; }
2045         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2046 }
2047 #[no_mangle]
2048 /// Serialize the RouteHint object into a byte array which can be read by RouteHint_read
2049 pub extern "C" fn RouteHint_write(obj: &crate::lightning::routing::router::RouteHint) -> crate::c_types::derived::CVec_u8Z {
2050         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
2051 }
2052 #[allow(unused)]
2053 pub(crate) extern "C" fn RouteHint_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
2054         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRouteHint) })
2055 }
2056 #[no_mangle]
2057 /// Read a RouteHint from a byte array, created by RouteHint_write
2058 pub extern "C" fn RouteHint_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RouteHintDecodeErrorZ {
2059         let res: Result<lightning::routing::router::RouteHint, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
2060         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() };
2061         local_res
2062 }
2063
2064 use lightning::routing::router::RouteHintHop as nativeRouteHintHopImport;
2065 pub(crate) type nativeRouteHintHop = nativeRouteHintHopImport;
2066
2067 /// A channel descriptor for a hop along a payment path.
2068 ///
2069 /// While this generally comes from BOLT 11's `r` field, this struct includes more fields than are
2070 /// available in BOLT 11. Thus, encoding and decoding this via `lightning-invoice` is lossy, as
2071 /// fields not supported in BOLT 11 will be stripped.
2072 #[must_use]
2073 #[repr(C)]
2074 pub struct RouteHintHop {
2075         /// A pointer to the opaque Rust object.
2076
2077         /// Nearly everywhere, inner must be non-null, however in places where
2078         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2079         pub inner: *mut nativeRouteHintHop,
2080         /// Indicates that this is the only struct which contains the same pointer.
2081
2082         /// Rust functions which take ownership of an object provided via an argument require
2083         /// this to be true and invalidate the object pointed to by inner.
2084         pub is_owned: bool,
2085 }
2086
2087 impl Drop for RouteHintHop {
2088         fn drop(&mut self) {
2089                 if self.is_owned && !<*mut nativeRouteHintHop>::is_null(self.inner) {
2090                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2091                 }
2092         }
2093 }
2094 /// Frees any resources used by the RouteHintHop, if is_owned is set and inner is non-NULL.
2095 #[no_mangle]
2096 pub extern "C" fn RouteHintHop_free(this_obj: RouteHintHop) { }
2097 #[allow(unused)]
2098 /// Used only if an object of this type is returned as a trait impl by a method
2099 pub(crate) extern "C" fn RouteHintHop_free_void(this_ptr: *mut c_void) {
2100         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRouteHintHop) };
2101 }
2102 #[allow(unused)]
2103 impl RouteHintHop {
2104         pub(crate) fn get_native_ref(&self) -> &'static nativeRouteHintHop {
2105                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2106         }
2107         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRouteHintHop {
2108                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2109         }
2110         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2111         pub(crate) fn take_inner(mut self) -> *mut nativeRouteHintHop {
2112                 assert!(self.is_owned);
2113                 let ret = ObjOps::untweak_ptr(self.inner);
2114                 self.inner = core::ptr::null_mut();
2115                 ret
2116         }
2117 }
2118 /// The node_id of the non-target end of the route
2119 #[no_mangle]
2120 pub extern "C" fn RouteHintHop_get_src_node_id(this_ptr: &RouteHintHop) -> crate::c_types::PublicKey {
2121         let mut inner_val = &mut this_ptr.get_native_mut_ref().src_node_id;
2122         crate::c_types::PublicKey::from_rust(&inner_val)
2123 }
2124 /// The node_id of the non-target end of the route
2125 #[no_mangle]
2126 pub extern "C" fn RouteHintHop_set_src_node_id(this_ptr: &mut RouteHintHop, mut val: crate::c_types::PublicKey) {
2127         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.src_node_id = val.into_rust();
2128 }
2129 /// The short_channel_id of this channel
2130 #[no_mangle]
2131 pub extern "C" fn RouteHintHop_get_short_channel_id(this_ptr: &RouteHintHop) -> u64 {
2132         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
2133         *inner_val
2134 }
2135 /// The short_channel_id of this channel
2136 #[no_mangle]
2137 pub extern "C" fn RouteHintHop_set_short_channel_id(this_ptr: &mut RouteHintHop, mut val: u64) {
2138         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
2139 }
2140 /// The fees which must be paid to use this channel
2141 #[no_mangle]
2142 pub extern "C" fn RouteHintHop_get_fees(this_ptr: &RouteHintHop) -> crate::lightning::routing::gossip::RoutingFees {
2143         let mut inner_val = &mut this_ptr.get_native_mut_ref().fees;
2144         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 }
2145 }
2146 /// The fees which must be paid to use this channel
2147 #[no_mangle]
2148 pub extern "C" fn RouteHintHop_set_fees(this_ptr: &mut RouteHintHop, mut val: crate::lightning::routing::gossip::RoutingFees) {
2149         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fees = *unsafe { Box::from_raw(val.take_inner()) };
2150 }
2151 /// The difference in CLTV values between this node and the next node.
2152 #[no_mangle]
2153 pub extern "C" fn RouteHintHop_get_cltv_expiry_delta(this_ptr: &RouteHintHop) -> u16 {
2154         let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
2155         *inner_val
2156 }
2157 /// The difference in CLTV values between this node and the next node.
2158 #[no_mangle]
2159 pub extern "C" fn RouteHintHop_set_cltv_expiry_delta(this_ptr: &mut RouteHintHop, mut val: u16) {
2160         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
2161 }
2162 /// The minimum value, in msat, which must be relayed to the next hop.
2163 #[no_mangle]
2164 pub extern "C" fn RouteHintHop_get_htlc_minimum_msat(this_ptr: &RouteHintHop) -> crate::c_types::derived::COption_u64Z {
2165         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
2166         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() }) };
2167         local_inner_val
2168 }
2169 /// The minimum value, in msat, which must be relayed to the next hop.
2170 #[no_mangle]
2171 pub extern "C" fn RouteHintHop_set_htlc_minimum_msat(this_ptr: &mut RouteHintHop, mut val: crate::c_types::derived::COption_u64Z) {
2172         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
2173         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = local_val;
2174 }
2175 /// The maximum value in msat available for routing with a single HTLC.
2176 #[no_mangle]
2177 pub extern "C" fn RouteHintHop_get_htlc_maximum_msat(this_ptr: &RouteHintHop) -> crate::c_types::derived::COption_u64Z {
2178         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat;
2179         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() }) };
2180         local_inner_val
2181 }
2182 /// The maximum value in msat available for routing with a single HTLC.
2183 #[no_mangle]
2184 pub extern "C" fn RouteHintHop_set_htlc_maximum_msat(this_ptr: &mut RouteHintHop, mut val: crate::c_types::derived::COption_u64Z) {
2185         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
2186         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = local_val;
2187 }
2188 /// Constructs a new RouteHintHop given each field
2189 #[must_use]
2190 #[no_mangle]
2191 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 {
2192         let mut local_htlc_minimum_msat_arg = if htlc_minimum_msat_arg.is_some() { Some( { htlc_minimum_msat_arg.take() }) } else { None };
2193         let mut local_htlc_maximum_msat_arg = if htlc_maximum_msat_arg.is_some() { Some( { htlc_maximum_msat_arg.take() }) } else { None };
2194         RouteHintHop { inner: ObjOps::heap_alloc(nativeRouteHintHop {
2195                 src_node_id: src_node_id_arg.into_rust(),
2196                 short_channel_id: short_channel_id_arg,
2197                 fees: *unsafe { Box::from_raw(fees_arg.take_inner()) },
2198                 cltv_expiry_delta: cltv_expiry_delta_arg,
2199                 htlc_minimum_msat: local_htlc_minimum_msat_arg,
2200                 htlc_maximum_msat: local_htlc_maximum_msat_arg,
2201         }), is_owned: true }
2202 }
2203 impl Clone for RouteHintHop {
2204         fn clone(&self) -> Self {
2205                 Self {
2206                         inner: if <*mut nativeRouteHintHop>::is_null(self.inner) { core::ptr::null_mut() } else {
2207                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2208                         is_owned: true,
2209                 }
2210         }
2211 }
2212 #[allow(unused)]
2213 /// Used only if an object of this type is returned as a trait impl by a method
2214 pub(crate) extern "C" fn RouteHintHop_clone_void(this_ptr: *const c_void) -> *mut c_void {
2215         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRouteHintHop)).clone() })) as *mut c_void
2216 }
2217 #[no_mangle]
2218 /// Creates a copy of the RouteHintHop
2219 pub extern "C" fn RouteHintHop_clone(orig: &RouteHintHop) -> RouteHintHop {
2220         orig.clone()
2221 }
2222 /// Get a string which allows debug introspection of a RouteHintHop object
2223 pub extern "C" fn RouteHintHop_debug_str_void(o: *const c_void) -> Str {
2224         alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::router::RouteHintHop }).into()}
2225 /// Generates a non-cryptographic 64-bit hash of the RouteHintHop.
2226 #[no_mangle]
2227 pub extern "C" fn RouteHintHop_hash(o: &RouteHintHop) -> u64 {
2228         if o.inner.is_null() { return 0; }
2229         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
2230         #[allow(deprecated)]
2231         let mut hasher = core::hash::SipHasher::new();
2232         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
2233         core::hash::Hasher::finish(&hasher)
2234 }
2235 /// Checks if two RouteHintHops contain equal inner contents.
2236 /// This ignores pointers and is_owned flags and looks at the values in fields.
2237 /// Two objects with NULL inner values will be considered "equal" here.
2238 #[no_mangle]
2239 pub extern "C" fn RouteHintHop_eq(a: &RouteHintHop, b: &RouteHintHop) -> bool {
2240         if a.inner == b.inner { return true; }
2241         if a.inner.is_null() || b.inner.is_null() { return false; }
2242         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2243 }
2244 #[no_mangle]
2245 /// Serialize the RouteHintHop object into a byte array which can be read by RouteHintHop_read
2246 pub extern "C" fn RouteHintHop_write(obj: &crate::lightning::routing::router::RouteHintHop) -> crate::c_types::derived::CVec_u8Z {
2247         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
2248 }
2249 #[allow(unused)]
2250 pub(crate) extern "C" fn RouteHintHop_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
2251         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRouteHintHop) })
2252 }
2253 #[no_mangle]
2254 /// Read a RouteHintHop from a byte array, created by RouteHintHop_write
2255 pub extern "C" fn RouteHintHop_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RouteHintHopDecodeErrorZ {
2256         let res: Result<lightning::routing::router::RouteHintHop, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
2257         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() };
2258         local_res
2259 }
2260
2261 use lightning::routing::router::FirstHopCandidate as nativeFirstHopCandidateImport;
2262 pub(crate) type nativeFirstHopCandidate = nativeFirstHopCandidateImport<'static>;
2263
2264 /// A [`CandidateRouteHop::FirstHop`] entry.
2265 #[must_use]
2266 #[repr(C)]
2267 pub struct FirstHopCandidate {
2268         /// A pointer to the opaque Rust object.
2269
2270         /// Nearly everywhere, inner must be non-null, however in places where
2271         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2272         pub inner: *mut nativeFirstHopCandidate,
2273         /// Indicates that this is the only struct which contains the same pointer.
2274
2275         /// Rust functions which take ownership of an object provided via an argument require
2276         /// this to be true and invalidate the object pointed to by inner.
2277         pub is_owned: bool,
2278 }
2279
2280 impl Drop for FirstHopCandidate {
2281         fn drop(&mut self) {
2282                 if self.is_owned && !<*mut nativeFirstHopCandidate>::is_null(self.inner) {
2283                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2284                 }
2285         }
2286 }
2287 /// Frees any resources used by the FirstHopCandidate, if is_owned is set and inner is non-NULL.
2288 #[no_mangle]
2289 pub extern "C" fn FirstHopCandidate_free(this_obj: FirstHopCandidate) { }
2290 #[allow(unused)]
2291 /// Used only if an object of this type is returned as a trait impl by a method
2292 pub(crate) extern "C" fn FirstHopCandidate_free_void(this_ptr: *mut c_void) {
2293         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFirstHopCandidate) };
2294 }
2295 #[allow(unused)]
2296 impl FirstHopCandidate {
2297         pub(crate) fn get_native_ref(&self) -> &'static nativeFirstHopCandidate {
2298                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2299         }
2300         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFirstHopCandidate {
2301                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2302         }
2303         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2304         pub(crate) fn take_inner(mut self) -> *mut nativeFirstHopCandidate {
2305                 assert!(self.is_owned);
2306                 let ret = ObjOps::untweak_ptr(self.inner);
2307                 self.inner = core::ptr::null_mut();
2308                 ret
2309         }
2310 }
2311 impl Clone for FirstHopCandidate {
2312         fn clone(&self) -> Self {
2313                 Self {
2314                         inner: if <*mut nativeFirstHopCandidate>::is_null(self.inner) { core::ptr::null_mut() } else {
2315                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2316                         is_owned: true,
2317                 }
2318         }
2319 }
2320 #[allow(unused)]
2321 /// Used only if an object of this type is returned as a trait impl by a method
2322 pub(crate) extern "C" fn FirstHopCandidate_clone_void(this_ptr: *const c_void) -> *mut c_void {
2323         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeFirstHopCandidate)).clone() })) as *mut c_void
2324 }
2325 #[no_mangle]
2326 /// Creates a copy of the FirstHopCandidate
2327 pub extern "C" fn FirstHopCandidate_clone(orig: &FirstHopCandidate) -> FirstHopCandidate {
2328         orig.clone()
2329 }
2330 /// Get a string which allows debug introspection of a FirstHopCandidate object
2331 pub extern "C" fn FirstHopCandidate_debug_str_void(o: *const c_void) -> Str {
2332         alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::router::FirstHopCandidate }).into()}
2333
2334 use lightning::routing::router::PublicHopCandidate as nativePublicHopCandidateImport;
2335 pub(crate) type nativePublicHopCandidate = nativePublicHopCandidateImport<'static>;
2336
2337 /// A [`CandidateRouteHop::PublicHop`] entry.
2338 #[must_use]
2339 #[repr(C)]
2340 pub struct PublicHopCandidate {
2341         /// A pointer to the opaque Rust object.
2342
2343         /// Nearly everywhere, inner must be non-null, however in places where
2344         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2345         pub inner: *mut nativePublicHopCandidate,
2346         /// Indicates that this is the only struct which contains the same pointer.
2347
2348         /// Rust functions which take ownership of an object provided via an argument require
2349         /// this to be true and invalidate the object pointed to by inner.
2350         pub is_owned: bool,
2351 }
2352
2353 impl Drop for PublicHopCandidate {
2354         fn drop(&mut self) {
2355                 if self.is_owned && !<*mut nativePublicHopCandidate>::is_null(self.inner) {
2356                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2357                 }
2358         }
2359 }
2360 /// Frees any resources used by the PublicHopCandidate, if is_owned is set and inner is non-NULL.
2361 #[no_mangle]
2362 pub extern "C" fn PublicHopCandidate_free(this_obj: PublicHopCandidate) { }
2363 #[allow(unused)]
2364 /// Used only if an object of this type is returned as a trait impl by a method
2365 pub(crate) extern "C" fn PublicHopCandidate_free_void(this_ptr: *mut c_void) {
2366         let _ = unsafe { Box::from_raw(this_ptr as *mut nativePublicHopCandidate) };
2367 }
2368 #[allow(unused)]
2369 impl PublicHopCandidate {
2370         pub(crate) fn get_native_ref(&self) -> &'static nativePublicHopCandidate {
2371                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2372         }
2373         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePublicHopCandidate {
2374                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2375         }
2376         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2377         pub(crate) fn take_inner(mut self) -> *mut nativePublicHopCandidate {
2378                 assert!(self.is_owned);
2379                 let ret = ObjOps::untweak_ptr(self.inner);
2380                 self.inner = core::ptr::null_mut();
2381                 ret
2382         }
2383 }
2384 /// The short channel ID of the channel, i.e. the identifier by which we refer to this
2385 /// channel.
2386 #[no_mangle]
2387 pub extern "C" fn PublicHopCandidate_get_short_channel_id(this_ptr: &PublicHopCandidate) -> u64 {
2388         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
2389         *inner_val
2390 }
2391 /// The short channel ID of the channel, i.e. the identifier by which we refer to this
2392 /// channel.
2393 #[no_mangle]
2394 pub extern "C" fn PublicHopCandidate_set_short_channel_id(this_ptr: &mut PublicHopCandidate, mut val: u64) {
2395         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
2396 }
2397 impl Clone for PublicHopCandidate {
2398         fn clone(&self) -> Self {
2399                 Self {
2400                         inner: if <*mut nativePublicHopCandidate>::is_null(self.inner) { core::ptr::null_mut() } else {
2401                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2402                         is_owned: true,
2403                 }
2404         }
2405 }
2406 #[allow(unused)]
2407 /// Used only if an object of this type is returned as a trait impl by a method
2408 pub(crate) extern "C" fn PublicHopCandidate_clone_void(this_ptr: *const c_void) -> *mut c_void {
2409         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePublicHopCandidate)).clone() })) as *mut c_void
2410 }
2411 #[no_mangle]
2412 /// Creates a copy of the PublicHopCandidate
2413 pub extern "C" fn PublicHopCandidate_clone(orig: &PublicHopCandidate) -> PublicHopCandidate {
2414         orig.clone()
2415 }
2416 /// Get a string which allows debug introspection of a PublicHopCandidate object
2417 pub extern "C" fn PublicHopCandidate_debug_str_void(o: *const c_void) -> Str {
2418         alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::router::PublicHopCandidate }).into()}
2419
2420 use lightning::routing::router::PrivateHopCandidate as nativePrivateHopCandidateImport;
2421 pub(crate) type nativePrivateHopCandidate = nativePrivateHopCandidateImport<'static>;
2422
2423 /// A [`CandidateRouteHop::PrivateHop`] entry.
2424 #[must_use]
2425 #[repr(C)]
2426 pub struct PrivateHopCandidate {
2427         /// A pointer to the opaque Rust object.
2428
2429         /// Nearly everywhere, inner must be non-null, however in places where
2430         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2431         pub inner: *mut nativePrivateHopCandidate,
2432         /// Indicates that this is the only struct which contains the same pointer.
2433
2434         /// Rust functions which take ownership of an object provided via an argument require
2435         /// this to be true and invalidate the object pointed to by inner.
2436         pub is_owned: bool,
2437 }
2438
2439 impl Drop for PrivateHopCandidate {
2440         fn drop(&mut self) {
2441                 if self.is_owned && !<*mut nativePrivateHopCandidate>::is_null(self.inner) {
2442                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2443                 }
2444         }
2445 }
2446 /// Frees any resources used by the PrivateHopCandidate, if is_owned is set and inner is non-NULL.
2447 #[no_mangle]
2448 pub extern "C" fn PrivateHopCandidate_free(this_obj: PrivateHopCandidate) { }
2449 #[allow(unused)]
2450 /// Used only if an object of this type is returned as a trait impl by a method
2451 pub(crate) extern "C" fn PrivateHopCandidate_free_void(this_ptr: *mut c_void) {
2452         let _ = unsafe { Box::from_raw(this_ptr as *mut nativePrivateHopCandidate) };
2453 }
2454 #[allow(unused)]
2455 impl PrivateHopCandidate {
2456         pub(crate) fn get_native_ref(&self) -> &'static nativePrivateHopCandidate {
2457                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2458         }
2459         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePrivateHopCandidate {
2460                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2461         }
2462         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2463         pub(crate) fn take_inner(mut self) -> *mut nativePrivateHopCandidate {
2464                 assert!(self.is_owned);
2465                 let ret = ObjOps::untweak_ptr(self.inner);
2466                 self.inner = core::ptr::null_mut();
2467                 ret
2468         }
2469 }
2470 impl Clone for PrivateHopCandidate {
2471         fn clone(&self) -> Self {
2472                 Self {
2473                         inner: if <*mut nativePrivateHopCandidate>::is_null(self.inner) { core::ptr::null_mut() } else {
2474                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2475                         is_owned: true,
2476                 }
2477         }
2478 }
2479 #[allow(unused)]
2480 /// Used only if an object of this type is returned as a trait impl by a method
2481 pub(crate) extern "C" fn PrivateHopCandidate_clone_void(this_ptr: *const c_void) -> *mut c_void {
2482         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePrivateHopCandidate)).clone() })) as *mut c_void
2483 }
2484 #[no_mangle]
2485 /// Creates a copy of the PrivateHopCandidate
2486 pub extern "C" fn PrivateHopCandidate_clone(orig: &PrivateHopCandidate) -> PrivateHopCandidate {
2487         orig.clone()
2488 }
2489 /// Get a string which allows debug introspection of a PrivateHopCandidate object
2490 pub extern "C" fn PrivateHopCandidate_debug_str_void(o: *const c_void) -> Str {
2491         alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::router::PrivateHopCandidate }).into()}
2492
2493 use lightning::routing::router::BlindedPathCandidate as nativeBlindedPathCandidateImport;
2494 pub(crate) type nativeBlindedPathCandidate = nativeBlindedPathCandidateImport<'static>;
2495
2496 /// A [`CandidateRouteHop::Blinded`] entry.
2497 #[must_use]
2498 #[repr(C)]
2499 pub struct BlindedPathCandidate {
2500         /// A pointer to the opaque Rust object.
2501
2502         /// Nearly everywhere, inner must be non-null, however in places where
2503         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2504         pub inner: *mut nativeBlindedPathCandidate,
2505         /// Indicates that this is the only struct which contains the same pointer.
2506
2507         /// Rust functions which take ownership of an object provided via an argument require
2508         /// this to be true and invalidate the object pointed to by inner.
2509         pub is_owned: bool,
2510 }
2511
2512 impl Drop for BlindedPathCandidate {
2513         fn drop(&mut self) {
2514                 if self.is_owned && !<*mut nativeBlindedPathCandidate>::is_null(self.inner) {
2515                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2516                 }
2517         }
2518 }
2519 /// Frees any resources used by the BlindedPathCandidate, if is_owned is set and inner is non-NULL.
2520 #[no_mangle]
2521 pub extern "C" fn BlindedPathCandidate_free(this_obj: BlindedPathCandidate) { }
2522 #[allow(unused)]
2523 /// Used only if an object of this type is returned as a trait impl by a method
2524 pub(crate) extern "C" fn BlindedPathCandidate_free_void(this_ptr: *mut c_void) {
2525         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBlindedPathCandidate) };
2526 }
2527 #[allow(unused)]
2528 impl BlindedPathCandidate {
2529         pub(crate) fn get_native_ref(&self) -> &'static nativeBlindedPathCandidate {
2530                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2531         }
2532         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBlindedPathCandidate {
2533                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2534         }
2535         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2536         pub(crate) fn take_inner(mut self) -> *mut nativeBlindedPathCandidate {
2537                 assert!(self.is_owned);
2538                 let ret = ObjOps::untweak_ptr(self.inner);
2539                 self.inner = core::ptr::null_mut();
2540                 ret
2541         }
2542 }
2543 impl Clone for BlindedPathCandidate {
2544         fn clone(&self) -> Self {
2545                 Self {
2546                         inner: if <*mut nativeBlindedPathCandidate>::is_null(self.inner) { core::ptr::null_mut() } else {
2547                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2548                         is_owned: true,
2549                 }
2550         }
2551 }
2552 #[allow(unused)]
2553 /// Used only if an object of this type is returned as a trait impl by a method
2554 pub(crate) extern "C" fn BlindedPathCandidate_clone_void(this_ptr: *const c_void) -> *mut c_void {
2555         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBlindedPathCandidate)).clone() })) as *mut c_void
2556 }
2557 #[no_mangle]
2558 /// Creates a copy of the BlindedPathCandidate
2559 pub extern "C" fn BlindedPathCandidate_clone(orig: &BlindedPathCandidate) -> BlindedPathCandidate {
2560         orig.clone()
2561 }
2562 /// Get a string which allows debug introspection of a BlindedPathCandidate object
2563 pub extern "C" fn BlindedPathCandidate_debug_str_void(o: *const c_void) -> Str {
2564         alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::router::BlindedPathCandidate }).into()}
2565
2566 use lightning::routing::router::OneHopBlindedPathCandidate as nativeOneHopBlindedPathCandidateImport;
2567 pub(crate) type nativeOneHopBlindedPathCandidate = nativeOneHopBlindedPathCandidateImport<'static>;
2568
2569 /// A [`CandidateRouteHop::OneHopBlinded`] entry.
2570 #[must_use]
2571 #[repr(C)]
2572 pub struct OneHopBlindedPathCandidate {
2573         /// A pointer to the opaque Rust object.
2574
2575         /// Nearly everywhere, inner must be non-null, however in places where
2576         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2577         pub inner: *mut nativeOneHopBlindedPathCandidate,
2578         /// Indicates that this is the only struct which contains the same pointer.
2579
2580         /// Rust functions which take ownership of an object provided via an argument require
2581         /// this to be true and invalidate the object pointed to by inner.
2582         pub is_owned: bool,
2583 }
2584
2585 impl Drop for OneHopBlindedPathCandidate {
2586         fn drop(&mut self) {
2587                 if self.is_owned && !<*mut nativeOneHopBlindedPathCandidate>::is_null(self.inner) {
2588                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2589                 }
2590         }
2591 }
2592 /// Frees any resources used by the OneHopBlindedPathCandidate, if is_owned is set and inner is non-NULL.
2593 #[no_mangle]
2594 pub extern "C" fn OneHopBlindedPathCandidate_free(this_obj: OneHopBlindedPathCandidate) { }
2595 #[allow(unused)]
2596 /// Used only if an object of this type is returned as a trait impl by a method
2597 pub(crate) extern "C" fn OneHopBlindedPathCandidate_free_void(this_ptr: *mut c_void) {
2598         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOneHopBlindedPathCandidate) };
2599 }
2600 #[allow(unused)]
2601 impl OneHopBlindedPathCandidate {
2602         pub(crate) fn get_native_ref(&self) -> &'static nativeOneHopBlindedPathCandidate {
2603                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2604         }
2605         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOneHopBlindedPathCandidate {
2606                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2607         }
2608         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2609         pub(crate) fn take_inner(mut self) -> *mut nativeOneHopBlindedPathCandidate {
2610                 assert!(self.is_owned);
2611                 let ret = ObjOps::untweak_ptr(self.inner);
2612                 self.inner = core::ptr::null_mut();
2613                 ret
2614         }
2615 }
2616 impl Clone for OneHopBlindedPathCandidate {
2617         fn clone(&self) -> Self {
2618                 Self {
2619                         inner: if <*mut nativeOneHopBlindedPathCandidate>::is_null(self.inner) { core::ptr::null_mut() } else {
2620                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2621                         is_owned: true,
2622                 }
2623         }
2624 }
2625 #[allow(unused)]
2626 /// Used only if an object of this type is returned as a trait impl by a method
2627 pub(crate) extern "C" fn OneHopBlindedPathCandidate_clone_void(this_ptr: *const c_void) -> *mut c_void {
2628         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOneHopBlindedPathCandidate)).clone() })) as *mut c_void
2629 }
2630 #[no_mangle]
2631 /// Creates a copy of the OneHopBlindedPathCandidate
2632 pub extern "C" fn OneHopBlindedPathCandidate_clone(orig: &OneHopBlindedPathCandidate) -> OneHopBlindedPathCandidate {
2633         orig.clone()
2634 }
2635 /// Get a string which allows debug introspection of a OneHopBlindedPathCandidate object
2636 pub extern "C" fn OneHopBlindedPathCandidate_debug_str_void(o: *const c_void) -> Str {
2637         alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::router::OneHopBlindedPathCandidate }).into()}
2638 /// A wrapper around the various hop representations.
2639 ///
2640 /// Can be used to examine the properties of a hop,
2641 /// potentially to decide whether to include it in a route.
2642 #[derive(Clone)]
2643 #[must_use]
2644 #[repr(C)]
2645 pub enum CandidateRouteHop {
2646         /// A hop from the payer, where the outbound liquidity is known.
2647         FirstHop(
2648                 crate::lightning::routing::router::FirstHopCandidate),
2649         /// A hop found in the [`ReadOnlyNetworkGraph`].
2650         PublicHop(
2651                 crate::lightning::routing::router::PublicHopCandidate),
2652         /// A private hop communicated by the payee, generally via a BOLT 11 invoice.
2653         ///
2654         /// Because BOLT 11 route hints can take multiple hops to get to the destination, this may not
2655         /// terminate at the payee.
2656         PrivateHop(
2657                 crate::lightning::routing::router::PrivateHopCandidate),
2658         /// A blinded path which starts with an introduction point and ultimately terminates with the
2659         /// payee.
2660         ///
2661         /// Because we don't know the payee's identity, [`CandidateRouteHop::target`] will return
2662         /// `None` in this state.
2663         ///
2664         /// Because blinded paths are \"all or nothing\", and we cannot use just one part of a blinded
2665         /// path, the full path is treated as a single [`CandidateRouteHop`].
2666         Blinded(
2667                 crate::lightning::routing::router::BlindedPathCandidate),
2668         /// Similar to [`Self::Blinded`], but the path here only has one hop.
2669         ///
2670         /// While we treat this similarly to [`CandidateRouteHop::Blinded`] in many respects (e.g.
2671         /// returning `None` from [`CandidateRouteHop::target`]), in this case we do actually know the
2672         /// payee's identity - it's the introduction point!
2673         ///
2674         /// [`BlindedPayInfo`] provided for 1-hop blinded paths is ignored because it is meant to apply
2675         /// to the hops *between* the introduction node and the destination.
2676         ///
2677         /// This primarily exists to track that we need to included a blinded path at the end of our
2678         /// [`Route`], even though it doesn't actually add an additional hop in the payment.
2679         OneHopBlinded(
2680                 crate::lightning::routing::router::OneHopBlindedPathCandidate),
2681 }
2682 use lightning::routing::router::CandidateRouteHop as CandidateRouteHopImport;
2683 pub(crate) type nativeCandidateRouteHop = CandidateRouteHopImport<'static>;
2684
2685 impl CandidateRouteHop {
2686         #[allow(unused)]
2687         pub(crate) fn to_native(&self) -> nativeCandidateRouteHop {
2688                 match self {
2689                         CandidateRouteHop::FirstHop (ref a, ) => {
2690                                 let mut a_nonref = Clone::clone(a);
2691                                 nativeCandidateRouteHop::FirstHop (
2692                                         *unsafe { Box::from_raw(a_nonref.take_inner()) },
2693                                 )
2694                         },
2695                         CandidateRouteHop::PublicHop (ref a, ) => {
2696                                 let mut a_nonref = Clone::clone(a);
2697                                 nativeCandidateRouteHop::PublicHop (
2698                                         *unsafe { Box::from_raw(a_nonref.take_inner()) },
2699                                 )
2700                         },
2701                         CandidateRouteHop::PrivateHop (ref a, ) => {
2702                                 let mut a_nonref = Clone::clone(a);
2703                                 nativeCandidateRouteHop::PrivateHop (
2704                                         *unsafe { Box::from_raw(a_nonref.take_inner()) },
2705                                 )
2706                         },
2707                         CandidateRouteHop::Blinded (ref a, ) => {
2708                                 let mut a_nonref = Clone::clone(a);
2709                                 nativeCandidateRouteHop::Blinded (
2710                                         *unsafe { Box::from_raw(a_nonref.take_inner()) },
2711                                 )
2712                         },
2713                         CandidateRouteHop::OneHopBlinded (ref a, ) => {
2714                                 let mut a_nonref = Clone::clone(a);
2715                                 nativeCandidateRouteHop::OneHopBlinded (
2716                                         *unsafe { Box::from_raw(a_nonref.take_inner()) },
2717                                 )
2718                         },
2719                 }
2720         }
2721         #[allow(unused)]
2722         pub(crate) fn into_native(self) -> nativeCandidateRouteHop {
2723                 match self {
2724                         CandidateRouteHop::FirstHop (mut a, ) => {
2725                                 nativeCandidateRouteHop::FirstHop (
2726                                         *unsafe { Box::from_raw(a.take_inner()) },
2727                                 )
2728                         },
2729                         CandidateRouteHop::PublicHop (mut a, ) => {
2730                                 nativeCandidateRouteHop::PublicHop (
2731                                         *unsafe { Box::from_raw(a.take_inner()) },
2732                                 )
2733                         },
2734                         CandidateRouteHop::PrivateHop (mut a, ) => {
2735                                 nativeCandidateRouteHop::PrivateHop (
2736                                         *unsafe { Box::from_raw(a.take_inner()) },
2737                                 )
2738                         },
2739                         CandidateRouteHop::Blinded (mut a, ) => {
2740                                 nativeCandidateRouteHop::Blinded (
2741                                         *unsafe { Box::from_raw(a.take_inner()) },
2742                                 )
2743                         },
2744                         CandidateRouteHop::OneHopBlinded (mut a, ) => {
2745                                 nativeCandidateRouteHop::OneHopBlinded (
2746                                         *unsafe { Box::from_raw(a.take_inner()) },
2747                                 )
2748                         },
2749                 }
2750         }
2751         #[allow(unused)]
2752         pub(crate) fn from_native(native: &CandidateRouteHopImport<'_>) -> Self {
2753                 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeCandidateRouteHop) };
2754                 match native {
2755                         nativeCandidateRouteHop::FirstHop (ref a, ) => {
2756                                 let mut a_nonref = Clone::clone(a);
2757                                 CandidateRouteHop::FirstHop (
2758                                         crate::lightning::routing::router::FirstHopCandidate { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
2759                                 )
2760                         },
2761                         nativeCandidateRouteHop::PublicHop (ref a, ) => {
2762                                 let mut a_nonref = Clone::clone(a);
2763                                 CandidateRouteHop::PublicHop (
2764                                         crate::lightning::routing::router::PublicHopCandidate { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
2765                                 )
2766                         },
2767                         nativeCandidateRouteHop::PrivateHop (ref a, ) => {
2768                                 let mut a_nonref = Clone::clone(a);
2769                                 CandidateRouteHop::PrivateHop (
2770                                         crate::lightning::routing::router::PrivateHopCandidate { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
2771                                 )
2772                         },
2773                         nativeCandidateRouteHop::Blinded (ref a, ) => {
2774                                 let mut a_nonref = Clone::clone(a);
2775                                 CandidateRouteHop::Blinded (
2776                                         crate::lightning::routing::router::BlindedPathCandidate { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
2777                                 )
2778                         },
2779                         nativeCandidateRouteHop::OneHopBlinded (ref a, ) => {
2780                                 let mut a_nonref = Clone::clone(a);
2781                                 CandidateRouteHop::OneHopBlinded (
2782                                         crate::lightning::routing::router::OneHopBlindedPathCandidate { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
2783                                 )
2784                         },
2785                 }
2786         }
2787         #[allow(unused)]
2788         pub(crate) fn native_into(native: nativeCandidateRouteHop) -> Self {
2789                 match native {
2790                         nativeCandidateRouteHop::FirstHop (mut a, ) => {
2791                                 CandidateRouteHop::FirstHop (
2792                                         crate::lightning::routing::router::FirstHopCandidate { inner: ObjOps::heap_alloc(a), is_owned: true },
2793                                 )
2794                         },
2795                         nativeCandidateRouteHop::PublicHop (mut a, ) => {
2796                                 CandidateRouteHop::PublicHop (
2797                                         crate::lightning::routing::router::PublicHopCandidate { inner: ObjOps::heap_alloc(a), is_owned: true },
2798                                 )
2799                         },
2800                         nativeCandidateRouteHop::PrivateHop (mut a, ) => {
2801                                 CandidateRouteHop::PrivateHop (
2802                                         crate::lightning::routing::router::PrivateHopCandidate { inner: ObjOps::heap_alloc(a), is_owned: true },
2803                                 )
2804                         },
2805                         nativeCandidateRouteHop::Blinded (mut a, ) => {
2806                                 CandidateRouteHop::Blinded (
2807                                         crate::lightning::routing::router::BlindedPathCandidate { inner: ObjOps::heap_alloc(a), is_owned: true },
2808                                 )
2809                         },
2810                         nativeCandidateRouteHop::OneHopBlinded (mut a, ) => {
2811                                 CandidateRouteHop::OneHopBlinded (
2812                                         crate::lightning::routing::router::OneHopBlindedPathCandidate { inner: ObjOps::heap_alloc(a), is_owned: true },
2813                                 )
2814                         },
2815                 }
2816         }
2817 }
2818 /// Frees any resources used by the CandidateRouteHop
2819 #[no_mangle]
2820 pub extern "C" fn CandidateRouteHop_free(this_ptr: CandidateRouteHop) { }
2821 /// Creates a copy of the CandidateRouteHop
2822 #[no_mangle]
2823 pub extern "C" fn CandidateRouteHop_clone(orig: &CandidateRouteHop) -> CandidateRouteHop {
2824         orig.clone()
2825 }
2826 #[allow(unused)]
2827 /// Used only if an object of this type is returned as a trait impl by a method
2828 pub(crate) extern "C" fn CandidateRouteHop_clone_void(this_ptr: *const c_void) -> *mut c_void {
2829         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const CandidateRouteHop)).clone() })) as *mut c_void
2830 }
2831 #[allow(unused)]
2832 /// Used only if an object of this type is returned as a trait impl by a method
2833 pub(crate) extern "C" fn CandidateRouteHop_free_void(this_ptr: *mut c_void) {
2834         let _ = unsafe { Box::from_raw(this_ptr as *mut CandidateRouteHop) };
2835 }
2836 #[no_mangle]
2837 /// Utility method to constructs a new FirstHop-variant CandidateRouteHop
2838 pub extern "C" fn CandidateRouteHop_first_hop(a: crate::lightning::routing::router::FirstHopCandidate) -> CandidateRouteHop {
2839         CandidateRouteHop::FirstHop(a, )
2840 }
2841 #[no_mangle]
2842 /// Utility method to constructs a new PublicHop-variant CandidateRouteHop
2843 pub extern "C" fn CandidateRouteHop_public_hop(a: crate::lightning::routing::router::PublicHopCandidate) -> CandidateRouteHop {
2844         CandidateRouteHop::PublicHop(a, )
2845 }
2846 #[no_mangle]
2847 /// Utility method to constructs a new PrivateHop-variant CandidateRouteHop
2848 pub extern "C" fn CandidateRouteHop_private_hop(a: crate::lightning::routing::router::PrivateHopCandidate) -> CandidateRouteHop {
2849         CandidateRouteHop::PrivateHop(a, )
2850 }
2851 #[no_mangle]
2852 /// Utility method to constructs a new Blinded-variant CandidateRouteHop
2853 pub extern "C" fn CandidateRouteHop_blinded(a: crate::lightning::routing::router::BlindedPathCandidate) -> CandidateRouteHop {
2854         CandidateRouteHop::Blinded(a, )
2855 }
2856 #[no_mangle]
2857 /// Utility method to constructs a new OneHopBlinded-variant CandidateRouteHop
2858 pub extern "C" fn CandidateRouteHop_one_hop_blinded(a: crate::lightning::routing::router::OneHopBlindedPathCandidate) -> CandidateRouteHop {
2859         CandidateRouteHop::OneHopBlinded(a, )
2860 }
2861 /// Get a string which allows debug introspection of a CandidateRouteHop object
2862 pub extern "C" fn CandidateRouteHop_debug_str_void(o: *const c_void) -> Str {
2863         alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::router::CandidateRouteHop }).into()}
2864 /// Returns the globally unique short channel ID for this hop, if one is known.
2865 ///
2866 /// This only returns `Some` if the channel is public (either our own, or one we've learned
2867 /// from the public network graph), and thus the short channel ID we have for this channel is
2868 /// globally unique and identifies this channel in a global namespace.
2869 #[must_use]
2870 #[no_mangle]
2871 pub extern "C" fn CandidateRouteHop_globally_unique_short_channel_id(this_arg: &crate::lightning::routing::router::CandidateRouteHop) -> crate::c_types::derived::COption_u64Z {
2872         let mut ret = this_arg.to_native().globally_unique_short_channel_id();
2873         let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap() }) };
2874         local_ret
2875 }
2876
2877 /// Returns the required difference in HTLC CLTV expiry between the [`Self::source`] and the
2878 /// next-hop for an HTLC taking this hop.
2879 ///
2880 /// This is the time that the node(s) in this hop have to claim the HTLC on-chain if the
2881 /// next-hop goes on chain with a payment preimage.
2882 #[must_use]
2883 #[no_mangle]
2884 pub extern "C" fn CandidateRouteHop_cltv_expiry_delta(this_arg: &crate::lightning::routing::router::CandidateRouteHop) -> u32 {
2885         let mut ret = this_arg.to_native().cltv_expiry_delta();
2886         ret
2887 }
2888
2889 /// Returns the minimum amount that can be sent over this hop, in millisatoshis.
2890 #[must_use]
2891 #[no_mangle]
2892 pub extern "C" fn CandidateRouteHop_htlc_minimum_msat(this_arg: &crate::lightning::routing::router::CandidateRouteHop) -> u64 {
2893         let mut ret = this_arg.to_native().htlc_minimum_msat();
2894         ret
2895 }
2896
2897 /// Returns the fees that must be paid to route an HTLC over this channel.
2898 #[must_use]
2899 #[no_mangle]
2900 pub extern "C" fn CandidateRouteHop_fees(this_arg: &crate::lightning::routing::router::CandidateRouteHop) -> crate::lightning::routing::gossip::RoutingFees {
2901         let mut ret = this_arg.to_native().fees();
2902         crate::lightning::routing::gossip::RoutingFees { inner: ObjOps::heap_alloc(ret), is_owned: true }
2903 }
2904
2905 /// Returns the source node id of current hop.
2906 ///
2907 /// Source node id refers to the node forwarding the HTLC through this hop.
2908 ///
2909 /// For [`Self::FirstHop`] we return payer's node id.
2910 #[must_use]
2911 #[no_mangle]
2912 pub extern "C" fn CandidateRouteHop_source(this_arg: &crate::lightning::routing::router::CandidateRouteHop) -> crate::lightning::routing::gossip::NodeId {
2913         let mut ret = this_arg.to_native().source();
2914         crate::lightning::routing::gossip::NodeId { inner: ObjOps::heap_alloc(ret), is_owned: true }
2915 }
2916
2917 /// Returns the target node id of this hop, if known.
2918 ///
2919 /// Target node id refers to the node receiving the HTLC after this hop.
2920 ///
2921 /// For [`Self::Blinded`] we return `None` because the ultimate destination after the blinded
2922 /// path is unknown.
2923 ///
2924 /// For [`Self::OneHopBlinded`] we return `None` because the target is the same as the source,
2925 /// and such a return value would be somewhat nonsensical.
2926 ///
2927 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
2928 #[must_use]
2929 #[no_mangle]
2930 pub extern "C" fn CandidateRouteHop_target(this_arg: &crate::lightning::routing::router::CandidateRouteHop) -> crate::lightning::routing::gossip::NodeId {
2931         let mut ret = this_arg.to_native().target();
2932         let mut local_ret = crate::lightning::routing::gossip::NodeId { inner: if ret.is_none() { core::ptr::null_mut() } else {  { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true };
2933         local_ret
2934 }
2935
2936 /// Finds a route from us (payer) to the given target node (payee).
2937 ///
2938 /// If the payee provided features in their invoice, they should be provided via the `payee` field
2939 /// in the given [`RouteParameters::payment_params`].
2940 /// Without this, MPP will only be used if the payee's features are available in the network graph.
2941 ///
2942 /// Private routing paths between a public node and the target may be included in the `payee` field
2943 /// of [`RouteParameters::payment_params`].
2944 ///
2945 /// If some channels aren't announced, it may be useful to fill in `first_hops` with the results
2946 /// from [`ChannelManager::list_usable_channels`]. If it is filled in, the view of these channels
2947 /// from `network_graph` will be ignored, and only those in `first_hops` will be used.
2948 ///
2949 /// The fees on channels from us to the next hop are ignored as they are assumed to all be equal.
2950 /// However, the enabled/disabled bit on such channels as well as the `htlc_minimum_msat` /
2951 /// `htlc_maximum_msat` *are* checked as they may change based on the receiving node.
2952 ///
2953 /// # Panics
2954 ///
2955 /// Panics if first_hops contains channels without `short_channel_id`s;
2956 /// [`ChannelManager::list_usable_channels`] will never include such channels.
2957 ///
2958 /// [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels
2959 /// [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed
2960 /// [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
2961 ///
2962 /// Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None
2963 #[no_mangle]
2964 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::ScoreLookUp, score_params: &crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters, random_seed_bytes: *const [u8; 32]) -> crate::c_types::derived::CResult_RouteLightningErrorZ {
2965         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[..]);
2966         let mut ret = lightning::routing::router::find_route::<crate::lightning::util::logger::Logger, crate::lightning::util::logger::Logger, crate::lightning::routing::scoring::ScoreLookUp>(&our_node_pubkey.into_rust(), route_params.get_native_ref(), network_graph.get_native_ref(), local_first_hops, logger, scorer, score_params.get_native_ref(), unsafe { &*random_seed_bytes});
2967         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() };
2968         local_ret
2969 }
2970
2971 /// Construct a route from us (payer) to the target node (payee) via the given hops (which should
2972 /// exclude the payer, but include the payee). This may be useful, e.g., for probing the chosen path.
2973 ///
2974 /// Re-uses logic from `find_route`, so the restrictions described there also apply here.
2975 #[no_mangle]
2976 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 {
2977         let mut local_hops = Vec::new(); for mut item in hops.into_rust().drain(..) { local_hops.push( { item.into_rust() }); };
2978         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});
2979         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() };
2980         local_ret
2981 }
2982