Update auto-generated bindings
[ldk-c-bindings] / lightning-c-bindings / src / lightning / routing / gossip.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 alloc::str::FromStr;
12 use core::ffi::c_void;
13 use core::convert::Infallible;
14 use bitcoin::hashes::Hash;
15 use crate::c_types::*;
16 #[cfg(feature="no-std")]
17 use alloc::{vec::Vec, boxed::Box};
18
19
20 use lightning::routing::gossip::NodeId as nativeNodeIdImport;
21 pub(crate) type nativeNodeId = nativeNodeIdImport;
22
23 /// Represents the compressed public key of a node
24 #[must_use]
25 #[repr(C)]
26 pub struct NodeId {
27         /// A pointer to the opaque Rust object.
28
29         /// Nearly everywhere, inner must be non-null, however in places where
30         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
31         pub inner: *mut nativeNodeId,
32         /// Indicates that this is the only struct which contains the same pointer.
33
34         /// Rust functions which take ownership of an object provided via an argument require
35         /// this to be true and invalidate the object pointed to by inner.
36         pub is_owned: bool,
37 }
38
39 impl Drop for NodeId {
40         fn drop(&mut self) {
41                 if self.is_owned && !<*mut nativeNodeId>::is_null(self.inner) {
42                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
43                 }
44         }
45 }
46 /// Frees any resources used by the NodeId, if is_owned is set and inner is non-NULL.
47 #[no_mangle]
48 pub extern "C" fn NodeId_free(this_obj: NodeId) { }
49 #[allow(unused)]
50 /// Used only if an object of this type is returned as a trait impl by a method
51 pub(crate) extern "C" fn NodeId_free_void(this_ptr: *mut c_void) {
52         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeId); }
53 }
54 #[allow(unused)]
55 impl NodeId {
56         pub(crate) fn get_native_ref(&self) -> &'static nativeNodeId {
57                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
58         }
59         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeId {
60                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
61         }
62         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
63         pub(crate) fn take_inner(mut self) -> *mut nativeNodeId {
64                 assert!(self.is_owned);
65                 let ret = ObjOps::untweak_ptr(self.inner);
66                 self.inner = core::ptr::null_mut();
67                 ret
68         }
69 }
70 impl Clone for NodeId {
71         fn clone(&self) -> Self {
72                 Self {
73                         inner: if <*mut nativeNodeId>::is_null(self.inner) { core::ptr::null_mut() } else {
74                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
75                         is_owned: true,
76                 }
77         }
78 }
79 #[allow(unused)]
80 /// Used only if an object of this type is returned as a trait impl by a method
81 pub(crate) extern "C" fn NodeId_clone_void(this_ptr: *const c_void) -> *mut c_void {
82         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeId)).clone() })) as *mut c_void
83 }
84 #[no_mangle]
85 /// Creates a copy of the NodeId
86 pub extern "C" fn NodeId_clone(orig: &NodeId) -> NodeId {
87         orig.clone()
88 }
89 /// Create a new NodeId from a public key
90 #[must_use]
91 #[no_mangle]
92 pub extern "C" fn NodeId_from_pubkey(mut pubkey: crate::c_types::PublicKey) -> crate::lightning::routing::gossip::NodeId {
93         let mut ret = lightning::routing::gossip::NodeId::from_pubkey(&pubkey.into_rust());
94         crate::lightning::routing::gossip::NodeId { inner: ObjOps::heap_alloc(ret), is_owned: true }
95 }
96
97 /// Get the public key slice from this NodeId
98 #[must_use]
99 #[no_mangle]
100 pub extern "C" fn NodeId_as_slice(this_arg: &crate::lightning::routing::gossip::NodeId) -> crate::c_types::u8slice {
101         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.as_slice();
102         let mut local_ret = crate::c_types::u8slice::from_slice(ret);
103         local_ret
104 }
105
106 /// Checks if two NodeIds contain equal inner contents.
107 #[no_mangle]
108 pub extern "C" fn NodeId_hash(o: &NodeId) -> u64 {
109         if o.inner.is_null() { return 0; }
110         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
111         #[allow(deprecated)]
112         let mut hasher = core::hash::SipHasher::new();
113         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
114         core::hash::Hasher::finish(&hasher)
115 }
116 #[no_mangle]
117 /// Serialize the NodeId object into a byte array which can be read by NodeId_read
118 pub extern "C" fn NodeId_write(obj: &crate::lightning::routing::gossip::NodeId) -> crate::c_types::derived::CVec_u8Z {
119         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
120 }
121 #[no_mangle]
122 pub(crate) extern "C" fn NodeId_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
123         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeId) })
124 }
125 #[no_mangle]
126 /// Read a NodeId from a byte array, created by NodeId_write
127 pub extern "C" fn NodeId_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeIdDecodeErrorZ {
128         let res: Result<lightning::routing::gossip::NodeId, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
129         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::gossip::NodeId { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
130         local_res
131 }
132
133 use lightning::routing::gossip::NetworkGraph as nativeNetworkGraphImport;
134 pub(crate) type nativeNetworkGraph = nativeNetworkGraphImport<crate::lightning::util::logger::Logger>;
135
136 /// Represents the network as nodes and channels between them
137 #[must_use]
138 #[repr(C)]
139 pub struct NetworkGraph {
140         /// A pointer to the opaque Rust object.
141
142         /// Nearly everywhere, inner must be non-null, however in places where
143         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
144         pub inner: *mut nativeNetworkGraph,
145         /// Indicates that this is the only struct which contains the same pointer.
146
147         /// Rust functions which take ownership of an object provided via an argument require
148         /// this to be true and invalidate the object pointed to by inner.
149         pub is_owned: bool,
150 }
151
152 impl Drop for NetworkGraph {
153         fn drop(&mut self) {
154                 if self.is_owned && !<*mut nativeNetworkGraph>::is_null(self.inner) {
155                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
156                 }
157         }
158 }
159 /// Frees any resources used by the NetworkGraph, if is_owned is set and inner is non-NULL.
160 #[no_mangle]
161 pub extern "C" fn NetworkGraph_free(this_obj: NetworkGraph) { }
162 #[allow(unused)]
163 /// Used only if an object of this type is returned as a trait impl by a method
164 pub(crate) extern "C" fn NetworkGraph_free_void(this_ptr: *mut c_void) {
165         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNetworkGraph); }
166 }
167 #[allow(unused)]
168 impl NetworkGraph {
169         pub(crate) fn get_native_ref(&self) -> &'static nativeNetworkGraph {
170                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
171         }
172         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNetworkGraph {
173                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
174         }
175         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
176         pub(crate) fn take_inner(mut self) -> *mut nativeNetworkGraph {
177                 assert!(self.is_owned);
178                 let ret = ObjOps::untweak_ptr(self.inner);
179                 self.inner = core::ptr::null_mut();
180                 ret
181         }
182 }
183
184 use lightning::routing::gossip::ReadOnlyNetworkGraph as nativeReadOnlyNetworkGraphImport;
185 pub(crate) type nativeReadOnlyNetworkGraph = nativeReadOnlyNetworkGraphImport<'static>;
186
187 /// A read-only view of [`NetworkGraph`].
188 #[must_use]
189 #[repr(C)]
190 pub struct ReadOnlyNetworkGraph {
191         /// A pointer to the opaque Rust object.
192
193         /// Nearly everywhere, inner must be non-null, however in places where
194         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
195         pub inner: *mut nativeReadOnlyNetworkGraph,
196         /// Indicates that this is the only struct which contains the same pointer.
197
198         /// Rust functions which take ownership of an object provided via an argument require
199         /// this to be true and invalidate the object pointed to by inner.
200         pub is_owned: bool,
201 }
202
203 impl Drop for ReadOnlyNetworkGraph {
204         fn drop(&mut self) {
205                 if self.is_owned && !<*mut nativeReadOnlyNetworkGraph>::is_null(self.inner) {
206                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
207                 }
208         }
209 }
210 /// Frees any resources used by the ReadOnlyNetworkGraph, if is_owned is set and inner is non-NULL.
211 #[no_mangle]
212 pub extern "C" fn ReadOnlyNetworkGraph_free(this_obj: ReadOnlyNetworkGraph) { }
213 #[allow(unused)]
214 /// Used only if an object of this type is returned as a trait impl by a method
215 pub(crate) extern "C" fn ReadOnlyNetworkGraph_free_void(this_ptr: *mut c_void) {
216         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReadOnlyNetworkGraph); }
217 }
218 #[allow(unused)]
219 impl ReadOnlyNetworkGraph {
220         pub(crate) fn get_native_ref(&self) -> &'static nativeReadOnlyNetworkGraph {
221                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
222         }
223         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReadOnlyNetworkGraph {
224                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
225         }
226         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
227         pub(crate) fn take_inner(mut self) -> *mut nativeReadOnlyNetworkGraph {
228                 assert!(self.is_owned);
229                 let ret = ObjOps::untweak_ptr(self.inner);
230                 self.inner = core::ptr::null_mut();
231                 ret
232         }
233 }
234 /// Update to the [`NetworkGraph`] based on payment failure information conveyed via the Onion
235 /// return packet by a node along the route. See [BOLT #4] for details.
236 ///
237 /// [BOLT #4]: https://github.com/lightning/bolts/blob/master/04-onion-routing.md
238 #[derive(Clone)]
239 #[must_use]
240 #[repr(C)]
241 pub enum NetworkUpdate {
242         /// An error indicating a `channel_update` messages should be applied via
243         /// [`NetworkGraph::update_channel`].
244         ChannelUpdateMessage {
245                 /// The update to apply via [`NetworkGraph::update_channel`].
246                 msg: crate::lightning::ln::msgs::ChannelUpdate,
247         },
248         /// An error indicating that a channel failed to route a payment, which should be applied via
249         /// [`NetworkGraph::channel_failed`].
250         ChannelFailure {
251                 /// The short channel id of the closed channel.
252                 short_channel_id: u64,
253                 /// Whether the channel should be permanently removed or temporarily disabled until a new
254                 /// `channel_update` message is received.
255                 is_permanent: bool,
256         },
257         /// An error indicating that a node failed to route a payment, which should be applied via
258         /// [`NetworkGraph::node_failed_permanent`] if permanent.
259         NodeFailure {
260                 /// The node id of the failed node.
261                 node_id: crate::c_types::PublicKey,
262                 /// Whether the node should be permanently removed from consideration or can be restored
263                 /// when a new `channel_update` message is received.
264                 is_permanent: bool,
265         },
266 }
267 use lightning::routing::gossip::NetworkUpdate as NetworkUpdateImport;
268 pub(crate) type nativeNetworkUpdate = NetworkUpdateImport;
269
270 impl NetworkUpdate {
271         #[allow(unused)]
272         pub(crate) fn to_native(&self) -> nativeNetworkUpdate {
273                 match self {
274                         NetworkUpdate::ChannelUpdateMessage {ref msg, } => {
275                                 let mut msg_nonref = (*msg).clone();
276                                 nativeNetworkUpdate::ChannelUpdateMessage {
277                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
278                                 }
279                         },
280                         NetworkUpdate::ChannelFailure {ref short_channel_id, ref is_permanent, } => {
281                                 let mut short_channel_id_nonref = (*short_channel_id).clone();
282                                 let mut is_permanent_nonref = (*is_permanent).clone();
283                                 nativeNetworkUpdate::ChannelFailure {
284                                         short_channel_id: short_channel_id_nonref,
285                                         is_permanent: is_permanent_nonref,
286                                 }
287                         },
288                         NetworkUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
289                                 let mut node_id_nonref = (*node_id).clone();
290                                 let mut is_permanent_nonref = (*is_permanent).clone();
291                                 nativeNetworkUpdate::NodeFailure {
292                                         node_id: node_id_nonref.into_rust(),
293                                         is_permanent: is_permanent_nonref,
294                                 }
295                         },
296                 }
297         }
298         #[allow(unused)]
299         pub(crate) fn into_native(self) -> nativeNetworkUpdate {
300                 match self {
301                         NetworkUpdate::ChannelUpdateMessage {mut msg, } => {
302                                 nativeNetworkUpdate::ChannelUpdateMessage {
303                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
304                                 }
305                         },
306                         NetworkUpdate::ChannelFailure {mut short_channel_id, mut is_permanent, } => {
307                                 nativeNetworkUpdate::ChannelFailure {
308                                         short_channel_id: short_channel_id,
309                                         is_permanent: is_permanent,
310                                 }
311                         },
312                         NetworkUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
313                                 nativeNetworkUpdate::NodeFailure {
314                                         node_id: node_id.into_rust(),
315                                         is_permanent: is_permanent,
316                                 }
317                         },
318                 }
319         }
320         #[allow(unused)]
321         pub(crate) fn from_native(native: &nativeNetworkUpdate) -> Self {
322                 match native {
323                         nativeNetworkUpdate::ChannelUpdateMessage {ref msg, } => {
324                                 let mut msg_nonref = (*msg).clone();
325                                 NetworkUpdate::ChannelUpdateMessage {
326                                         msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
327                                 }
328                         },
329                         nativeNetworkUpdate::ChannelFailure {ref short_channel_id, ref is_permanent, } => {
330                                 let mut short_channel_id_nonref = (*short_channel_id).clone();
331                                 let mut is_permanent_nonref = (*is_permanent).clone();
332                                 NetworkUpdate::ChannelFailure {
333                                         short_channel_id: short_channel_id_nonref,
334                                         is_permanent: is_permanent_nonref,
335                                 }
336                         },
337                         nativeNetworkUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
338                                 let mut node_id_nonref = (*node_id).clone();
339                                 let mut is_permanent_nonref = (*is_permanent).clone();
340                                 NetworkUpdate::NodeFailure {
341                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
342                                         is_permanent: is_permanent_nonref,
343                                 }
344                         },
345                 }
346         }
347         #[allow(unused)]
348         pub(crate) fn native_into(native: nativeNetworkUpdate) -> Self {
349                 match native {
350                         nativeNetworkUpdate::ChannelUpdateMessage {mut msg, } => {
351                                 NetworkUpdate::ChannelUpdateMessage {
352                                         msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg), is_owned: true },
353                                 }
354                         },
355                         nativeNetworkUpdate::ChannelFailure {mut short_channel_id, mut is_permanent, } => {
356                                 NetworkUpdate::ChannelFailure {
357                                         short_channel_id: short_channel_id,
358                                         is_permanent: is_permanent,
359                                 }
360                         },
361                         nativeNetworkUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
362                                 NetworkUpdate::NodeFailure {
363                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
364                                         is_permanent: is_permanent,
365                                 }
366                         },
367                 }
368         }
369 }
370 /// Frees any resources used by the NetworkUpdate
371 #[no_mangle]
372 pub extern "C" fn NetworkUpdate_free(this_ptr: NetworkUpdate) { }
373 /// Creates a copy of the NetworkUpdate
374 #[no_mangle]
375 pub extern "C" fn NetworkUpdate_clone(orig: &NetworkUpdate) -> NetworkUpdate {
376         orig.clone()
377 }
378 #[no_mangle]
379 /// Utility method to constructs a new ChannelUpdateMessage-variant NetworkUpdate
380 pub extern "C" fn NetworkUpdate_channel_update_message(msg: crate::lightning::ln::msgs::ChannelUpdate) -> NetworkUpdate {
381         NetworkUpdate::ChannelUpdateMessage {
382                 msg,
383         }
384 }
385 #[no_mangle]
386 /// Utility method to constructs a new ChannelFailure-variant NetworkUpdate
387 pub extern "C" fn NetworkUpdate_channel_failure(short_channel_id: u64, is_permanent: bool) -> NetworkUpdate {
388         NetworkUpdate::ChannelFailure {
389                 short_channel_id,
390                 is_permanent,
391         }
392 }
393 #[no_mangle]
394 /// Utility method to constructs a new NodeFailure-variant NetworkUpdate
395 pub extern "C" fn NetworkUpdate_node_failure(node_id: crate::c_types::PublicKey, is_permanent: bool) -> NetworkUpdate {
396         NetworkUpdate::NodeFailure {
397                 node_id,
398                 is_permanent,
399         }
400 }
401 /// Checks if two NetworkUpdates contain equal inner contents.
402 /// This ignores pointers and is_owned flags and looks at the values in fields.
403 #[no_mangle]
404 pub extern "C" fn NetworkUpdate_eq(a: &NetworkUpdate, b: &NetworkUpdate) -> bool {
405         if &a.to_native() == &b.to_native() { true } else { false }
406 }
407 #[no_mangle]
408 /// Serialize the NetworkUpdate object into a byte array which can be read by NetworkUpdate_read
409 pub extern "C" fn NetworkUpdate_write(obj: &crate::lightning::routing::gossip::NetworkUpdate) -> crate::c_types::derived::CVec_u8Z {
410         crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
411 }
412 #[no_mangle]
413 /// Read a NetworkUpdate from a byte array, created by NetworkUpdate_write
414 pub extern "C" fn NetworkUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_NetworkUpdateZDecodeErrorZ {
415         let res: Result<Option<lightning::routing::gossip::NetworkUpdate>, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser);
416         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_NetworkUpdateZ::None } else { crate::c_types::derived::COption_NetworkUpdateZ::Some( { crate::lightning::routing::gossip::NetworkUpdate::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
417         local_res
418 }
419
420 use lightning::routing::gossip::P2PGossipSync as nativeP2PGossipSyncImport;
421 pub(crate) type nativeP2PGossipSync = nativeP2PGossipSyncImport<&'static lightning::routing::gossip::NetworkGraph<crate::lightning::util::logger::Logger>, crate::lightning::chain::Access, crate::lightning::util::logger::Logger>;
422
423 /// Receives and validates network updates from peers,
424 /// stores authentic and relevant data as a network graph.
425 /// This network graph is then used for routing payments.
426 /// Provides interface to help with initial routing sync by
427 /// serving historical announcements.
428 ///
429 /// Serves as an [`EventHandler`] for applying updates from [`Event::PaymentPathFailed`] to the
430 /// [`NetworkGraph`].
431 #[must_use]
432 #[repr(C)]
433 pub struct P2PGossipSync {
434         /// A pointer to the opaque Rust object.
435
436         /// Nearly everywhere, inner must be non-null, however in places where
437         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
438         pub inner: *mut nativeP2PGossipSync,
439         /// Indicates that this is the only struct which contains the same pointer.
440
441         /// Rust functions which take ownership of an object provided via an argument require
442         /// this to be true and invalidate the object pointed to by inner.
443         pub is_owned: bool,
444 }
445
446 impl Drop for P2PGossipSync {
447         fn drop(&mut self) {
448                 if self.is_owned && !<*mut nativeP2PGossipSync>::is_null(self.inner) {
449                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
450                 }
451         }
452 }
453 /// Frees any resources used by the P2PGossipSync, if is_owned is set and inner is non-NULL.
454 #[no_mangle]
455 pub extern "C" fn P2PGossipSync_free(this_obj: P2PGossipSync) { }
456 #[allow(unused)]
457 /// Used only if an object of this type is returned as a trait impl by a method
458 pub(crate) extern "C" fn P2PGossipSync_free_void(this_ptr: *mut c_void) {
459         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeP2PGossipSync); }
460 }
461 #[allow(unused)]
462 impl P2PGossipSync {
463         pub(crate) fn get_native_ref(&self) -> &'static nativeP2PGossipSync {
464                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
465         }
466         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeP2PGossipSync {
467                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
468         }
469         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
470         pub(crate) fn take_inner(mut self) -> *mut nativeP2PGossipSync {
471                 assert!(self.is_owned);
472                 let ret = ObjOps::untweak_ptr(self.inner);
473                 self.inner = core::ptr::null_mut();
474                 ret
475         }
476 }
477 /// Creates a new tracker of the actual state of the network of channels and nodes,
478 /// assuming an existing Network Graph.
479 /// Chain monitor is used to make sure announced channels exist on-chain,
480 /// channel data is correct, and that the announcement is signed with
481 /// channel owners' keys.
482 #[must_use]
483 #[no_mangle]
484 pub extern "C" fn P2PGossipSync_new(network_graph: &crate::lightning::routing::gossip::NetworkGraph, mut chain_access: crate::c_types::derived::COption_AccessZ, mut logger: crate::lightning::util::logger::Logger) -> crate::lightning::routing::gossip::P2PGossipSync {
485         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() }) } };
486         let mut ret = lightning::routing::gossip::P2PGossipSync::new(network_graph.get_native_ref(), local_chain_access, logger);
487         crate::lightning::routing::gossip::P2PGossipSync { inner: ObjOps::heap_alloc(ret), is_owned: true }
488 }
489
490 /// Adds a provider used to check new announcements. Does not affect
491 /// existing announcements unless they are updated.
492 /// Add, update or remove the provider would replace the current one.
493 #[no_mangle]
494 pub extern "C" fn P2PGossipSync_add_chain_access(this_arg: &mut crate::lightning::routing::gossip::P2PGossipSync, mut chain_access: crate::c_types::derived::COption_AccessZ) {
495         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() }) } };
496         unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::gossip::nativeP2PGossipSync)) }.add_chain_access(local_chain_access)
497 }
498
499 impl From<nativeNetworkGraph> for crate::lightning::util::events::EventHandler {
500         fn from(obj: nativeNetworkGraph) -> Self {
501                 let mut rust_obj = NetworkGraph { inner: ObjOps::heap_alloc(obj), is_owned: true };
502                 let mut ret = NetworkGraph_as_EventHandler(&rust_obj);
503                 // 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
504                 rust_obj.inner = core::ptr::null_mut();
505                 ret.free = Some(NetworkGraph_free_void);
506                 ret
507         }
508 }
509 /// Constructs a new EventHandler which calls the relevant methods on this_arg.
510 /// This copies the `inner` pointer in this_arg and thus the returned EventHandler must be freed before this_arg is
511 #[no_mangle]
512 pub extern "C" fn NetworkGraph_as_EventHandler(this_arg: &NetworkGraph) -> crate::lightning::util::events::EventHandler {
513         crate::lightning::util::events::EventHandler {
514                 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
515                 free: None,
516                 handle_event: NetworkGraph_EventHandler_handle_event,
517         }
518 }
519
520 extern "C" fn NetworkGraph_EventHandler_handle_event(this_arg: *const c_void, event: &crate::lightning::util::events::Event) {
521         <nativeNetworkGraph as lightning::util::events::EventHandler<>>::handle_event(unsafe { &mut *(this_arg as *mut nativeNetworkGraph) }, &event.to_native())
522 }
523
524 impl From<nativeP2PGossipSync> for crate::lightning::ln::msgs::RoutingMessageHandler {
525         fn from(obj: nativeP2PGossipSync) -> Self {
526                 let mut rust_obj = P2PGossipSync { inner: ObjOps::heap_alloc(obj), is_owned: true };
527                 let mut ret = P2PGossipSync_as_RoutingMessageHandler(&rust_obj);
528                 // 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
529                 rust_obj.inner = core::ptr::null_mut();
530                 ret.free = Some(P2PGossipSync_free_void);
531                 ret
532         }
533 }
534 /// Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg.
535 /// This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is
536 #[no_mangle]
537 pub extern "C" fn P2PGossipSync_as_RoutingMessageHandler(this_arg: &P2PGossipSync) -> crate::lightning::ln::msgs::RoutingMessageHandler {
538         crate::lightning::ln::msgs::RoutingMessageHandler {
539                 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
540                 free: None,
541                 handle_node_announcement: P2PGossipSync_RoutingMessageHandler_handle_node_announcement,
542                 handle_channel_announcement: P2PGossipSync_RoutingMessageHandler_handle_channel_announcement,
543                 handle_channel_update: P2PGossipSync_RoutingMessageHandler_handle_channel_update,
544                 get_next_channel_announcement: P2PGossipSync_RoutingMessageHandler_get_next_channel_announcement,
545                 get_next_node_announcement: P2PGossipSync_RoutingMessageHandler_get_next_node_announcement,
546                 peer_connected: P2PGossipSync_RoutingMessageHandler_peer_connected,
547                 handle_reply_channel_range: P2PGossipSync_RoutingMessageHandler_handle_reply_channel_range,
548                 handle_reply_short_channel_ids_end: P2PGossipSync_RoutingMessageHandler_handle_reply_short_channel_ids_end,
549                 handle_query_channel_range: P2PGossipSync_RoutingMessageHandler_handle_query_channel_range,
550                 handle_query_short_channel_ids: P2PGossipSync_RoutingMessageHandler_handle_query_short_channel_ids,
551                 provided_node_features: P2PGossipSync_RoutingMessageHandler_provided_node_features,
552                 provided_init_features: P2PGossipSync_RoutingMessageHandler_provided_init_features,
553                 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider {
554                         this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
555                         free: None,
556                         get_and_clear_pending_msg_events: P2PGossipSync_MessageSendEventsProvider_get_and_clear_pending_msg_events,
557                 },
558         }
559 }
560
561 #[must_use]
562 extern "C" fn P2PGossipSync_RoutingMessageHandler_handle_node_announcement(this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ {
563         let mut ret = <nativeP2PGossipSync as lightning::ln::msgs::RoutingMessageHandler<>>::handle_node_announcement(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, msg.get_native_ref());
564         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() };
565         local_ret
566 }
567 #[must_use]
568 extern "C" fn P2PGossipSync_RoutingMessageHandler_handle_channel_announcement(this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ {
569         let mut ret = <nativeP2PGossipSync as lightning::ln::msgs::RoutingMessageHandler<>>::handle_channel_announcement(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, msg.get_native_ref());
570         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() };
571         local_ret
572 }
573 #[must_use]
574 extern "C" fn P2PGossipSync_RoutingMessageHandler_handle_channel_update(this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ {
575         let mut ret = <nativeP2PGossipSync as lightning::ln::msgs::RoutingMessageHandler<>>::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, msg.get_native_ref());
576         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() };
577         local_ret
578 }
579 #[must_use]
580 extern "C" fn P2PGossipSync_RoutingMessageHandler_get_next_channel_announcement(this_arg: *const c_void, mut starting_point: u64) -> crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
581         let mut ret = <nativeP2PGossipSync as lightning::ln::msgs::RoutingMessageHandler<>>::get_next_channel_announcement(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, starting_point);
582         let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ::None } else { crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ::Some( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = (ret.unwrap()); let mut local_orig_ret_0_1 = crate::lightning::ln::msgs::ChannelUpdate { inner: if orig_ret_0_1.is_none() { core::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() { core::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 }) };
583         local_ret
584 }
585 #[must_use]
586 extern "C" fn P2PGossipSync_RoutingMessageHandler_get_next_node_announcement(this_arg: *const c_void, mut starting_point: crate::c_types::PublicKey) -> crate::lightning::ln::msgs::NodeAnnouncement {
587         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();
588         let mut ret = <nativeP2PGossipSync as lightning::ln::msgs::RoutingMessageHandler<>>::get_next_node_announcement(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, local_starting_point);
589         let mut local_ret = crate::lightning::ln::msgs::NodeAnnouncement { inner: if ret.is_none() { core::ptr::null_mut() } else {  { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true };
590         local_ret
591 }
592 #[must_use]
593 extern "C" fn P2PGossipSync_RoutingMessageHandler_peer_connected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init) -> crate::c_types::derived::CResult_NoneNoneZ {
594         let mut ret = <nativeP2PGossipSync as lightning::ln::msgs::RoutingMessageHandler<>>::peer_connected(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, &their_node_id.into_rust(), init.get_native_ref());
595         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
596         local_ret
597 }
598 #[must_use]
599 extern "C" fn P2PGossipSync_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 {
600         let mut ret = <nativeP2PGossipSync as lightning::ln::msgs::RoutingMessageHandler<>>::handle_reply_channel_range(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) });
601         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() };
602         local_ret
603 }
604 #[must_use]
605 extern "C" fn P2PGossipSync_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 {
606         let mut ret = <nativeP2PGossipSync as lightning::ln::msgs::RoutingMessageHandler<>>::handle_reply_short_channel_ids_end(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) });
607         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() };
608         local_ret
609 }
610 #[must_use]
611 extern "C" fn P2PGossipSync_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 {
612         let mut ret = <nativeP2PGossipSync as lightning::ln::msgs::RoutingMessageHandler<>>::handle_query_channel_range(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) });
613         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() };
614         local_ret
615 }
616 #[must_use]
617 extern "C" fn P2PGossipSync_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 {
618         let mut ret = <nativeP2PGossipSync as lightning::ln::msgs::RoutingMessageHandler<>>::handle_query_short_channel_ids(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) });
619         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() };
620         local_ret
621 }
622 #[must_use]
623 extern "C" fn P2PGossipSync_RoutingMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures {
624         let mut ret = <nativeP2PGossipSync as lightning::ln::msgs::RoutingMessageHandler<>>::provided_node_features(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, );
625         crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
626 }
627 #[must_use]
628 extern "C" fn P2PGossipSync_RoutingMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures {
629         let mut ret = <nativeP2PGossipSync as lightning::ln::msgs::RoutingMessageHandler<>>::provided_init_features(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, &their_node_id.into_rust());
630         crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
631 }
632
633 impl From<nativeP2PGossipSync> for crate::lightning::util::events::MessageSendEventsProvider {
634         fn from(obj: nativeP2PGossipSync) -> Self {
635                 let mut rust_obj = P2PGossipSync { inner: ObjOps::heap_alloc(obj), is_owned: true };
636                 let mut ret = P2PGossipSync_as_MessageSendEventsProvider(&rust_obj);
637                 // 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
638                 rust_obj.inner = core::ptr::null_mut();
639                 ret.free = Some(P2PGossipSync_free_void);
640                 ret
641         }
642 }
643 /// Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg.
644 /// This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is
645 #[no_mangle]
646 pub extern "C" fn P2PGossipSync_as_MessageSendEventsProvider(this_arg: &P2PGossipSync) -> crate::lightning::util::events::MessageSendEventsProvider {
647         crate::lightning::util::events::MessageSendEventsProvider {
648                 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
649                 free: None,
650                 get_and_clear_pending_msg_events: P2PGossipSync_MessageSendEventsProvider_get_and_clear_pending_msg_events,
651         }
652 }
653
654 #[must_use]
655 extern "C" fn P2PGossipSync_MessageSendEventsProvider_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ {
656         let mut ret = <nativeP2PGossipSync as lightning::util::events::MessageSendEventsProvider<>>::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, );
657         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::util::events::MessageSendEvent::native_into(item) }); };
658         local_ret.into()
659 }
660
661
662 use lightning::routing::gossip::ChannelUpdateInfo as nativeChannelUpdateInfoImport;
663 pub(crate) type nativeChannelUpdateInfo = nativeChannelUpdateInfoImport;
664
665 /// Details about one direction of a channel as received within a [`ChannelUpdate`].
666 #[must_use]
667 #[repr(C)]
668 pub struct ChannelUpdateInfo {
669         /// A pointer to the opaque Rust object.
670
671         /// Nearly everywhere, inner must be non-null, however in places where
672         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
673         pub inner: *mut nativeChannelUpdateInfo,
674         /// Indicates that this is the only struct which contains the same pointer.
675
676         /// Rust functions which take ownership of an object provided via an argument require
677         /// this to be true and invalidate the object pointed to by inner.
678         pub is_owned: bool,
679 }
680
681 impl Drop for ChannelUpdateInfo {
682         fn drop(&mut self) {
683                 if self.is_owned && !<*mut nativeChannelUpdateInfo>::is_null(self.inner) {
684                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
685                 }
686         }
687 }
688 /// Frees any resources used by the ChannelUpdateInfo, if is_owned is set and inner is non-NULL.
689 #[no_mangle]
690 pub extern "C" fn ChannelUpdateInfo_free(this_obj: ChannelUpdateInfo) { }
691 #[allow(unused)]
692 /// Used only if an object of this type is returned as a trait impl by a method
693 pub(crate) extern "C" fn ChannelUpdateInfo_free_void(this_ptr: *mut c_void) {
694         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelUpdateInfo); }
695 }
696 #[allow(unused)]
697 impl ChannelUpdateInfo {
698         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelUpdateInfo {
699                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
700         }
701         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelUpdateInfo {
702                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
703         }
704         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
705         pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdateInfo {
706                 assert!(self.is_owned);
707                 let ret = ObjOps::untweak_ptr(self.inner);
708                 self.inner = core::ptr::null_mut();
709                 ret
710         }
711 }
712 /// When the last update to the channel direction was issued.
713 /// Value is opaque, as set in the announcement.
714 #[no_mangle]
715 pub extern "C" fn ChannelUpdateInfo_get_last_update(this_ptr: &ChannelUpdateInfo) -> u32 {
716         let mut inner_val = &mut this_ptr.get_native_mut_ref().last_update;
717         *inner_val
718 }
719 /// When the last update to the channel direction was issued.
720 /// Value is opaque, as set in the announcement.
721 #[no_mangle]
722 pub extern "C" fn ChannelUpdateInfo_set_last_update(this_ptr: &mut ChannelUpdateInfo, mut val: u32) {
723         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.last_update = val;
724 }
725 /// Whether the channel can be currently used for payments (in this one direction).
726 #[no_mangle]
727 pub extern "C" fn ChannelUpdateInfo_get_enabled(this_ptr: &ChannelUpdateInfo) -> bool {
728         let mut inner_val = &mut this_ptr.get_native_mut_ref().enabled;
729         *inner_val
730 }
731 /// Whether the channel can be currently used for payments (in this one direction).
732 #[no_mangle]
733 pub extern "C" fn ChannelUpdateInfo_set_enabled(this_ptr: &mut ChannelUpdateInfo, mut val: bool) {
734         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.enabled = val;
735 }
736 /// The difference in CLTV values that you must have when routing through this channel.
737 #[no_mangle]
738 pub extern "C" fn ChannelUpdateInfo_get_cltv_expiry_delta(this_ptr: &ChannelUpdateInfo) -> u16 {
739         let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
740         *inner_val
741 }
742 /// The difference in CLTV values that you must have when routing through this channel.
743 #[no_mangle]
744 pub extern "C" fn ChannelUpdateInfo_set_cltv_expiry_delta(this_ptr: &mut ChannelUpdateInfo, mut val: u16) {
745         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
746 }
747 /// The minimum value, which must be relayed to the next hop via the channel
748 #[no_mangle]
749 pub extern "C" fn ChannelUpdateInfo_get_htlc_minimum_msat(this_ptr: &ChannelUpdateInfo) -> u64 {
750         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
751         *inner_val
752 }
753 /// The minimum value, which must be relayed to the next hop via the channel
754 #[no_mangle]
755 pub extern "C" fn ChannelUpdateInfo_set_htlc_minimum_msat(this_ptr: &mut ChannelUpdateInfo, mut val: u64) {
756         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
757 }
758 /// The maximum value which may be relayed to the next hop via the channel.
759 #[no_mangle]
760 pub extern "C" fn ChannelUpdateInfo_get_htlc_maximum_msat(this_ptr: &ChannelUpdateInfo) -> u64 {
761         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat;
762         *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 ChannelUpdateInfo_set_htlc_maximum_msat(this_ptr: &mut ChannelUpdateInfo, mut val: u64) {
767         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val;
768 }
769 /// Fees charged when the channel is used for routing
770 #[no_mangle]
771 pub extern "C" fn ChannelUpdateInfo_get_fees(this_ptr: &ChannelUpdateInfo) -> crate::lightning::routing::gossip::RoutingFees {
772         let mut inner_val = &mut this_ptr.get_native_mut_ref().fees;
773         crate::lightning::routing::gossip::RoutingFees { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::RoutingFees<>) as *mut _) }, is_owned: false }
774 }
775 /// Fees charged when the channel is used for routing
776 #[no_mangle]
777 pub extern "C" fn ChannelUpdateInfo_set_fees(this_ptr: &mut ChannelUpdateInfo, mut val: crate::lightning::routing::gossip::RoutingFees) {
778         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fees = *unsafe { Box::from_raw(val.take_inner()) };
779 }
780 /// Most recent update for the channel received from the network
781 /// Mostly redundant with the data we store in fields explicitly.
782 /// Everything else is useful only for sending out for initial routing sync.
783 /// Not stored if contains excess data to prevent DoS.
784 ///
785 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
786 #[no_mangle]
787 pub extern "C" fn ChannelUpdateInfo_get_last_update_message(this_ptr: &ChannelUpdateInfo) -> crate::lightning::ln::msgs::ChannelUpdate {
788         let mut inner_val = &mut this_ptr.get_native_mut_ref().last_update_message;
789         let mut local_inner_val = crate::lightning::ln::msgs::ChannelUpdate { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::ChannelUpdate<>) as *mut _ }, is_owned: false };
790         local_inner_val
791 }
792 /// Most recent update for the channel received from the network
793 /// Mostly redundant with the data we store in fields explicitly.
794 /// Everything else is useful only for sending out for initial routing sync.
795 /// Not stored if contains excess data to prevent DoS.
796 ///
797 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
798 #[no_mangle]
799 pub extern "C" fn ChannelUpdateInfo_set_last_update_message(this_ptr: &mut ChannelUpdateInfo, mut val: crate::lightning::ln::msgs::ChannelUpdate) {
800         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
801         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.last_update_message = local_val;
802 }
803 /// Constructs a new ChannelUpdateInfo given each field
804 #[must_use]
805 #[no_mangle]
806 pub extern "C" fn ChannelUpdateInfo_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: u64, mut fees_arg: crate::lightning::routing::gossip::RoutingFees, mut last_update_message_arg: crate::lightning::ln::msgs::ChannelUpdate) -> ChannelUpdateInfo {
807         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()) } }) };
808         ChannelUpdateInfo { inner: ObjOps::heap_alloc(nativeChannelUpdateInfo {
809                 last_update: last_update_arg,
810                 enabled: enabled_arg,
811                 cltv_expiry_delta: cltv_expiry_delta_arg,
812                 htlc_minimum_msat: htlc_minimum_msat_arg,
813                 htlc_maximum_msat: htlc_maximum_msat_arg,
814                 fees: *unsafe { Box::from_raw(fees_arg.take_inner()) },
815                 last_update_message: local_last_update_message_arg,
816         }), is_owned: true }
817 }
818 impl Clone for ChannelUpdateInfo {
819         fn clone(&self) -> Self {
820                 Self {
821                         inner: if <*mut nativeChannelUpdateInfo>::is_null(self.inner) { core::ptr::null_mut() } else {
822                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
823                         is_owned: true,
824                 }
825         }
826 }
827 #[allow(unused)]
828 /// Used only if an object of this type is returned as a trait impl by a method
829 pub(crate) extern "C" fn ChannelUpdateInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
830         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelUpdateInfo)).clone() })) as *mut c_void
831 }
832 #[no_mangle]
833 /// Creates a copy of the ChannelUpdateInfo
834 pub extern "C" fn ChannelUpdateInfo_clone(orig: &ChannelUpdateInfo) -> ChannelUpdateInfo {
835         orig.clone()
836 }
837 /// Checks if two ChannelUpdateInfos contain equal inner contents.
838 /// This ignores pointers and is_owned flags and looks at the values in fields.
839 /// Two objects with NULL inner values will be considered "equal" here.
840 #[no_mangle]
841 pub extern "C" fn ChannelUpdateInfo_eq(a: &ChannelUpdateInfo, b: &ChannelUpdateInfo) -> bool {
842         if a.inner == b.inner { return true; }
843         if a.inner.is_null() || b.inner.is_null() { return false; }
844         if a.get_native_ref() == b.get_native_ref() { true } else { false }
845 }
846 #[no_mangle]
847 /// Serialize the ChannelUpdateInfo object into a byte array which can be read by ChannelUpdateInfo_read
848 pub extern "C" fn ChannelUpdateInfo_write(obj: &crate::lightning::routing::gossip::ChannelUpdateInfo) -> crate::c_types::derived::CVec_u8Z {
849         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
850 }
851 #[no_mangle]
852 pub(crate) extern "C" fn ChannelUpdateInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
853         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdateInfo) })
854 }
855 #[no_mangle]
856 /// Read a ChannelUpdateInfo from a byte array, created by ChannelUpdateInfo_write
857 pub extern "C" fn ChannelUpdateInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateInfoDecodeErrorZ {
858         let res: Result<lightning::routing::gossip::ChannelUpdateInfo, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
859         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::gossip::ChannelUpdateInfo { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
860         local_res
861 }
862
863 use lightning::routing::gossip::ChannelInfo as nativeChannelInfoImport;
864 pub(crate) type nativeChannelInfo = nativeChannelInfoImport;
865
866 /// Details about a channel (both directions).
867 /// Received within a channel announcement.
868 #[must_use]
869 #[repr(C)]
870 pub struct ChannelInfo {
871         /// A pointer to the opaque Rust object.
872
873         /// Nearly everywhere, inner must be non-null, however in places where
874         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
875         pub inner: *mut nativeChannelInfo,
876         /// Indicates that this is the only struct which contains the same pointer.
877
878         /// Rust functions which take ownership of an object provided via an argument require
879         /// this to be true and invalidate the object pointed to by inner.
880         pub is_owned: bool,
881 }
882
883 impl Drop for ChannelInfo {
884         fn drop(&mut self) {
885                 if self.is_owned && !<*mut nativeChannelInfo>::is_null(self.inner) {
886                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
887                 }
888         }
889 }
890 /// Frees any resources used by the ChannelInfo, if is_owned is set and inner is non-NULL.
891 #[no_mangle]
892 pub extern "C" fn ChannelInfo_free(this_obj: ChannelInfo) { }
893 #[allow(unused)]
894 /// Used only if an object of this type is returned as a trait impl by a method
895 pub(crate) extern "C" fn ChannelInfo_free_void(this_ptr: *mut c_void) {
896         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelInfo); }
897 }
898 #[allow(unused)]
899 impl ChannelInfo {
900         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelInfo {
901                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
902         }
903         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelInfo {
904                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
905         }
906         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
907         pub(crate) fn take_inner(mut self) -> *mut nativeChannelInfo {
908                 assert!(self.is_owned);
909                 let ret = ObjOps::untweak_ptr(self.inner);
910                 self.inner = core::ptr::null_mut();
911                 ret
912         }
913 }
914 /// Protocol features of a channel communicated during its announcement
915 #[no_mangle]
916 pub extern "C" fn ChannelInfo_get_features(this_ptr: &ChannelInfo) -> crate::lightning::ln::features::ChannelFeatures {
917         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
918         crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::ChannelFeatures<>) as *mut _) }, is_owned: false }
919 }
920 /// Protocol features of a channel communicated during its announcement
921 #[no_mangle]
922 pub extern "C" fn ChannelInfo_set_features(this_ptr: &mut ChannelInfo, mut val: crate::lightning::ln::features::ChannelFeatures) {
923         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
924 }
925 /// Source node of the first direction of a channel
926 #[no_mangle]
927 pub extern "C" fn ChannelInfo_get_node_one(this_ptr: &ChannelInfo) -> crate::lightning::routing::gossip::NodeId {
928         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_one;
929         crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }
930 }
931 /// Source node of the first direction of a channel
932 #[no_mangle]
933 pub extern "C" fn ChannelInfo_set_node_one(this_ptr: &mut ChannelInfo, mut val: crate::lightning::routing::gossip::NodeId) {
934         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_one = *unsafe { Box::from_raw(val.take_inner()) };
935 }
936 /// Details about the first direction of a channel
937 ///
938 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
939 #[no_mangle]
940 pub extern "C" fn ChannelInfo_get_one_to_two(this_ptr: &ChannelInfo) -> crate::lightning::routing::gossip::ChannelUpdateInfo {
941         let mut inner_val = &mut this_ptr.get_native_mut_ref().one_to_two;
942         let mut local_inner_val = crate::lightning::routing::gossip::ChannelUpdateInfo { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::routing::gossip::ChannelUpdateInfo<>) as *mut _ }, is_owned: false };
943         local_inner_val
944 }
945 /// Details about the first direction of a channel
946 ///
947 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
948 #[no_mangle]
949 pub extern "C" fn ChannelInfo_set_one_to_two(this_ptr: &mut ChannelInfo, mut val: crate::lightning::routing::gossip::ChannelUpdateInfo) {
950         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
951         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.one_to_two = local_val;
952 }
953 /// Source node of the second direction of a channel
954 #[no_mangle]
955 pub extern "C" fn ChannelInfo_get_node_two(this_ptr: &ChannelInfo) -> crate::lightning::routing::gossip::NodeId {
956         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_two;
957         crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }
958 }
959 /// Source node of the second direction of a channel
960 #[no_mangle]
961 pub extern "C" fn ChannelInfo_set_node_two(this_ptr: &mut ChannelInfo, mut val: crate::lightning::routing::gossip::NodeId) {
962         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_two = *unsafe { Box::from_raw(val.take_inner()) };
963 }
964 /// Details about the second direction of a channel
965 ///
966 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
967 #[no_mangle]
968 pub extern "C" fn ChannelInfo_get_two_to_one(this_ptr: &ChannelInfo) -> crate::lightning::routing::gossip::ChannelUpdateInfo {
969         let mut inner_val = &mut this_ptr.get_native_mut_ref().two_to_one;
970         let mut local_inner_val = crate::lightning::routing::gossip::ChannelUpdateInfo { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::routing::gossip::ChannelUpdateInfo<>) as *mut _ }, is_owned: false };
971         local_inner_val
972 }
973 /// Details about the second direction of a channel
974 ///
975 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
976 #[no_mangle]
977 pub extern "C" fn ChannelInfo_set_two_to_one(this_ptr: &mut ChannelInfo, mut val: crate::lightning::routing::gossip::ChannelUpdateInfo) {
978         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
979         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.two_to_one = local_val;
980 }
981 /// The channel capacity as seen on-chain, if chain lookup is available.
982 #[no_mangle]
983 pub extern "C" fn ChannelInfo_get_capacity_sats(this_ptr: &ChannelInfo) -> crate::c_types::derived::COption_u64Z {
984         let mut inner_val = &mut this_ptr.get_native_mut_ref().capacity_sats;
985         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() }) };
986         local_inner_val
987 }
988 /// The channel capacity as seen on-chain, if chain lookup is available.
989 #[no_mangle]
990 pub extern "C" fn ChannelInfo_set_capacity_sats(this_ptr: &mut ChannelInfo, mut val: crate::c_types::derived::COption_u64Z) {
991         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
992         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.capacity_sats = local_val;
993 }
994 /// An initial announcement of the channel
995 /// Mostly redundant with the data we store in fields explicitly.
996 /// Everything else is useful only for sending out for initial routing sync.
997 /// Not stored if contains excess data to prevent DoS.
998 ///
999 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1000 #[no_mangle]
1001 pub extern "C" fn ChannelInfo_get_announcement_message(this_ptr: &ChannelInfo) -> crate::lightning::ln::msgs::ChannelAnnouncement {
1002         let mut inner_val = &mut this_ptr.get_native_mut_ref().announcement_message;
1003         let mut local_inner_val = crate::lightning::ln::msgs::ChannelAnnouncement { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::ChannelAnnouncement<>) as *mut _ }, is_owned: false };
1004         local_inner_val
1005 }
1006 /// An initial announcement of the channel
1007 /// Mostly redundant with the data we store in fields explicitly.
1008 /// Everything else is useful only for sending out for initial routing sync.
1009 /// Not stored if contains excess data to prevent DoS.
1010 ///
1011 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1012 #[no_mangle]
1013 pub extern "C" fn ChannelInfo_set_announcement_message(this_ptr: &mut ChannelInfo, mut val: crate::lightning::ln::msgs::ChannelAnnouncement) {
1014         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1015         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.announcement_message = local_val;
1016 }
1017 impl Clone for ChannelInfo {
1018         fn clone(&self) -> Self {
1019                 Self {
1020                         inner: if <*mut nativeChannelInfo>::is_null(self.inner) { core::ptr::null_mut() } else {
1021                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1022                         is_owned: true,
1023                 }
1024         }
1025 }
1026 #[allow(unused)]
1027 /// Used only if an object of this type is returned as a trait impl by a method
1028 pub(crate) extern "C" fn ChannelInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
1029         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelInfo)).clone() })) as *mut c_void
1030 }
1031 #[no_mangle]
1032 /// Creates a copy of the ChannelInfo
1033 pub extern "C" fn ChannelInfo_clone(orig: &ChannelInfo) -> ChannelInfo {
1034         orig.clone()
1035 }
1036 /// Checks if two ChannelInfos contain equal inner contents.
1037 /// This ignores pointers and is_owned flags and looks at the values in fields.
1038 /// Two objects with NULL inner values will be considered "equal" here.
1039 #[no_mangle]
1040 pub extern "C" fn ChannelInfo_eq(a: &ChannelInfo, b: &ChannelInfo) -> bool {
1041         if a.inner == b.inner { return true; }
1042         if a.inner.is_null() || b.inner.is_null() { return false; }
1043         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1044 }
1045 /// Returns a [`ChannelUpdateInfo`] based on the direction implied by the channel_flag.
1046 ///
1047 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1048 #[must_use]
1049 #[no_mangle]
1050 pub extern "C" fn ChannelInfo_get_directional_info(this_arg: &crate::lightning::routing::gossip::ChannelInfo, mut channel_flags: u8) -> crate::lightning::routing::gossip::ChannelUpdateInfo {
1051         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_directional_info(channel_flags);
1052         let mut local_ret = crate::lightning::routing::gossip::ChannelUpdateInfo { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::routing::gossip::ChannelUpdateInfo<>) as *mut _ }, is_owned: false };
1053         local_ret
1054 }
1055
1056 #[no_mangle]
1057 /// Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read
1058 pub extern "C" fn ChannelInfo_write(obj: &crate::lightning::routing::gossip::ChannelInfo) -> crate::c_types::derived::CVec_u8Z {
1059         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1060 }
1061 #[no_mangle]
1062 pub(crate) extern "C" fn ChannelInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1063         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelInfo) })
1064 }
1065 #[no_mangle]
1066 /// Read a ChannelInfo from a byte array, created by ChannelInfo_write
1067 pub extern "C" fn ChannelInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelInfoDecodeErrorZ {
1068         let res: Result<lightning::routing::gossip::ChannelInfo, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
1069         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::gossip::ChannelInfo { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
1070         local_res
1071 }
1072
1073 use lightning::routing::gossip::DirectedChannelInfo as nativeDirectedChannelInfoImport;
1074 pub(crate) type nativeDirectedChannelInfo = nativeDirectedChannelInfoImport<'static>;
1075
1076 /// A wrapper around [`ChannelInfo`] representing information about the channel as directed from a
1077 /// source node to a target node.
1078 #[must_use]
1079 #[repr(C)]
1080 pub struct DirectedChannelInfo {
1081         /// A pointer to the opaque Rust object.
1082
1083         /// Nearly everywhere, inner must be non-null, however in places where
1084         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1085         pub inner: *mut nativeDirectedChannelInfo,
1086         /// Indicates that this is the only struct which contains the same pointer.
1087
1088         /// Rust functions which take ownership of an object provided via an argument require
1089         /// this to be true and invalidate the object pointed to by inner.
1090         pub is_owned: bool,
1091 }
1092
1093 impl Drop for DirectedChannelInfo {
1094         fn drop(&mut self) {
1095                 if self.is_owned && !<*mut nativeDirectedChannelInfo>::is_null(self.inner) {
1096                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1097                 }
1098         }
1099 }
1100 /// Frees any resources used by the DirectedChannelInfo, if is_owned is set and inner is non-NULL.
1101 #[no_mangle]
1102 pub extern "C" fn DirectedChannelInfo_free(this_obj: DirectedChannelInfo) { }
1103 #[allow(unused)]
1104 /// Used only if an object of this type is returned as a trait impl by a method
1105 pub(crate) extern "C" fn DirectedChannelInfo_free_void(this_ptr: *mut c_void) {
1106         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDirectedChannelInfo); }
1107 }
1108 #[allow(unused)]
1109 impl DirectedChannelInfo {
1110         pub(crate) fn get_native_ref(&self) -> &'static nativeDirectedChannelInfo {
1111                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1112         }
1113         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeDirectedChannelInfo {
1114                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1115         }
1116         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1117         pub(crate) fn take_inner(mut self) -> *mut nativeDirectedChannelInfo {
1118                 assert!(self.is_owned);
1119                 let ret = ObjOps::untweak_ptr(self.inner);
1120                 self.inner = core::ptr::null_mut();
1121                 ret
1122         }
1123 }
1124 impl Clone for DirectedChannelInfo {
1125         fn clone(&self) -> Self {
1126                 Self {
1127                         inner: if <*mut nativeDirectedChannelInfo>::is_null(self.inner) { core::ptr::null_mut() } else {
1128                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1129                         is_owned: true,
1130                 }
1131         }
1132 }
1133 #[allow(unused)]
1134 /// Used only if an object of this type is returned as a trait impl by a method
1135 pub(crate) extern "C" fn DirectedChannelInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
1136         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDirectedChannelInfo)).clone() })) as *mut c_void
1137 }
1138 #[no_mangle]
1139 /// Creates a copy of the DirectedChannelInfo
1140 pub extern "C" fn DirectedChannelInfo_clone(orig: &DirectedChannelInfo) -> DirectedChannelInfo {
1141         orig.clone()
1142 }
1143 /// Returns information for the channel.
1144 #[must_use]
1145 #[no_mangle]
1146 pub extern "C" fn DirectedChannelInfo_channel(this_arg: &crate::lightning::routing::gossip::DirectedChannelInfo) -> crate::lightning::routing::gossip::ChannelInfo {
1147         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel();
1148         crate::lightning::routing::gossip::ChannelInfo { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::routing::gossip::ChannelInfo<>) as *mut _) }, is_owned: false }
1149 }
1150
1151 /// Returns information for the direction.
1152 ///
1153 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1154 #[must_use]
1155 #[no_mangle]
1156 pub extern "C" fn DirectedChannelInfo_direction(this_arg: &crate::lightning::routing::gossip::DirectedChannelInfo) -> crate::lightning::routing::gossip::ChannelUpdateInfo {
1157         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.direction();
1158         let mut local_ret = crate::lightning::routing::gossip::ChannelUpdateInfo { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::routing::gossip::ChannelUpdateInfo<>) as *mut _ }, is_owned: false };
1159         local_ret
1160 }
1161
1162 /// Returns the maximum HTLC amount allowed over the channel in the direction.
1163 #[must_use]
1164 #[no_mangle]
1165 pub extern "C" fn DirectedChannelInfo_htlc_maximum_msat(this_arg: &crate::lightning::routing::gossip::DirectedChannelInfo) -> u64 {
1166         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.htlc_maximum_msat();
1167         ret
1168 }
1169
1170 /// Returns the [`EffectiveCapacity`] of the channel in the direction.
1171 ///
1172 /// This is either the total capacity from the funding transaction, if known, or the
1173 /// `htlc_maximum_msat` for the direction as advertised by the gossip network, if known,
1174 /// otherwise.
1175 #[must_use]
1176 #[no_mangle]
1177 pub extern "C" fn DirectedChannelInfo_effective_capacity(this_arg: &crate::lightning::routing::gossip::DirectedChannelInfo) -> crate::lightning::routing::gossip::EffectiveCapacity {
1178         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.effective_capacity();
1179         crate::lightning::routing::gossip::EffectiveCapacity::native_into(ret)
1180 }
1181
1182 /// The effective capacity of a channel for routing purposes.
1183 ///
1184 /// While this may be smaller than the actual channel capacity, amounts greater than
1185 /// [`Self::as_msat`] should not be routed through the channel.
1186 #[derive(Clone)]
1187 #[must_use]
1188 #[repr(C)]
1189 pub enum EffectiveCapacity {
1190         /// The available liquidity in the channel known from being a channel counterparty, and thus a
1191         /// direct hop.
1192         ExactLiquidity {
1193                 /// Either the inbound or outbound liquidity depending on the direction, denominated in
1194                 /// millisatoshi.
1195                 liquidity_msat: u64,
1196         },
1197         /// The maximum HTLC amount in one direction as advertised on the gossip network.
1198         MaximumHTLC {
1199                 /// The maximum HTLC amount denominated in millisatoshi.
1200                 amount_msat: u64,
1201         },
1202         /// The total capacity of the channel as determined by the funding transaction.
1203         Total {
1204                 /// The funding amount denominated in millisatoshi.
1205                 capacity_msat: u64,
1206                 /// The maximum HTLC amount denominated in millisatoshi.
1207                 htlc_maximum_msat: crate::c_types::derived::COption_u64Z,
1208         },
1209         /// A capacity sufficient to route any payment, typically used for private channels provided by
1210         /// an invoice.
1211         Infinite,
1212         /// A capacity that is unknown possibly because either the chain state is unavailable to know
1213         /// the total capacity or the `htlc_maximum_msat` was not advertised on the gossip network.
1214         Unknown,
1215 }
1216 use lightning::routing::gossip::EffectiveCapacity as EffectiveCapacityImport;
1217 pub(crate) type nativeEffectiveCapacity = EffectiveCapacityImport;
1218
1219 impl EffectiveCapacity {
1220         #[allow(unused)]
1221         pub(crate) fn to_native(&self) -> nativeEffectiveCapacity {
1222                 match self {
1223                         EffectiveCapacity::ExactLiquidity {ref liquidity_msat, } => {
1224                                 let mut liquidity_msat_nonref = (*liquidity_msat).clone();
1225                                 nativeEffectiveCapacity::ExactLiquidity {
1226                                         liquidity_msat: liquidity_msat_nonref,
1227                                 }
1228                         },
1229                         EffectiveCapacity::MaximumHTLC {ref amount_msat, } => {
1230                                 let mut amount_msat_nonref = (*amount_msat).clone();
1231                                 nativeEffectiveCapacity::MaximumHTLC {
1232                                         amount_msat: amount_msat_nonref,
1233                                 }
1234                         },
1235                         EffectiveCapacity::Total {ref capacity_msat, ref htlc_maximum_msat, } => {
1236                                 let mut capacity_msat_nonref = (*capacity_msat).clone();
1237                                 let mut htlc_maximum_msat_nonref = (*htlc_maximum_msat).clone();
1238                                 let mut local_htlc_maximum_msat_nonref = if htlc_maximum_msat_nonref.is_some() { Some( { htlc_maximum_msat_nonref.take() }) } else { None };
1239                                 nativeEffectiveCapacity::Total {
1240                                         capacity_msat: capacity_msat_nonref,
1241                                         htlc_maximum_msat: local_htlc_maximum_msat_nonref,
1242                                 }
1243                         },
1244                         EffectiveCapacity::Infinite => nativeEffectiveCapacity::Infinite,
1245                         EffectiveCapacity::Unknown => nativeEffectiveCapacity::Unknown,
1246                 }
1247         }
1248         #[allow(unused)]
1249         pub(crate) fn into_native(self) -> nativeEffectiveCapacity {
1250                 match self {
1251                         EffectiveCapacity::ExactLiquidity {mut liquidity_msat, } => {
1252                                 nativeEffectiveCapacity::ExactLiquidity {
1253                                         liquidity_msat: liquidity_msat,
1254                                 }
1255                         },
1256                         EffectiveCapacity::MaximumHTLC {mut amount_msat, } => {
1257                                 nativeEffectiveCapacity::MaximumHTLC {
1258                                         amount_msat: amount_msat,
1259                                 }
1260                         },
1261                         EffectiveCapacity::Total {mut capacity_msat, mut htlc_maximum_msat, } => {
1262                                 let mut local_htlc_maximum_msat = if htlc_maximum_msat.is_some() { Some( { htlc_maximum_msat.take() }) } else { None };
1263                                 nativeEffectiveCapacity::Total {
1264                                         capacity_msat: capacity_msat,
1265                                         htlc_maximum_msat: local_htlc_maximum_msat,
1266                                 }
1267                         },
1268                         EffectiveCapacity::Infinite => nativeEffectiveCapacity::Infinite,
1269                         EffectiveCapacity::Unknown => nativeEffectiveCapacity::Unknown,
1270                 }
1271         }
1272         #[allow(unused)]
1273         pub(crate) fn from_native(native: &nativeEffectiveCapacity) -> Self {
1274                 match native {
1275                         nativeEffectiveCapacity::ExactLiquidity {ref liquidity_msat, } => {
1276                                 let mut liquidity_msat_nonref = (*liquidity_msat).clone();
1277                                 EffectiveCapacity::ExactLiquidity {
1278                                         liquidity_msat: liquidity_msat_nonref,
1279                                 }
1280                         },
1281                         nativeEffectiveCapacity::MaximumHTLC {ref amount_msat, } => {
1282                                 let mut amount_msat_nonref = (*amount_msat).clone();
1283                                 EffectiveCapacity::MaximumHTLC {
1284                                         amount_msat: amount_msat_nonref,
1285                                 }
1286                         },
1287                         nativeEffectiveCapacity::Total {ref capacity_msat, ref htlc_maximum_msat, } => {
1288                                 let mut capacity_msat_nonref = (*capacity_msat).clone();
1289                                 let mut htlc_maximum_msat_nonref = (*htlc_maximum_msat).clone();
1290                                 let mut local_htlc_maximum_msat_nonref = if htlc_maximum_msat_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { htlc_maximum_msat_nonref.unwrap() }) };
1291                                 EffectiveCapacity::Total {
1292                                         capacity_msat: capacity_msat_nonref,
1293                                         htlc_maximum_msat: local_htlc_maximum_msat_nonref,
1294                                 }
1295                         },
1296                         nativeEffectiveCapacity::Infinite => EffectiveCapacity::Infinite,
1297                         nativeEffectiveCapacity::Unknown => EffectiveCapacity::Unknown,
1298                 }
1299         }
1300         #[allow(unused)]
1301         pub(crate) fn native_into(native: nativeEffectiveCapacity) -> Self {
1302                 match native {
1303                         nativeEffectiveCapacity::ExactLiquidity {mut liquidity_msat, } => {
1304                                 EffectiveCapacity::ExactLiquidity {
1305                                         liquidity_msat: liquidity_msat,
1306                                 }
1307                         },
1308                         nativeEffectiveCapacity::MaximumHTLC {mut amount_msat, } => {
1309                                 EffectiveCapacity::MaximumHTLC {
1310                                         amount_msat: amount_msat,
1311                                 }
1312                         },
1313                         nativeEffectiveCapacity::Total {mut capacity_msat, mut htlc_maximum_msat, } => {
1314                                 let mut local_htlc_maximum_msat = if htlc_maximum_msat.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { htlc_maximum_msat.unwrap() }) };
1315                                 EffectiveCapacity::Total {
1316                                         capacity_msat: capacity_msat,
1317                                         htlc_maximum_msat: local_htlc_maximum_msat,
1318                                 }
1319                         },
1320                         nativeEffectiveCapacity::Infinite => EffectiveCapacity::Infinite,
1321                         nativeEffectiveCapacity::Unknown => EffectiveCapacity::Unknown,
1322                 }
1323         }
1324 }
1325 /// Frees any resources used by the EffectiveCapacity
1326 #[no_mangle]
1327 pub extern "C" fn EffectiveCapacity_free(this_ptr: EffectiveCapacity) { }
1328 /// Creates a copy of the EffectiveCapacity
1329 #[no_mangle]
1330 pub extern "C" fn EffectiveCapacity_clone(orig: &EffectiveCapacity) -> EffectiveCapacity {
1331         orig.clone()
1332 }
1333 #[no_mangle]
1334 /// Utility method to constructs a new ExactLiquidity-variant EffectiveCapacity
1335 pub extern "C" fn EffectiveCapacity_exact_liquidity(liquidity_msat: u64) -> EffectiveCapacity {
1336         EffectiveCapacity::ExactLiquidity {
1337                 liquidity_msat,
1338         }
1339 }
1340 #[no_mangle]
1341 /// Utility method to constructs a new MaximumHTLC-variant EffectiveCapacity
1342 pub extern "C" fn EffectiveCapacity_maximum_htlc(amount_msat: u64) -> EffectiveCapacity {
1343         EffectiveCapacity::MaximumHTLC {
1344                 amount_msat,
1345         }
1346 }
1347 #[no_mangle]
1348 /// Utility method to constructs a new Total-variant EffectiveCapacity
1349 pub extern "C" fn EffectiveCapacity_total(capacity_msat: u64, htlc_maximum_msat: crate::c_types::derived::COption_u64Z) -> EffectiveCapacity {
1350         EffectiveCapacity::Total {
1351                 capacity_msat,
1352                 htlc_maximum_msat,
1353         }
1354 }
1355 #[no_mangle]
1356 /// Utility method to constructs a new Infinite-variant EffectiveCapacity
1357 pub extern "C" fn EffectiveCapacity_infinite() -> EffectiveCapacity {
1358         EffectiveCapacity::Infinite}
1359 #[no_mangle]
1360 /// Utility method to constructs a new Unknown-variant EffectiveCapacity
1361 pub extern "C" fn EffectiveCapacity_unknown() -> EffectiveCapacity {
1362         EffectiveCapacity::Unknown}
1363 /// The presumed channel capacity denominated in millisatoshi for [`EffectiveCapacity::Unknown`] to
1364 /// use when making routing decisions.
1365
1366 #[no_mangle]
1367 pub static UNKNOWN_CHANNEL_CAPACITY_MSAT: u64 = lightning::routing::gossip::UNKNOWN_CHANNEL_CAPACITY_MSAT;
1368 /// Returns the effective capacity denominated in millisatoshi.
1369 #[must_use]
1370 #[no_mangle]
1371 pub extern "C" fn EffectiveCapacity_as_msat(this_arg: &crate::lightning::routing::gossip::EffectiveCapacity) -> u64 {
1372         let mut ret = this_arg.to_native().as_msat();
1373         ret
1374 }
1375
1376
1377 use lightning::routing::gossip::RoutingFees as nativeRoutingFeesImport;
1378 pub(crate) type nativeRoutingFees = nativeRoutingFeesImport;
1379
1380 /// Fees for routing via a given channel or a node
1381 #[must_use]
1382 #[repr(C)]
1383 pub struct RoutingFees {
1384         /// A pointer to the opaque Rust object.
1385
1386         /// Nearly everywhere, inner must be non-null, however in places where
1387         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1388         pub inner: *mut nativeRoutingFees,
1389         /// Indicates that this is the only struct which contains the same pointer.
1390
1391         /// Rust functions which take ownership of an object provided via an argument require
1392         /// this to be true and invalidate the object pointed to by inner.
1393         pub is_owned: bool,
1394 }
1395
1396 impl Drop for RoutingFees {
1397         fn drop(&mut self) {
1398                 if self.is_owned && !<*mut nativeRoutingFees>::is_null(self.inner) {
1399                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1400                 }
1401         }
1402 }
1403 /// Frees any resources used by the RoutingFees, if is_owned is set and inner is non-NULL.
1404 #[no_mangle]
1405 pub extern "C" fn RoutingFees_free(this_obj: RoutingFees) { }
1406 #[allow(unused)]
1407 /// Used only if an object of this type is returned as a trait impl by a method
1408 pub(crate) extern "C" fn RoutingFees_free_void(this_ptr: *mut c_void) {
1409         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRoutingFees); }
1410 }
1411 #[allow(unused)]
1412 impl RoutingFees {
1413         pub(crate) fn get_native_ref(&self) -> &'static nativeRoutingFees {
1414                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1415         }
1416         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRoutingFees {
1417                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1418         }
1419         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1420         pub(crate) fn take_inner(mut self) -> *mut nativeRoutingFees {
1421                 assert!(self.is_owned);
1422                 let ret = ObjOps::untweak_ptr(self.inner);
1423                 self.inner = core::ptr::null_mut();
1424                 ret
1425         }
1426 }
1427 /// Flat routing fee in satoshis
1428 #[no_mangle]
1429 pub extern "C" fn RoutingFees_get_base_msat(this_ptr: &RoutingFees) -> u32 {
1430         let mut inner_val = &mut this_ptr.get_native_mut_ref().base_msat;
1431         *inner_val
1432 }
1433 /// Flat routing fee in satoshis
1434 #[no_mangle]
1435 pub extern "C" fn RoutingFees_set_base_msat(this_ptr: &mut RoutingFees, mut val: u32) {
1436         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.base_msat = val;
1437 }
1438 /// Liquidity-based routing fee in millionths of a routed amount.
1439 /// In other words, 10000 is 1%.
1440 #[no_mangle]
1441 pub extern "C" fn RoutingFees_get_proportional_millionths(this_ptr: &RoutingFees) -> u32 {
1442         let mut inner_val = &mut this_ptr.get_native_mut_ref().proportional_millionths;
1443         *inner_val
1444 }
1445 /// Liquidity-based routing fee in millionths of a routed amount.
1446 /// In other words, 10000 is 1%.
1447 #[no_mangle]
1448 pub extern "C" fn RoutingFees_set_proportional_millionths(this_ptr: &mut RoutingFees, mut val: u32) {
1449         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.proportional_millionths = val;
1450 }
1451 /// Constructs a new RoutingFees given each field
1452 #[must_use]
1453 #[no_mangle]
1454 pub extern "C" fn RoutingFees_new(mut base_msat_arg: u32, mut proportional_millionths_arg: u32) -> RoutingFees {
1455         RoutingFees { inner: ObjOps::heap_alloc(nativeRoutingFees {
1456                 base_msat: base_msat_arg,
1457                 proportional_millionths: proportional_millionths_arg,
1458         }), is_owned: true }
1459 }
1460 /// Checks if two RoutingFeess contain equal inner contents.
1461 /// This ignores pointers and is_owned flags and looks at the values in fields.
1462 /// Two objects with NULL inner values will be considered "equal" here.
1463 #[no_mangle]
1464 pub extern "C" fn RoutingFees_eq(a: &RoutingFees, b: &RoutingFees) -> bool {
1465         if a.inner == b.inner { return true; }
1466         if a.inner.is_null() || b.inner.is_null() { return false; }
1467         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1468 }
1469 impl Clone for RoutingFees {
1470         fn clone(&self) -> Self {
1471                 Self {
1472                         inner: if <*mut nativeRoutingFees>::is_null(self.inner) { core::ptr::null_mut() } else {
1473                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1474                         is_owned: true,
1475                 }
1476         }
1477 }
1478 #[allow(unused)]
1479 /// Used only if an object of this type is returned as a trait impl by a method
1480 pub(crate) extern "C" fn RoutingFees_clone_void(this_ptr: *const c_void) -> *mut c_void {
1481         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRoutingFees)).clone() })) as *mut c_void
1482 }
1483 #[no_mangle]
1484 /// Creates a copy of the RoutingFees
1485 pub extern "C" fn RoutingFees_clone(orig: &RoutingFees) -> RoutingFees {
1486         orig.clone()
1487 }
1488 /// Checks if two RoutingFeess contain equal inner contents.
1489 #[no_mangle]
1490 pub extern "C" fn RoutingFees_hash(o: &RoutingFees) -> u64 {
1491         if o.inner.is_null() { return 0; }
1492         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1493         #[allow(deprecated)]
1494         let mut hasher = core::hash::SipHasher::new();
1495         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1496         core::hash::Hasher::finish(&hasher)
1497 }
1498 #[no_mangle]
1499 /// Serialize the RoutingFees object into a byte array which can be read by RoutingFees_read
1500 pub extern "C" fn RoutingFees_write(obj: &crate::lightning::routing::gossip::RoutingFees) -> crate::c_types::derived::CVec_u8Z {
1501         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1502 }
1503 #[no_mangle]
1504 pub(crate) extern "C" fn RoutingFees_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1505         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRoutingFees) })
1506 }
1507 #[no_mangle]
1508 /// Read a RoutingFees from a byte array, created by RoutingFees_write
1509 pub extern "C" fn RoutingFees_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RoutingFeesDecodeErrorZ {
1510         let res: Result<lightning::routing::gossip::RoutingFees, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
1511         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::gossip::RoutingFees { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
1512         local_res
1513 }
1514
1515 use lightning::routing::gossip::NodeAnnouncementInfo as nativeNodeAnnouncementInfoImport;
1516 pub(crate) type nativeNodeAnnouncementInfo = nativeNodeAnnouncementInfoImport;
1517
1518 /// Information received in the latest node_announcement from this node.
1519 #[must_use]
1520 #[repr(C)]
1521 pub struct NodeAnnouncementInfo {
1522         /// A pointer to the opaque Rust object.
1523
1524         /// Nearly everywhere, inner must be non-null, however in places where
1525         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1526         pub inner: *mut nativeNodeAnnouncementInfo,
1527         /// Indicates that this is the only struct which contains the same pointer.
1528
1529         /// Rust functions which take ownership of an object provided via an argument require
1530         /// this to be true and invalidate the object pointed to by inner.
1531         pub is_owned: bool,
1532 }
1533
1534 impl Drop for NodeAnnouncementInfo {
1535         fn drop(&mut self) {
1536                 if self.is_owned && !<*mut nativeNodeAnnouncementInfo>::is_null(self.inner) {
1537                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1538                 }
1539         }
1540 }
1541 /// Frees any resources used by the NodeAnnouncementInfo, if is_owned is set and inner is non-NULL.
1542 #[no_mangle]
1543 pub extern "C" fn NodeAnnouncementInfo_free(this_obj: NodeAnnouncementInfo) { }
1544 #[allow(unused)]
1545 /// Used only if an object of this type is returned as a trait impl by a method
1546 pub(crate) extern "C" fn NodeAnnouncementInfo_free_void(this_ptr: *mut c_void) {
1547         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAnnouncementInfo); }
1548 }
1549 #[allow(unused)]
1550 impl NodeAnnouncementInfo {
1551         pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncementInfo {
1552                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1553         }
1554         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncementInfo {
1555                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1556         }
1557         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1558         pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncementInfo {
1559                 assert!(self.is_owned);
1560                 let ret = ObjOps::untweak_ptr(self.inner);
1561                 self.inner = core::ptr::null_mut();
1562                 ret
1563         }
1564 }
1565 /// Protocol features the node announced support for
1566 #[no_mangle]
1567 pub extern "C" fn NodeAnnouncementInfo_get_features(this_ptr: &NodeAnnouncementInfo) -> crate::lightning::ln::features::NodeFeatures {
1568         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
1569         crate::lightning::ln::features::NodeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::NodeFeatures<>) as *mut _) }, is_owned: false }
1570 }
1571 /// Protocol features the node announced support for
1572 #[no_mangle]
1573 pub extern "C" fn NodeAnnouncementInfo_set_features(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::lightning::ln::features::NodeFeatures) {
1574         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
1575 }
1576 /// When the last known update to the node state was issued.
1577 /// Value is opaque, as set in the announcement.
1578 #[no_mangle]
1579 pub extern "C" fn NodeAnnouncementInfo_get_last_update(this_ptr: &NodeAnnouncementInfo) -> u32 {
1580         let mut inner_val = &mut this_ptr.get_native_mut_ref().last_update;
1581         *inner_val
1582 }
1583 /// When the last known update to the node state was issued.
1584 /// Value is opaque, as set in the announcement.
1585 #[no_mangle]
1586 pub extern "C" fn NodeAnnouncementInfo_set_last_update(this_ptr: &mut NodeAnnouncementInfo, mut val: u32) {
1587         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.last_update = val;
1588 }
1589 /// Color assigned to the node
1590 #[no_mangle]
1591 pub extern "C" fn NodeAnnouncementInfo_get_rgb(this_ptr: &NodeAnnouncementInfo) -> *const [u8; 3] {
1592         let mut inner_val = &mut this_ptr.get_native_mut_ref().rgb;
1593         inner_val
1594 }
1595 /// Color assigned to the node
1596 #[no_mangle]
1597 pub extern "C" fn NodeAnnouncementInfo_set_rgb(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::c_types::ThreeBytes) {
1598         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.rgb = val.data;
1599 }
1600 /// Moniker assigned to the node.
1601 /// May be invalid or malicious (eg control chars),
1602 /// should not be exposed to the user.
1603 #[no_mangle]
1604 pub extern "C" fn NodeAnnouncementInfo_get_alias(this_ptr: &NodeAnnouncementInfo) -> crate::lightning::routing::gossip::NodeAlias {
1605         let mut inner_val = &mut this_ptr.get_native_mut_ref().alias;
1606         crate::lightning::routing::gossip::NodeAlias { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeAlias<>) as *mut _) }, is_owned: false }
1607 }
1608 /// Moniker assigned to the node.
1609 /// May be invalid or malicious (eg control chars),
1610 /// should not be exposed to the user.
1611 #[no_mangle]
1612 pub extern "C" fn NodeAnnouncementInfo_set_alias(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::lightning::routing::gossip::NodeAlias) {
1613         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = *unsafe { Box::from_raw(val.take_inner()) };
1614 }
1615 /// Internet-level addresses via which one can connect to the node
1616 ///
1617 /// Returns a copy of the field.
1618 #[no_mangle]
1619 pub extern "C" fn NodeAnnouncementInfo_get_addresses(this_ptr: &NodeAnnouncementInfo) -> crate::c_types::derived::CVec_NetAddressZ {
1620         let mut inner_val = this_ptr.get_native_mut_ref().addresses.clone();
1621         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::lightning::ln::msgs::NetAddress::native_into(item) }); };
1622         local_inner_val.into()
1623 }
1624 /// Internet-level addresses via which one can connect to the node
1625 #[no_mangle]
1626 pub extern "C" fn NodeAnnouncementInfo_set_addresses(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::c_types::derived::CVec_NetAddressZ) {
1627         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
1628         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.addresses = local_val;
1629 }
1630 /// An initial announcement of the node
1631 /// Mostly redundant with the data we store in fields explicitly.
1632 /// Everything else is useful only for sending out for initial routing sync.
1633 /// Not stored if contains excess data to prevent DoS.
1634 ///
1635 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1636 #[no_mangle]
1637 pub extern "C" fn NodeAnnouncementInfo_get_announcement_message(this_ptr: &NodeAnnouncementInfo) -> crate::lightning::ln::msgs::NodeAnnouncement {
1638         let mut inner_val = &mut this_ptr.get_native_mut_ref().announcement_message;
1639         let mut local_inner_val = crate::lightning::ln::msgs::NodeAnnouncement { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::NodeAnnouncement<>) as *mut _ }, is_owned: false };
1640         local_inner_val
1641 }
1642 /// An initial announcement of the node
1643 /// Mostly redundant with the data we store in fields explicitly.
1644 /// Everything else is useful only for sending out for initial routing sync.
1645 /// Not stored if contains excess data to prevent DoS.
1646 ///
1647 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1648 #[no_mangle]
1649 pub extern "C" fn NodeAnnouncementInfo_set_announcement_message(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::lightning::ln::msgs::NodeAnnouncement) {
1650         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1651         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.announcement_message = local_val;
1652 }
1653 /// Constructs a new NodeAnnouncementInfo given each field
1654 #[must_use]
1655 #[no_mangle]
1656 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::lightning::routing::gossip::NodeAlias, mut addresses_arg: crate::c_types::derived::CVec_NetAddressZ, mut announcement_message_arg: crate::lightning::ln::msgs::NodeAnnouncement) -> NodeAnnouncementInfo {
1657         let mut local_addresses_arg = Vec::new(); for mut item in addresses_arg.into_rust().drain(..) { local_addresses_arg.push( { item.into_native() }); };
1658         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()) } }) };
1659         NodeAnnouncementInfo { inner: ObjOps::heap_alloc(nativeNodeAnnouncementInfo {
1660                 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
1661                 last_update: last_update_arg,
1662                 rgb: rgb_arg.data,
1663                 alias: *unsafe { Box::from_raw(alias_arg.take_inner()) },
1664                 addresses: local_addresses_arg,
1665                 announcement_message: local_announcement_message_arg,
1666         }), is_owned: true }
1667 }
1668 impl Clone for NodeAnnouncementInfo {
1669         fn clone(&self) -> Self {
1670                 Self {
1671                         inner: if <*mut nativeNodeAnnouncementInfo>::is_null(self.inner) { core::ptr::null_mut() } else {
1672                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1673                         is_owned: true,
1674                 }
1675         }
1676 }
1677 #[allow(unused)]
1678 /// Used only if an object of this type is returned as a trait impl by a method
1679 pub(crate) extern "C" fn NodeAnnouncementInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
1680         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncementInfo)).clone() })) as *mut c_void
1681 }
1682 #[no_mangle]
1683 /// Creates a copy of the NodeAnnouncementInfo
1684 pub extern "C" fn NodeAnnouncementInfo_clone(orig: &NodeAnnouncementInfo) -> NodeAnnouncementInfo {
1685         orig.clone()
1686 }
1687 /// Checks if two NodeAnnouncementInfos contain equal inner contents.
1688 /// This ignores pointers and is_owned flags and looks at the values in fields.
1689 /// Two objects with NULL inner values will be considered "equal" here.
1690 #[no_mangle]
1691 pub extern "C" fn NodeAnnouncementInfo_eq(a: &NodeAnnouncementInfo, b: &NodeAnnouncementInfo) -> bool {
1692         if a.inner == b.inner { return true; }
1693         if a.inner.is_null() || b.inner.is_null() { return false; }
1694         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1695 }
1696 #[no_mangle]
1697 /// Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read
1698 pub extern "C" fn NodeAnnouncementInfo_write(obj: &crate::lightning::routing::gossip::NodeAnnouncementInfo) -> crate::c_types::derived::CVec_u8Z {
1699         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1700 }
1701 #[no_mangle]
1702 pub(crate) extern "C" fn NodeAnnouncementInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1703         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncementInfo) })
1704 }
1705 #[no_mangle]
1706 /// Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write
1707 pub extern "C" fn NodeAnnouncementInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementInfoDecodeErrorZ {
1708         let res: Result<lightning::routing::gossip::NodeAnnouncementInfo, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
1709         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::gossip::NodeAnnouncementInfo { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
1710         local_res
1711 }
1712
1713 use lightning::routing::gossip::NodeAlias as nativeNodeAliasImport;
1714 pub(crate) type nativeNodeAlias = nativeNodeAliasImport;
1715
1716 /// A user-defined name for a node, which may be used when displaying the node in a graph.
1717 ///
1718 /// Since node aliases are provided by third parties, they are a potential avenue for injection
1719 /// attacks. Care must be taken when processing.
1720 #[must_use]
1721 #[repr(C)]
1722 pub struct NodeAlias {
1723         /// A pointer to the opaque Rust object.
1724
1725         /// Nearly everywhere, inner must be non-null, however in places where
1726         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1727         pub inner: *mut nativeNodeAlias,
1728         /// Indicates that this is the only struct which contains the same pointer.
1729
1730         /// Rust functions which take ownership of an object provided via an argument require
1731         /// this to be true and invalidate the object pointed to by inner.
1732         pub is_owned: bool,
1733 }
1734
1735 impl Drop for NodeAlias {
1736         fn drop(&mut self) {
1737                 if self.is_owned && !<*mut nativeNodeAlias>::is_null(self.inner) {
1738                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1739                 }
1740         }
1741 }
1742 /// Frees any resources used by the NodeAlias, if is_owned is set and inner is non-NULL.
1743 #[no_mangle]
1744 pub extern "C" fn NodeAlias_free(this_obj: NodeAlias) { }
1745 #[allow(unused)]
1746 /// Used only if an object of this type is returned as a trait impl by a method
1747 pub(crate) extern "C" fn NodeAlias_free_void(this_ptr: *mut c_void) {
1748         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAlias); }
1749 }
1750 #[allow(unused)]
1751 impl NodeAlias {
1752         pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAlias {
1753                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1754         }
1755         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAlias {
1756                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1757         }
1758         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1759         pub(crate) fn take_inner(mut self) -> *mut nativeNodeAlias {
1760                 assert!(self.is_owned);
1761                 let ret = ObjOps::untweak_ptr(self.inner);
1762                 self.inner = core::ptr::null_mut();
1763                 ret
1764         }
1765 }
1766 #[no_mangle]
1767 pub extern "C" fn NodeAlias_get_a(this_ptr: &NodeAlias) -> *const [u8; 32] {
1768         let mut inner_val = &mut this_ptr.get_native_mut_ref().0;
1769         inner_val
1770 }
1771 #[no_mangle]
1772 pub extern "C" fn NodeAlias_set_a(this_ptr: &mut NodeAlias, mut val: crate::c_types::ThirtyTwoBytes) {
1773         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.0 = val.data;
1774 }
1775 /// Constructs a new NodeAlias given each field
1776 #[must_use]
1777 #[no_mangle]
1778 pub extern "C" fn NodeAlias_new(mut a_arg: crate::c_types::ThirtyTwoBytes) -> NodeAlias {
1779         NodeAlias { inner: ObjOps::heap_alloc(lightning::routing::gossip::NodeAlias (
1780                 a_arg.data,
1781         )), is_owned: true }
1782 }
1783 impl Clone for NodeAlias {
1784         fn clone(&self) -> Self {
1785                 Self {
1786                         inner: if <*mut nativeNodeAlias>::is_null(self.inner) { core::ptr::null_mut() } else {
1787                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1788                         is_owned: true,
1789                 }
1790         }
1791 }
1792 #[allow(unused)]
1793 /// Used only if an object of this type is returned as a trait impl by a method
1794 pub(crate) extern "C" fn NodeAlias_clone_void(this_ptr: *const c_void) -> *mut c_void {
1795         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAlias)).clone() })) as *mut c_void
1796 }
1797 #[no_mangle]
1798 /// Creates a copy of the NodeAlias
1799 pub extern "C" fn NodeAlias_clone(orig: &NodeAlias) -> NodeAlias {
1800         orig.clone()
1801 }
1802 /// Checks if two NodeAliass contain equal inner contents.
1803 /// This ignores pointers and is_owned flags and looks at the values in fields.
1804 /// Two objects with NULL inner values will be considered "equal" here.
1805 #[no_mangle]
1806 pub extern "C" fn NodeAlias_eq(a: &NodeAlias, b: &NodeAlias) -> bool {
1807         if a.inner == b.inner { return true; }
1808         if a.inner.is_null() || b.inner.is_null() { return false; }
1809         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1810 }
1811 #[no_mangle]
1812 /// Serialize the NodeAlias object into a byte array which can be read by NodeAlias_read
1813 pub extern "C" fn NodeAlias_write(obj: &crate::lightning::routing::gossip::NodeAlias) -> crate::c_types::derived::CVec_u8Z {
1814         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1815 }
1816 #[no_mangle]
1817 pub(crate) extern "C" fn NodeAlias_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1818         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAlias) })
1819 }
1820 #[no_mangle]
1821 /// Read a NodeAlias from a byte array, created by NodeAlias_write
1822 pub extern "C" fn NodeAlias_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAliasDecodeErrorZ {
1823         let res: Result<lightning::routing::gossip::NodeAlias, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
1824         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::gossip::NodeAlias { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
1825         local_res
1826 }
1827
1828 use lightning::routing::gossip::NodeInfo as nativeNodeInfoImport;
1829 pub(crate) type nativeNodeInfo = nativeNodeInfoImport;
1830
1831 /// Details about a node in the network, known from the network announcement.
1832 #[must_use]
1833 #[repr(C)]
1834 pub struct NodeInfo {
1835         /// A pointer to the opaque Rust object.
1836
1837         /// Nearly everywhere, inner must be non-null, however in places where
1838         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1839         pub inner: *mut nativeNodeInfo,
1840         /// Indicates that this is the only struct which contains the same pointer.
1841
1842         /// Rust functions which take ownership of an object provided via an argument require
1843         /// this to be true and invalidate the object pointed to by inner.
1844         pub is_owned: bool,
1845 }
1846
1847 impl Drop for NodeInfo {
1848         fn drop(&mut self) {
1849                 if self.is_owned && !<*mut nativeNodeInfo>::is_null(self.inner) {
1850                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1851                 }
1852         }
1853 }
1854 /// Frees any resources used by the NodeInfo, if is_owned is set and inner is non-NULL.
1855 #[no_mangle]
1856 pub extern "C" fn NodeInfo_free(this_obj: NodeInfo) { }
1857 #[allow(unused)]
1858 /// Used only if an object of this type is returned as a trait impl by a method
1859 pub(crate) extern "C" fn NodeInfo_free_void(this_ptr: *mut c_void) {
1860         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeInfo); }
1861 }
1862 #[allow(unused)]
1863 impl NodeInfo {
1864         pub(crate) fn get_native_ref(&self) -> &'static nativeNodeInfo {
1865                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1866         }
1867         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeInfo {
1868                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1869         }
1870         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1871         pub(crate) fn take_inner(mut self) -> *mut nativeNodeInfo {
1872                 assert!(self.is_owned);
1873                 let ret = ObjOps::untweak_ptr(self.inner);
1874                 self.inner = core::ptr::null_mut();
1875                 ret
1876         }
1877 }
1878 /// All valid channels a node has announced
1879 ///
1880 /// Returns a copy of the field.
1881 #[no_mangle]
1882 pub extern "C" fn NodeInfo_get_channels(this_ptr: &NodeInfo) -> crate::c_types::derived::CVec_u64Z {
1883         let mut inner_val = this_ptr.get_native_mut_ref().channels.clone();
1884         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
1885         local_inner_val.into()
1886 }
1887 /// All valid channels a node has announced
1888 #[no_mangle]
1889 pub extern "C" fn NodeInfo_set_channels(this_ptr: &mut NodeInfo, mut val: crate::c_types::derived::CVec_u64Z) {
1890         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
1891         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channels = local_val;
1892 }
1893 /// Lowest fees enabling routing via any of the enabled, known channels to a node.
1894 /// The two fields (flat and proportional fee) are independent,
1895 /// meaning they don't have to refer to the same channel.
1896 ///
1897 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1898 #[no_mangle]
1899 pub extern "C" fn NodeInfo_get_lowest_inbound_channel_fees(this_ptr: &NodeInfo) -> crate::lightning::routing::gossip::RoutingFees {
1900         let mut inner_val = &mut this_ptr.get_native_mut_ref().lowest_inbound_channel_fees;
1901         let mut local_inner_val = crate::lightning::routing::gossip::RoutingFees { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::routing::gossip::RoutingFees<>) as *mut _ }, is_owned: false };
1902         local_inner_val
1903 }
1904 /// Lowest fees enabling routing via any of the enabled, known channels to a node.
1905 /// The two fields (flat and proportional fee) are independent,
1906 /// meaning they don't have to refer to the same channel.
1907 ///
1908 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1909 #[no_mangle]
1910 pub extern "C" fn NodeInfo_set_lowest_inbound_channel_fees(this_ptr: &mut NodeInfo, mut val: crate::lightning::routing::gossip::RoutingFees) {
1911         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1912         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.lowest_inbound_channel_fees = local_val;
1913 }
1914 /// More information about a node from node_announcement.
1915 /// Optional because we store a Node entry after learning about it from
1916 /// a channel announcement, but before receiving a node announcement.
1917 ///
1918 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1919 #[no_mangle]
1920 pub extern "C" fn NodeInfo_get_announcement_info(this_ptr: &NodeInfo) -> crate::lightning::routing::gossip::NodeAnnouncementInfo {
1921         let mut inner_val = &mut this_ptr.get_native_mut_ref().announcement_info;
1922         let mut local_inner_val = crate::lightning::routing::gossip::NodeAnnouncementInfo { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::routing::gossip::NodeAnnouncementInfo<>) as *mut _ }, is_owned: false };
1923         local_inner_val
1924 }
1925 /// More information about a node from node_announcement.
1926 /// Optional because we store a Node entry after learning about it from
1927 /// a channel announcement, but before receiving a node announcement.
1928 ///
1929 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1930 #[no_mangle]
1931 pub extern "C" fn NodeInfo_set_announcement_info(this_ptr: &mut NodeInfo, mut val: crate::lightning::routing::gossip::NodeAnnouncementInfo) {
1932         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1933         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.announcement_info = local_val;
1934 }
1935 /// Constructs a new NodeInfo given each field
1936 #[must_use]
1937 #[no_mangle]
1938 pub extern "C" fn NodeInfo_new(mut channels_arg: crate::c_types::derived::CVec_u64Z, mut lowest_inbound_channel_fees_arg: crate::lightning::routing::gossip::RoutingFees, mut announcement_info_arg: crate::lightning::routing::gossip::NodeAnnouncementInfo) -> NodeInfo {
1939         let mut local_channels_arg = Vec::new(); for mut item in channels_arg.into_rust().drain(..) { local_channels_arg.push( { item }); };
1940         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()) } }) };
1941         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()) } }) };
1942         NodeInfo { inner: ObjOps::heap_alloc(nativeNodeInfo {
1943                 channels: local_channels_arg,
1944                 lowest_inbound_channel_fees: local_lowest_inbound_channel_fees_arg,
1945                 announcement_info: local_announcement_info_arg,
1946         }), is_owned: true }
1947 }
1948 impl Clone for NodeInfo {
1949         fn clone(&self) -> Self {
1950                 Self {
1951                         inner: if <*mut nativeNodeInfo>::is_null(self.inner) { core::ptr::null_mut() } else {
1952                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1953                         is_owned: true,
1954                 }
1955         }
1956 }
1957 #[allow(unused)]
1958 /// Used only if an object of this type is returned as a trait impl by a method
1959 pub(crate) extern "C" fn NodeInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
1960         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeInfo)).clone() })) as *mut c_void
1961 }
1962 #[no_mangle]
1963 /// Creates a copy of the NodeInfo
1964 pub extern "C" fn NodeInfo_clone(orig: &NodeInfo) -> NodeInfo {
1965         orig.clone()
1966 }
1967 /// Checks if two NodeInfos contain equal inner contents.
1968 /// This ignores pointers and is_owned flags and looks at the values in fields.
1969 /// Two objects with NULL inner values will be considered "equal" here.
1970 #[no_mangle]
1971 pub extern "C" fn NodeInfo_eq(a: &NodeInfo, b: &NodeInfo) -> bool {
1972         if a.inner == b.inner { return true; }
1973         if a.inner.is_null() || b.inner.is_null() { return false; }
1974         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1975 }
1976 #[no_mangle]
1977 /// Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read
1978 pub extern "C" fn NodeInfo_write(obj: &crate::lightning::routing::gossip::NodeInfo) -> crate::c_types::derived::CVec_u8Z {
1979         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1980 }
1981 #[no_mangle]
1982 pub(crate) extern "C" fn NodeInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1983         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeInfo) })
1984 }
1985 #[no_mangle]
1986 /// Read a NodeInfo from a byte array, created by NodeInfo_write
1987 pub extern "C" fn NodeInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeInfoDecodeErrorZ {
1988         let res: Result<lightning::routing::gossip::NodeInfo, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
1989         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::gossip::NodeInfo { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
1990         local_res
1991 }
1992 #[no_mangle]
1993 /// Serialize the NetworkGraph object into a byte array which can be read by NetworkGraph_read
1994 pub extern "C" fn NetworkGraph_write(obj: &crate::lightning::routing::gossip::NetworkGraph) -> crate::c_types::derived::CVec_u8Z {
1995         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1996 }
1997 #[no_mangle]
1998 pub(crate) extern "C" fn NetworkGraph_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1999         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNetworkGraph) })
2000 }
2001 #[no_mangle]
2002 /// Read a NetworkGraph from a byte array, created by NetworkGraph_write
2003 pub extern "C" fn NetworkGraph_read(ser: crate::c_types::u8slice, arg: crate::lightning::util::logger::Logger) -> crate::c_types::derived::CResult_NetworkGraphDecodeErrorZ {
2004         let arg_conv = arg;
2005         let res: Result<lightning::routing::gossip::NetworkGraph<crate::lightning::util::logger::Logger>, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj_arg(ser, arg_conv);
2006         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::gossip::NetworkGraph { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
2007         local_res
2008 }
2009 /// Creates a new, empty, network graph.
2010 #[must_use]
2011 #[no_mangle]
2012 pub extern "C" fn NetworkGraph_new(mut genesis_hash: crate::c_types::ThirtyTwoBytes, mut logger: crate::lightning::util::logger::Logger) -> crate::lightning::routing::gossip::NetworkGraph {
2013         let mut ret = lightning::routing::gossip::NetworkGraph::new(::bitcoin::hash_types::BlockHash::from_slice(&genesis_hash.data[..]).unwrap(), logger);
2014         crate::lightning::routing::gossip::NetworkGraph { inner: ObjOps::heap_alloc(ret), is_owned: true }
2015 }
2016
2017 /// Returns a read-only view of the network graph.
2018 #[must_use]
2019 #[no_mangle]
2020 pub extern "C" fn NetworkGraph_read_only(this_arg: &crate::lightning::routing::gossip::NetworkGraph) -> crate::lightning::routing::gossip::ReadOnlyNetworkGraph {
2021         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.read_only();
2022         crate::lightning::routing::gossip::ReadOnlyNetworkGraph { inner: ObjOps::heap_alloc(ret), is_owned: true }
2023 }
2024
2025 /// The unix timestamp provided by the most recent rapid gossip sync.
2026 /// It will be set by the rapid sync process after every sync completion.
2027 #[must_use]
2028 #[no_mangle]
2029 pub extern "C" fn NetworkGraph_get_last_rapid_gossip_sync_timestamp(this_arg: &crate::lightning::routing::gossip::NetworkGraph) -> crate::c_types::derived::COption_u32Z {
2030         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_last_rapid_gossip_sync_timestamp();
2031         let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { ret.unwrap() }) };
2032         local_ret
2033 }
2034
2035 /// Update the unix timestamp provided by the most recent rapid gossip sync.
2036 /// This should be done automatically by the rapid sync process after every sync completion.
2037 #[no_mangle]
2038 pub extern "C" fn NetworkGraph_set_last_rapid_gossip_sync_timestamp(this_arg: &crate::lightning::routing::gossip::NetworkGraph, mut last_rapid_gossip_sync_timestamp: u32) {
2039         unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.set_last_rapid_gossip_sync_timestamp(last_rapid_gossip_sync_timestamp)
2040 }
2041
2042 /// For an already known node (from channel announcements), update its stored properties from a
2043 /// given node announcement.
2044 ///
2045 /// You probably don't want to call this directly, instead relying on a P2PGossipSync's
2046 /// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
2047 /// routing messages from a source using a protocol other than the lightning P2P protocol.
2048 #[must_use]
2049 #[no_mangle]
2050 pub extern "C" fn NetworkGraph_update_node_from_announcement(this_arg: &crate::lightning::routing::gossip::NetworkGraph, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
2051         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_node_from_announcement(msg.get_native_ref());
2052         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() };
2053         local_ret
2054 }
2055
2056 /// For an already known node (from channel announcements), update its stored properties from a
2057 /// given node announcement without verifying the associated signatures. Because we aren't
2058 /// given the associated signatures here we cannot relay the node announcement to any of our
2059 /// peers.
2060 #[must_use]
2061 #[no_mangle]
2062 pub extern "C" fn NetworkGraph_update_node_from_unsigned_announcement(this_arg: &crate::lightning::routing::gossip::NetworkGraph, msg: &crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
2063         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_node_from_unsigned_announcement(msg.get_native_ref());
2064         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() };
2065         local_ret
2066 }
2067
2068 /// Store or update channel info from a channel announcement.
2069 ///
2070 /// You probably don't want to call this directly, instead relying on a P2PGossipSync's
2071 /// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
2072 /// routing messages from a source using a protocol other than the lightning P2P protocol.
2073 ///
2074 /// If a `chain::Access` object is provided via `chain_access`, it will be called to verify
2075 /// the corresponding UTXO exists on chain and is correctly-formatted.
2076 #[must_use]
2077 #[no_mangle]
2078 pub extern "C" fn NetworkGraph_update_channel_from_announcement(this_arg: &crate::lightning::routing::gossip::NetworkGraph, msg: &crate::lightning::ln::msgs::ChannelAnnouncement, mut chain_access: crate::c_types::derived::COption_AccessZ) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
2079         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() }) } };
2080         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_channel_from_announcement(msg.get_native_ref(), &local_chain_access);
2081         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() };
2082         local_ret
2083 }
2084
2085 /// Store or update channel info from a channel announcement without verifying the associated
2086 /// signatures. Because we aren't given the associated signatures here we cannot relay the
2087 /// channel announcement to any of our peers.
2088 ///
2089 /// If a `chain::Access` object is provided via `chain_access`, it will be called to verify
2090 /// the corresponding UTXO exists on chain and is correctly-formatted.
2091 #[must_use]
2092 #[no_mangle]
2093 pub extern "C" fn NetworkGraph_update_channel_from_unsigned_announcement(this_arg: &crate::lightning::routing::gossip::NetworkGraph, msg: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement, mut chain_access: crate::c_types::derived::COption_AccessZ) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
2094         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() }) } };
2095         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_channel_from_unsigned_announcement(msg.get_native_ref(), &local_chain_access);
2096         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() };
2097         local_ret
2098 }
2099
2100 /// Update channel from partial announcement data received via rapid gossip sync
2101 ///
2102 /// `timestamp: u64`: Timestamp emulating the backdated original announcement receipt (by the
2103 /// rapid gossip sync server)
2104 ///
2105 /// All other parameters as used in [`msgs::UnsignedChannelAnnouncement`] fields.
2106 #[must_use]
2107 #[no_mangle]
2108 pub extern "C" fn NetworkGraph_add_channel_from_partial_announcement(this_arg: &crate::lightning::routing::gossip::NetworkGraph, mut short_channel_id: u64, mut timestamp: u64, mut features: crate::lightning::ln::features::ChannelFeatures, mut node_id_1: crate::c_types::PublicKey, mut node_id_2: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
2109         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.add_channel_from_partial_announcement(short_channel_id, timestamp, *unsafe { Box::from_raw(features.take_inner()) }, node_id_1.into_rust(), node_id_2.into_rust());
2110         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() };
2111         local_ret
2112 }
2113
2114 /// Marks a channel in the graph as failed if a corresponding HTLC fail was sent.
2115 /// If permanent, removes a channel from the local storage.
2116 /// May cause the removal of nodes too, if this was their last channel.
2117 /// If not permanent, makes channels unavailable for routing.
2118 #[no_mangle]
2119 pub extern "C" fn NetworkGraph_channel_failed(this_arg: &crate::lightning::routing::gossip::NetworkGraph, mut short_channel_id: u64, mut is_permanent: bool) {
2120         unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel_failed(short_channel_id, is_permanent)
2121 }
2122
2123 /// Marks a node in the graph as permanently failed, effectively removing it and its channels
2124 /// from local storage.
2125 #[no_mangle]
2126 pub extern "C" fn NetworkGraph_node_failed_permanent(this_arg: &crate::lightning::routing::gossip::NetworkGraph, mut node_id: crate::c_types::PublicKey) {
2127         unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.node_failed_permanent(&node_id.into_rust())
2128 }
2129
2130 /// Removes information about channels that we haven't heard any updates about in some time.
2131 /// This can be used regularly to prune the network graph of channels that likely no longer
2132 /// exist.
2133 ///
2134 /// While there is no formal requirement that nodes regularly re-broadcast their channel
2135 /// updates every two weeks, the non-normative section of BOLT 7 currently suggests that
2136 /// pruning occur for updates which are at least two weeks old, which we implement here.
2137 ///
2138 /// Note that for users of the `lightning-background-processor` crate this method may be
2139 /// automatically called regularly for you.
2140 ///
2141 /// This method will also cause us to stop tracking removed nodes and channels if they have been
2142 /// in the map for a while so that these can be resynced from gossip in the future.
2143 ///
2144 /// This method is only available with the `std` feature. See
2145 /// [`NetworkGraph::remove_stale_channels_and_tracking_with_time`] for `no-std` use.
2146 #[no_mangle]
2147 pub extern "C" fn NetworkGraph_remove_stale_channels_and_tracking(this_arg: &crate::lightning::routing::gossip::NetworkGraph) {
2148         unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.remove_stale_channels_and_tracking()
2149 }
2150
2151 /// Removes information about channels that we haven't heard any updates about in some time.
2152 /// This can be used regularly to prune the network graph of channels that likely no longer
2153 /// exist.
2154 ///
2155 /// While there is no formal requirement that nodes regularly re-broadcast their channel
2156 /// updates every two weeks, the non-normative section of BOLT 7 currently suggests that
2157 /// pruning occur for updates which are at least two weeks old, which we implement here.
2158 ///
2159 /// This method will also cause us to stop tracking removed nodes and channels if they have been
2160 /// in the map for a while so that these can be resynced from gossip in the future.
2161 ///
2162 /// This function takes the current unix time as an argument. For users with the `std` feature
2163 /// enabled, [`NetworkGraph::remove_stale_channels_and_tracking`] may be preferable.
2164 #[no_mangle]
2165 pub extern "C" fn NetworkGraph_remove_stale_channels_and_tracking_with_time(this_arg: &crate::lightning::routing::gossip::NetworkGraph, mut current_time_unix: u64) {
2166         unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.remove_stale_channels_and_tracking_with_time(current_time_unix)
2167 }
2168
2169 /// For an already known (from announcement) channel, update info about one of the directions
2170 /// of the channel.
2171 ///
2172 /// You probably don't want to call this directly, instead relying on a P2PGossipSync's
2173 /// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
2174 /// routing messages from a source using a protocol other than the lightning P2P protocol.
2175 ///
2176 /// If built with `no-std`, any updates with a timestamp more than two weeks in the past or
2177 /// materially in the future will be rejected.
2178 #[must_use]
2179 #[no_mangle]
2180 pub extern "C" fn NetworkGraph_update_channel(this_arg: &crate::lightning::routing::gossip::NetworkGraph, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
2181         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_channel(msg.get_native_ref());
2182         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() };
2183         local_ret
2184 }
2185
2186 /// For an already known (from announcement) channel, update info about one of the directions
2187 /// of the channel without verifying the associated signatures. Because we aren't given the
2188 /// associated signatures here we cannot relay the channel update to any of our peers.
2189 ///
2190 /// If built with `no-std`, any updates with a timestamp more than two weeks in the past or
2191 /// materially in the future will be rejected.
2192 #[must_use]
2193 #[no_mangle]
2194 pub extern "C" fn NetworkGraph_update_channel_unsigned(this_arg: &crate::lightning::routing::gossip::NetworkGraph, msg: &crate::lightning::ln::msgs::UnsignedChannelUpdate) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
2195         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_channel_unsigned(msg.get_native_ref());
2196         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() };
2197         local_ret
2198 }
2199
2200 /// Returns information on a channel with the given id.
2201 ///
2202 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
2203 #[must_use]
2204 #[no_mangle]
2205 pub extern "C" fn ReadOnlyNetworkGraph_channel(this_arg: &crate::lightning::routing::gossip::ReadOnlyNetworkGraph, mut short_channel_id: u64) -> crate::lightning::routing::gossip::ChannelInfo {
2206         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel(short_channel_id);
2207         let mut local_ret = crate::lightning::routing::gossip::ChannelInfo { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::routing::gossip::ChannelInfo<>) as *mut _ }, is_owned: false };
2208         local_ret
2209 }
2210
2211 /// Returns the list of channels in the graph
2212 #[must_use]
2213 #[no_mangle]
2214 pub extern "C" fn ReadOnlyNetworkGraph_list_channels(this_arg: &crate::lightning::routing::gossip::ReadOnlyNetworkGraph) -> crate::c_types::derived::CVec_u64Z {
2215         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.list_channels();
2216         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { item }); };
2217         local_ret.into()
2218 }
2219
2220 /// Returns information on a node with the given id.
2221 ///
2222 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
2223 #[must_use]
2224 #[no_mangle]
2225 pub extern "C" fn ReadOnlyNetworkGraph_node(this_arg: &crate::lightning::routing::gossip::ReadOnlyNetworkGraph, node_id: &crate::lightning::routing::gossip::NodeId) -> crate::lightning::routing::gossip::NodeInfo {
2226         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.node(node_id.get_native_ref());
2227         let mut local_ret = crate::lightning::routing::gossip::NodeInfo { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::routing::gossip::NodeInfo<>) as *mut _ }, is_owned: false };
2228         local_ret
2229 }
2230
2231 /// Returns the list of nodes in the graph
2232 #[must_use]
2233 #[no_mangle]
2234 pub extern "C" fn ReadOnlyNetworkGraph_list_nodes(this_arg: &crate::lightning::routing::gossip::ReadOnlyNetworkGraph) -> crate::c_types::derived::CVec_NodeIdZ {
2235         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.list_nodes();
2236         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::routing::gossip::NodeId { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
2237         local_ret.into()
2238 }
2239
2240 /// Get network addresses by node id.
2241 /// Returns None if the requested node is completely unknown,
2242 /// or if node announcement for the node was never received.
2243 #[must_use]
2244 #[no_mangle]
2245 pub extern "C" fn ReadOnlyNetworkGraph_get_addresses(this_arg: &crate::lightning::routing::gossip::ReadOnlyNetworkGraph, mut pubkey: crate::c_types::PublicKey) -> crate::c_types::derived::COption_CVec_NetAddressZZ {
2246         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_addresses(&pubkey.into_rust());
2247         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() }) };
2248         local_ret
2249 }
2250