Update auto-generated bindings
[ldk-c-bindings] / lightning-c-bindings / src / lightning / routing / network_graph.rs
1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
3 //
4 // This file is licensed under the license available in the LICENSE or LICENSE.md
5 // file in the root of this repository or, if no such file exists, the same
6 // license as that which applies to the original source files from which this
7 // source was automatically generated.
8
9 //! The top-level network map tracking logic lives here.
10
11 use std::str::FromStr;
12 use std::ffi::c_void;
13 use core::convert::Infallible;
14 use bitcoin::hashes::Hash;
15 use crate::c_types::*;
16
17
18 use lightning::routing::network_graph::NodeId as nativeNodeIdImport;
19 type nativeNodeId = nativeNodeIdImport;
20
21 /// Represents the compressed public key of a node
22 #[must_use]
23 #[repr(C)]
24 pub struct NodeId {
25         /// A pointer to the opaque Rust object.
26
27         /// Nearly everywhere, inner must be non-null, however in places where
28         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
29         pub inner: *mut nativeNodeId,
30         /// Indicates that this is the only struct which contains the same pointer.
31
32         /// Rust functions which take ownership of an object provided via an argument require
33         /// this to be true and invalidate the object pointed to by inner.
34         pub is_owned: bool,
35 }
36
37 impl Drop for NodeId {
38         fn drop(&mut self) {
39                 if self.is_owned && !<*mut nativeNodeId>::is_null(self.inner) {
40                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
41                 }
42         }
43 }
44 /// Frees any resources used by the NodeId, if is_owned is set and inner is non-NULL.
45 #[no_mangle]
46 pub extern "C" fn NodeId_free(this_obj: NodeId) { }
47 #[allow(unused)]
48 /// Used only if an object of this type is returned as a trait impl by a method
49 extern "C" fn NodeId_free_void(this_ptr: *mut c_void) {
50         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeId); }
51 }
52 #[allow(unused)]
53 impl NodeId {
54         pub(crate) fn get_native_ref(&self) -> &'static nativeNodeId {
55                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
56         }
57         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeId {
58                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
59         }
60         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
61         pub(crate) fn take_inner(mut self) -> *mut nativeNodeId {
62                 assert!(self.is_owned);
63                 let ret = ObjOps::untweak_ptr(self.inner);
64                 self.inner = std::ptr::null_mut();
65                 ret
66         }
67 }
68 impl Clone for NodeId {
69         fn clone(&self) -> Self {
70                 Self {
71                         inner: if <*mut nativeNodeId>::is_null(self.inner) { std::ptr::null_mut() } else {
72                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
73                         is_owned: true,
74                 }
75         }
76 }
77 #[allow(unused)]
78 /// Used only if an object of this type is returned as a trait impl by a method
79 pub(crate) extern "C" fn NodeId_clone_void(this_ptr: *const c_void) -> *mut c_void {
80         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeId)).clone() })) as *mut c_void
81 }
82 #[no_mangle]
83 /// Creates a copy of the NodeId
84 pub extern "C" fn NodeId_clone(orig: &NodeId) -> NodeId {
85         orig.clone()
86 }
87 /// Create a new NodeId from a public key
88 #[must_use]
89 #[no_mangle]
90 pub extern "C" fn NodeId_from_pubkey(mut pubkey: crate::c_types::PublicKey) -> NodeId {
91         let mut ret = lightning::routing::network_graph::NodeId::from_pubkey(&pubkey.into_rust());
92         NodeId { inner: ObjOps::heap_alloc(ret), is_owned: true }
93 }
94
95 /// Get the public key slice from this NodeId
96 #[must_use]
97 #[no_mangle]
98 pub extern "C" fn NodeId_as_slice(this_arg: &NodeId) -> crate::c_types::u8slice {
99         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.as_slice();
100         let mut local_ret = crate::c_types::u8slice::from_slice(ret);
101         local_ret
102 }
103
104 /// Checks if two NodeIds contain equal inner contents.
105 #[no_mangle]
106 pub extern "C" fn NodeId_hash(o: &NodeId) -> u64 {
107         if o.inner.is_null() { return 0; }
108         // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
109         #[allow(deprecated)]
110         let mut hasher = core::hash::SipHasher::new();
111         std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
112         std::hash::Hasher::finish(&hasher)
113 }
114 #[no_mangle]
115 /// Serialize the NodeId object into a byte array which can be read by NodeId_read
116 pub extern "C" fn NodeId_write(obj: &NodeId) -> crate::c_types::derived::CVec_u8Z {
117         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
118 }
119 #[no_mangle]
120 pub(crate) extern "C" fn NodeId_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
121         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeId) })
122 }
123 #[no_mangle]
124 /// Read a NodeId from a byte array, created by NodeId_write
125 pub extern "C" fn NodeId_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeIdDecodeErrorZ {
126         let res = crate::c_types::deserialize_obj(ser);
127         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::network_graph::NodeId { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
128         local_res
129 }
130
131 use lightning::routing::network_graph::NetworkGraph as nativeNetworkGraphImport;
132 type nativeNetworkGraph = nativeNetworkGraphImport;
133
134 /// Represents the network as nodes and channels between them
135 #[must_use]
136 #[repr(C)]
137 pub struct NetworkGraph {
138         /// A pointer to the opaque Rust object.
139
140         /// Nearly everywhere, inner must be non-null, however in places where
141         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
142         pub inner: *mut nativeNetworkGraph,
143         /// Indicates that this is the only struct which contains the same pointer.
144
145         /// Rust functions which take ownership of an object provided via an argument require
146         /// this to be true and invalidate the object pointed to by inner.
147         pub is_owned: bool,
148 }
149
150 impl Drop for NetworkGraph {
151         fn drop(&mut self) {
152                 if self.is_owned && !<*mut nativeNetworkGraph>::is_null(self.inner) {
153                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
154                 }
155         }
156 }
157 /// Frees any resources used by the NetworkGraph, if is_owned is set and inner is non-NULL.
158 #[no_mangle]
159 pub extern "C" fn NetworkGraph_free(this_obj: NetworkGraph) { }
160 #[allow(unused)]
161 /// Used only if an object of this type is returned as a trait impl by a method
162 extern "C" fn NetworkGraph_free_void(this_ptr: *mut c_void) {
163         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNetworkGraph); }
164 }
165 #[allow(unused)]
166 impl NetworkGraph {
167         pub(crate) fn get_native_ref(&self) -> &'static nativeNetworkGraph {
168                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
169         }
170         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNetworkGraph {
171                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
172         }
173         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
174         pub(crate) fn take_inner(mut self) -> *mut nativeNetworkGraph {
175                 assert!(self.is_owned);
176                 let ret = ObjOps::untweak_ptr(self.inner);
177                 self.inner = std::ptr::null_mut();
178                 ret
179         }
180 }
181 impl Clone for NetworkGraph {
182         fn clone(&self) -> Self {
183                 Self {
184                         inner: if <*mut nativeNetworkGraph>::is_null(self.inner) { std::ptr::null_mut() } else {
185                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
186                         is_owned: true,
187                 }
188         }
189 }
190 #[allow(unused)]
191 /// Used only if an object of this type is returned as a trait impl by a method
192 pub(crate) extern "C" fn NetworkGraph_clone_void(this_ptr: *const c_void) -> *mut c_void {
193         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNetworkGraph)).clone() })) as *mut c_void
194 }
195 #[no_mangle]
196 /// Creates a copy of the NetworkGraph
197 pub extern "C" fn NetworkGraph_clone(orig: &NetworkGraph) -> NetworkGraph {
198         orig.clone()
199 }
200
201 use lightning::routing::network_graph::ReadOnlyNetworkGraph as nativeReadOnlyNetworkGraphImport;
202 type nativeReadOnlyNetworkGraph = nativeReadOnlyNetworkGraphImport<'static>;
203
204 /// A read-only view of [`NetworkGraph`].
205 #[must_use]
206 #[repr(C)]
207 pub struct ReadOnlyNetworkGraph {
208         /// A pointer to the opaque Rust object.
209
210         /// Nearly everywhere, inner must be non-null, however in places where
211         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
212         pub inner: *mut nativeReadOnlyNetworkGraph,
213         /// Indicates that this is the only struct which contains the same pointer.
214
215         /// Rust functions which take ownership of an object provided via an argument require
216         /// this to be true and invalidate the object pointed to by inner.
217         pub is_owned: bool,
218 }
219
220 impl Drop for ReadOnlyNetworkGraph {
221         fn drop(&mut self) {
222                 if self.is_owned && !<*mut nativeReadOnlyNetworkGraph>::is_null(self.inner) {
223                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
224                 }
225         }
226 }
227 /// Frees any resources used by the ReadOnlyNetworkGraph, if is_owned is set and inner is non-NULL.
228 #[no_mangle]
229 pub extern "C" fn ReadOnlyNetworkGraph_free(this_obj: ReadOnlyNetworkGraph) { }
230 #[allow(unused)]
231 /// Used only if an object of this type is returned as a trait impl by a method
232 extern "C" fn ReadOnlyNetworkGraph_free_void(this_ptr: *mut c_void) {
233         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReadOnlyNetworkGraph); }
234 }
235 #[allow(unused)]
236 impl ReadOnlyNetworkGraph {
237         pub(crate) fn get_native_ref(&self) -> &'static nativeReadOnlyNetworkGraph {
238                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
239         }
240         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReadOnlyNetworkGraph {
241                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
242         }
243         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
244         pub(crate) fn take_inner(mut self) -> *mut nativeReadOnlyNetworkGraph {
245                 assert!(self.is_owned);
246                 let ret = ObjOps::untweak_ptr(self.inner);
247                 self.inner = std::ptr::null_mut();
248                 ret
249         }
250 }
251 /// Update to the [`NetworkGraph`] based on payment failure information conveyed via the Onion
252 /// return packet by a node along the route. See [BOLT #4] for details.
253 ///
254 /// [BOLT #4]: https://github.com/lightningnetwork/lightning-rfc/blob/master/04-onion-routing.md
255 #[must_use]
256 #[derive(Clone)]
257 #[repr(C)]
258 pub enum NetworkUpdate {
259         /// An error indicating a `channel_update` messages should be applied via
260         /// [`NetworkGraph::update_channel`].
261         ChannelUpdateMessage {
262                 /// The update to apply via [`NetworkGraph::update_channel`].
263                 msg: crate::lightning::ln::msgs::ChannelUpdate,
264         },
265         /// An error indicating only that a channel has been closed, which should be applied via
266         /// [`NetworkGraph::close_channel_from_update`].
267         ChannelClosed {
268                 /// The short channel id of the closed channel.
269                 short_channel_id: u64,
270                 /// Whether the channel should be permanently removed or temporarily disabled until a new
271                 /// `channel_update` message is received.
272                 is_permanent: bool,
273         },
274         /// An error indicating only that a node has failed, which should be applied via
275         /// [`NetworkGraph::fail_node`].
276         NodeFailure {
277                 /// The node id of the failed node.
278                 node_id: crate::c_types::PublicKey,
279                 /// Whether the node should be permanently removed from consideration or can be restored
280                 /// when a new `channel_update` message is received.
281                 is_permanent: bool,
282         },
283 }
284 use lightning::routing::network_graph::NetworkUpdate as nativeNetworkUpdate;
285 impl NetworkUpdate {
286         #[allow(unused)]
287         pub(crate) fn to_native(&self) -> nativeNetworkUpdate {
288                 match self {
289                         NetworkUpdate::ChannelUpdateMessage {ref msg, } => {
290                                 let mut msg_nonref = (*msg).clone();
291                                 nativeNetworkUpdate::ChannelUpdateMessage {
292                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
293                                 }
294                         },
295                         NetworkUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
296                                 let mut short_channel_id_nonref = (*short_channel_id).clone();
297                                 let mut is_permanent_nonref = (*is_permanent).clone();
298                                 nativeNetworkUpdate::ChannelClosed {
299                                         short_channel_id: short_channel_id_nonref,
300                                         is_permanent: is_permanent_nonref,
301                                 }
302                         },
303                         NetworkUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
304                                 let mut node_id_nonref = (*node_id).clone();
305                                 let mut is_permanent_nonref = (*is_permanent).clone();
306                                 nativeNetworkUpdate::NodeFailure {
307                                         node_id: node_id_nonref.into_rust(),
308                                         is_permanent: is_permanent_nonref,
309                                 }
310                         },
311                 }
312         }
313         #[allow(unused)]
314         pub(crate) fn into_native(self) -> nativeNetworkUpdate {
315                 match self {
316                         NetworkUpdate::ChannelUpdateMessage {mut msg, } => {
317                                 nativeNetworkUpdate::ChannelUpdateMessage {
318                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
319                                 }
320                         },
321                         NetworkUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
322                                 nativeNetworkUpdate::ChannelClosed {
323                                         short_channel_id: short_channel_id,
324                                         is_permanent: is_permanent,
325                                 }
326                         },
327                         NetworkUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
328                                 nativeNetworkUpdate::NodeFailure {
329                                         node_id: node_id.into_rust(),
330                                         is_permanent: is_permanent,
331                                 }
332                         },
333                 }
334         }
335         #[allow(unused)]
336         pub(crate) fn from_native(native: &nativeNetworkUpdate) -> Self {
337                 match native {
338                         nativeNetworkUpdate::ChannelUpdateMessage {ref msg, } => {
339                                 let mut msg_nonref = (*msg).clone();
340                                 NetworkUpdate::ChannelUpdateMessage {
341                                         msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
342                                 }
343                         },
344                         nativeNetworkUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
345                                 let mut short_channel_id_nonref = (*short_channel_id).clone();
346                                 let mut is_permanent_nonref = (*is_permanent).clone();
347                                 NetworkUpdate::ChannelClosed {
348                                         short_channel_id: short_channel_id_nonref,
349                                         is_permanent: is_permanent_nonref,
350                                 }
351                         },
352                         nativeNetworkUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
353                                 let mut node_id_nonref = (*node_id).clone();
354                                 let mut is_permanent_nonref = (*is_permanent).clone();
355                                 NetworkUpdate::NodeFailure {
356                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
357                                         is_permanent: is_permanent_nonref,
358                                 }
359                         },
360                 }
361         }
362         #[allow(unused)]
363         pub(crate) fn native_into(native: nativeNetworkUpdate) -> Self {
364                 match native {
365                         nativeNetworkUpdate::ChannelUpdateMessage {mut msg, } => {
366                                 NetworkUpdate::ChannelUpdateMessage {
367                                         msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg), is_owned: true },
368                                 }
369                         },
370                         nativeNetworkUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
371                                 NetworkUpdate::ChannelClosed {
372                                         short_channel_id: short_channel_id,
373                                         is_permanent: is_permanent,
374                                 }
375                         },
376                         nativeNetworkUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
377                                 NetworkUpdate::NodeFailure {
378                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
379                                         is_permanent: is_permanent,
380                                 }
381                         },
382                 }
383         }
384 }
385 /// Frees any resources used by the NetworkUpdate
386 #[no_mangle]
387 pub extern "C" fn NetworkUpdate_free(this_ptr: NetworkUpdate) { }
388 /// Creates a copy of the NetworkUpdate
389 #[no_mangle]
390 pub extern "C" fn NetworkUpdate_clone(orig: &NetworkUpdate) -> NetworkUpdate {
391         orig.clone()
392 }
393 #[no_mangle]
394 /// Utility method to constructs a new ChannelUpdateMessage-variant NetworkUpdate
395 pub extern "C" fn NetworkUpdate_channel_update_message(msg: crate::lightning::ln::msgs::ChannelUpdate) -> NetworkUpdate {
396         NetworkUpdate::ChannelUpdateMessage {
397                 msg,
398         }
399 }
400 #[no_mangle]
401 /// Utility method to constructs a new ChannelClosed-variant NetworkUpdate
402 pub extern "C" fn NetworkUpdate_channel_closed(short_channel_id: u64, is_permanent: bool) -> NetworkUpdate {
403         NetworkUpdate::ChannelClosed {
404                 short_channel_id,
405                 is_permanent,
406         }
407 }
408 #[no_mangle]
409 /// Utility method to constructs a new NodeFailure-variant NetworkUpdate
410 pub extern "C" fn NetworkUpdate_node_failure(node_id: crate::c_types::PublicKey, is_permanent: bool) -> NetworkUpdate {
411         NetworkUpdate::NodeFailure {
412                 node_id,
413                 is_permanent,
414         }
415 }
416 #[no_mangle]
417 /// Serialize the NetworkUpdate object into a byte array which can be read by NetworkUpdate_read
418 pub extern "C" fn NetworkUpdate_write(obj: &NetworkUpdate) -> crate::c_types::derived::CVec_u8Z {
419         crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
420 }
421 impl From<nativeNetGraphMsgHandler> for crate::lightning::util::events::EventHandler {
422         fn from(obj: nativeNetGraphMsgHandler) -> Self {
423                 let mut rust_obj = NetGraphMsgHandler { inner: ObjOps::heap_alloc(obj), is_owned: true };
424                 let mut ret = NetGraphMsgHandler_as_EventHandler(&rust_obj);
425                 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
426                 rust_obj.inner = std::ptr::null_mut();
427                 ret.free = Some(NetGraphMsgHandler_free_void);
428                 ret
429         }
430 }
431 /// Constructs a new EventHandler which calls the relevant methods on this_arg.
432 /// This copies the `inner` pointer in this_arg and thus the returned EventHandler must be freed before this_arg is
433 #[no_mangle]
434 pub extern "C" fn NetGraphMsgHandler_as_EventHandler(this_arg: &NetGraphMsgHandler) -> crate::lightning::util::events::EventHandler {
435         crate::lightning::util::events::EventHandler {
436                 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
437                 free: None,
438                 handle_event: NetGraphMsgHandler_EventHandler_handle_event,
439         }
440 }
441
442 extern "C" fn NetGraphMsgHandler_EventHandler_handle_event(this_arg: *const c_void, event: &crate::lightning::util::events::Event) {
443         <nativeNetGraphMsgHandler as lightning::util::events::EventHandler<>>::handle_event(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, &event.to_native())
444 }
445
446
447 use lightning::routing::network_graph::NetGraphMsgHandler as nativeNetGraphMsgHandlerImport;
448 type nativeNetGraphMsgHandler = nativeNetGraphMsgHandlerImport<crate::lightning::chain::Access, crate::lightning::util::logger::Logger>;
449
450 /// Receives and validates network updates from peers,
451 /// stores authentic and relevant data as a network graph.
452 /// This network graph is then used for routing payments.
453 /// Provides interface to help with initial routing sync by
454 /// serving historical announcements.
455 ///
456 /// Serves as an [`EventHandler`] for applying updates from [`Event::PaymentPathFailed`] to the
457 /// [`NetworkGraph`].
458 #[must_use]
459 #[repr(C)]
460 pub struct NetGraphMsgHandler {
461         /// A pointer to the opaque Rust object.
462
463         /// Nearly everywhere, inner must be non-null, however in places where
464         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
465         pub inner: *mut nativeNetGraphMsgHandler,
466         /// Indicates that this is the only struct which contains the same pointer.
467
468         /// Rust functions which take ownership of an object provided via an argument require
469         /// this to be true and invalidate the object pointed to by inner.
470         pub is_owned: bool,
471 }
472
473 impl Drop for NetGraphMsgHandler {
474         fn drop(&mut self) {
475                 if self.is_owned && !<*mut nativeNetGraphMsgHandler>::is_null(self.inner) {
476                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
477                 }
478         }
479 }
480 /// Frees any resources used by the NetGraphMsgHandler, if is_owned is set and inner is non-NULL.
481 #[no_mangle]
482 pub extern "C" fn NetGraphMsgHandler_free(this_obj: NetGraphMsgHandler) { }
483 #[allow(unused)]
484 /// Used only if an object of this type is returned as a trait impl by a method
485 extern "C" fn NetGraphMsgHandler_free_void(this_ptr: *mut c_void) {
486         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNetGraphMsgHandler); }
487 }
488 #[allow(unused)]
489 impl NetGraphMsgHandler {
490         pub(crate) fn get_native_ref(&self) -> &'static nativeNetGraphMsgHandler {
491                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
492         }
493         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNetGraphMsgHandler {
494                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
495         }
496         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
497         pub(crate) fn take_inner(mut self) -> *mut nativeNetGraphMsgHandler {
498                 assert!(self.is_owned);
499                 let ret = ObjOps::untweak_ptr(self.inner);
500                 self.inner = std::ptr::null_mut();
501                 ret
502         }
503 }
504 /// Representation of the payment channel network
505 #[no_mangle]
506 pub extern "C" fn NetGraphMsgHandler_get_network_graph(this_ptr: &NetGraphMsgHandler) -> crate::lightning::routing::network_graph::NetworkGraph {
507         let mut inner_val = &mut this_ptr.get_native_mut_ref().network_graph;
508         crate::lightning::routing::network_graph::NetworkGraph { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
509 }
510 /// Representation of the payment channel network
511 #[no_mangle]
512 pub extern "C" fn NetGraphMsgHandler_set_network_graph(this_ptr: &mut NetGraphMsgHandler, mut val: crate::lightning::routing::network_graph::NetworkGraph) {
513         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.network_graph = *unsafe { Box::from_raw(val.take_inner()) };
514 }
515 /// Creates a new tracker of the actual state of the network of channels and nodes,
516 /// assuming an existing Network Graph.
517 /// Chain monitor is used to make sure announced channels exist on-chain,
518 /// channel data is correct, and that the announcement is signed with
519 /// channel owners' keys.
520 #[must_use]
521 #[no_mangle]
522 pub extern "C" fn NetGraphMsgHandler_new(mut network_graph: crate::lightning::routing::network_graph::NetworkGraph, mut chain_access: crate::c_types::derived::COption_AccessZ, mut logger: crate::lightning::util::logger::Logger) -> NetGraphMsgHandler {
523         let mut local_chain_access = { /* chain_access*/ let chain_access_opt = chain_access; { } if chain_access_opt.is_none() { None } else { Some({ chain_access_opt.take() }) } };
524         let mut ret = lightning::routing::network_graph::NetGraphMsgHandler::new(*unsafe { Box::from_raw(network_graph.take_inner()) }, local_chain_access, logger);
525         NetGraphMsgHandler { inner: ObjOps::heap_alloc(ret), is_owned: true }
526 }
527
528 /// Adds a provider used to check new announcements. Does not affect
529 /// existing announcements unless they are updated.
530 /// Add, update or remove the provider would replace the current one.
531 #[no_mangle]
532 pub extern "C" fn NetGraphMsgHandler_add_chain_access(this_arg: &mut NetGraphMsgHandler, mut chain_access: crate::c_types::derived::COption_AccessZ) {
533         let mut local_chain_access = { /* chain_access*/ let chain_access_opt = chain_access; { } if chain_access_opt.is_none() { None } else { Some({ chain_access_opt.take() }) } };
534         unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut nativeNetGraphMsgHandler)) }.add_chain_access(local_chain_access)
535 }
536
537 impl From<nativeNetGraphMsgHandler> for crate::lightning::ln::msgs::RoutingMessageHandler {
538         fn from(obj: nativeNetGraphMsgHandler) -> Self {
539                 let mut rust_obj = NetGraphMsgHandler { inner: ObjOps::heap_alloc(obj), is_owned: true };
540                 let mut ret = NetGraphMsgHandler_as_RoutingMessageHandler(&rust_obj);
541                 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
542                 rust_obj.inner = std::ptr::null_mut();
543                 ret.free = Some(NetGraphMsgHandler_free_void);
544                 ret
545         }
546 }
547 /// Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg.
548 /// This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is
549 #[no_mangle]
550 pub extern "C" fn NetGraphMsgHandler_as_RoutingMessageHandler(this_arg: &NetGraphMsgHandler) -> crate::lightning::ln::msgs::RoutingMessageHandler {
551         crate::lightning::ln::msgs::RoutingMessageHandler {
552                 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
553                 free: None,
554                 handle_node_announcement: NetGraphMsgHandler_RoutingMessageHandler_handle_node_announcement,
555                 handle_channel_announcement: NetGraphMsgHandler_RoutingMessageHandler_handle_channel_announcement,
556                 handle_channel_update: NetGraphMsgHandler_RoutingMessageHandler_handle_channel_update,
557                 get_next_channel_announcements: NetGraphMsgHandler_RoutingMessageHandler_get_next_channel_announcements,
558                 get_next_node_announcements: NetGraphMsgHandler_RoutingMessageHandler_get_next_node_announcements,
559                 sync_routing_table: NetGraphMsgHandler_RoutingMessageHandler_sync_routing_table,
560                 handle_reply_channel_range: NetGraphMsgHandler_RoutingMessageHandler_handle_reply_channel_range,
561                 handle_reply_short_channel_ids_end: NetGraphMsgHandler_RoutingMessageHandler_handle_reply_short_channel_ids_end,
562                 handle_query_channel_range: NetGraphMsgHandler_RoutingMessageHandler_handle_query_channel_range,
563                 handle_query_short_channel_ids: NetGraphMsgHandler_RoutingMessageHandler_handle_query_short_channel_ids,
564                 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider {
565                         this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
566                         free: None,
567                         get_and_clear_pending_msg_events: NetGraphMsgHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events,
568                 },
569         }
570 }
571
572 #[must_use]
573 extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_node_announcement(this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ {
574         let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_node_announcement(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, msg.get_native_ref());
575         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
576         local_ret
577 }
578 #[must_use]
579 extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_channel_announcement(this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ {
580         let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_channel_announcement(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, msg.get_native_ref());
581         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
582         local_ret
583 }
584 #[must_use]
585 extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_channel_update(this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ {
586         let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, msg.get_native_ref());
587         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
588         local_ret
589 }
590 #[must_use]
591 extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_get_next_channel_announcements(this_arg: *const c_void, mut starting_point: u64, mut batch_amount: u8) -> crate::c_types::derived::CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
592         let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::get_next_channel_announcements(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, starting_point, batch_amount);
593         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = item; let mut local_orig_ret_0_1 = crate::lightning::ln::msgs::ChannelUpdate { inner: if orig_ret_0_1.is_none() { std::ptr::null_mut() } else {  { ObjOps::heap_alloc((orig_ret_0_1.unwrap())) } }, is_owned: true }; let mut local_orig_ret_0_2 = crate::lightning::ln::msgs::ChannelUpdate { inner: if orig_ret_0_2.is_none() { std::ptr::null_mut() } else {  { ObjOps::heap_alloc((orig_ret_0_2.unwrap())) } }, is_owned: true }; let mut local_ret_0 = (crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(orig_ret_0_0), is_owned: true }, local_orig_ret_0_1, local_orig_ret_0_2).into(); local_ret_0 }); };
594         local_ret.into()
595 }
596 #[must_use]
597 extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_get_next_node_announcements(this_arg: *const c_void, mut starting_point: crate::c_types::PublicKey, mut batch_amount: u8) -> crate::c_types::derived::CVec_NodeAnnouncementZ {
598         let mut local_starting_point_base = if starting_point.is_null() { None } else { Some( { starting_point.into_rust() }) }; let mut local_starting_point = local_starting_point_base.as_ref();
599         let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::get_next_node_announcements(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, local_starting_point, batch_amount);
600         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
601         local_ret.into()
602 }
603 extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_sync_routing_table(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, init_msg: &crate::lightning::ln::msgs::Init) {
604         <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::sync_routing_table(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, &their_node_id.into_rust(), init_msg.get_native_ref())
605 }
606 #[must_use]
607 extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_reply_channel_range(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
608         let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_reply_channel_range(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) });
609         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
610         local_ret
611 }
612 #[must_use]
613 extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_reply_short_channel_ids_end(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
614         let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_reply_short_channel_ids_end(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) });
615         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
616         local_ret
617 }
618 #[must_use]
619 extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_query_channel_range(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
620         let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_query_channel_range(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) });
621         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
622         local_ret
623 }
624 #[must_use]
625 extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_query_short_channel_ids(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, mut _msg: crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
626         let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_query_short_channel_ids(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, &_their_node_id.into_rust(), *unsafe { Box::from_raw(_msg.take_inner()) });
627         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
628         local_ret
629 }
630
631 impl From<nativeNetGraphMsgHandler> for crate::lightning::util::events::MessageSendEventsProvider {
632         fn from(obj: nativeNetGraphMsgHandler) -> Self {
633                 let mut rust_obj = NetGraphMsgHandler { inner: ObjOps::heap_alloc(obj), is_owned: true };
634                 let mut ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&rust_obj);
635                 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
636                 rust_obj.inner = std::ptr::null_mut();
637                 ret.free = Some(NetGraphMsgHandler_free_void);
638                 ret
639         }
640 }
641 /// Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg.
642 /// This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is
643 #[no_mangle]
644 pub extern "C" fn NetGraphMsgHandler_as_MessageSendEventsProvider(this_arg: &NetGraphMsgHandler) -> crate::lightning::util::events::MessageSendEventsProvider {
645         crate::lightning::util::events::MessageSendEventsProvider {
646                 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
647                 free: None,
648                 get_and_clear_pending_msg_events: NetGraphMsgHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events,
649         }
650 }
651
652 #[must_use]
653 extern "C" fn NetGraphMsgHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ {
654         let mut ret = <nativeNetGraphMsgHandler as lightning::util::events::MessageSendEventsProvider<>>::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, );
655         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::util::events::MessageSendEvent::native_into(item) }); };
656         local_ret.into()
657 }
658
659
660 use lightning::routing::network_graph::DirectionalChannelInfo as nativeDirectionalChannelInfoImport;
661 type nativeDirectionalChannelInfo = nativeDirectionalChannelInfoImport;
662
663 /// Details about one direction of a channel. Received
664 /// within a channel update.
665 #[must_use]
666 #[repr(C)]
667 pub struct DirectionalChannelInfo {
668         /// A pointer to the opaque Rust object.
669
670         /// Nearly everywhere, inner must be non-null, however in places where
671         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
672         pub inner: *mut nativeDirectionalChannelInfo,
673         /// Indicates that this is the only struct which contains the same pointer.
674
675         /// Rust functions which take ownership of an object provided via an argument require
676         /// this to be true and invalidate the object pointed to by inner.
677         pub is_owned: bool,
678 }
679
680 impl Drop for DirectionalChannelInfo {
681         fn drop(&mut self) {
682                 if self.is_owned && !<*mut nativeDirectionalChannelInfo>::is_null(self.inner) {
683                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
684                 }
685         }
686 }
687 /// Frees any resources used by the DirectionalChannelInfo, if is_owned is set and inner is non-NULL.
688 #[no_mangle]
689 pub extern "C" fn DirectionalChannelInfo_free(this_obj: DirectionalChannelInfo) { }
690 #[allow(unused)]
691 /// Used only if an object of this type is returned as a trait impl by a method
692 extern "C" fn DirectionalChannelInfo_free_void(this_ptr: *mut c_void) {
693         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDirectionalChannelInfo); }
694 }
695 #[allow(unused)]
696 impl DirectionalChannelInfo {
697         pub(crate) fn get_native_ref(&self) -> &'static nativeDirectionalChannelInfo {
698                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
699         }
700         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeDirectionalChannelInfo {
701                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
702         }
703         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
704         pub(crate) fn take_inner(mut self) -> *mut nativeDirectionalChannelInfo {
705                 assert!(self.is_owned);
706                 let ret = ObjOps::untweak_ptr(self.inner);
707                 self.inner = std::ptr::null_mut();
708                 ret
709         }
710 }
711 /// When the last update to the channel direction was issued.
712 /// Value is opaque, as set in the announcement.
713 #[no_mangle]
714 pub extern "C" fn DirectionalChannelInfo_get_last_update(this_ptr: &DirectionalChannelInfo) -> u32 {
715         let mut inner_val = &mut this_ptr.get_native_mut_ref().last_update;
716         *inner_val
717 }
718 /// When the last update to the channel direction was issued.
719 /// Value is opaque, as set in the announcement.
720 #[no_mangle]
721 pub extern "C" fn DirectionalChannelInfo_set_last_update(this_ptr: &mut DirectionalChannelInfo, mut val: u32) {
722         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.last_update = val;
723 }
724 /// Whether the channel can be currently used for payments (in this one direction).
725 #[no_mangle]
726 pub extern "C" fn DirectionalChannelInfo_get_enabled(this_ptr: &DirectionalChannelInfo) -> bool {
727         let mut inner_val = &mut this_ptr.get_native_mut_ref().enabled;
728         *inner_val
729 }
730 /// Whether the channel can be currently used for payments (in this one direction).
731 #[no_mangle]
732 pub extern "C" fn DirectionalChannelInfo_set_enabled(this_ptr: &mut DirectionalChannelInfo, mut val: bool) {
733         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.enabled = val;
734 }
735 /// The difference in CLTV values that you must have when routing through this channel.
736 #[no_mangle]
737 pub extern "C" fn DirectionalChannelInfo_get_cltv_expiry_delta(this_ptr: &DirectionalChannelInfo) -> u16 {
738         let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
739         *inner_val
740 }
741 /// The difference in CLTV values that you must have when routing through this channel.
742 #[no_mangle]
743 pub extern "C" fn DirectionalChannelInfo_set_cltv_expiry_delta(this_ptr: &mut DirectionalChannelInfo, mut val: u16) {
744         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
745 }
746 /// The minimum value, which must be relayed to the next hop via the channel
747 #[no_mangle]
748 pub extern "C" fn DirectionalChannelInfo_get_htlc_minimum_msat(this_ptr: &DirectionalChannelInfo) -> u64 {
749         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
750         *inner_val
751 }
752 /// The minimum value, which must be relayed to the next hop via the channel
753 #[no_mangle]
754 pub extern "C" fn DirectionalChannelInfo_set_htlc_minimum_msat(this_ptr: &mut DirectionalChannelInfo, mut val: u64) {
755         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
756 }
757 /// The maximum value which may be relayed to the next hop via the channel.
758 #[no_mangle]
759 pub extern "C" fn DirectionalChannelInfo_get_htlc_maximum_msat(this_ptr: &DirectionalChannelInfo) -> crate::c_types::derived::COption_u64Z {
760         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat;
761         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() }) };
762         local_inner_val
763 }
764 /// The maximum value which may be relayed to the next hop via the channel.
765 #[no_mangle]
766 pub extern "C" fn DirectionalChannelInfo_set_htlc_maximum_msat(this_ptr: &mut DirectionalChannelInfo, mut val: crate::c_types::derived::COption_u64Z) {
767         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
768         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = local_val;
769 }
770 /// Fees charged when the channel is used for routing
771 #[no_mangle]
772 pub extern "C" fn DirectionalChannelInfo_get_fees(this_ptr: &DirectionalChannelInfo) -> crate::lightning::routing::network_graph::RoutingFees {
773         let mut inner_val = &mut this_ptr.get_native_mut_ref().fees;
774         crate::lightning::routing::network_graph::RoutingFees { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
775 }
776 /// Fees charged when the channel is used for routing
777 #[no_mangle]
778 pub extern "C" fn DirectionalChannelInfo_set_fees(this_ptr: &mut DirectionalChannelInfo, mut val: crate::lightning::routing::network_graph::RoutingFees) {
779         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fees = *unsafe { Box::from_raw(val.take_inner()) };
780 }
781 /// Most recent update for the channel received from the network
782 /// Mostly redundant with the data we store in fields explicitly.
783 /// Everything else is useful only for sending out for initial routing sync.
784 /// Not stored if contains excess data to prevent DoS.
785 ///
786 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
787 #[no_mangle]
788 pub extern "C" fn DirectionalChannelInfo_get_last_update_message(this_ptr: &DirectionalChannelInfo) -> crate::lightning::ln::msgs::ChannelUpdate {
789         let mut inner_val = &mut this_ptr.get_native_mut_ref().last_update_message;
790         let mut local_inner_val = crate::lightning::ln::msgs::ChannelUpdate { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const _) as *mut _ }, is_owned: false };
791         local_inner_val
792 }
793 /// Most recent update for the channel received from the network
794 /// Mostly redundant with the data we store in fields explicitly.
795 /// Everything else is useful only for sending out for initial routing sync.
796 /// Not stored if contains excess data to prevent DoS.
797 ///
798 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
799 #[no_mangle]
800 pub extern "C" fn DirectionalChannelInfo_set_last_update_message(this_ptr: &mut DirectionalChannelInfo, mut val: crate::lightning::ln::msgs::ChannelUpdate) {
801         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
802         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.last_update_message = local_val;
803 }
804 /// Constructs a new DirectionalChannelInfo given each field
805 #[must_use]
806 #[no_mangle]
807 pub extern "C" fn DirectionalChannelInfo_new(mut last_update_arg: u32, mut enabled_arg: bool, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: u64, mut htlc_maximum_msat_arg: crate::c_types::derived::COption_u64Z, mut fees_arg: crate::lightning::routing::network_graph::RoutingFees, mut last_update_message_arg: crate::lightning::ln::msgs::ChannelUpdate) -> DirectionalChannelInfo {
808         let mut local_htlc_maximum_msat_arg = if htlc_maximum_msat_arg.is_some() { Some( { htlc_maximum_msat_arg.take() }) } else { None };
809         let mut local_last_update_message_arg = if last_update_message_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(last_update_message_arg.take_inner()) } }) };
810         DirectionalChannelInfo { inner: ObjOps::heap_alloc(nativeDirectionalChannelInfo {
811                 last_update: last_update_arg,
812                 enabled: enabled_arg,
813                 cltv_expiry_delta: cltv_expiry_delta_arg,
814                 htlc_minimum_msat: htlc_minimum_msat_arg,
815                 htlc_maximum_msat: local_htlc_maximum_msat_arg,
816                 fees: *unsafe { Box::from_raw(fees_arg.take_inner()) },
817                 last_update_message: local_last_update_message_arg,
818         }), is_owned: true }
819 }
820 impl Clone for DirectionalChannelInfo {
821         fn clone(&self) -> Self {
822                 Self {
823                         inner: if <*mut nativeDirectionalChannelInfo>::is_null(self.inner) { std::ptr::null_mut() } else {
824                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
825                         is_owned: true,
826                 }
827         }
828 }
829 #[allow(unused)]
830 /// Used only if an object of this type is returned as a trait impl by a method
831 pub(crate) extern "C" fn DirectionalChannelInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
832         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDirectionalChannelInfo)).clone() })) as *mut c_void
833 }
834 #[no_mangle]
835 /// Creates a copy of the DirectionalChannelInfo
836 pub extern "C" fn DirectionalChannelInfo_clone(orig: &DirectionalChannelInfo) -> DirectionalChannelInfo {
837         orig.clone()
838 }
839 #[no_mangle]
840 /// Serialize the DirectionalChannelInfo object into a byte array which can be read by DirectionalChannelInfo_read
841 pub extern "C" fn DirectionalChannelInfo_write(obj: &DirectionalChannelInfo) -> crate::c_types::derived::CVec_u8Z {
842         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
843 }
844 #[no_mangle]
845 pub(crate) extern "C" fn DirectionalChannelInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
846         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeDirectionalChannelInfo) })
847 }
848 #[no_mangle]
849 /// Read a DirectionalChannelInfo from a byte array, created by DirectionalChannelInfo_write
850 pub extern "C" fn DirectionalChannelInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_DirectionalChannelInfoDecodeErrorZ {
851         let res = crate::c_types::deserialize_obj(ser);
852         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::network_graph::DirectionalChannelInfo { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
853         local_res
854 }
855
856 use lightning::routing::network_graph::ChannelInfo as nativeChannelInfoImport;
857 type nativeChannelInfo = nativeChannelInfoImport;
858
859 /// Details about a channel (both directions).
860 /// Received within a channel announcement.
861 #[must_use]
862 #[repr(C)]
863 pub struct ChannelInfo {
864         /// A pointer to the opaque Rust object.
865
866         /// Nearly everywhere, inner must be non-null, however in places where
867         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
868         pub inner: *mut nativeChannelInfo,
869         /// Indicates that this is the only struct which contains the same pointer.
870
871         /// Rust functions which take ownership of an object provided via an argument require
872         /// this to be true and invalidate the object pointed to by inner.
873         pub is_owned: bool,
874 }
875
876 impl Drop for ChannelInfo {
877         fn drop(&mut self) {
878                 if self.is_owned && !<*mut nativeChannelInfo>::is_null(self.inner) {
879                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
880                 }
881         }
882 }
883 /// Frees any resources used by the ChannelInfo, if is_owned is set and inner is non-NULL.
884 #[no_mangle]
885 pub extern "C" fn ChannelInfo_free(this_obj: ChannelInfo) { }
886 #[allow(unused)]
887 /// Used only if an object of this type is returned as a trait impl by a method
888 extern "C" fn ChannelInfo_free_void(this_ptr: *mut c_void) {
889         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelInfo); }
890 }
891 #[allow(unused)]
892 impl ChannelInfo {
893         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelInfo {
894                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
895         }
896         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelInfo {
897                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
898         }
899         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
900         pub(crate) fn take_inner(mut self) -> *mut nativeChannelInfo {
901                 assert!(self.is_owned);
902                 let ret = ObjOps::untweak_ptr(self.inner);
903                 self.inner = std::ptr::null_mut();
904                 ret
905         }
906 }
907 /// Protocol features of a channel communicated during its announcement
908 #[no_mangle]
909 pub extern "C" fn ChannelInfo_get_features(this_ptr: &ChannelInfo) -> crate::lightning::ln::features::ChannelFeatures {
910         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
911         crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
912 }
913 /// Protocol features of a channel communicated during its announcement
914 #[no_mangle]
915 pub extern "C" fn ChannelInfo_set_features(this_ptr: &mut ChannelInfo, mut val: crate::lightning::ln::features::ChannelFeatures) {
916         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
917 }
918 /// Source node of the first direction of a channel
919 #[no_mangle]
920 pub extern "C" fn ChannelInfo_get_node_one(this_ptr: &ChannelInfo) -> crate::lightning::routing::network_graph::NodeId {
921         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_one;
922         crate::lightning::routing::network_graph::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
923 }
924 /// Source node of the first direction of a channel
925 #[no_mangle]
926 pub extern "C" fn ChannelInfo_set_node_one(this_ptr: &mut ChannelInfo, mut val: crate::lightning::routing::network_graph::NodeId) {
927         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_one = *unsafe { Box::from_raw(val.take_inner()) };
928 }
929 /// Details about the first direction of a channel
930 ///
931 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
932 #[no_mangle]
933 pub extern "C" fn ChannelInfo_get_one_to_two(this_ptr: &ChannelInfo) -> crate::lightning::routing::network_graph::DirectionalChannelInfo {
934         let mut inner_val = &mut this_ptr.get_native_mut_ref().one_to_two;
935         let mut local_inner_val = crate::lightning::routing::network_graph::DirectionalChannelInfo { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const _) as *mut _ }, is_owned: false };
936         local_inner_val
937 }
938 /// Details about the first direction of a channel
939 ///
940 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
941 #[no_mangle]
942 pub extern "C" fn ChannelInfo_set_one_to_two(this_ptr: &mut ChannelInfo, mut val: crate::lightning::routing::network_graph::DirectionalChannelInfo) {
943         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
944         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.one_to_two = local_val;
945 }
946 /// Source node of the second direction of a channel
947 #[no_mangle]
948 pub extern "C" fn ChannelInfo_get_node_two(this_ptr: &ChannelInfo) -> crate::lightning::routing::network_graph::NodeId {
949         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_two;
950         crate::lightning::routing::network_graph::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
951 }
952 /// Source node of the second direction of a channel
953 #[no_mangle]
954 pub extern "C" fn ChannelInfo_set_node_two(this_ptr: &mut ChannelInfo, mut val: crate::lightning::routing::network_graph::NodeId) {
955         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_two = *unsafe { Box::from_raw(val.take_inner()) };
956 }
957 /// Details about the second direction of a channel
958 ///
959 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
960 #[no_mangle]
961 pub extern "C" fn ChannelInfo_get_two_to_one(this_ptr: &ChannelInfo) -> crate::lightning::routing::network_graph::DirectionalChannelInfo {
962         let mut inner_val = &mut this_ptr.get_native_mut_ref().two_to_one;
963         let mut local_inner_val = crate::lightning::routing::network_graph::DirectionalChannelInfo { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const _) as *mut _ }, is_owned: false };
964         local_inner_val
965 }
966 /// Details about the second direction of a channel
967 ///
968 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
969 #[no_mangle]
970 pub extern "C" fn ChannelInfo_set_two_to_one(this_ptr: &mut ChannelInfo, mut val: crate::lightning::routing::network_graph::DirectionalChannelInfo) {
971         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
972         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.two_to_one = local_val;
973 }
974 /// The channel capacity as seen on-chain, if chain lookup is available.
975 #[no_mangle]
976 pub extern "C" fn ChannelInfo_get_capacity_sats(this_ptr: &ChannelInfo) -> crate::c_types::derived::COption_u64Z {
977         let mut inner_val = &mut this_ptr.get_native_mut_ref().capacity_sats;
978         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() }) };
979         local_inner_val
980 }
981 /// The channel capacity as seen on-chain, if chain lookup is available.
982 #[no_mangle]
983 pub extern "C" fn ChannelInfo_set_capacity_sats(this_ptr: &mut ChannelInfo, mut val: crate::c_types::derived::COption_u64Z) {
984         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
985         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.capacity_sats = local_val;
986 }
987 /// An initial announcement of the channel
988 /// Mostly redundant with the data we store in fields explicitly.
989 /// Everything else is useful only for sending out for initial routing sync.
990 /// Not stored if contains excess data to prevent DoS.
991 ///
992 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
993 #[no_mangle]
994 pub extern "C" fn ChannelInfo_get_announcement_message(this_ptr: &ChannelInfo) -> crate::lightning::ln::msgs::ChannelAnnouncement {
995         let mut inner_val = &mut this_ptr.get_native_mut_ref().announcement_message;
996         let mut local_inner_val = crate::lightning::ln::msgs::ChannelAnnouncement { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const _) as *mut _ }, is_owned: false };
997         local_inner_val
998 }
999 /// An initial announcement of the channel
1000 /// Mostly redundant with the data we store in fields explicitly.
1001 /// Everything else is useful only for sending out for initial routing sync.
1002 /// Not stored if contains excess data to prevent DoS.
1003 ///
1004 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1005 #[no_mangle]
1006 pub extern "C" fn ChannelInfo_set_announcement_message(this_ptr: &mut ChannelInfo, mut val: crate::lightning::ln::msgs::ChannelAnnouncement) {
1007         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1008         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.announcement_message = local_val;
1009 }
1010 /// Constructs a new ChannelInfo given each field
1011 #[must_use]
1012 #[no_mangle]
1013 pub extern "C" fn ChannelInfo_new(mut features_arg: crate::lightning::ln::features::ChannelFeatures, mut node_one_arg: crate::lightning::routing::network_graph::NodeId, mut one_to_two_arg: crate::lightning::routing::network_graph::DirectionalChannelInfo, mut node_two_arg: crate::lightning::routing::network_graph::NodeId, mut two_to_one_arg: crate::lightning::routing::network_graph::DirectionalChannelInfo, mut capacity_sats_arg: crate::c_types::derived::COption_u64Z, mut announcement_message_arg: crate::lightning::ln::msgs::ChannelAnnouncement) -> ChannelInfo {
1014         let mut local_one_to_two_arg = if one_to_two_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(one_to_two_arg.take_inner()) } }) };
1015         let mut local_two_to_one_arg = if two_to_one_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(two_to_one_arg.take_inner()) } }) };
1016         let mut local_capacity_sats_arg = if capacity_sats_arg.is_some() { Some( { capacity_sats_arg.take() }) } else { None };
1017         let mut local_announcement_message_arg = if announcement_message_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(announcement_message_arg.take_inner()) } }) };
1018         ChannelInfo { inner: ObjOps::heap_alloc(nativeChannelInfo {
1019                 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
1020                 node_one: *unsafe { Box::from_raw(node_one_arg.take_inner()) },
1021                 one_to_two: local_one_to_two_arg,
1022                 node_two: *unsafe { Box::from_raw(node_two_arg.take_inner()) },
1023                 two_to_one: local_two_to_one_arg,
1024                 capacity_sats: local_capacity_sats_arg,
1025                 announcement_message: local_announcement_message_arg,
1026         }), is_owned: true }
1027 }
1028 impl Clone for ChannelInfo {
1029         fn clone(&self) -> Self {
1030                 Self {
1031                         inner: if <*mut nativeChannelInfo>::is_null(self.inner) { std::ptr::null_mut() } else {
1032                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1033                         is_owned: true,
1034                 }
1035         }
1036 }
1037 #[allow(unused)]
1038 /// Used only if an object of this type is returned as a trait impl by a method
1039 pub(crate) extern "C" fn ChannelInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
1040         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelInfo)).clone() })) as *mut c_void
1041 }
1042 #[no_mangle]
1043 /// Creates a copy of the ChannelInfo
1044 pub extern "C" fn ChannelInfo_clone(orig: &ChannelInfo) -> ChannelInfo {
1045         orig.clone()
1046 }
1047 #[no_mangle]
1048 /// Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read
1049 pub extern "C" fn ChannelInfo_write(obj: &ChannelInfo) -> crate::c_types::derived::CVec_u8Z {
1050         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1051 }
1052 #[no_mangle]
1053 pub(crate) extern "C" fn ChannelInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1054         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelInfo) })
1055 }
1056 #[no_mangle]
1057 /// Read a ChannelInfo from a byte array, created by ChannelInfo_write
1058 pub extern "C" fn ChannelInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelInfoDecodeErrorZ {
1059         let res = crate::c_types::deserialize_obj(ser);
1060         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::network_graph::ChannelInfo { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
1061         local_res
1062 }
1063
1064 use lightning::routing::network_graph::RoutingFees as nativeRoutingFeesImport;
1065 type nativeRoutingFees = nativeRoutingFeesImport;
1066
1067 /// Fees for routing via a given channel or a node
1068 #[must_use]
1069 #[repr(C)]
1070 pub struct RoutingFees {
1071         /// A pointer to the opaque Rust object.
1072
1073         /// Nearly everywhere, inner must be non-null, however in places where
1074         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1075         pub inner: *mut nativeRoutingFees,
1076         /// Indicates that this is the only struct which contains the same pointer.
1077
1078         /// Rust functions which take ownership of an object provided via an argument require
1079         /// this to be true and invalidate the object pointed to by inner.
1080         pub is_owned: bool,
1081 }
1082
1083 impl Drop for RoutingFees {
1084         fn drop(&mut self) {
1085                 if self.is_owned && !<*mut nativeRoutingFees>::is_null(self.inner) {
1086                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1087                 }
1088         }
1089 }
1090 /// Frees any resources used by the RoutingFees, if is_owned is set and inner is non-NULL.
1091 #[no_mangle]
1092 pub extern "C" fn RoutingFees_free(this_obj: RoutingFees) { }
1093 #[allow(unused)]
1094 /// Used only if an object of this type is returned as a trait impl by a method
1095 extern "C" fn RoutingFees_free_void(this_ptr: *mut c_void) {
1096         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRoutingFees); }
1097 }
1098 #[allow(unused)]
1099 impl RoutingFees {
1100         pub(crate) fn get_native_ref(&self) -> &'static nativeRoutingFees {
1101                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1102         }
1103         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRoutingFees {
1104                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1105         }
1106         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1107         pub(crate) fn take_inner(mut self) -> *mut nativeRoutingFees {
1108                 assert!(self.is_owned);
1109                 let ret = ObjOps::untweak_ptr(self.inner);
1110                 self.inner = std::ptr::null_mut();
1111                 ret
1112         }
1113 }
1114 /// Flat routing fee in satoshis
1115 #[no_mangle]
1116 pub extern "C" fn RoutingFees_get_base_msat(this_ptr: &RoutingFees) -> u32 {
1117         let mut inner_val = &mut this_ptr.get_native_mut_ref().base_msat;
1118         *inner_val
1119 }
1120 /// Flat routing fee in satoshis
1121 #[no_mangle]
1122 pub extern "C" fn RoutingFees_set_base_msat(this_ptr: &mut RoutingFees, mut val: u32) {
1123         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.base_msat = val;
1124 }
1125 /// Liquidity-based routing fee in millionths of a routed amount.
1126 /// In other words, 10000 is 1%.
1127 #[no_mangle]
1128 pub extern "C" fn RoutingFees_get_proportional_millionths(this_ptr: &RoutingFees) -> u32 {
1129         let mut inner_val = &mut this_ptr.get_native_mut_ref().proportional_millionths;
1130         *inner_val
1131 }
1132 /// Liquidity-based routing fee in millionths of a routed amount.
1133 /// In other words, 10000 is 1%.
1134 #[no_mangle]
1135 pub extern "C" fn RoutingFees_set_proportional_millionths(this_ptr: &mut RoutingFees, mut val: u32) {
1136         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.proportional_millionths = val;
1137 }
1138 /// Constructs a new RoutingFees given each field
1139 #[must_use]
1140 #[no_mangle]
1141 pub extern "C" fn RoutingFees_new(mut base_msat_arg: u32, mut proportional_millionths_arg: u32) -> RoutingFees {
1142         RoutingFees { inner: ObjOps::heap_alloc(nativeRoutingFees {
1143                 base_msat: base_msat_arg,
1144                 proportional_millionths: proportional_millionths_arg,
1145         }), is_owned: true }
1146 }
1147 /// Checks if two RoutingFeess contain equal inner contents.
1148 /// This ignores pointers and is_owned flags and looks at the values in fields.
1149 /// Two objects with NULL inner values will be considered "equal" here.
1150 #[no_mangle]
1151 pub extern "C" fn RoutingFees_eq(a: &RoutingFees, b: &RoutingFees) -> bool {
1152         if a.inner == b.inner { return true; }
1153         if a.inner.is_null() || b.inner.is_null() { return false; }
1154         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1155 }
1156 impl Clone for RoutingFees {
1157         fn clone(&self) -> Self {
1158                 Self {
1159                         inner: if <*mut nativeRoutingFees>::is_null(self.inner) { std::ptr::null_mut() } else {
1160                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1161                         is_owned: true,
1162                 }
1163         }
1164 }
1165 #[allow(unused)]
1166 /// Used only if an object of this type is returned as a trait impl by a method
1167 pub(crate) extern "C" fn RoutingFees_clone_void(this_ptr: *const c_void) -> *mut c_void {
1168         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRoutingFees)).clone() })) as *mut c_void
1169 }
1170 #[no_mangle]
1171 /// Creates a copy of the RoutingFees
1172 pub extern "C" fn RoutingFees_clone(orig: &RoutingFees) -> RoutingFees {
1173         orig.clone()
1174 }
1175 /// Checks if two RoutingFeess contain equal inner contents.
1176 #[no_mangle]
1177 pub extern "C" fn RoutingFees_hash(o: &RoutingFees) -> u64 {
1178         if o.inner.is_null() { return 0; }
1179         // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
1180         #[allow(deprecated)]
1181         let mut hasher = core::hash::SipHasher::new();
1182         std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1183         std::hash::Hasher::finish(&hasher)
1184 }
1185 #[no_mangle]
1186 /// Serialize the RoutingFees object into a byte array which can be read by RoutingFees_read
1187 pub extern "C" fn RoutingFees_write(obj: &RoutingFees) -> crate::c_types::derived::CVec_u8Z {
1188         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1189 }
1190 #[no_mangle]
1191 pub(crate) extern "C" fn RoutingFees_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1192         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRoutingFees) })
1193 }
1194 #[no_mangle]
1195 /// Read a RoutingFees from a byte array, created by RoutingFees_write
1196 pub extern "C" fn RoutingFees_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RoutingFeesDecodeErrorZ {
1197         let res = crate::c_types::deserialize_obj(ser);
1198         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::network_graph::RoutingFees { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
1199         local_res
1200 }
1201
1202 use lightning::routing::network_graph::NodeAnnouncementInfo as nativeNodeAnnouncementInfoImport;
1203 type nativeNodeAnnouncementInfo = nativeNodeAnnouncementInfoImport;
1204
1205 /// Information received in the latest node_announcement from this node.
1206 #[must_use]
1207 #[repr(C)]
1208 pub struct NodeAnnouncementInfo {
1209         /// A pointer to the opaque Rust object.
1210
1211         /// Nearly everywhere, inner must be non-null, however in places where
1212         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1213         pub inner: *mut nativeNodeAnnouncementInfo,
1214         /// Indicates that this is the only struct which contains the same pointer.
1215
1216         /// Rust functions which take ownership of an object provided via an argument require
1217         /// this to be true and invalidate the object pointed to by inner.
1218         pub is_owned: bool,
1219 }
1220
1221 impl Drop for NodeAnnouncementInfo {
1222         fn drop(&mut self) {
1223                 if self.is_owned && !<*mut nativeNodeAnnouncementInfo>::is_null(self.inner) {
1224                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1225                 }
1226         }
1227 }
1228 /// Frees any resources used by the NodeAnnouncementInfo, if is_owned is set and inner is non-NULL.
1229 #[no_mangle]
1230 pub extern "C" fn NodeAnnouncementInfo_free(this_obj: NodeAnnouncementInfo) { }
1231 #[allow(unused)]
1232 /// Used only if an object of this type is returned as a trait impl by a method
1233 extern "C" fn NodeAnnouncementInfo_free_void(this_ptr: *mut c_void) {
1234         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAnnouncementInfo); }
1235 }
1236 #[allow(unused)]
1237 impl NodeAnnouncementInfo {
1238         pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncementInfo {
1239                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1240         }
1241         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncementInfo {
1242                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1243         }
1244         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1245         pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncementInfo {
1246                 assert!(self.is_owned);
1247                 let ret = ObjOps::untweak_ptr(self.inner);
1248                 self.inner = std::ptr::null_mut();
1249                 ret
1250         }
1251 }
1252 /// Protocol features the node announced support for
1253 #[no_mangle]
1254 pub extern "C" fn NodeAnnouncementInfo_get_features(this_ptr: &NodeAnnouncementInfo) -> crate::lightning::ln::features::NodeFeatures {
1255         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
1256         crate::lightning::ln::features::NodeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
1257 }
1258 /// Protocol features the node announced support for
1259 #[no_mangle]
1260 pub extern "C" fn NodeAnnouncementInfo_set_features(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::lightning::ln::features::NodeFeatures) {
1261         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
1262 }
1263 /// When the last known update to the node state was issued.
1264 /// Value is opaque, as set in the announcement.
1265 #[no_mangle]
1266 pub extern "C" fn NodeAnnouncementInfo_get_last_update(this_ptr: &NodeAnnouncementInfo) -> u32 {
1267         let mut inner_val = &mut this_ptr.get_native_mut_ref().last_update;
1268         *inner_val
1269 }
1270 /// When the last known update to the node state was issued.
1271 /// Value is opaque, as set in the announcement.
1272 #[no_mangle]
1273 pub extern "C" fn NodeAnnouncementInfo_set_last_update(this_ptr: &mut NodeAnnouncementInfo, mut val: u32) {
1274         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.last_update = val;
1275 }
1276 /// Color assigned to the node
1277 #[no_mangle]
1278 pub extern "C" fn NodeAnnouncementInfo_get_rgb(this_ptr: &NodeAnnouncementInfo) -> *const [u8; 3] {
1279         let mut inner_val = &mut this_ptr.get_native_mut_ref().rgb;
1280         inner_val
1281 }
1282 /// Color assigned to the node
1283 #[no_mangle]
1284 pub extern "C" fn NodeAnnouncementInfo_set_rgb(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::c_types::ThreeBytes) {
1285         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.rgb = val.data;
1286 }
1287 /// Moniker assigned to the node.
1288 /// May be invalid or malicious (eg control chars),
1289 /// should not be exposed to the user.
1290 #[no_mangle]
1291 pub extern "C" fn NodeAnnouncementInfo_get_alias(this_ptr: &NodeAnnouncementInfo) -> *const [u8; 32] {
1292         let mut inner_val = &mut this_ptr.get_native_mut_ref().alias;
1293         inner_val
1294 }
1295 /// Moniker assigned to the node.
1296 /// May be invalid or malicious (eg control chars),
1297 /// should not be exposed to the user.
1298 #[no_mangle]
1299 pub extern "C" fn NodeAnnouncementInfo_set_alias(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::c_types::ThirtyTwoBytes) {
1300         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = val.data;
1301 }
1302 /// Internet-level addresses via which one can connect to the node
1303 #[no_mangle]
1304 pub extern "C" fn NodeAnnouncementInfo_set_addresses(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::c_types::derived::CVec_NetAddressZ) {
1305         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
1306         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.addresses = local_val;
1307 }
1308 /// An initial announcement of the node
1309 /// Mostly redundant with the data we store in fields explicitly.
1310 /// Everything else is useful only for sending out for initial routing sync.
1311 /// Not stored if contains excess data to prevent DoS.
1312 ///
1313 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1314 #[no_mangle]
1315 pub extern "C" fn NodeAnnouncementInfo_get_announcement_message(this_ptr: &NodeAnnouncementInfo) -> crate::lightning::ln::msgs::NodeAnnouncement {
1316         let mut inner_val = &mut this_ptr.get_native_mut_ref().announcement_message;
1317         let mut local_inner_val = crate::lightning::ln::msgs::NodeAnnouncement { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const _) as *mut _ }, is_owned: false };
1318         local_inner_val
1319 }
1320 /// An initial announcement of the node
1321 /// Mostly redundant with the data we store in fields explicitly.
1322 /// Everything else is useful only for sending out for initial routing sync.
1323 /// Not stored if contains excess data to prevent DoS.
1324 ///
1325 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1326 #[no_mangle]
1327 pub extern "C" fn NodeAnnouncementInfo_set_announcement_message(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::lightning::ln::msgs::NodeAnnouncement) {
1328         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1329         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.announcement_message = local_val;
1330 }
1331 /// Constructs a new NodeAnnouncementInfo given each field
1332 #[must_use]
1333 #[no_mangle]
1334 pub extern "C" fn NodeAnnouncementInfo_new(mut features_arg: crate::lightning::ln::features::NodeFeatures, mut last_update_arg: u32, mut rgb_arg: crate::c_types::ThreeBytes, mut alias_arg: crate::c_types::ThirtyTwoBytes, mut addresses_arg: crate::c_types::derived::CVec_NetAddressZ, mut announcement_message_arg: crate::lightning::ln::msgs::NodeAnnouncement) -> NodeAnnouncementInfo {
1335         let mut local_addresses_arg = Vec::new(); for mut item in addresses_arg.into_rust().drain(..) { local_addresses_arg.push( { item.into_native() }); };
1336         let mut local_announcement_message_arg = if announcement_message_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(announcement_message_arg.take_inner()) } }) };
1337         NodeAnnouncementInfo { inner: ObjOps::heap_alloc(nativeNodeAnnouncementInfo {
1338                 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
1339                 last_update: last_update_arg,
1340                 rgb: rgb_arg.data,
1341                 alias: alias_arg.data,
1342                 addresses: local_addresses_arg,
1343                 announcement_message: local_announcement_message_arg,
1344         }), is_owned: true }
1345 }
1346 impl Clone for NodeAnnouncementInfo {
1347         fn clone(&self) -> Self {
1348                 Self {
1349                         inner: if <*mut nativeNodeAnnouncementInfo>::is_null(self.inner) { std::ptr::null_mut() } else {
1350                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1351                         is_owned: true,
1352                 }
1353         }
1354 }
1355 #[allow(unused)]
1356 /// Used only if an object of this type is returned as a trait impl by a method
1357 pub(crate) extern "C" fn NodeAnnouncementInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
1358         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncementInfo)).clone() })) as *mut c_void
1359 }
1360 #[no_mangle]
1361 /// Creates a copy of the NodeAnnouncementInfo
1362 pub extern "C" fn NodeAnnouncementInfo_clone(orig: &NodeAnnouncementInfo) -> NodeAnnouncementInfo {
1363         orig.clone()
1364 }
1365 #[no_mangle]
1366 /// Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read
1367 pub extern "C" fn NodeAnnouncementInfo_write(obj: &NodeAnnouncementInfo) -> crate::c_types::derived::CVec_u8Z {
1368         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1369 }
1370 #[no_mangle]
1371 pub(crate) extern "C" fn NodeAnnouncementInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1372         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncementInfo) })
1373 }
1374 #[no_mangle]
1375 /// Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write
1376 pub extern "C" fn NodeAnnouncementInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementInfoDecodeErrorZ {
1377         let res = crate::c_types::deserialize_obj(ser);
1378         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::network_graph::NodeAnnouncementInfo { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
1379         local_res
1380 }
1381
1382 use lightning::routing::network_graph::NodeInfo as nativeNodeInfoImport;
1383 type nativeNodeInfo = nativeNodeInfoImport;
1384
1385 /// Details about a node in the network, known from the network announcement.
1386 #[must_use]
1387 #[repr(C)]
1388 pub struct NodeInfo {
1389         /// A pointer to the opaque Rust object.
1390
1391         /// Nearly everywhere, inner must be non-null, however in places where
1392         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1393         pub inner: *mut nativeNodeInfo,
1394         /// Indicates that this is the only struct which contains the same pointer.
1395
1396         /// Rust functions which take ownership of an object provided via an argument require
1397         /// this to be true and invalidate the object pointed to by inner.
1398         pub is_owned: bool,
1399 }
1400
1401 impl Drop for NodeInfo {
1402         fn drop(&mut self) {
1403                 if self.is_owned && !<*mut nativeNodeInfo>::is_null(self.inner) {
1404                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1405                 }
1406         }
1407 }
1408 /// Frees any resources used by the NodeInfo, if is_owned is set and inner is non-NULL.
1409 #[no_mangle]
1410 pub extern "C" fn NodeInfo_free(this_obj: NodeInfo) { }
1411 #[allow(unused)]
1412 /// Used only if an object of this type is returned as a trait impl by a method
1413 extern "C" fn NodeInfo_free_void(this_ptr: *mut c_void) {
1414         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeInfo); }
1415 }
1416 #[allow(unused)]
1417 impl NodeInfo {
1418         pub(crate) fn get_native_ref(&self) -> &'static nativeNodeInfo {
1419                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1420         }
1421         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeInfo {
1422                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1423         }
1424         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1425         pub(crate) fn take_inner(mut self) -> *mut nativeNodeInfo {
1426                 assert!(self.is_owned);
1427                 let ret = ObjOps::untweak_ptr(self.inner);
1428                 self.inner = std::ptr::null_mut();
1429                 ret
1430         }
1431 }
1432 /// All valid channels a node has announced
1433 #[no_mangle]
1434 pub extern "C" fn NodeInfo_set_channels(this_ptr: &mut NodeInfo, mut val: crate::c_types::derived::CVec_u64Z) {
1435         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
1436         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channels = local_val;
1437 }
1438 /// Lowest fees enabling routing via any of the enabled, known channels to a node.
1439 /// The two fields (flat and proportional fee) are independent,
1440 /// meaning they don't have to refer to the same channel.
1441 ///
1442 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1443 #[no_mangle]
1444 pub extern "C" fn NodeInfo_get_lowest_inbound_channel_fees(this_ptr: &NodeInfo) -> crate::lightning::routing::network_graph::RoutingFees {
1445         let mut inner_val = &mut this_ptr.get_native_mut_ref().lowest_inbound_channel_fees;
1446         let mut local_inner_val = crate::lightning::routing::network_graph::RoutingFees { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const _) as *mut _ }, is_owned: false };
1447         local_inner_val
1448 }
1449 /// Lowest fees enabling routing via any of the enabled, known channels to a node.
1450 /// The two fields (flat and proportional fee) are independent,
1451 /// meaning they don't have to refer to the same channel.
1452 ///
1453 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1454 #[no_mangle]
1455 pub extern "C" fn NodeInfo_set_lowest_inbound_channel_fees(this_ptr: &mut NodeInfo, mut val: crate::lightning::routing::network_graph::RoutingFees) {
1456         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1457         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.lowest_inbound_channel_fees = local_val;
1458 }
1459 /// More information about a node from node_announcement.
1460 /// Optional because we store a Node entry after learning about it from
1461 /// a channel announcement, but before receiving a node announcement.
1462 ///
1463 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1464 #[no_mangle]
1465 pub extern "C" fn NodeInfo_get_announcement_info(this_ptr: &NodeInfo) -> crate::lightning::routing::network_graph::NodeAnnouncementInfo {
1466         let mut inner_val = &mut this_ptr.get_native_mut_ref().announcement_info;
1467         let mut local_inner_val = crate::lightning::routing::network_graph::NodeAnnouncementInfo { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const _) as *mut _ }, is_owned: false };
1468         local_inner_val
1469 }
1470 /// More information about a node from node_announcement.
1471 /// Optional because we store a Node entry after learning about it from
1472 /// a channel announcement, but before receiving a node announcement.
1473 ///
1474 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1475 #[no_mangle]
1476 pub extern "C" fn NodeInfo_set_announcement_info(this_ptr: &mut NodeInfo, mut val: crate::lightning::routing::network_graph::NodeAnnouncementInfo) {
1477         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1478         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.announcement_info = local_val;
1479 }
1480 /// Constructs a new NodeInfo given each field
1481 #[must_use]
1482 #[no_mangle]
1483 pub extern "C" fn NodeInfo_new(mut channels_arg: crate::c_types::derived::CVec_u64Z, mut lowest_inbound_channel_fees_arg: crate::lightning::routing::network_graph::RoutingFees, mut announcement_info_arg: crate::lightning::routing::network_graph::NodeAnnouncementInfo) -> NodeInfo {
1484         let mut local_channels_arg = Vec::new(); for mut item in channels_arg.into_rust().drain(..) { local_channels_arg.push( { item }); };
1485         let mut local_lowest_inbound_channel_fees_arg = if lowest_inbound_channel_fees_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(lowest_inbound_channel_fees_arg.take_inner()) } }) };
1486         let mut local_announcement_info_arg = if announcement_info_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(announcement_info_arg.take_inner()) } }) };
1487         NodeInfo { inner: ObjOps::heap_alloc(nativeNodeInfo {
1488                 channels: local_channels_arg,
1489                 lowest_inbound_channel_fees: local_lowest_inbound_channel_fees_arg,
1490                 announcement_info: local_announcement_info_arg,
1491         }), is_owned: true }
1492 }
1493 impl Clone for NodeInfo {
1494         fn clone(&self) -> Self {
1495                 Self {
1496                         inner: if <*mut nativeNodeInfo>::is_null(self.inner) { std::ptr::null_mut() } else {
1497                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1498                         is_owned: true,
1499                 }
1500         }
1501 }
1502 #[allow(unused)]
1503 /// Used only if an object of this type is returned as a trait impl by a method
1504 pub(crate) extern "C" fn NodeInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
1505         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeInfo)).clone() })) as *mut c_void
1506 }
1507 #[no_mangle]
1508 /// Creates a copy of the NodeInfo
1509 pub extern "C" fn NodeInfo_clone(orig: &NodeInfo) -> NodeInfo {
1510         orig.clone()
1511 }
1512 #[no_mangle]
1513 /// Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read
1514 pub extern "C" fn NodeInfo_write(obj: &NodeInfo) -> crate::c_types::derived::CVec_u8Z {
1515         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1516 }
1517 #[no_mangle]
1518 pub(crate) extern "C" fn NodeInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1519         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeInfo) })
1520 }
1521 #[no_mangle]
1522 /// Read a NodeInfo from a byte array, created by NodeInfo_write
1523 pub extern "C" fn NodeInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeInfoDecodeErrorZ {
1524         let res = crate::c_types::deserialize_obj(ser);
1525         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::network_graph::NodeInfo { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
1526         local_res
1527 }
1528 #[no_mangle]
1529 /// Serialize the NetworkGraph object into a byte array which can be read by NetworkGraph_read
1530 pub extern "C" fn NetworkGraph_write(obj: &NetworkGraph) -> crate::c_types::derived::CVec_u8Z {
1531         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1532 }
1533 #[no_mangle]
1534 pub(crate) extern "C" fn NetworkGraph_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1535         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNetworkGraph) })
1536 }
1537 #[no_mangle]
1538 /// Read a NetworkGraph from a byte array, created by NetworkGraph_write
1539 pub extern "C" fn NetworkGraph_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NetworkGraphDecodeErrorZ {
1540         let res = crate::c_types::deserialize_obj(ser);
1541         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::network_graph::NetworkGraph { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
1542         local_res
1543 }
1544 /// Creates a new, empty, network graph.
1545 #[must_use]
1546 #[no_mangle]
1547 pub extern "C" fn NetworkGraph_new(mut genesis_hash: crate::c_types::ThirtyTwoBytes) -> crate::lightning::routing::network_graph::NetworkGraph {
1548         let mut ret = lightning::routing::network_graph::NetworkGraph::new(::bitcoin::hash_types::BlockHash::from_slice(&genesis_hash.data[..]).unwrap());
1549         crate::lightning::routing::network_graph::NetworkGraph { inner: ObjOps::heap_alloc(ret), is_owned: true }
1550 }
1551
1552 /// Returns a read-only view of the network graph.
1553 #[must_use]
1554 #[no_mangle]
1555 pub extern "C" fn NetworkGraph_read_only(this_arg: &NetworkGraph) -> crate::lightning::routing::network_graph::ReadOnlyNetworkGraph {
1556         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.read_only();
1557         crate::lightning::routing::network_graph::ReadOnlyNetworkGraph { inner: ObjOps::heap_alloc(ret), is_owned: true }
1558 }
1559
1560 /// For an already known node (from channel announcements), update its stored properties from a
1561 /// given node announcement.
1562 ///
1563 /// You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's
1564 /// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
1565 /// routing messages from a source using a protocol other than the lightning P2P protocol.
1566 #[must_use]
1567 #[no_mangle]
1568 pub extern "C" fn NetworkGraph_update_node_from_announcement(this_arg: &NetworkGraph, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
1569         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_node_from_announcement(msg.get_native_ref(), secp256k1::SECP256K1);
1570         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
1571         local_ret
1572 }
1573
1574 /// For an already known node (from channel announcements), update its stored properties from a
1575 /// given node announcement without verifying the associated signatures. Because we aren't
1576 /// given the associated signatures here we cannot relay the node announcement to any of our
1577 /// peers.
1578 #[must_use]
1579 #[no_mangle]
1580 pub extern "C" fn NetworkGraph_update_node_from_unsigned_announcement(this_arg: &NetworkGraph, msg: &crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
1581         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_node_from_unsigned_announcement(msg.get_native_ref());
1582         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
1583         local_ret
1584 }
1585
1586 /// Store or update channel info from a channel announcement.
1587 ///
1588 /// You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's
1589 /// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
1590 /// routing messages from a source using a protocol other than the lightning P2P protocol.
1591 ///
1592 /// If a `chain::Access` object is provided via `chain_access`, it will be called to verify
1593 /// the corresponding UTXO exists on chain and is correctly-formatted.
1594 #[must_use]
1595 #[no_mangle]
1596 pub extern "C" fn NetworkGraph_update_channel_from_announcement(this_arg: &NetworkGraph, msg: &crate::lightning::ln::msgs::ChannelAnnouncement, mut chain_access: crate::c_types::derived::COption_AccessZ) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
1597         let mut local_chain_access = { /* chain_access*/ let chain_access_opt = chain_access; { } if chain_access_opt.is_none() { None } else { Some({ chain_access_opt.take() }) } };
1598         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_channel_from_announcement(msg.get_native_ref(), &local_chain_access, secp256k1::SECP256K1);
1599         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
1600         local_ret
1601 }
1602
1603 /// Store or update channel info from a channel announcement without verifying the associated
1604 /// signatures. Because we aren't given the associated signatures here we cannot relay the
1605 /// channel announcement to any of our peers.
1606 ///
1607 /// If a `chain::Access` object is provided via `chain_access`, it will be called to verify
1608 /// the corresponding UTXO exists on chain and is correctly-formatted.
1609 #[must_use]
1610 #[no_mangle]
1611 pub extern "C" fn NetworkGraph_update_channel_from_unsigned_announcement(this_arg: &NetworkGraph, msg: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement, mut chain_access: crate::c_types::derived::COption_AccessZ) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
1612         let mut local_chain_access = { /* chain_access*/ let chain_access_opt = chain_access; { } if chain_access_opt.is_none() { None } else { Some({ chain_access_opt.take() }) } };
1613         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_channel_from_unsigned_announcement(msg.get_native_ref(), &local_chain_access);
1614         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
1615         local_ret
1616 }
1617
1618 /// Close a channel if a corresponding HTLC fail was sent.
1619 /// If permanent, removes a channel from the local storage.
1620 /// May cause the removal of nodes too, if this was their last channel.
1621 /// If not permanent, makes channels unavailable for routing.
1622 #[no_mangle]
1623 pub extern "C" fn NetworkGraph_close_channel_from_update(this_arg: &NetworkGraph, mut short_channel_id: u64, mut is_permanent: bool) {
1624         unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.close_channel_from_update(short_channel_id, is_permanent)
1625 }
1626
1627 /// Marks a node in the graph as failed.
1628 #[no_mangle]
1629 pub extern "C" fn NetworkGraph_fail_node(this_arg: &NetworkGraph, mut _node_id: crate::c_types::PublicKey, mut is_permanent: bool) {
1630         unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fail_node(&_node_id.into_rust(), is_permanent)
1631 }
1632
1633 /// For an already known (from announcement) channel, update info about one of the directions
1634 /// of the channel.
1635 ///
1636 /// You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's
1637 /// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
1638 /// routing messages from a source using a protocol other than the lightning P2P protocol.
1639 #[must_use]
1640 #[no_mangle]
1641 pub extern "C" fn NetworkGraph_update_channel(this_arg: &NetworkGraph, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
1642         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_channel(msg.get_native_ref(), secp256k1::SECP256K1);
1643         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
1644         local_ret
1645 }
1646
1647 /// For an already known (from announcement) channel, update info about one of the directions
1648 /// of the channel without verifying the associated signatures. Because we aren't given the
1649 /// associated signatures here we cannot relay the channel update to any of our peers.
1650 #[must_use]
1651 #[no_mangle]
1652 pub extern "C" fn NetworkGraph_update_channel_unsigned(this_arg: &NetworkGraph, msg: &crate::lightning::ln::msgs::UnsignedChannelUpdate) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
1653         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_channel_unsigned(msg.get_native_ref());
1654         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
1655         local_ret
1656 }
1657
1658 /// Get network addresses by node id.
1659 /// Returns None if the requested node is completely unknown,
1660 /// or if node announcement for the node was never received.
1661 #[must_use]
1662 #[no_mangle]
1663 pub extern "C" fn ReadOnlyNetworkGraph_get_addresses(this_arg: &ReadOnlyNetworkGraph, mut pubkey: crate::c_types::PublicKey) -> crate::c_types::derived::COption_CVec_NetAddressZZ {
1664         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_addresses(&pubkey.into_rust());
1665         let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_CVec_NetAddressZZ::None } else { crate::c_types::derived::COption_CVec_NetAddressZZ::Some( { let mut local_ret_0 = Vec::new(); for mut item in ret.unwrap().drain(..) { local_ret_0.push( { crate::lightning::ln::msgs::NetAddress::native_into(item) }); }; local_ret_0.into() }) };
1666         local_ret
1667 }
1668