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