1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
4 // This file is licensed under the license available in the LICENSE or LICENSE.md
5 // file in the root of this repository or, if no such file exists, the same
6 // license as that which applies to the original source files from which this
7 // source was automatically generated.
9 //! The top-level network map tracking logic lives here.
11 use std::str::FromStr;
13 use bitcoin::hashes::Hash;
14 use crate::c_types::*;
17 use lightning::routing::network_graph::NetworkGraph as nativeNetworkGraphImport;
18 type nativeNetworkGraph = nativeNetworkGraphImport;
20 /// Represents the network as nodes and channels between them
23 pub struct NetworkGraph {
24 /// A pointer to the opaque Rust object.
26 /// Nearly everywhere, inner must be non-null, however in places where
27 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
28 pub inner: *mut nativeNetworkGraph,
29 /// Indicates that this is the only struct which contains the same pointer.
31 /// Rust functions which take ownership of an object provided via an argument require
32 /// this to be true and invalidate the object pointed to by inner.
36 impl Drop for NetworkGraph {
38 if self.is_owned && !<*mut nativeNetworkGraph>::is_null(self.inner) {
39 let _ = unsafe { Box::from_raw(self.inner) };
43 /// Frees any resources used by the NetworkGraph, if is_owned is set and inner is non-NULL.
45 pub extern "C" fn NetworkGraph_free(this_obj: NetworkGraph) { }
47 /// Used only if an object of this type is returned as a trait impl by a method
48 extern "C" fn NetworkGraph_free_void(this_ptr: *mut c_void) {
49 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNetworkGraph); }
52 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
54 pub(crate) fn take_inner(mut self) -> *mut nativeNetworkGraph {
55 assert!(self.is_owned);
57 self.inner = std::ptr::null_mut();
61 impl Clone for NetworkGraph {
62 fn clone(&self) -> Self {
64 inner: if <*mut nativeNetworkGraph>::is_null(self.inner) { std::ptr::null_mut() } else {
65 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
71 /// Used only if an object of this type is returned as a trait impl by a method
72 pub(crate) extern "C" fn NetworkGraph_clone_void(this_ptr: *const c_void) -> *mut c_void {
73 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNetworkGraph)).clone() })) as *mut c_void
76 /// Creates a copy of the NetworkGraph
77 pub extern "C" fn NetworkGraph_clone(orig: &NetworkGraph) -> NetworkGraph {
81 use lightning::routing::network_graph::LockedNetworkGraph as nativeLockedNetworkGraphImport;
82 type nativeLockedNetworkGraph = nativeLockedNetworkGraphImport<'static>;
84 /// A simple newtype for RwLockReadGuard<'a, NetworkGraph>.
85 /// This exists only to make accessing a RwLock<NetworkGraph> possible from
86 /// the C bindings, as it can be done directly in Rust code.
89 pub struct LockedNetworkGraph {
90 /// A pointer to the opaque Rust object.
92 /// Nearly everywhere, inner must be non-null, however in places where
93 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
94 pub inner: *mut nativeLockedNetworkGraph,
95 /// Indicates that this is the only struct which contains the same pointer.
97 /// Rust functions which take ownership of an object provided via an argument require
98 /// this to be true and invalidate the object pointed to by inner.
102 impl Drop for LockedNetworkGraph {
104 if self.is_owned && !<*mut nativeLockedNetworkGraph>::is_null(self.inner) {
105 let _ = unsafe { Box::from_raw(self.inner) };
109 /// Frees any resources used by the LockedNetworkGraph, if is_owned is set and inner is non-NULL.
111 pub extern "C" fn LockedNetworkGraph_free(this_obj: LockedNetworkGraph) { }
113 /// Used only if an object of this type is returned as a trait impl by a method
114 extern "C" fn LockedNetworkGraph_free_void(this_ptr: *mut c_void) {
115 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeLockedNetworkGraph); }
118 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
119 impl LockedNetworkGraph {
120 pub(crate) fn take_inner(mut self) -> *mut nativeLockedNetworkGraph {
121 assert!(self.is_owned);
122 let ret = self.inner;
123 self.inner = std::ptr::null_mut();
128 use lightning::routing::network_graph::NetGraphMsgHandler as nativeNetGraphMsgHandlerImport;
129 type nativeNetGraphMsgHandler = nativeNetGraphMsgHandlerImport<crate::lightning::chain::Access, crate::lightning::util::logger::Logger>;
131 /// Receives and validates network updates from peers,
132 /// stores authentic and relevant data as a network graph.
133 /// This network graph is then used for routing payments.
134 /// Provides interface to help with initial routing sync by
135 /// serving historical announcements.
138 pub struct NetGraphMsgHandler {
139 /// A pointer to the opaque Rust object.
141 /// Nearly everywhere, inner must be non-null, however in places where
142 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
143 pub inner: *mut nativeNetGraphMsgHandler,
144 /// Indicates that this is the only struct which contains the same pointer.
146 /// Rust functions which take ownership of an object provided via an argument require
147 /// this to be true and invalidate the object pointed to by inner.
151 impl Drop for NetGraphMsgHandler {
153 if self.is_owned && !<*mut nativeNetGraphMsgHandler>::is_null(self.inner) {
154 let _ = unsafe { Box::from_raw(self.inner) };
158 /// Frees any resources used by the NetGraphMsgHandler, if is_owned is set and inner is non-NULL.
160 pub extern "C" fn NetGraphMsgHandler_free(this_obj: NetGraphMsgHandler) { }
162 /// Used only if an object of this type is returned as a trait impl by a method
163 extern "C" fn NetGraphMsgHandler_free_void(this_ptr: *mut c_void) {
164 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNetGraphMsgHandler); }
167 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
168 impl NetGraphMsgHandler {
169 pub(crate) fn take_inner(mut self) -> *mut nativeNetGraphMsgHandler {
170 assert!(self.is_owned);
171 let ret = self.inner;
172 self.inner = std::ptr::null_mut();
176 /// Creates a new tracker of the actual state of the network of channels and nodes,
177 /// assuming a fresh network graph.
178 /// Chain monitor is used to make sure announced channels exist on-chain,
179 /// channel data is correct, and that the announcement is signed with
180 /// channel owners' keys.
182 /// Note that chain_access (or a relevant inner pointer) may be NULL or all-0s to represent None
185 pub extern "C" fn NetGraphMsgHandler_new(mut genesis_hash: crate::c_types::ThirtyTwoBytes, chain_access: *mut crate::lightning::chain::Access, mut logger: crate::lightning::util::logger::Logger) -> NetGraphMsgHandler {
186 let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) };
187 let mut ret = lightning::routing::network_graph::NetGraphMsgHandler::new(::bitcoin::hash_types::BlockHash::from_slice(&genesis_hash.data[..]).unwrap(), local_chain_access, logger);
188 NetGraphMsgHandler { inner: Box::into_raw(Box::new(ret)), is_owned: true }
191 /// Creates a new tracker of the actual state of the network of channels and nodes,
192 /// assuming an existing Network Graph.
194 /// Note that chain_access (or a relevant inner pointer) may be NULL or all-0s to represent None
197 pub extern "C" fn NetGraphMsgHandler_from_net_graph(chain_access: *mut crate::lightning::chain::Access, mut logger: crate::lightning::util::logger::Logger, mut network_graph: crate::lightning::routing::network_graph::NetworkGraph) -> NetGraphMsgHandler {
198 let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) };
199 let mut ret = lightning::routing::network_graph::NetGraphMsgHandler::from_net_graph(local_chain_access, logger, *unsafe { Box::from_raw(network_graph.take_inner()) });
200 NetGraphMsgHandler { inner: Box::into_raw(Box::new(ret)), is_owned: true }
203 /// Adds a provider used to check new announcements. Does not affect
204 /// existing announcements unless they are updated.
205 /// Add, update or remove the provider would replace the current one.
207 /// Note that chain_access (or a relevant inner pointer) may be NULL or all-0s to represent None
209 pub extern "C" fn NetGraphMsgHandler_add_chain_access(this_arg: &mut NetGraphMsgHandler, chain_access: *mut crate::lightning::chain::Access) {
210 let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) };
211 unsafe { &mut (*(this_arg.inner as *mut nativeNetGraphMsgHandler)) }.add_chain_access(local_chain_access)
214 /// Take a read lock on the network_graph and return it in the C-bindings
215 /// newtype helper. This is likely only useful when called via the C
216 /// bindings as you can call `self.network_graph.read().unwrap()` in Rust
220 pub extern "C" fn NetGraphMsgHandler_read_locked_graph(this_arg: &NetGraphMsgHandler) -> crate::lightning::routing::network_graph::LockedNetworkGraph {
221 let mut ret = unsafe { &*this_arg.inner }.read_locked_graph();
222 crate::lightning::routing::network_graph::LockedNetworkGraph { inner: Box::into_raw(Box::new(ret)), is_owned: true }
225 /// Get a reference to the NetworkGraph which this read-lock contains.
228 pub extern "C" fn LockedNetworkGraph_graph(this_arg: &LockedNetworkGraph) -> crate::lightning::routing::network_graph::NetworkGraph {
229 let mut ret = unsafe { &*this_arg.inner }.graph();
230 crate::lightning::routing::network_graph::NetworkGraph { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false }
233 impl From<nativeNetGraphMsgHandler> for crate::lightning::ln::msgs::RoutingMessageHandler {
234 fn from(obj: nativeNetGraphMsgHandler) -> Self {
235 let mut rust_obj = NetGraphMsgHandler { inner: Box::into_raw(Box::new(obj)), is_owned: true };
236 let mut ret = NetGraphMsgHandler_as_RoutingMessageHandler(&rust_obj);
237 // 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
238 rust_obj.inner = std::ptr::null_mut();
239 ret.free = Some(NetGraphMsgHandler_free_void);
243 /// Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg.
244 /// This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is
246 pub extern "C" fn NetGraphMsgHandler_as_RoutingMessageHandler(this_arg: &NetGraphMsgHandler) -> crate::lightning::ln::msgs::RoutingMessageHandler {
247 crate::lightning::ln::msgs::RoutingMessageHandler {
248 this_arg: unsafe { (*this_arg).inner as *mut c_void },
250 handle_node_announcement: NetGraphMsgHandler_RoutingMessageHandler_handle_node_announcement,
251 handle_channel_announcement: NetGraphMsgHandler_RoutingMessageHandler_handle_channel_announcement,
252 handle_channel_update: NetGraphMsgHandler_RoutingMessageHandler_handle_channel_update,
253 handle_htlc_fail_channel_update: NetGraphMsgHandler_RoutingMessageHandler_handle_htlc_fail_channel_update,
254 get_next_channel_announcements: NetGraphMsgHandler_RoutingMessageHandler_get_next_channel_announcements,
255 get_next_node_announcements: NetGraphMsgHandler_RoutingMessageHandler_get_next_node_announcements,
256 sync_routing_table: NetGraphMsgHandler_RoutingMessageHandler_sync_routing_table,
257 handle_reply_channel_range: NetGraphMsgHandler_RoutingMessageHandler_handle_reply_channel_range,
258 handle_reply_short_channel_ids_end: NetGraphMsgHandler_RoutingMessageHandler_handle_reply_short_channel_ids_end,
259 handle_query_channel_range: NetGraphMsgHandler_RoutingMessageHandler_handle_query_channel_range,
260 handle_query_short_channel_ids: NetGraphMsgHandler_RoutingMessageHandler_handle_query_short_channel_ids,
261 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider {
262 this_arg: unsafe { (*this_arg).inner as *mut c_void },
264 get_and_clear_pending_msg_events: NetGraphMsgHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events,
270 extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_node_announcement(this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ {
271 let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_node_announcement(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, unsafe { &*msg.inner });
272 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
276 extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_channel_announcement(this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ {
277 let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_channel_announcement(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, unsafe { &*msg.inner });
278 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
281 extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_htlc_fail_channel_update(this_arg: *const c_void, update: &crate::lightning::ln::msgs::HTLCFailChannelUpdate) {
282 <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_htlc_fail_channel_update(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, &update.to_native())
285 extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_channel_update(this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ {
286 let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, unsafe { &*msg.inner });
287 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
291 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 {
292 let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::get_next_channel_announcements(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, starting_point, batch_amount);
293 let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = item; let mut local_orig_ret_0_1 = crate::lightning::ln::msgs::ChannelUpdate { inner: if orig_ret_0_1.is_none() { std::ptr::null_mut() } else { { Box::into_raw(Box::new((orig_ret_0_1.unwrap()))) } }, is_owned: true }; let mut local_orig_ret_0_2 = crate::lightning::ln::msgs::ChannelUpdate { inner: if orig_ret_0_2.is_none() { std::ptr::null_mut() } else { { Box::into_raw(Box::new((orig_ret_0_2.unwrap()))) } }, is_owned: true }; let mut local_ret_0 = (crate::lightning::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 }); };
297 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 {
298 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();
299 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);
300 let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::msgs::NodeAnnouncement { inner: Box::into_raw(Box::new(item)), is_owned: true } }); };
303 extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_sync_routing_table(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, init_msg: &crate::lightning::ln::msgs::Init) {
304 <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 })
307 extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_reply_channel_range(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
308 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()) });
309 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
313 extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_reply_short_channel_ids_end(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
314 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()) });
315 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
319 extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_query_channel_range(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
320 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()) });
321 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
325 extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_query_short_channel_ids(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, mut _msg: crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
326 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()) });
327 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
331 impl From<nativeNetGraphMsgHandler> for crate::lightning::util::events::MessageSendEventsProvider {
332 fn from(obj: nativeNetGraphMsgHandler) -> Self {
333 let mut rust_obj = NetGraphMsgHandler { inner: Box::into_raw(Box::new(obj)), is_owned: true };
334 let mut ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&rust_obj);
335 // 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
336 rust_obj.inner = std::ptr::null_mut();
337 ret.free = Some(NetGraphMsgHandler_free_void);
341 /// Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg.
342 /// This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is
344 pub extern "C" fn NetGraphMsgHandler_as_MessageSendEventsProvider(this_arg: &NetGraphMsgHandler) -> crate::lightning::util::events::MessageSendEventsProvider {
345 crate::lightning::util::events::MessageSendEventsProvider {
346 this_arg: unsafe { (*this_arg).inner as *mut c_void },
348 get_and_clear_pending_msg_events: NetGraphMsgHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events,
353 extern "C" fn NetGraphMsgHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ {
354 let mut ret = <nativeNetGraphMsgHandler as lightning::util::events::MessageSendEventsProvider<>>::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, );
355 let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::util::events::MessageSendEvent::native_into(item) }); };
360 use lightning::routing::network_graph::DirectionalChannelInfo as nativeDirectionalChannelInfoImport;
361 type nativeDirectionalChannelInfo = nativeDirectionalChannelInfoImport;
363 /// Details about one direction of a channel. Received
364 /// within a channel update.
367 pub struct DirectionalChannelInfo {
368 /// A pointer to the opaque Rust object.
370 /// Nearly everywhere, inner must be non-null, however in places where
371 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
372 pub inner: *mut nativeDirectionalChannelInfo,
373 /// Indicates that this is the only struct which contains the same pointer.
375 /// Rust functions which take ownership of an object provided via an argument require
376 /// this to be true and invalidate the object pointed to by inner.
380 impl Drop for DirectionalChannelInfo {
382 if self.is_owned && !<*mut nativeDirectionalChannelInfo>::is_null(self.inner) {
383 let _ = unsafe { Box::from_raw(self.inner) };
387 /// Frees any resources used by the DirectionalChannelInfo, if is_owned is set and inner is non-NULL.
389 pub extern "C" fn DirectionalChannelInfo_free(this_obj: DirectionalChannelInfo) { }
391 /// Used only if an object of this type is returned as a trait impl by a method
392 extern "C" fn DirectionalChannelInfo_free_void(this_ptr: *mut c_void) {
393 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDirectionalChannelInfo); }
396 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
397 impl DirectionalChannelInfo {
398 pub(crate) fn take_inner(mut self) -> *mut nativeDirectionalChannelInfo {
399 assert!(self.is_owned);
400 let ret = self.inner;
401 self.inner = std::ptr::null_mut();
405 /// When the last update to the channel direction was issued.
406 /// Value is opaque, as set in the announcement.
408 pub extern "C" fn DirectionalChannelInfo_get_last_update(this_ptr: &DirectionalChannelInfo) -> u32 {
409 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.last_update;
412 /// When the last update to the channel direction was issued.
413 /// Value is opaque, as set in the announcement.
415 pub extern "C" fn DirectionalChannelInfo_set_last_update(this_ptr: &mut DirectionalChannelInfo, mut val: u32) {
416 unsafe { &mut *this_ptr.inner }.last_update = val;
418 /// Whether the channel can be currently used for payments (in this one direction).
420 pub extern "C" fn DirectionalChannelInfo_get_enabled(this_ptr: &DirectionalChannelInfo) -> bool {
421 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.enabled;
424 /// Whether the channel can be currently used for payments (in this one direction).
426 pub extern "C" fn DirectionalChannelInfo_set_enabled(this_ptr: &mut DirectionalChannelInfo, mut val: bool) {
427 unsafe { &mut *this_ptr.inner }.enabled = val;
429 /// The difference in CLTV values that you must have when routing through this channel.
431 pub extern "C" fn DirectionalChannelInfo_get_cltv_expiry_delta(this_ptr: &DirectionalChannelInfo) -> u16 {
432 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry_delta;
435 /// The difference in CLTV values that you must have when routing through this channel.
437 pub extern "C" fn DirectionalChannelInfo_set_cltv_expiry_delta(this_ptr: &mut DirectionalChannelInfo, mut val: u16) {
438 unsafe { &mut *this_ptr.inner }.cltv_expiry_delta = val;
440 /// The minimum value, which must be relayed to the next hop via the channel
442 pub extern "C" fn DirectionalChannelInfo_get_htlc_minimum_msat(this_ptr: &DirectionalChannelInfo) -> u64 {
443 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat;
446 /// The minimum value, which must be relayed to the next hop via the channel
448 pub extern "C" fn DirectionalChannelInfo_set_htlc_minimum_msat(this_ptr: &mut DirectionalChannelInfo, mut val: u64) {
449 unsafe { &mut *this_ptr.inner }.htlc_minimum_msat = val;
451 /// The maximum value which may be relayed to the next hop via the channel.
453 pub extern "C" fn DirectionalChannelInfo_get_htlc_maximum_msat(this_ptr: &DirectionalChannelInfo) -> crate::c_types::derived::COption_u64Z {
454 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_maximum_msat;
455 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { { crate::c_types::derived::COption_u64Z::Some(inner_val.unwrap()) } };
458 /// The maximum value which may be relayed to the next hop via the channel.
460 pub extern "C" fn DirectionalChannelInfo_set_htlc_maximum_msat(this_ptr: &mut DirectionalChannelInfo, mut val: crate::c_types::derived::COption_u64Z) {
461 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
462 unsafe { &mut *this_ptr.inner }.htlc_maximum_msat = local_val;
464 /// Fees charged when the channel is used for routing
466 pub extern "C" fn DirectionalChannelInfo_get_fees(this_ptr: &DirectionalChannelInfo) -> crate::lightning::routing::network_graph::RoutingFees {
467 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fees;
468 crate::lightning::routing::network_graph::RoutingFees { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
470 /// Fees charged when the channel is used for routing
472 pub extern "C" fn DirectionalChannelInfo_set_fees(this_ptr: &mut DirectionalChannelInfo, mut val: crate::lightning::routing::network_graph::RoutingFees) {
473 unsafe { &mut *this_ptr.inner }.fees = *unsafe { Box::from_raw(val.take_inner()) };
475 /// Most recent update for the channel received from the network
476 /// Mostly redundant with the data we store in fields explicitly.
477 /// Everything else is useful only for sending out for initial routing sync.
478 /// Not stored if contains excess data to prevent DoS.
480 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
482 pub extern "C" fn DirectionalChannelInfo_get_last_update_message(this_ptr: &DirectionalChannelInfo) -> crate::lightning::ln::msgs::ChannelUpdate {
483 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.last_update_message;
484 let mut local_inner_val = crate::lightning::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 };
487 /// Most recent update for the channel received from the network
488 /// Mostly redundant with the data we store in fields explicitly.
489 /// Everything else is useful only for sending out for initial routing sync.
490 /// Not stored if contains excess data to prevent DoS.
492 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
494 pub extern "C" fn DirectionalChannelInfo_set_last_update_message(this_ptr: &mut DirectionalChannelInfo, mut val: crate::lightning::ln::msgs::ChannelUpdate) {
495 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
496 unsafe { &mut *this_ptr.inner }.last_update_message = local_val;
498 /// Constructs a new DirectionalChannelInfo given each field
501 pub extern "C" fn DirectionalChannelInfo_new(mut last_update_arg: u32, mut enabled_arg: bool, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: u64, mut htlc_maximum_msat_arg: crate::c_types::derived::COption_u64Z, mut fees_arg: crate::lightning::routing::network_graph::RoutingFees, mut last_update_message_arg: crate::lightning::ln::msgs::ChannelUpdate) -> DirectionalChannelInfo {
502 let mut local_htlc_maximum_msat_arg = if htlc_maximum_msat_arg.is_some() { Some( { htlc_maximum_msat_arg.take() }) } else { None };
503 let mut local_last_update_message_arg = if last_update_message_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(last_update_message_arg.take_inner()) } }) };
504 DirectionalChannelInfo { inner: Box::into_raw(Box::new(nativeDirectionalChannelInfo {
505 last_update: last_update_arg,
506 enabled: enabled_arg,
507 cltv_expiry_delta: cltv_expiry_delta_arg,
508 htlc_minimum_msat: htlc_minimum_msat_arg,
509 htlc_maximum_msat: local_htlc_maximum_msat_arg,
510 fees: *unsafe { Box::from_raw(fees_arg.take_inner()) },
511 last_update_message: local_last_update_message_arg,
512 })), is_owned: true }
514 impl Clone for DirectionalChannelInfo {
515 fn clone(&self) -> Self {
517 inner: if <*mut nativeDirectionalChannelInfo>::is_null(self.inner) { std::ptr::null_mut() } else {
518 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
524 /// Used only if an object of this type is returned as a trait impl by a method
525 pub(crate) extern "C" fn DirectionalChannelInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
526 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDirectionalChannelInfo)).clone() })) as *mut c_void
529 /// Creates a copy of the DirectionalChannelInfo
530 pub extern "C" fn DirectionalChannelInfo_clone(orig: &DirectionalChannelInfo) -> DirectionalChannelInfo {
534 /// Serialize the DirectionalChannelInfo object into a byte array which can be read by DirectionalChannelInfo_read
535 pub extern "C" fn DirectionalChannelInfo_write(obj: &DirectionalChannelInfo) -> crate::c_types::derived::CVec_u8Z {
536 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
539 pub(crate) extern "C" fn DirectionalChannelInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
540 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeDirectionalChannelInfo) })
543 /// Read a DirectionalChannelInfo from a byte array, created by DirectionalChannelInfo_write
544 pub extern "C" fn DirectionalChannelInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_DirectionalChannelInfoDecodeErrorZ {
545 let res = crate::c_types::deserialize_obj(ser);
546 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::network_graph::DirectionalChannelInfo { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
550 use lightning::routing::network_graph::ChannelInfo as nativeChannelInfoImport;
551 type nativeChannelInfo = nativeChannelInfoImport;
553 /// Details about a channel (both directions).
554 /// Received within a channel announcement.
557 pub struct ChannelInfo {
558 /// A pointer to the opaque Rust object.
560 /// Nearly everywhere, inner must be non-null, however in places where
561 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
562 pub inner: *mut nativeChannelInfo,
563 /// Indicates that this is the only struct which contains the same pointer.
565 /// Rust functions which take ownership of an object provided via an argument require
566 /// this to be true and invalidate the object pointed to by inner.
570 impl Drop for ChannelInfo {
572 if self.is_owned && !<*mut nativeChannelInfo>::is_null(self.inner) {
573 let _ = unsafe { Box::from_raw(self.inner) };
577 /// Frees any resources used by the ChannelInfo, if is_owned is set and inner is non-NULL.
579 pub extern "C" fn ChannelInfo_free(this_obj: ChannelInfo) { }
581 /// Used only if an object of this type is returned as a trait impl by a method
582 extern "C" fn ChannelInfo_free_void(this_ptr: *mut c_void) {
583 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelInfo); }
586 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
588 pub(crate) fn take_inner(mut self) -> *mut nativeChannelInfo {
589 assert!(self.is_owned);
590 let ret = self.inner;
591 self.inner = std::ptr::null_mut();
595 /// Protocol features of a channel communicated during its announcement
597 pub extern "C" fn ChannelInfo_get_features(this_ptr: &ChannelInfo) -> crate::lightning::ln::features::ChannelFeatures {
598 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features;
599 crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
601 /// Protocol features of a channel communicated during its announcement
603 pub extern "C" fn ChannelInfo_set_features(this_ptr: &mut ChannelInfo, mut val: crate::lightning::ln::features::ChannelFeatures) {
604 unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) };
606 /// Source node of the first direction of a channel
608 pub extern "C" fn ChannelInfo_get_node_one(this_ptr: &ChannelInfo) -> crate::c_types::PublicKey {
609 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_one;
610 crate::c_types::PublicKey::from_rust(&inner_val)
612 /// Source node of the first direction of a channel
614 pub extern "C" fn ChannelInfo_set_node_one(this_ptr: &mut ChannelInfo, mut val: crate::c_types::PublicKey) {
615 unsafe { &mut *this_ptr.inner }.node_one = val.into_rust();
617 /// Details about the first direction of a channel
619 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
621 pub extern "C" fn ChannelInfo_get_one_to_two(this_ptr: &ChannelInfo) -> crate::lightning::routing::network_graph::DirectionalChannelInfo {
622 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.one_to_two;
623 let mut local_inner_val = crate::lightning::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 };
626 /// Details about the first direction of a channel
628 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
630 pub extern "C" fn ChannelInfo_set_one_to_two(this_ptr: &mut ChannelInfo, mut val: crate::lightning::routing::network_graph::DirectionalChannelInfo) {
631 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
632 unsafe { &mut *this_ptr.inner }.one_to_two = local_val;
634 /// Source node of the second direction of a channel
636 pub extern "C" fn ChannelInfo_get_node_two(this_ptr: &ChannelInfo) -> crate::c_types::PublicKey {
637 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_two;
638 crate::c_types::PublicKey::from_rust(&inner_val)
640 /// Source node of the second direction of a channel
642 pub extern "C" fn ChannelInfo_set_node_two(this_ptr: &mut ChannelInfo, mut val: crate::c_types::PublicKey) {
643 unsafe { &mut *this_ptr.inner }.node_two = val.into_rust();
645 /// Details about the second direction of a channel
647 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
649 pub extern "C" fn ChannelInfo_get_two_to_one(this_ptr: &ChannelInfo) -> crate::lightning::routing::network_graph::DirectionalChannelInfo {
650 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.two_to_one;
651 let mut local_inner_val = crate::lightning::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 };
654 /// Details about the second direction of a channel
656 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
658 pub extern "C" fn ChannelInfo_set_two_to_one(this_ptr: &mut ChannelInfo, mut val: crate::lightning::routing::network_graph::DirectionalChannelInfo) {
659 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
660 unsafe { &mut *this_ptr.inner }.two_to_one = local_val;
662 /// The channel capacity as seen on-chain, if chain lookup is available.
664 pub extern "C" fn ChannelInfo_get_capacity_sats(this_ptr: &ChannelInfo) -> crate::c_types::derived::COption_u64Z {
665 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.capacity_sats;
666 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { { crate::c_types::derived::COption_u64Z::Some(inner_val.unwrap()) } };
669 /// The channel capacity as seen on-chain, if chain lookup is available.
671 pub extern "C" fn ChannelInfo_set_capacity_sats(this_ptr: &mut ChannelInfo, mut val: crate::c_types::derived::COption_u64Z) {
672 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
673 unsafe { &mut *this_ptr.inner }.capacity_sats = local_val;
675 /// An initial announcement of the channel
676 /// Mostly redundant with the data we store in fields explicitly.
677 /// Everything else is useful only for sending out for initial routing sync.
678 /// Not stored if contains excess data to prevent DoS.
680 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
682 pub extern "C" fn ChannelInfo_get_announcement_message(this_ptr: &ChannelInfo) -> crate::lightning::ln::msgs::ChannelAnnouncement {
683 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.announcement_message;
684 let mut local_inner_val = crate::lightning::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 };
687 /// An initial announcement of the channel
688 /// Mostly redundant with the data we store in fields explicitly.
689 /// Everything else is useful only for sending out for initial routing sync.
690 /// Not stored if contains excess data to prevent DoS.
692 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
694 pub extern "C" fn ChannelInfo_set_announcement_message(this_ptr: &mut ChannelInfo, mut val: crate::lightning::ln::msgs::ChannelAnnouncement) {
695 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
696 unsafe { &mut *this_ptr.inner }.announcement_message = local_val;
698 /// Constructs a new ChannelInfo given each field
701 pub extern "C" fn ChannelInfo_new(mut features_arg: crate::lightning::ln::features::ChannelFeatures, mut node_one_arg: crate::c_types::PublicKey, mut one_to_two_arg: crate::lightning::routing::network_graph::DirectionalChannelInfo, mut node_two_arg: crate::c_types::PublicKey, mut two_to_one_arg: crate::lightning::routing::network_graph::DirectionalChannelInfo, mut capacity_sats_arg: crate::c_types::derived::COption_u64Z, mut announcement_message_arg: crate::lightning::ln::msgs::ChannelAnnouncement) -> ChannelInfo {
702 let mut local_one_to_two_arg = if one_to_two_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(one_to_two_arg.take_inner()) } }) };
703 let mut local_two_to_one_arg = if two_to_one_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(two_to_one_arg.take_inner()) } }) };
704 let mut local_capacity_sats_arg = if capacity_sats_arg.is_some() { Some( { capacity_sats_arg.take() }) } else { None };
705 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()) } }) };
706 ChannelInfo { inner: Box::into_raw(Box::new(nativeChannelInfo {
707 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
708 node_one: node_one_arg.into_rust(),
709 one_to_two: local_one_to_two_arg,
710 node_two: node_two_arg.into_rust(),
711 two_to_one: local_two_to_one_arg,
712 capacity_sats: local_capacity_sats_arg,
713 announcement_message: local_announcement_message_arg,
714 })), is_owned: true }
716 impl Clone for ChannelInfo {
717 fn clone(&self) -> Self {
719 inner: if <*mut nativeChannelInfo>::is_null(self.inner) { std::ptr::null_mut() } else {
720 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
726 /// Used only if an object of this type is returned as a trait impl by a method
727 pub(crate) extern "C" fn ChannelInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
728 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelInfo)).clone() })) as *mut c_void
731 /// Creates a copy of the ChannelInfo
732 pub extern "C" fn ChannelInfo_clone(orig: &ChannelInfo) -> ChannelInfo {
736 /// Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read
737 pub extern "C" fn ChannelInfo_write(obj: &ChannelInfo) -> crate::c_types::derived::CVec_u8Z {
738 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
741 pub(crate) extern "C" fn ChannelInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
742 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelInfo) })
745 /// Read a ChannelInfo from a byte array, created by ChannelInfo_write
746 pub extern "C" fn ChannelInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelInfoDecodeErrorZ {
747 let res = crate::c_types::deserialize_obj(ser);
748 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::network_graph::ChannelInfo { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
752 use lightning::routing::network_graph::RoutingFees as nativeRoutingFeesImport;
753 type nativeRoutingFees = nativeRoutingFeesImport;
755 /// Fees for routing via a given channel or a node
758 pub struct RoutingFees {
759 /// A pointer to the opaque Rust object.
761 /// Nearly everywhere, inner must be non-null, however in places where
762 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
763 pub inner: *mut nativeRoutingFees,
764 /// Indicates that this is the only struct which contains the same pointer.
766 /// Rust functions which take ownership of an object provided via an argument require
767 /// this to be true and invalidate the object pointed to by inner.
771 impl Drop for RoutingFees {
773 if self.is_owned && !<*mut nativeRoutingFees>::is_null(self.inner) {
774 let _ = unsafe { Box::from_raw(self.inner) };
778 /// Frees any resources used by the RoutingFees, if is_owned is set and inner is non-NULL.
780 pub extern "C" fn RoutingFees_free(this_obj: RoutingFees) { }
782 /// Used only if an object of this type is returned as a trait impl by a method
783 extern "C" fn RoutingFees_free_void(this_ptr: *mut c_void) {
784 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRoutingFees); }
787 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
789 pub(crate) fn take_inner(mut self) -> *mut nativeRoutingFees {
790 assert!(self.is_owned);
791 let ret = self.inner;
792 self.inner = std::ptr::null_mut();
796 /// Flat routing fee in satoshis
798 pub extern "C" fn RoutingFees_get_base_msat(this_ptr: &RoutingFees) -> u32 {
799 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.base_msat;
802 /// Flat routing fee in satoshis
804 pub extern "C" fn RoutingFees_set_base_msat(this_ptr: &mut RoutingFees, mut val: u32) {
805 unsafe { &mut *this_ptr.inner }.base_msat = val;
807 /// Liquidity-based routing fee in millionths of a routed amount.
808 /// In other words, 10000 is 1%.
810 pub extern "C" fn RoutingFees_get_proportional_millionths(this_ptr: &RoutingFees) -> u32 {
811 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.proportional_millionths;
814 /// Liquidity-based routing fee in millionths of a routed amount.
815 /// In other words, 10000 is 1%.
817 pub extern "C" fn RoutingFees_set_proportional_millionths(this_ptr: &mut RoutingFees, mut val: u32) {
818 unsafe { &mut *this_ptr.inner }.proportional_millionths = val;
820 /// Constructs a new RoutingFees given each field
823 pub extern "C" fn RoutingFees_new(mut base_msat_arg: u32, mut proportional_millionths_arg: u32) -> RoutingFees {
824 RoutingFees { inner: Box::into_raw(Box::new(nativeRoutingFees {
825 base_msat: base_msat_arg,
826 proportional_millionths: proportional_millionths_arg,
827 })), is_owned: true }
829 /// Checks if two RoutingFeess contain equal inner contents.
830 /// This ignores pointers and is_owned flags and looks at the values in fields.
831 /// Two objects with NULL inner values will be considered "equal" here.
833 pub extern "C" fn RoutingFees_eq(a: &RoutingFees, b: &RoutingFees) -> bool {
834 if a.inner == b.inner { return true; }
835 if a.inner.is_null() || b.inner.is_null() { return false; }
836 if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
838 impl Clone for RoutingFees {
839 fn clone(&self) -> Self {
841 inner: if <*mut nativeRoutingFees>::is_null(self.inner) { std::ptr::null_mut() } else {
842 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
848 /// Used only if an object of this type is returned as a trait impl by a method
849 pub(crate) extern "C" fn RoutingFees_clone_void(this_ptr: *const c_void) -> *mut c_void {
850 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRoutingFees)).clone() })) as *mut c_void
853 /// Creates a copy of the RoutingFees
854 pub extern "C" fn RoutingFees_clone(orig: &RoutingFees) -> RoutingFees {
858 /// Serialize the RoutingFees object into a byte array which can be read by RoutingFees_read
859 pub extern "C" fn RoutingFees_write(obj: &RoutingFees) -> crate::c_types::derived::CVec_u8Z {
860 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
863 pub(crate) extern "C" fn RoutingFees_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
864 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRoutingFees) })
867 /// Read a RoutingFees from a byte array, created by RoutingFees_write
868 pub extern "C" fn RoutingFees_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RoutingFeesDecodeErrorZ {
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::lightning::routing::network_graph::RoutingFees { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
874 use lightning::routing::network_graph::NodeAnnouncementInfo as nativeNodeAnnouncementInfoImport;
875 type nativeNodeAnnouncementInfo = nativeNodeAnnouncementInfoImport;
877 /// Information received in the latest node_announcement from this node.
880 pub struct NodeAnnouncementInfo {
881 /// A pointer to the opaque Rust object.
883 /// Nearly everywhere, inner must be non-null, however in places where
884 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
885 pub inner: *mut nativeNodeAnnouncementInfo,
886 /// Indicates that this is the only struct which contains the same pointer.
888 /// Rust functions which take ownership of an object provided via an argument require
889 /// this to be true and invalidate the object pointed to by inner.
893 impl Drop for NodeAnnouncementInfo {
895 if self.is_owned && !<*mut nativeNodeAnnouncementInfo>::is_null(self.inner) {
896 let _ = unsafe { Box::from_raw(self.inner) };
900 /// Frees any resources used by the NodeAnnouncementInfo, if is_owned is set and inner is non-NULL.
902 pub extern "C" fn NodeAnnouncementInfo_free(this_obj: NodeAnnouncementInfo) { }
904 /// Used only if an object of this type is returned as a trait impl by a method
905 extern "C" fn NodeAnnouncementInfo_free_void(this_ptr: *mut c_void) {
906 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAnnouncementInfo); }
909 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
910 impl NodeAnnouncementInfo {
911 pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncementInfo {
912 assert!(self.is_owned);
913 let ret = self.inner;
914 self.inner = std::ptr::null_mut();
918 /// Protocol features the node announced support for
920 pub extern "C" fn NodeAnnouncementInfo_get_features(this_ptr: &NodeAnnouncementInfo) -> crate::lightning::ln::features::NodeFeatures {
921 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features;
922 crate::lightning::ln::features::NodeFeatures { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
924 /// Protocol features the node announced support for
926 pub extern "C" fn NodeAnnouncementInfo_set_features(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::lightning::ln::features::NodeFeatures) {
927 unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) };
929 /// When the last known update to the node state was issued.
930 /// Value is opaque, as set in the announcement.
932 pub extern "C" fn NodeAnnouncementInfo_get_last_update(this_ptr: &NodeAnnouncementInfo) -> u32 {
933 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.last_update;
936 /// When the last known update to the node state was issued.
937 /// Value is opaque, as set in the announcement.
939 pub extern "C" fn NodeAnnouncementInfo_set_last_update(this_ptr: &mut NodeAnnouncementInfo, mut val: u32) {
940 unsafe { &mut *this_ptr.inner }.last_update = val;
942 /// Color assigned to the node
944 pub extern "C" fn NodeAnnouncementInfo_get_rgb(this_ptr: &NodeAnnouncementInfo) -> *const [u8; 3] {
945 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.rgb;
948 /// Color assigned to the node
950 pub extern "C" fn NodeAnnouncementInfo_set_rgb(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::c_types::ThreeBytes) {
951 unsafe { &mut *this_ptr.inner }.rgb = val.data;
953 /// Moniker assigned to the node.
954 /// May be invalid or malicious (eg control chars),
955 /// should not be exposed to the user.
957 pub extern "C" fn NodeAnnouncementInfo_get_alias(this_ptr: &NodeAnnouncementInfo) -> *const [u8; 32] {
958 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.alias;
961 /// Moniker assigned to the node.
962 /// May be invalid or malicious (eg control chars),
963 /// should not be exposed to the user.
965 pub extern "C" fn NodeAnnouncementInfo_set_alias(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::c_types::ThirtyTwoBytes) {
966 unsafe { &mut *this_ptr.inner }.alias = val.data;
968 /// Internet-level addresses via which one can connect to the node
970 pub extern "C" fn NodeAnnouncementInfo_set_addresses(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::c_types::derived::CVec_NetAddressZ) {
971 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
972 unsafe { &mut *this_ptr.inner }.addresses = local_val;
974 /// An initial announcement of the node
975 /// Mostly redundant with the data we store in fields explicitly.
976 /// Everything else is useful only for sending out for initial routing sync.
977 /// Not stored if contains excess data to prevent DoS.
979 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
981 pub extern "C" fn NodeAnnouncementInfo_get_announcement_message(this_ptr: &NodeAnnouncementInfo) -> crate::lightning::ln::msgs::NodeAnnouncement {
982 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.announcement_message;
983 let mut local_inner_val = crate::lightning::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 };
986 /// An initial announcement of the node
987 /// Mostly redundant with the data we store in fields explicitly.
988 /// Everything else is useful only for sending out for initial routing sync.
989 /// Not stored if contains excess data to prevent DoS.
991 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
993 pub extern "C" fn NodeAnnouncementInfo_set_announcement_message(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::lightning::ln::msgs::NodeAnnouncement) {
994 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
995 unsafe { &mut *this_ptr.inner }.announcement_message = local_val;
997 /// Constructs a new NodeAnnouncementInfo given each field
1000 pub extern "C" fn NodeAnnouncementInfo_new(mut features_arg: crate::lightning::ln::features::NodeFeatures, mut last_update_arg: u32, mut rgb_arg: crate::c_types::ThreeBytes, mut alias_arg: crate::c_types::ThirtyTwoBytes, mut addresses_arg: crate::c_types::derived::CVec_NetAddressZ, mut announcement_message_arg: crate::lightning::ln::msgs::NodeAnnouncement) -> NodeAnnouncementInfo {
1001 let mut local_addresses_arg = Vec::new(); for mut item in addresses_arg.into_rust().drain(..) { local_addresses_arg.push( { item.into_native() }); };
1002 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()) } }) };
1003 NodeAnnouncementInfo { inner: Box::into_raw(Box::new(nativeNodeAnnouncementInfo {
1004 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
1005 last_update: last_update_arg,
1007 alias: alias_arg.data,
1008 addresses: local_addresses_arg,
1009 announcement_message: local_announcement_message_arg,
1010 })), is_owned: true }
1012 impl Clone for NodeAnnouncementInfo {
1013 fn clone(&self) -> Self {
1015 inner: if <*mut nativeNodeAnnouncementInfo>::is_null(self.inner) { std::ptr::null_mut() } else {
1016 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1022 /// Used only if an object of this type is returned as a trait impl by a method
1023 pub(crate) extern "C" fn NodeAnnouncementInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
1024 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncementInfo)).clone() })) as *mut c_void
1027 /// Creates a copy of the NodeAnnouncementInfo
1028 pub extern "C" fn NodeAnnouncementInfo_clone(orig: &NodeAnnouncementInfo) -> NodeAnnouncementInfo {
1032 /// Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read
1033 pub extern "C" fn NodeAnnouncementInfo_write(obj: &NodeAnnouncementInfo) -> crate::c_types::derived::CVec_u8Z {
1034 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
1037 pub(crate) extern "C" fn NodeAnnouncementInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1038 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncementInfo) })
1041 /// Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write
1042 pub extern "C" fn NodeAnnouncementInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementInfoDecodeErrorZ {
1043 let res = crate::c_types::deserialize_obj(ser);
1044 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::network_graph::NodeAnnouncementInfo { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
1048 use lightning::routing::network_graph::NodeInfo as nativeNodeInfoImport;
1049 type nativeNodeInfo = nativeNodeInfoImport;
1051 /// Details about a node in the network, known from the network announcement.
1054 pub struct NodeInfo {
1055 /// A pointer to the opaque Rust object.
1057 /// Nearly everywhere, inner must be non-null, however in places where
1058 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1059 pub inner: *mut nativeNodeInfo,
1060 /// Indicates that this is the only struct which contains the same pointer.
1062 /// Rust functions which take ownership of an object provided via an argument require
1063 /// this to be true and invalidate the object pointed to by inner.
1067 impl Drop for NodeInfo {
1068 fn drop(&mut self) {
1069 if self.is_owned && !<*mut nativeNodeInfo>::is_null(self.inner) {
1070 let _ = unsafe { Box::from_raw(self.inner) };
1074 /// Frees any resources used by the NodeInfo, if is_owned is set and inner is non-NULL.
1076 pub extern "C" fn NodeInfo_free(this_obj: NodeInfo) { }
1078 /// Used only if an object of this type is returned as a trait impl by a method
1079 extern "C" fn NodeInfo_free_void(this_ptr: *mut c_void) {
1080 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeInfo); }
1083 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1085 pub(crate) fn take_inner(mut self) -> *mut nativeNodeInfo {
1086 assert!(self.is_owned);
1087 let ret = self.inner;
1088 self.inner = std::ptr::null_mut();
1092 /// All valid channels a node has announced
1094 pub extern "C" fn NodeInfo_set_channels(this_ptr: &mut NodeInfo, mut val: crate::c_types::derived::CVec_u64Z) {
1095 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
1096 unsafe { &mut *this_ptr.inner }.channels = local_val;
1098 /// Lowest fees enabling routing via any of the enabled, known channels to a node.
1099 /// The two fields (flat and proportional fee) are independent,
1100 /// meaning they don't have to refer to the same channel.
1102 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1104 pub extern "C" fn NodeInfo_get_lowest_inbound_channel_fees(this_ptr: &NodeInfo) -> crate::lightning::routing::network_graph::RoutingFees {
1105 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.lowest_inbound_channel_fees;
1106 let mut local_inner_val = crate::lightning::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 };
1109 /// Lowest fees enabling routing via any of the enabled, known channels to a node.
1110 /// The two fields (flat and proportional fee) are independent,
1111 /// meaning they don't have to refer to the same channel.
1113 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1115 pub extern "C" fn NodeInfo_set_lowest_inbound_channel_fees(this_ptr: &mut NodeInfo, mut val: crate::lightning::routing::network_graph::RoutingFees) {
1116 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1117 unsafe { &mut *this_ptr.inner }.lowest_inbound_channel_fees = local_val;
1119 /// More information about a node from node_announcement.
1120 /// Optional because we store a Node entry after learning about it from
1121 /// a channel announcement, but before receiving a node announcement.
1123 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1125 pub extern "C" fn NodeInfo_get_announcement_info(this_ptr: &NodeInfo) -> crate::lightning::routing::network_graph::NodeAnnouncementInfo {
1126 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.announcement_info;
1127 let mut local_inner_val = crate::lightning::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 };
1130 /// More information about a node from node_announcement.
1131 /// Optional because we store a Node entry after learning about it from
1132 /// a channel announcement, but before receiving a node announcement.
1134 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1136 pub extern "C" fn NodeInfo_set_announcement_info(this_ptr: &mut NodeInfo, mut val: crate::lightning::routing::network_graph::NodeAnnouncementInfo) {
1137 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1138 unsafe { &mut *this_ptr.inner }.announcement_info = local_val;
1140 /// Constructs a new NodeInfo given each field
1143 pub extern "C" fn NodeInfo_new(mut channels_arg: crate::c_types::derived::CVec_u64Z, mut lowest_inbound_channel_fees_arg: crate::lightning::routing::network_graph::RoutingFees, mut announcement_info_arg: crate::lightning::routing::network_graph::NodeAnnouncementInfo) -> NodeInfo {
1144 let mut local_channels_arg = Vec::new(); for mut item in channels_arg.into_rust().drain(..) { local_channels_arg.push( { item }); };
1145 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()) } }) };
1146 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()) } }) };
1147 NodeInfo { inner: Box::into_raw(Box::new(nativeNodeInfo {
1148 channels: local_channels_arg,
1149 lowest_inbound_channel_fees: local_lowest_inbound_channel_fees_arg,
1150 announcement_info: local_announcement_info_arg,
1151 })), is_owned: true }
1153 impl Clone for NodeInfo {
1154 fn clone(&self) -> Self {
1156 inner: if <*mut nativeNodeInfo>::is_null(self.inner) { std::ptr::null_mut() } else {
1157 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1163 /// Used only if an object of this type is returned as a trait impl by a method
1164 pub(crate) extern "C" fn NodeInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
1165 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeInfo)).clone() })) as *mut c_void
1168 /// Creates a copy of the NodeInfo
1169 pub extern "C" fn NodeInfo_clone(orig: &NodeInfo) -> NodeInfo {
1173 /// Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read
1174 pub extern "C" fn NodeInfo_write(obj: &NodeInfo) -> crate::c_types::derived::CVec_u8Z {
1175 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
1178 pub(crate) extern "C" fn NodeInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1179 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeInfo) })
1182 /// Read a NodeInfo from a byte array, created by NodeInfo_write
1183 pub extern "C" fn NodeInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeInfoDecodeErrorZ {
1184 let res = crate::c_types::deserialize_obj(ser);
1185 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::network_graph::NodeInfo { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
1189 /// Serialize the NetworkGraph object into a byte array which can be read by NetworkGraph_read
1190 pub extern "C" fn NetworkGraph_write(obj: &NetworkGraph) -> crate::c_types::derived::CVec_u8Z {
1191 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
1194 pub(crate) extern "C" fn NetworkGraph_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1195 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNetworkGraph) })
1198 /// Read a NetworkGraph from a byte array, created by NetworkGraph_write
1199 pub extern "C" fn NetworkGraph_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NetworkGraphDecodeErrorZ {
1200 let res = crate::c_types::deserialize_obj(ser);
1201 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::network_graph::NetworkGraph { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
1204 /// Creates a new, empty, network graph.
1207 pub extern "C" fn NetworkGraph_new(mut genesis_hash: crate::c_types::ThirtyTwoBytes) -> crate::lightning::routing::network_graph::NetworkGraph {
1208 let mut ret = lightning::routing::network_graph::NetworkGraph::new(::bitcoin::hash_types::BlockHash::from_slice(&genesis_hash.data[..]).unwrap());
1209 crate::lightning::routing::network_graph::NetworkGraph { inner: Box::into_raw(Box::new(ret)), is_owned: true }
1212 /// For an already known node (from channel announcements), update its stored properties from a
1213 /// given node announcement.
1215 /// You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's
1216 /// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
1217 /// routing messages from a source using a protocol other than the lightning P2P protocol.
1220 pub extern "C" fn NetworkGraph_update_node_from_announcement(this_arg: &mut NetworkGraph, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
1221 let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_node_from_announcement(unsafe { &*msg.inner }, secp256k1::SECP256K1);
1222 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
1226 /// For an already known node (from channel announcements), update its stored properties from a
1227 /// given node announcement without verifying the associated signatures. Because we aren't
1228 /// given the associated signatures here we cannot relay the node announcement to any of our
1232 pub extern "C" fn NetworkGraph_update_node_from_unsigned_announcement(this_arg: &mut NetworkGraph, msg: &crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
1233 let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_node_from_unsigned_announcement(unsafe { &*msg.inner });
1234 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
1238 /// Store or update channel info from a channel announcement.
1240 /// You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's
1241 /// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
1242 /// routing messages from a source using a protocol other than the lightning P2P protocol.
1244 /// If a `chain::Access` object is provided via `chain_access`, it will be called to verify
1245 /// the corresponding UTXO exists on chain and is correctly-formatted.
1247 /// Note that chain_access (or a relevant inner pointer) may be NULL or all-0s to represent None
1250 pub extern "C" fn NetworkGraph_update_channel_from_announcement(this_arg: &mut NetworkGraph, msg: &crate::lightning::ln::msgs::ChannelAnnouncement, chain_access: *mut crate::lightning::chain::Access) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
1251 let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) };
1252 let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_channel_from_announcement(unsafe { &*msg.inner }, &local_chain_access, secp256k1::SECP256K1);
1253 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
1257 /// Store or update channel info from a channel announcement without verifying the associated
1258 /// signatures. Because we aren't given the associated signatures here we cannot relay the
1259 /// channel announcement to any of our peers.
1261 /// If a `chain::Access` object is provided via `chain_access`, it will be called to verify
1262 /// the corresponding UTXO exists on chain and is correctly-formatted.
1264 /// Note that chain_access (or a relevant inner pointer) may be NULL or all-0s to represent None
1267 pub extern "C" fn NetworkGraph_update_channel_from_unsigned_announcement(this_arg: &mut NetworkGraph, msg: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement, chain_access: *mut crate::lightning::chain::Access) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
1268 let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) };
1269 let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_channel_from_unsigned_announcement(unsafe { &*msg.inner }, &local_chain_access);
1270 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
1274 /// Close a channel if a corresponding HTLC fail was sent.
1275 /// If permanent, removes a channel from the local storage.
1276 /// May cause the removal of nodes too, if this was their last channel.
1277 /// If not permanent, makes channels unavailable for routing.
1279 pub extern "C" fn NetworkGraph_close_channel_from_update(this_arg: &mut NetworkGraph, mut short_channel_id: u64, mut is_permanent: bool) {
1280 unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.close_channel_from_update(short_channel_id, is_permanent)
1283 /// For an already known (from announcement) channel, update info about one of the directions
1286 /// You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's
1287 /// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
1288 /// routing messages from a source using a protocol other than the lightning P2P protocol.
1291 pub extern "C" fn NetworkGraph_update_channel(this_arg: &mut NetworkGraph, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
1292 let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_channel(unsafe { &*msg.inner }, secp256k1::SECP256K1);
1293 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
1297 /// For an already known (from announcement) channel, update info about one of the directions
1298 /// of the channel without verifying the associated signatures. Because we aren't given the
1299 /// associated signatures here we cannot relay the channel update to any of our peers.
1302 pub extern "C" fn NetworkGraph_update_channel_unsigned(this_arg: &mut NetworkGraph, msg: &crate::lightning::ln::msgs::UnsignedChannelUpdate) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
1303 let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_channel_unsigned(unsafe { &*msg.inner });
1304 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };