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