Rebuild against current RL main
[ldk-c-bindings] / lightning-c-bindings / src / routing / network_graph.rs
1 //! The top-level network map tracking logic lives here.
2
3 use std::ffi::c_void;
4 use bitcoin::hashes::Hash;
5 use crate::c_types::*;
6
7
8 use lightning::routing::network_graph::NetworkGraph as nativeNetworkGraphImport;
9 type nativeNetworkGraph = nativeNetworkGraphImport;
10
11 /// Represents the network as nodes and channels between them
12 #[must_use]
13 #[repr(C)]
14 pub struct NetworkGraph {
15         /// A pointer to the opaque Rust object.
16
17         /// Nearly everywhere, inner must be non-null, however in places where
18         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
19         pub inner: *mut nativeNetworkGraph,
20         /// Indicates that this is the only struct which contains the same pointer.
21
22         /// Rust functions which take ownership of an object provided via an argument require
23         /// this to be true and invalidate the object pointed to by inner.
24         pub is_owned: bool,
25 }
26
27 impl Drop for NetworkGraph {
28         fn drop(&mut self) {
29                 if self.is_owned && !<*mut nativeNetworkGraph>::is_null(self.inner) {
30                         let _ = unsafe { Box::from_raw(self.inner) };
31                 }
32         }
33 }
34 /// Frees any resources used by the NetworkGraph, if is_owned is set and inner is non-NULL.
35 #[no_mangle]
36 pub extern "C" fn NetworkGraph_free(this_obj: NetworkGraph) { }
37 #[allow(unused)]
38 /// Used only if an object of this type is returned as a trait impl by a method
39 extern "C" fn NetworkGraph_free_void(this_ptr: *mut c_void) {
40         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNetworkGraph); }
41 }
42 #[allow(unused)]
43 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
44 impl NetworkGraph {
45         pub(crate) fn take_inner(mut self) -> *mut nativeNetworkGraph {
46                 assert!(self.is_owned);
47                 let ret = self.inner;
48                 self.inner = std::ptr::null_mut();
49                 ret
50         }
51 }
52 impl Clone for NetworkGraph {
53         fn clone(&self) -> Self {
54                 Self {
55                         inner: if <*mut nativeNetworkGraph>::is_null(self.inner) { std::ptr::null_mut() } else {
56                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
57                         is_owned: true,
58                 }
59         }
60 }
61 #[allow(unused)]
62 /// Used only if an object of this type is returned as a trait impl by a method
63 pub(crate) extern "C" fn NetworkGraph_clone_void(this_ptr: *const c_void) -> *mut c_void {
64         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNetworkGraph)).clone() })) as *mut c_void
65 }
66 #[no_mangle]
67 /// Creates a copy of the NetworkGraph
68 pub extern "C" fn NetworkGraph_clone(orig: &NetworkGraph) -> NetworkGraph {
69         orig.clone()
70 }
71
72 use lightning::routing::network_graph::LockedNetworkGraph as nativeLockedNetworkGraphImport;
73 type nativeLockedNetworkGraph = nativeLockedNetworkGraphImport<'static>;
74
75 /// A simple newtype for RwLockReadGuard<'a, NetworkGraph>.
76 /// This exists only to make accessing a RwLock<NetworkGraph> possible from
77 /// the C bindings, as it can be done directly in Rust code.
78 #[must_use]
79 #[repr(C)]
80 pub struct LockedNetworkGraph {
81         /// A pointer to the opaque Rust object.
82
83         /// Nearly everywhere, inner must be non-null, however in places where
84         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
85         pub inner: *mut nativeLockedNetworkGraph,
86         /// Indicates that this is the only struct which contains the same pointer.
87
88         /// Rust functions which take ownership of an object provided via an argument require
89         /// this to be true and invalidate the object pointed to by inner.
90         pub is_owned: bool,
91 }
92
93 impl Drop for LockedNetworkGraph {
94         fn drop(&mut self) {
95                 if self.is_owned && !<*mut nativeLockedNetworkGraph>::is_null(self.inner) {
96                         let _ = unsafe { Box::from_raw(self.inner) };
97                 }
98         }
99 }
100 /// Frees any resources used by the LockedNetworkGraph, if is_owned is set and inner is non-NULL.
101 #[no_mangle]
102 pub extern "C" fn LockedNetworkGraph_free(this_obj: LockedNetworkGraph) { }
103 #[allow(unused)]
104 /// Used only if an object of this type is returned as a trait impl by a method
105 extern "C" fn LockedNetworkGraph_free_void(this_ptr: *mut c_void) {
106         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeLockedNetworkGraph); }
107 }
108 #[allow(unused)]
109 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
110 impl LockedNetworkGraph {
111         pub(crate) fn take_inner(mut self) -> *mut nativeLockedNetworkGraph {
112                 assert!(self.is_owned);
113                 let ret = self.inner;
114                 self.inner = std::ptr::null_mut();
115                 ret
116         }
117 }
118
119 use lightning::routing::network_graph::NetGraphMsgHandler as nativeNetGraphMsgHandlerImport;
120 type nativeNetGraphMsgHandler = nativeNetGraphMsgHandlerImport<crate::chain::Access, crate::util::logger::Logger>;
121
122 /// Receives and validates network updates from peers,
123 /// stores authentic and relevant data as a network graph.
124 /// This network graph is then used for routing payments.
125 /// Provides interface to help with initial routing sync by
126 /// serving historical announcements.
127 #[must_use]
128 #[repr(C)]
129 pub struct NetGraphMsgHandler {
130         /// A pointer to the opaque Rust object.
131
132         /// Nearly everywhere, inner must be non-null, however in places where
133         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
134         pub inner: *mut nativeNetGraphMsgHandler,
135         /// Indicates that this is the only struct which contains the same pointer.
136
137         /// Rust functions which take ownership of an object provided via an argument require
138         /// this to be true and invalidate the object pointed to by inner.
139         pub is_owned: bool,
140 }
141
142 impl Drop for NetGraphMsgHandler {
143         fn drop(&mut self) {
144                 if self.is_owned && !<*mut nativeNetGraphMsgHandler>::is_null(self.inner) {
145                         let _ = unsafe { Box::from_raw(self.inner) };
146                 }
147         }
148 }
149 /// Frees any resources used by the NetGraphMsgHandler, if is_owned is set and inner is non-NULL.
150 #[no_mangle]
151 pub extern "C" fn NetGraphMsgHandler_free(this_obj: NetGraphMsgHandler) { }
152 #[allow(unused)]
153 /// Used only if an object of this type is returned as a trait impl by a method
154 extern "C" fn NetGraphMsgHandler_free_void(this_ptr: *mut c_void) {
155         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNetGraphMsgHandler); }
156 }
157 #[allow(unused)]
158 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
159 impl NetGraphMsgHandler {
160         pub(crate) fn take_inner(mut self) -> *mut nativeNetGraphMsgHandler {
161                 assert!(self.is_owned);
162                 let ret = self.inner;
163                 self.inner = std::ptr::null_mut();
164                 ret
165         }
166 }
167 /// Creates a new tracker of the actual state of the network of channels and nodes,
168 /// assuming a fresh network graph.
169 /// Chain monitor is used to make sure announced channels exist on-chain,
170 /// channel data is correct, and that the announcement is signed with
171 /// channel owners' keys.
172 #[must_use]
173 #[no_mangle]
174 pub extern "C" fn NetGraphMsgHandler_new(mut genesis_hash: crate::c_types::ThirtyTwoBytes, chain_access: *mut crate::chain::Access, mut logger: crate::util::logger::Logger) -> NetGraphMsgHandler {
175         let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) };
176         let mut ret = lightning::routing::network_graph::NetGraphMsgHandler::new(::bitcoin::hash_types::BlockHash::from_slice(&genesis_hash.data[..]).unwrap(), local_chain_access, logger);
177         NetGraphMsgHandler { inner: Box::into_raw(Box::new(ret)), is_owned: true }
178 }
179
180 /// Creates a new tracker of the actual state of the network of channels and nodes,
181 /// assuming an existing Network Graph.
182 #[must_use]
183 #[no_mangle]
184 pub extern "C" fn NetGraphMsgHandler_from_net_graph(chain_access: *mut crate::chain::Access, mut logger: crate::util::logger::Logger, mut network_graph: crate::routing::network_graph::NetworkGraph) -> NetGraphMsgHandler {
185         let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) };
186         let mut ret = lightning::routing::network_graph::NetGraphMsgHandler::from_net_graph(local_chain_access, logger, *unsafe { Box::from_raw(network_graph.take_inner()) });
187         NetGraphMsgHandler { inner: Box::into_raw(Box::new(ret)), is_owned: true }
188 }
189
190 /// Adds a provider used to check new announcements. Does not affect
191 /// existing announcements unless they are updated.
192 /// Add, update or remove the provider would replace the current one.
193 #[no_mangle]
194 pub extern "C" fn NetGraphMsgHandler_add_chain_access(this_arg: &mut NetGraphMsgHandler, chain_access: *mut crate::chain::Access) {
195         let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) };
196         unsafe { &mut (*(this_arg.inner as *mut nativeNetGraphMsgHandler)) }.add_chain_access(local_chain_access)
197 }
198
199 /// Take a read lock on the network_graph and return it in the C-bindings
200 /// newtype helper. This is likely only useful when called via the C
201 /// bindings as you can call `self.network_graph.read().unwrap()` in Rust
202 /// yourself.
203 #[must_use]
204 #[no_mangle]
205 pub extern "C" fn NetGraphMsgHandler_read_locked_graph(this_arg: &NetGraphMsgHandler) -> crate::routing::network_graph::LockedNetworkGraph {
206         let mut ret = unsafe { &*this_arg.inner }.read_locked_graph();
207         crate::routing::network_graph::LockedNetworkGraph { inner: Box::into_raw(Box::new(ret)), is_owned: true }
208 }
209
210 /// Get a reference to the NetworkGraph which this read-lock contains.
211 #[must_use]
212 #[no_mangle]
213 pub extern "C" fn LockedNetworkGraph_graph(this_arg: &LockedNetworkGraph) -> crate::routing::network_graph::NetworkGraph {
214         let mut ret = unsafe { &*this_arg.inner }.graph();
215         crate::routing::network_graph::NetworkGraph { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false }
216 }
217
218 impl From<nativeNetGraphMsgHandler> for crate::ln::msgs::RoutingMessageHandler {
219         fn from(obj: nativeNetGraphMsgHandler) -> Self {
220                 let mut rust_obj = NetGraphMsgHandler { inner: Box::into_raw(Box::new(obj)), is_owned: true };
221                 let mut ret = NetGraphMsgHandler_as_RoutingMessageHandler(&rust_obj);
222                 // 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
223                 rust_obj.inner = std::ptr::null_mut();
224                 ret.free = Some(NetGraphMsgHandler_free_void);
225                 ret
226         }
227 }
228 /// Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg.
229 /// This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is
230 #[no_mangle]
231 pub extern "C" fn NetGraphMsgHandler_as_RoutingMessageHandler(this_arg: &NetGraphMsgHandler) -> crate::ln::msgs::RoutingMessageHandler {
232         crate::ln::msgs::RoutingMessageHandler {
233                 this_arg: unsafe { (*this_arg).inner as *mut c_void },
234                 free: None,
235                 handle_node_announcement: NetGraphMsgHandler_RoutingMessageHandler_handle_node_announcement,
236                 handle_channel_announcement: NetGraphMsgHandler_RoutingMessageHandler_handle_channel_announcement,
237                 handle_channel_update: NetGraphMsgHandler_RoutingMessageHandler_handle_channel_update,
238                 handle_htlc_fail_channel_update: NetGraphMsgHandler_RoutingMessageHandler_handle_htlc_fail_channel_update,
239                 get_next_channel_announcements: NetGraphMsgHandler_RoutingMessageHandler_get_next_channel_announcements,
240                 get_next_node_announcements: NetGraphMsgHandler_RoutingMessageHandler_get_next_node_announcements,
241                 sync_routing_table: NetGraphMsgHandler_RoutingMessageHandler_sync_routing_table,
242                 handle_reply_channel_range: NetGraphMsgHandler_RoutingMessageHandler_handle_reply_channel_range,
243                 handle_reply_short_channel_ids_end: NetGraphMsgHandler_RoutingMessageHandler_handle_reply_short_channel_ids_end,
244                 handle_query_channel_range: NetGraphMsgHandler_RoutingMessageHandler_handle_query_channel_range,
245                 handle_query_short_channel_ids: NetGraphMsgHandler_RoutingMessageHandler_handle_query_short_channel_ids,
246                 MessageSendEventsProvider: crate::util::events::MessageSendEventsProvider {
247                         this_arg: unsafe { (*this_arg).inner as *mut c_void },
248                         free: None,
249                         get_and_clear_pending_msg_events: NetGraphMsgHandler_RoutingMessageHandler_get_and_clear_pending_msg_events,
250                 },
251         }
252 }
253
254 #[must_use]
255 extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_node_announcement(this_arg: *const c_void, msg: &crate::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ {
256         let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_node_announcement(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, unsafe { &*msg.inner });
257         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::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
258         local_ret
259 }
260 #[must_use]
261 extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_channel_announcement(this_arg: *const c_void, msg: &crate::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ {
262         let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_channel_announcement(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, unsafe { &*msg.inner });
263         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::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
264         local_ret
265 }
266 extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_htlc_fail_channel_update(this_arg: *const c_void, update: &crate::ln::msgs::HTLCFailChannelUpdate) {
267         <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_htlc_fail_channel_update(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, &update.to_native())
268 }
269 #[must_use]
270 extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_channel_update(this_arg: *const c_void, msg: &crate::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ {
271         let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, unsafe { &*msg.inner });
272         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::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
273         local_ret
274 }
275 #[must_use]
276 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 {
277         let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::get_next_channel_announcements(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, starting_point, batch_amount);
278         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::ln::msgs::ChannelUpdate { inner: if orig_ret_0_1.is_none() { std::ptr::null_mut() } else {  { Box::into_raw(Box::new((orig_ret_0_1.unwrap()))) } }, is_owned: true }; let mut local_orig_ret_0_2 = crate::ln::msgs::ChannelUpdate { inner: if orig_ret_0_2.is_none() { std::ptr::null_mut() } else {  { Box::into_raw(Box::new((orig_ret_0_2.unwrap()))) } }, is_owned: true }; let mut local_ret_0 = (crate::ln::msgs::ChannelAnnouncement { inner: Box::into_raw(Box::new(orig_ret_0_0)), is_owned: true }, local_orig_ret_0_1, local_orig_ret_0_2).into(); local_ret_0 }); };
279         local_ret.into()
280 }
281 #[must_use]
282 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 {
283         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();
284         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);
285         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::ln::msgs::NodeAnnouncement { inner: Box::into_raw(Box::new(item)), is_owned: true } }); };
286         local_ret.into()
287 }
288 extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_sync_routing_table(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, init_msg: &crate::ln::msgs::Init) {
289         <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::sync_routing_table(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, &their_node_id.into_rust(), unsafe { &*init_msg.inner })
290 }
291 #[must_use]
292 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::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
293         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()) });
294         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
295         local_ret
296 }
297 #[must_use]
298 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::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
299         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()) });
300         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
301         local_ret
302 }
303 #[must_use]
304 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::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
305         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()) });
306         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
307         local_ret
308 }
309 #[must_use]
310 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::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
311         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()) });
312         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
313         local_ret
314 }
315 #[must_use]
316 extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ {
317         let mut ret = <nativeNetGraphMsgHandler as lightning::util::events::MessageSendEventsProvider<>>::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, );
318         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::util::events::MessageSendEvent::native_into(item) }); };
319         local_ret.into()
320 }
321
322 impl From<nativeNetGraphMsgHandler> for crate::util::events::MessageSendEventsProvider {
323         fn from(obj: nativeNetGraphMsgHandler) -> Self {
324                 let mut rust_obj = NetGraphMsgHandler { inner: Box::into_raw(Box::new(obj)), is_owned: true };
325                 let mut ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&rust_obj);
326                 // 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
327                 rust_obj.inner = std::ptr::null_mut();
328                 ret.free = Some(NetGraphMsgHandler_free_void);
329                 ret
330         }
331 }
332 /// Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg.
333 /// This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is
334 #[no_mangle]
335 pub extern "C" fn NetGraphMsgHandler_as_MessageSendEventsProvider(this_arg: &NetGraphMsgHandler) -> crate::util::events::MessageSendEventsProvider {
336         crate::util::events::MessageSendEventsProvider {
337                 this_arg: unsafe { (*this_arg).inner as *mut c_void },
338                 free: None,
339                 get_and_clear_pending_msg_events: NetGraphMsgHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events,
340         }
341 }
342
343 #[must_use]
344 extern "C" fn NetGraphMsgHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ {
345         let mut ret = <nativeNetGraphMsgHandler as lightning::util::events::MessageSendEventsProvider<>>::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, );
346         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::util::events::MessageSendEvent::native_into(item) }); };
347         local_ret.into()
348 }
349
350
351 use lightning::routing::network_graph::DirectionalChannelInfo as nativeDirectionalChannelInfoImport;
352 type nativeDirectionalChannelInfo = nativeDirectionalChannelInfoImport;
353
354 /// Details about one direction of a channel. Received
355 /// within a channel update.
356 #[must_use]
357 #[repr(C)]
358 pub struct DirectionalChannelInfo {
359         /// A pointer to the opaque Rust object.
360
361         /// Nearly everywhere, inner must be non-null, however in places where
362         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
363         pub inner: *mut nativeDirectionalChannelInfo,
364         /// Indicates that this is the only struct which contains the same pointer.
365
366         /// Rust functions which take ownership of an object provided via an argument require
367         /// this to be true and invalidate the object pointed to by inner.
368         pub is_owned: bool,
369 }
370
371 impl Drop for DirectionalChannelInfo {
372         fn drop(&mut self) {
373                 if self.is_owned && !<*mut nativeDirectionalChannelInfo>::is_null(self.inner) {
374                         let _ = unsafe { Box::from_raw(self.inner) };
375                 }
376         }
377 }
378 /// Frees any resources used by the DirectionalChannelInfo, if is_owned is set and inner is non-NULL.
379 #[no_mangle]
380 pub extern "C" fn DirectionalChannelInfo_free(this_obj: DirectionalChannelInfo) { }
381 #[allow(unused)]
382 /// Used only if an object of this type is returned as a trait impl by a method
383 extern "C" fn DirectionalChannelInfo_free_void(this_ptr: *mut c_void) {
384         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDirectionalChannelInfo); }
385 }
386 #[allow(unused)]
387 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
388 impl DirectionalChannelInfo {
389         pub(crate) fn take_inner(mut self) -> *mut nativeDirectionalChannelInfo {
390                 assert!(self.is_owned);
391                 let ret = self.inner;
392                 self.inner = std::ptr::null_mut();
393                 ret
394         }
395 }
396 /// When the last update to the channel direction was issued.
397 /// Value is opaque, as set in the announcement.
398 #[no_mangle]
399 pub extern "C" fn DirectionalChannelInfo_get_last_update(this_ptr: &DirectionalChannelInfo) -> u32 {
400         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.last_update;
401         (*inner_val)
402 }
403 /// When the last update to the channel direction was issued.
404 /// Value is opaque, as set in the announcement.
405 #[no_mangle]
406 pub extern "C" fn DirectionalChannelInfo_set_last_update(this_ptr: &mut DirectionalChannelInfo, mut val: u32) {
407         unsafe { &mut *this_ptr.inner }.last_update = val;
408 }
409 /// Whether the channel can be currently used for payments (in this one direction).
410 #[no_mangle]
411 pub extern "C" fn DirectionalChannelInfo_get_enabled(this_ptr: &DirectionalChannelInfo) -> bool {
412         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.enabled;
413         (*inner_val)
414 }
415 /// Whether the channel can be currently used for payments (in this one direction).
416 #[no_mangle]
417 pub extern "C" fn DirectionalChannelInfo_set_enabled(this_ptr: &mut DirectionalChannelInfo, mut val: bool) {
418         unsafe { &mut *this_ptr.inner }.enabled = val;
419 }
420 /// The difference in CLTV values that you must have when routing through this channel.
421 #[no_mangle]
422 pub extern "C" fn DirectionalChannelInfo_get_cltv_expiry_delta(this_ptr: &DirectionalChannelInfo) -> u16 {
423         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry_delta;
424         (*inner_val)
425 }
426 /// The difference in CLTV values that you must have when routing through this channel.
427 #[no_mangle]
428 pub extern "C" fn DirectionalChannelInfo_set_cltv_expiry_delta(this_ptr: &mut DirectionalChannelInfo, mut val: u16) {
429         unsafe { &mut *this_ptr.inner }.cltv_expiry_delta = val;
430 }
431 /// The minimum value, which must be relayed to the next hop via the channel
432 #[no_mangle]
433 pub extern "C" fn DirectionalChannelInfo_get_htlc_minimum_msat(this_ptr: &DirectionalChannelInfo) -> u64 {
434         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat;
435         (*inner_val)
436 }
437 /// The minimum value, which must be relayed to the next hop via the channel
438 #[no_mangle]
439 pub extern "C" fn DirectionalChannelInfo_set_htlc_minimum_msat(this_ptr: &mut DirectionalChannelInfo, mut val: u64) {
440         unsafe { &mut *this_ptr.inner }.htlc_minimum_msat = val;
441 }
442 /// Fees charged when the channel is used for routing
443 #[no_mangle]
444 pub extern "C" fn DirectionalChannelInfo_get_fees(this_ptr: &DirectionalChannelInfo) -> crate::routing::network_graph::RoutingFees {
445         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fees;
446         crate::routing::network_graph::RoutingFees { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
447 }
448 /// Fees charged when the channel is used for routing
449 #[no_mangle]
450 pub extern "C" fn DirectionalChannelInfo_set_fees(this_ptr: &mut DirectionalChannelInfo, mut val: crate::routing::network_graph::RoutingFees) {
451         unsafe { &mut *this_ptr.inner }.fees = *unsafe { Box::from_raw(val.take_inner()) };
452 }
453 /// Most recent update for the channel received from the network
454 /// Mostly redundant with the data we store in fields explicitly.
455 /// Everything else is useful only for sending out for initial routing sync.
456 /// Not stored if contains excess data to prevent DoS.
457 #[no_mangle]
458 pub extern "C" fn DirectionalChannelInfo_get_last_update_message(this_ptr: &DirectionalChannelInfo) -> crate::ln::msgs::ChannelUpdate {
459         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.last_update_message;
460         let mut local_inner_val = crate::ln::msgs::ChannelUpdate { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else {  { (inner_val.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false };
461         local_inner_val
462 }
463 /// Most recent update for the channel received from the network
464 /// Mostly redundant with the data we store in fields explicitly.
465 /// Everything else is useful only for sending out for initial routing sync.
466 /// Not stored if contains excess data to prevent DoS.
467 #[no_mangle]
468 pub extern "C" fn DirectionalChannelInfo_set_last_update_message(this_ptr: &mut DirectionalChannelInfo, mut val: crate::ln::msgs::ChannelUpdate) {
469         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
470         unsafe { &mut *this_ptr.inner }.last_update_message = local_val;
471 }
472 impl Clone for DirectionalChannelInfo {
473         fn clone(&self) -> Self {
474                 Self {
475                         inner: if <*mut nativeDirectionalChannelInfo>::is_null(self.inner) { std::ptr::null_mut() } else {
476                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
477                         is_owned: true,
478                 }
479         }
480 }
481 #[allow(unused)]
482 /// Used only if an object of this type is returned as a trait impl by a method
483 pub(crate) extern "C" fn DirectionalChannelInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
484         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDirectionalChannelInfo)).clone() })) as *mut c_void
485 }
486 #[no_mangle]
487 /// Creates a copy of the DirectionalChannelInfo
488 pub extern "C" fn DirectionalChannelInfo_clone(orig: &DirectionalChannelInfo) -> DirectionalChannelInfo {
489         orig.clone()
490 }
491 #[no_mangle]
492 /// Serialize the DirectionalChannelInfo object into a byte array which can be read by DirectionalChannelInfo_read
493 pub extern "C" fn DirectionalChannelInfo_write(obj: &DirectionalChannelInfo) -> crate::c_types::derived::CVec_u8Z {
494         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
495 }
496 #[no_mangle]
497 pub(crate) extern "C" fn DirectionalChannelInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
498         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeDirectionalChannelInfo) })
499 }
500 #[no_mangle]
501 /// Read a DirectionalChannelInfo from a byte array, created by DirectionalChannelInfo_write
502 pub extern "C" fn DirectionalChannelInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_DirectionalChannelInfoDecodeErrorZ {
503         let res = crate::c_types::deserialize_obj(ser);
504         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::routing::network_graph::DirectionalChannelInfo { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
505         local_res
506 }
507
508 use lightning::routing::network_graph::ChannelInfo as nativeChannelInfoImport;
509 type nativeChannelInfo = nativeChannelInfoImport;
510
511 /// Details about a channel (both directions).
512 /// Received within a channel announcement.
513 #[must_use]
514 #[repr(C)]
515 pub struct ChannelInfo {
516         /// A pointer to the opaque Rust object.
517
518         /// Nearly everywhere, inner must be non-null, however in places where
519         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
520         pub inner: *mut nativeChannelInfo,
521         /// Indicates that this is the only struct which contains the same pointer.
522
523         /// Rust functions which take ownership of an object provided via an argument require
524         /// this to be true and invalidate the object pointed to by inner.
525         pub is_owned: bool,
526 }
527
528 impl Drop for ChannelInfo {
529         fn drop(&mut self) {
530                 if self.is_owned && !<*mut nativeChannelInfo>::is_null(self.inner) {
531                         let _ = unsafe { Box::from_raw(self.inner) };
532                 }
533         }
534 }
535 /// Frees any resources used by the ChannelInfo, if is_owned is set and inner is non-NULL.
536 #[no_mangle]
537 pub extern "C" fn ChannelInfo_free(this_obj: ChannelInfo) { }
538 #[allow(unused)]
539 /// Used only if an object of this type is returned as a trait impl by a method
540 extern "C" fn ChannelInfo_free_void(this_ptr: *mut c_void) {
541         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelInfo); }
542 }
543 #[allow(unused)]
544 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
545 impl ChannelInfo {
546         pub(crate) fn take_inner(mut self) -> *mut nativeChannelInfo {
547                 assert!(self.is_owned);
548                 let ret = self.inner;
549                 self.inner = std::ptr::null_mut();
550                 ret
551         }
552 }
553 /// Protocol features of a channel communicated during its announcement
554 #[no_mangle]
555 pub extern "C" fn ChannelInfo_get_features(this_ptr: &ChannelInfo) -> crate::ln::features::ChannelFeatures {
556         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features;
557         crate::ln::features::ChannelFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
558 }
559 /// Protocol features of a channel communicated during its announcement
560 #[no_mangle]
561 pub extern "C" fn ChannelInfo_set_features(this_ptr: &mut ChannelInfo, mut val: crate::ln::features::ChannelFeatures) {
562         unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) };
563 }
564 /// Source node of the first direction of a channel
565 #[no_mangle]
566 pub extern "C" fn ChannelInfo_get_node_one(this_ptr: &ChannelInfo) -> crate::c_types::PublicKey {
567         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_one;
568         crate::c_types::PublicKey::from_rust(&(*inner_val))
569 }
570 /// Source node of the first direction of a channel
571 #[no_mangle]
572 pub extern "C" fn ChannelInfo_set_node_one(this_ptr: &mut ChannelInfo, mut val: crate::c_types::PublicKey) {
573         unsafe { &mut *this_ptr.inner }.node_one = val.into_rust();
574 }
575 /// Details about the first direction of a channel
576 #[no_mangle]
577 pub extern "C" fn ChannelInfo_get_one_to_two(this_ptr: &ChannelInfo) -> crate::routing::network_graph::DirectionalChannelInfo {
578         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.one_to_two;
579         let mut local_inner_val = crate::routing::network_graph::DirectionalChannelInfo { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else {  { (inner_val.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false };
580         local_inner_val
581 }
582 /// Details about the first direction of a channel
583 #[no_mangle]
584 pub extern "C" fn ChannelInfo_set_one_to_two(this_ptr: &mut ChannelInfo, mut val: crate::routing::network_graph::DirectionalChannelInfo) {
585         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
586         unsafe { &mut *this_ptr.inner }.one_to_two = local_val;
587 }
588 /// Source node of the second direction of a channel
589 #[no_mangle]
590 pub extern "C" fn ChannelInfo_get_node_two(this_ptr: &ChannelInfo) -> crate::c_types::PublicKey {
591         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_two;
592         crate::c_types::PublicKey::from_rust(&(*inner_val))
593 }
594 /// Source node of the second direction of a channel
595 #[no_mangle]
596 pub extern "C" fn ChannelInfo_set_node_two(this_ptr: &mut ChannelInfo, mut val: crate::c_types::PublicKey) {
597         unsafe { &mut *this_ptr.inner }.node_two = val.into_rust();
598 }
599 /// Details about the second direction of a channel
600 #[no_mangle]
601 pub extern "C" fn ChannelInfo_get_two_to_one(this_ptr: &ChannelInfo) -> crate::routing::network_graph::DirectionalChannelInfo {
602         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.two_to_one;
603         let mut local_inner_val = crate::routing::network_graph::DirectionalChannelInfo { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else {  { (inner_val.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false };
604         local_inner_val
605 }
606 /// Details about the second direction of a channel
607 #[no_mangle]
608 pub extern "C" fn ChannelInfo_set_two_to_one(this_ptr: &mut ChannelInfo, mut val: crate::routing::network_graph::DirectionalChannelInfo) {
609         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
610         unsafe { &mut *this_ptr.inner }.two_to_one = local_val;
611 }
612 /// An initial announcement of the channel
613 /// Mostly redundant with the data we store in fields explicitly.
614 /// Everything else is useful only for sending out for initial routing sync.
615 /// Not stored if contains excess data to prevent DoS.
616 #[no_mangle]
617 pub extern "C" fn ChannelInfo_get_announcement_message(this_ptr: &ChannelInfo) -> crate::ln::msgs::ChannelAnnouncement {
618         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.announcement_message;
619         let mut local_inner_val = crate::ln::msgs::ChannelAnnouncement { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else {  { (inner_val.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false };
620         local_inner_val
621 }
622 /// An initial announcement of the channel
623 /// Mostly redundant with the data we store in fields explicitly.
624 /// Everything else is useful only for sending out for initial routing sync.
625 /// Not stored if contains excess data to prevent DoS.
626 #[no_mangle]
627 pub extern "C" fn ChannelInfo_set_announcement_message(this_ptr: &mut ChannelInfo, mut val: crate::ln::msgs::ChannelAnnouncement) {
628         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
629         unsafe { &mut *this_ptr.inner }.announcement_message = local_val;
630 }
631 impl Clone for ChannelInfo {
632         fn clone(&self) -> Self {
633                 Self {
634                         inner: if <*mut nativeChannelInfo>::is_null(self.inner) { std::ptr::null_mut() } else {
635                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
636                         is_owned: true,
637                 }
638         }
639 }
640 #[allow(unused)]
641 /// Used only if an object of this type is returned as a trait impl by a method
642 pub(crate) extern "C" fn ChannelInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
643         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelInfo)).clone() })) as *mut c_void
644 }
645 #[no_mangle]
646 /// Creates a copy of the ChannelInfo
647 pub extern "C" fn ChannelInfo_clone(orig: &ChannelInfo) -> ChannelInfo {
648         orig.clone()
649 }
650 #[no_mangle]
651 /// Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read
652 pub extern "C" fn ChannelInfo_write(obj: &ChannelInfo) -> crate::c_types::derived::CVec_u8Z {
653         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
654 }
655 #[no_mangle]
656 pub(crate) extern "C" fn ChannelInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
657         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelInfo) })
658 }
659 #[no_mangle]
660 /// Read a ChannelInfo from a byte array, created by ChannelInfo_write
661 pub extern "C" fn ChannelInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelInfoDecodeErrorZ {
662         let res = crate::c_types::deserialize_obj(ser);
663         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::routing::network_graph::ChannelInfo { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
664         local_res
665 }
666
667 use lightning::routing::network_graph::RoutingFees as nativeRoutingFeesImport;
668 type nativeRoutingFees = nativeRoutingFeesImport;
669
670 /// Fees for routing via a given channel or a node
671 #[must_use]
672 #[repr(C)]
673 pub struct RoutingFees {
674         /// A pointer to the opaque Rust object.
675
676         /// Nearly everywhere, inner must be non-null, however in places where
677         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
678         pub inner: *mut nativeRoutingFees,
679         /// Indicates that this is the only struct which contains the same pointer.
680
681         /// Rust functions which take ownership of an object provided via an argument require
682         /// this to be true and invalidate the object pointed to by inner.
683         pub is_owned: bool,
684 }
685
686 impl Drop for RoutingFees {
687         fn drop(&mut self) {
688                 if self.is_owned && !<*mut nativeRoutingFees>::is_null(self.inner) {
689                         let _ = unsafe { Box::from_raw(self.inner) };
690                 }
691         }
692 }
693 /// Frees any resources used by the RoutingFees, if is_owned is set and inner is non-NULL.
694 #[no_mangle]
695 pub extern "C" fn RoutingFees_free(this_obj: RoutingFees) { }
696 #[allow(unused)]
697 /// Used only if an object of this type is returned as a trait impl by a method
698 extern "C" fn RoutingFees_free_void(this_ptr: *mut c_void) {
699         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRoutingFees); }
700 }
701 #[allow(unused)]
702 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
703 impl RoutingFees {
704         pub(crate) fn take_inner(mut self) -> *mut nativeRoutingFees {
705                 assert!(self.is_owned);
706                 let ret = self.inner;
707                 self.inner = std::ptr::null_mut();
708                 ret
709         }
710 }
711 /// Flat routing fee in satoshis
712 #[no_mangle]
713 pub extern "C" fn RoutingFees_get_base_msat(this_ptr: &RoutingFees) -> u32 {
714         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.base_msat;
715         (*inner_val)
716 }
717 /// Flat routing fee in satoshis
718 #[no_mangle]
719 pub extern "C" fn RoutingFees_set_base_msat(this_ptr: &mut RoutingFees, mut val: u32) {
720         unsafe { &mut *this_ptr.inner }.base_msat = val;
721 }
722 /// Liquidity-based routing fee in millionths of a routed amount.
723 /// In other words, 10000 is 1%.
724 #[no_mangle]
725 pub extern "C" fn RoutingFees_get_proportional_millionths(this_ptr: &RoutingFees) -> u32 {
726         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.proportional_millionths;
727         (*inner_val)
728 }
729 /// Liquidity-based routing fee in millionths of a routed amount.
730 /// In other words, 10000 is 1%.
731 #[no_mangle]
732 pub extern "C" fn RoutingFees_set_proportional_millionths(this_ptr: &mut RoutingFees, mut val: u32) {
733         unsafe { &mut *this_ptr.inner }.proportional_millionths = val;
734 }
735 /// Constructs a new RoutingFees given each field
736 #[must_use]
737 #[no_mangle]
738 pub extern "C" fn RoutingFees_new(mut base_msat_arg: u32, mut proportional_millionths_arg: u32) -> RoutingFees {
739         RoutingFees { inner: Box::into_raw(Box::new(nativeRoutingFees {
740                 base_msat: base_msat_arg,
741                 proportional_millionths: proportional_millionths_arg,
742         })), is_owned: true }
743 }
744 impl Clone for RoutingFees {
745         fn clone(&self) -> Self {
746                 Self {
747                         inner: if <*mut nativeRoutingFees>::is_null(self.inner) { std::ptr::null_mut() } else {
748                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
749                         is_owned: true,
750                 }
751         }
752 }
753 #[allow(unused)]
754 /// Used only if an object of this type is returned as a trait impl by a method
755 pub(crate) extern "C" fn RoutingFees_clone_void(this_ptr: *const c_void) -> *mut c_void {
756         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRoutingFees)).clone() })) as *mut c_void
757 }
758 #[no_mangle]
759 /// Creates a copy of the RoutingFees
760 pub extern "C" fn RoutingFees_clone(orig: &RoutingFees) -> RoutingFees {
761         orig.clone()
762 }
763 #[no_mangle]
764 /// Read a RoutingFees from a byte array, created by RoutingFees_write
765 pub extern "C" fn RoutingFees_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RoutingFeesDecodeErrorZ {
766         let res = crate::c_types::deserialize_obj(ser);
767         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::routing::network_graph::RoutingFees { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
768         local_res
769 }
770 #[no_mangle]
771 /// Serialize the RoutingFees object into a byte array which can be read by RoutingFees_read
772 pub extern "C" fn RoutingFees_write(obj: &RoutingFees) -> crate::c_types::derived::CVec_u8Z {
773         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
774 }
775 #[no_mangle]
776 pub(crate) extern "C" fn RoutingFees_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
777         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRoutingFees) })
778 }
779
780 use lightning::routing::network_graph::NodeAnnouncementInfo as nativeNodeAnnouncementInfoImport;
781 type nativeNodeAnnouncementInfo = nativeNodeAnnouncementInfoImport;
782
783 /// Information received in the latest node_announcement from this node.
784 #[must_use]
785 #[repr(C)]
786 pub struct NodeAnnouncementInfo {
787         /// A pointer to the opaque Rust object.
788
789         /// Nearly everywhere, inner must be non-null, however in places where
790         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
791         pub inner: *mut nativeNodeAnnouncementInfo,
792         /// Indicates that this is the only struct which contains the same pointer.
793
794         /// Rust functions which take ownership of an object provided via an argument require
795         /// this to be true and invalidate the object pointed to by inner.
796         pub is_owned: bool,
797 }
798
799 impl Drop for NodeAnnouncementInfo {
800         fn drop(&mut self) {
801                 if self.is_owned && !<*mut nativeNodeAnnouncementInfo>::is_null(self.inner) {
802                         let _ = unsafe { Box::from_raw(self.inner) };
803                 }
804         }
805 }
806 /// Frees any resources used by the NodeAnnouncementInfo, if is_owned is set and inner is non-NULL.
807 #[no_mangle]
808 pub extern "C" fn NodeAnnouncementInfo_free(this_obj: NodeAnnouncementInfo) { }
809 #[allow(unused)]
810 /// Used only if an object of this type is returned as a trait impl by a method
811 extern "C" fn NodeAnnouncementInfo_free_void(this_ptr: *mut c_void) {
812         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAnnouncementInfo); }
813 }
814 #[allow(unused)]
815 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
816 impl NodeAnnouncementInfo {
817         pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncementInfo {
818                 assert!(self.is_owned);
819                 let ret = self.inner;
820                 self.inner = std::ptr::null_mut();
821                 ret
822         }
823 }
824 /// Protocol features the node announced support for
825 #[no_mangle]
826 pub extern "C" fn NodeAnnouncementInfo_get_features(this_ptr: &NodeAnnouncementInfo) -> crate::ln::features::NodeFeatures {
827         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features;
828         crate::ln::features::NodeFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
829 }
830 /// Protocol features the node announced support for
831 #[no_mangle]
832 pub extern "C" fn NodeAnnouncementInfo_set_features(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::ln::features::NodeFeatures) {
833         unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) };
834 }
835 /// When the last known update to the node state was issued.
836 /// Value is opaque, as set in the announcement.
837 #[no_mangle]
838 pub extern "C" fn NodeAnnouncementInfo_get_last_update(this_ptr: &NodeAnnouncementInfo) -> u32 {
839         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.last_update;
840         (*inner_val)
841 }
842 /// When the last known update to the node state was issued.
843 /// Value is opaque, as set in the announcement.
844 #[no_mangle]
845 pub extern "C" fn NodeAnnouncementInfo_set_last_update(this_ptr: &mut NodeAnnouncementInfo, mut val: u32) {
846         unsafe { &mut *this_ptr.inner }.last_update = val;
847 }
848 /// Color assigned to the node
849 #[no_mangle]
850 pub extern "C" fn NodeAnnouncementInfo_get_rgb(this_ptr: &NodeAnnouncementInfo) -> *const [u8; 3] {
851         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.rgb;
852         &(*inner_val)
853 }
854 /// Color assigned to the node
855 #[no_mangle]
856 pub extern "C" fn NodeAnnouncementInfo_set_rgb(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::c_types::ThreeBytes) {
857         unsafe { &mut *this_ptr.inner }.rgb = val.data;
858 }
859 /// Moniker assigned to the node.
860 /// May be invalid or malicious (eg control chars),
861 /// should not be exposed to the user.
862 #[no_mangle]
863 pub extern "C" fn NodeAnnouncementInfo_get_alias(this_ptr: &NodeAnnouncementInfo) -> *const [u8; 32] {
864         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.alias;
865         &(*inner_val)
866 }
867 /// Moniker assigned to the node.
868 /// May be invalid or malicious (eg control chars),
869 /// should not be exposed to the user.
870 #[no_mangle]
871 pub extern "C" fn NodeAnnouncementInfo_set_alias(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::c_types::ThirtyTwoBytes) {
872         unsafe { &mut *this_ptr.inner }.alias = val.data;
873 }
874 /// Internet-level addresses via which one can connect to the node
875 #[no_mangle]
876 pub extern "C" fn NodeAnnouncementInfo_set_addresses(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::c_types::derived::CVec_NetAddressZ) {
877         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
878         unsafe { &mut *this_ptr.inner }.addresses = local_val;
879 }
880 /// An initial announcement of the node
881 /// Mostly redundant with the data we store in fields explicitly.
882 /// Everything else is useful only for sending out for initial routing sync.
883 /// Not stored if contains excess data to prevent DoS.
884 #[no_mangle]
885 pub extern "C" fn NodeAnnouncementInfo_get_announcement_message(this_ptr: &NodeAnnouncementInfo) -> crate::ln::msgs::NodeAnnouncement {
886         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.announcement_message;
887         let mut local_inner_val = crate::ln::msgs::NodeAnnouncement { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else {  { (inner_val.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false };
888         local_inner_val
889 }
890 /// An initial announcement of the node
891 /// Mostly redundant with the data we store in fields explicitly.
892 /// Everything else is useful only for sending out for initial routing sync.
893 /// Not stored if contains excess data to prevent DoS.
894 #[no_mangle]
895 pub extern "C" fn NodeAnnouncementInfo_set_announcement_message(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::ln::msgs::NodeAnnouncement) {
896         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
897         unsafe { &mut *this_ptr.inner }.announcement_message = local_val;
898 }
899 /// Constructs a new NodeAnnouncementInfo given each field
900 #[must_use]
901 #[no_mangle]
902 pub extern "C" fn NodeAnnouncementInfo_new(mut features_arg: crate::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::ln::msgs::NodeAnnouncement) -> NodeAnnouncementInfo {
903         let mut local_addresses_arg = Vec::new(); for mut item in addresses_arg.into_rust().drain(..) { local_addresses_arg.push( { item.into_native() }); };
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         NodeAnnouncementInfo { inner: Box::into_raw(Box::new(nativeNodeAnnouncementInfo {
906                 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
907                 last_update: last_update_arg,
908                 rgb: rgb_arg.data,
909                 alias: alias_arg.data,
910                 addresses: local_addresses_arg,
911                 announcement_message: local_announcement_message_arg,
912         })), is_owned: true }
913 }
914 impl Clone for NodeAnnouncementInfo {
915         fn clone(&self) -> Self {
916                 Self {
917                         inner: if <*mut nativeNodeAnnouncementInfo>::is_null(self.inner) { std::ptr::null_mut() } else {
918                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
919                         is_owned: true,
920                 }
921         }
922 }
923 #[allow(unused)]
924 /// Used only if an object of this type is returned as a trait impl by a method
925 pub(crate) extern "C" fn NodeAnnouncementInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
926         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncementInfo)).clone() })) as *mut c_void
927 }
928 #[no_mangle]
929 /// Creates a copy of the NodeAnnouncementInfo
930 pub extern "C" fn NodeAnnouncementInfo_clone(orig: &NodeAnnouncementInfo) -> NodeAnnouncementInfo {
931         orig.clone()
932 }
933 #[no_mangle]
934 /// Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read
935 pub extern "C" fn NodeAnnouncementInfo_write(obj: &NodeAnnouncementInfo) -> crate::c_types::derived::CVec_u8Z {
936         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
937 }
938 #[no_mangle]
939 pub(crate) extern "C" fn NodeAnnouncementInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
940         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncementInfo) })
941 }
942 #[no_mangle]
943 /// Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write
944 pub extern "C" fn NodeAnnouncementInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementInfoDecodeErrorZ {
945         let res = crate::c_types::deserialize_obj(ser);
946         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::routing::network_graph::NodeAnnouncementInfo { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
947         local_res
948 }
949
950 use lightning::routing::network_graph::NodeInfo as nativeNodeInfoImport;
951 type nativeNodeInfo = nativeNodeInfoImport;
952
953 /// Details about a node in the network, known from the network announcement.
954 #[must_use]
955 #[repr(C)]
956 pub struct NodeInfo {
957         /// A pointer to the opaque Rust object.
958
959         /// Nearly everywhere, inner must be non-null, however in places where
960         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
961         pub inner: *mut nativeNodeInfo,
962         /// Indicates that this is the only struct which contains the same pointer.
963
964         /// Rust functions which take ownership of an object provided via an argument require
965         /// this to be true and invalidate the object pointed to by inner.
966         pub is_owned: bool,
967 }
968
969 impl Drop for NodeInfo {
970         fn drop(&mut self) {
971                 if self.is_owned && !<*mut nativeNodeInfo>::is_null(self.inner) {
972                         let _ = unsafe { Box::from_raw(self.inner) };
973                 }
974         }
975 }
976 /// Frees any resources used by the NodeInfo, if is_owned is set and inner is non-NULL.
977 #[no_mangle]
978 pub extern "C" fn NodeInfo_free(this_obj: NodeInfo) { }
979 #[allow(unused)]
980 /// Used only if an object of this type is returned as a trait impl by a method
981 extern "C" fn NodeInfo_free_void(this_ptr: *mut c_void) {
982         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeInfo); }
983 }
984 #[allow(unused)]
985 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
986 impl NodeInfo {
987         pub(crate) fn take_inner(mut self) -> *mut nativeNodeInfo {
988                 assert!(self.is_owned);
989                 let ret = self.inner;
990                 self.inner = std::ptr::null_mut();
991                 ret
992         }
993 }
994 /// All valid channels a node has announced
995 #[no_mangle]
996 pub extern "C" fn NodeInfo_set_channels(this_ptr: &mut NodeInfo, mut val: crate::c_types::derived::CVec_u64Z) {
997         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
998         unsafe { &mut *this_ptr.inner }.channels = local_val;
999 }
1000 /// Lowest fees enabling routing via any of the enabled, known channels to a node.
1001 /// The two fields (flat and proportional fee) are independent,
1002 /// meaning they don't have to refer to the same channel.
1003 #[no_mangle]
1004 pub extern "C" fn NodeInfo_get_lowest_inbound_channel_fees(this_ptr: &NodeInfo) -> crate::routing::network_graph::RoutingFees {
1005         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.lowest_inbound_channel_fees;
1006         let mut local_inner_val = crate::routing::network_graph::RoutingFees { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else {  { (inner_val.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false };
1007         local_inner_val
1008 }
1009 /// Lowest fees enabling routing via any of the enabled, known channels to a node.
1010 /// The two fields (flat and proportional fee) are independent,
1011 /// meaning they don't have to refer to the same channel.
1012 #[no_mangle]
1013 pub extern "C" fn NodeInfo_set_lowest_inbound_channel_fees(this_ptr: &mut NodeInfo, mut val: crate::routing::network_graph::RoutingFees) {
1014         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1015         unsafe { &mut *this_ptr.inner }.lowest_inbound_channel_fees = local_val;
1016 }
1017 /// More information about a node from node_announcement.
1018 /// Optional because we store a Node entry after learning about it from
1019 /// a channel announcement, but before receiving a node announcement.
1020 #[no_mangle]
1021 pub extern "C" fn NodeInfo_get_announcement_info(this_ptr: &NodeInfo) -> crate::routing::network_graph::NodeAnnouncementInfo {
1022         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.announcement_info;
1023         let mut local_inner_val = crate::routing::network_graph::NodeAnnouncementInfo { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else {  { (inner_val.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false };
1024         local_inner_val
1025 }
1026 /// More information about a node from node_announcement.
1027 /// Optional because we store a Node entry after learning about it from
1028 /// a channel announcement, but before receiving a node announcement.
1029 #[no_mangle]
1030 pub extern "C" fn NodeInfo_set_announcement_info(this_ptr: &mut NodeInfo, mut val: crate::routing::network_graph::NodeAnnouncementInfo) {
1031         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1032         unsafe { &mut *this_ptr.inner }.announcement_info = local_val;
1033 }
1034 /// Constructs a new NodeInfo given each field
1035 #[must_use]
1036 #[no_mangle]
1037 pub extern "C" fn NodeInfo_new(mut channels_arg: crate::c_types::derived::CVec_u64Z, mut lowest_inbound_channel_fees_arg: crate::routing::network_graph::RoutingFees, mut announcement_info_arg: crate::routing::network_graph::NodeAnnouncementInfo) -> NodeInfo {
1038         let mut local_channels_arg = Vec::new(); for mut item in channels_arg.into_rust().drain(..) { local_channels_arg.push( { item }); };
1039         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()) } }) };
1040         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()) } }) };
1041         NodeInfo { inner: Box::into_raw(Box::new(nativeNodeInfo {
1042                 channels: local_channels_arg,
1043                 lowest_inbound_channel_fees: local_lowest_inbound_channel_fees_arg,
1044                 announcement_info: local_announcement_info_arg,
1045         })), is_owned: true }
1046 }
1047 impl Clone for NodeInfo {
1048         fn clone(&self) -> Self {
1049                 Self {
1050                         inner: if <*mut nativeNodeInfo>::is_null(self.inner) { std::ptr::null_mut() } else {
1051                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1052                         is_owned: true,
1053                 }
1054         }
1055 }
1056 #[allow(unused)]
1057 /// Used only if an object of this type is returned as a trait impl by a method
1058 pub(crate) extern "C" fn NodeInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
1059         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeInfo)).clone() })) as *mut c_void
1060 }
1061 #[no_mangle]
1062 /// Creates a copy of the NodeInfo
1063 pub extern "C" fn NodeInfo_clone(orig: &NodeInfo) -> NodeInfo {
1064         orig.clone()
1065 }
1066 #[no_mangle]
1067 /// Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read
1068 pub extern "C" fn NodeInfo_write(obj: &NodeInfo) -> crate::c_types::derived::CVec_u8Z {
1069         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
1070 }
1071 #[no_mangle]
1072 pub(crate) extern "C" fn NodeInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1073         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeInfo) })
1074 }
1075 #[no_mangle]
1076 /// Read a NodeInfo from a byte array, created by NodeInfo_write
1077 pub extern "C" fn NodeInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeInfoDecodeErrorZ {
1078         let res = crate::c_types::deserialize_obj(ser);
1079         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::routing::network_graph::NodeInfo { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
1080         local_res
1081 }
1082 #[no_mangle]
1083 /// Serialize the NetworkGraph object into a byte array which can be read by NetworkGraph_read
1084 pub extern "C" fn NetworkGraph_write(obj: &NetworkGraph) -> crate::c_types::derived::CVec_u8Z {
1085         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
1086 }
1087 #[no_mangle]
1088 pub(crate) extern "C" fn NetworkGraph_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1089         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNetworkGraph) })
1090 }
1091 #[no_mangle]
1092 /// Read a NetworkGraph from a byte array, created by NetworkGraph_write
1093 pub extern "C" fn NetworkGraph_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NetworkGraphDecodeErrorZ {
1094         let res = crate::c_types::deserialize_obj(ser);
1095         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::routing::network_graph::NetworkGraph { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
1096         local_res
1097 }
1098 /// Creates a new, empty, network graph.
1099 #[must_use]
1100 #[no_mangle]
1101 pub extern "C" fn NetworkGraph_new(mut genesis_hash: crate::c_types::ThirtyTwoBytes) -> crate::routing::network_graph::NetworkGraph {
1102         let mut ret = lightning::routing::network_graph::NetworkGraph::new(::bitcoin::hash_types::BlockHash::from_slice(&genesis_hash.data[..]).unwrap());
1103         crate::routing::network_graph::NetworkGraph { inner: Box::into_raw(Box::new(ret)), is_owned: true }
1104 }
1105
1106 /// For an already known node (from channel announcements), update its stored properties from a
1107 /// given node announcement.
1108 ///
1109 /// You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's
1110 /// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
1111 /// routing messages from a source using a protocol other than the lightning P2P protocol.
1112 #[must_use]
1113 #[no_mangle]
1114 pub extern "C" fn NetworkGraph_update_node_from_announcement(this_arg: &mut NetworkGraph, msg: &crate::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
1115         let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_node_from_announcement(unsafe { &*msg.inner }, secp256k1::SECP256K1);
1116         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
1117         local_ret
1118 }
1119
1120 /// For an already known node (from channel announcements), update its stored properties from a
1121 /// given node announcement without verifying the associated signatures. Because we aren't
1122 /// given the associated signatures here we cannot relay the node announcement to any of our
1123 /// peers.
1124 #[must_use]
1125 #[no_mangle]
1126 pub extern "C" fn NetworkGraph_update_node_from_unsigned_announcement(this_arg: &mut NetworkGraph, msg: &crate::ln::msgs::UnsignedNodeAnnouncement) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
1127         let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_node_from_unsigned_announcement(unsafe { &*msg.inner });
1128         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
1129         local_ret
1130 }
1131
1132 /// Store or update channel info from a channel announcement.
1133 ///
1134 /// You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's
1135 /// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
1136 /// routing messages from a source using a protocol other than the lightning P2P protocol.
1137 ///
1138 /// If a `chain::Access` object is provided via `chain_access`, it will be called to verify
1139 /// the corresponding UTXO exists on chain and is correctly-formatted.
1140 #[must_use]
1141 #[no_mangle]
1142 pub extern "C" fn NetworkGraph_update_channel_from_announcement(this_arg: &mut NetworkGraph, msg: &crate::ln::msgs::ChannelAnnouncement, chain_access: *mut crate::chain::Access) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
1143         let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) };
1144         let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_channel_from_announcement(unsafe { &*msg.inner }, &local_chain_access, secp256k1::SECP256K1);
1145         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
1146         local_ret
1147 }
1148
1149 /// Store or update channel info from a channel announcement without verifying the associated
1150 /// signatures. Because we aren't given the associated signatures here we cannot relay the
1151 /// channel announcement to any of our peers.
1152 ///
1153 /// If a `chain::Access` object is provided via `chain_access`, it will be called to verify
1154 /// the corresponding UTXO exists on chain and is correctly-formatted.
1155 #[must_use]
1156 #[no_mangle]
1157 pub extern "C" fn NetworkGraph_update_channel_from_unsigned_announcement(this_arg: &mut NetworkGraph, msg: &crate::ln::msgs::UnsignedChannelAnnouncement, chain_access: *mut crate::chain::Access) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
1158         let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) };
1159         let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_channel_from_unsigned_announcement(unsafe { &*msg.inner }, &local_chain_access);
1160         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
1161         local_ret
1162 }
1163
1164 /// Close a channel if a corresponding HTLC fail was sent.
1165 /// If permanent, removes a channel from the local storage.
1166 /// May cause the removal of nodes too, if this was their last channel.
1167 /// If not permanent, makes channels unavailable for routing.
1168 #[no_mangle]
1169 pub extern "C" fn NetworkGraph_close_channel_from_update(this_arg: &mut NetworkGraph, mut short_channel_id: u64, mut is_permanent: bool) {
1170         unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.close_channel_from_update(short_channel_id, is_permanent)
1171 }
1172
1173 /// For an already known (from announcement) channel, update info about one of the directions
1174 /// of the channel.
1175 ///
1176 /// You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's
1177 /// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
1178 /// routing messages from a source using a protocol other than the lightning P2P protocol.
1179 #[must_use]
1180 #[no_mangle]
1181 pub extern "C" fn NetworkGraph_update_channel(this_arg: &mut NetworkGraph, msg: &crate::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
1182         let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_channel(unsafe { &*msg.inner }, secp256k1::SECP256K1);
1183         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
1184         local_ret
1185 }
1186
1187 /// For an already known (from announcement) channel, update info about one of the directions
1188 /// of the channel without verifying the associated signatures. Because we aren't given the
1189 /// associated signatures here we cannot relay the channel update to any of our peers.
1190 #[must_use]
1191 #[no_mangle]
1192 pub extern "C" fn NetworkGraph_update_channel_unsigned(this_arg: &mut NetworkGraph, msg: &crate::ln::msgs::UnsignedChannelUpdate) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
1193         let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_channel_unsigned(unsafe { &*msg.inner });
1194         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
1195         local_ret
1196 }
1197