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