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