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.
183 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 {
184 let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) };
185 let mut ret = lightning::routing::network_graph::NetGraphMsgHandler::new(::bitcoin::hash_types::BlockHash::from_slice(&genesis_hash.data[..]).unwrap(), local_chain_access, logger);
186 NetGraphMsgHandler { inner: Box::into_raw(Box::new(ret)), is_owned: true }
189 /// Creates a new tracker of the actual state of the network of channels and nodes,
190 /// assuming an existing Network Graph.
193 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 {
194 let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) };
195 let mut ret = lightning::routing::network_graph::NetGraphMsgHandler::from_net_graph(local_chain_access, logger, *unsafe { Box::from_raw(network_graph.take_inner()) });
196 NetGraphMsgHandler { inner: Box::into_raw(Box::new(ret)), is_owned: true }
199 /// Adds a provider used to check new announcements. Does not affect
200 /// existing announcements unless they are updated.
201 /// Add, update or remove the provider would replace the current one.
203 pub extern "C" fn NetGraphMsgHandler_add_chain_access(this_arg: &mut NetGraphMsgHandler, chain_access: *mut crate::lightning::chain::Access) {
204 let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) };
205 unsafe { &mut (*(this_arg.inner as *mut nativeNetGraphMsgHandler)) }.add_chain_access(local_chain_access)
208 /// Take a read lock on the network_graph and return it in the C-bindings
209 /// newtype helper. This is likely only useful when called via the C
210 /// bindings as you can call `self.network_graph.read().unwrap()` in Rust
214 pub extern "C" fn NetGraphMsgHandler_read_locked_graph(this_arg: &NetGraphMsgHandler) -> crate::lightning::routing::network_graph::LockedNetworkGraph {
215 let mut ret = unsafe { &*this_arg.inner }.read_locked_graph();
216 crate::lightning::routing::network_graph::LockedNetworkGraph { inner: Box::into_raw(Box::new(ret)), is_owned: true }
219 /// Get a reference to the NetworkGraph which this read-lock contains.
222 pub extern "C" fn LockedNetworkGraph_graph(this_arg: &LockedNetworkGraph) -> crate::lightning::routing::network_graph::NetworkGraph {
223 let mut ret = unsafe { &*this_arg.inner }.graph();
224 crate::lightning::routing::network_graph::NetworkGraph { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false }
227 impl From<nativeNetGraphMsgHandler> for crate::lightning::ln::msgs::RoutingMessageHandler {
228 fn from(obj: nativeNetGraphMsgHandler) -> Self {
229 let mut rust_obj = NetGraphMsgHandler { inner: Box::into_raw(Box::new(obj)), is_owned: true };
230 let mut ret = NetGraphMsgHandler_as_RoutingMessageHandler(&rust_obj);
231 // 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
232 rust_obj.inner = std::ptr::null_mut();
233 ret.free = Some(NetGraphMsgHandler_free_void);
237 /// Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg.
238 /// This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is
240 pub extern "C" fn NetGraphMsgHandler_as_RoutingMessageHandler(this_arg: &NetGraphMsgHandler) -> crate::lightning::ln::msgs::RoutingMessageHandler {
241 crate::lightning::ln::msgs::RoutingMessageHandler {
242 this_arg: unsafe { (*this_arg).inner as *mut c_void },
244 handle_node_announcement: NetGraphMsgHandler_RoutingMessageHandler_handle_node_announcement,
245 handle_channel_announcement: NetGraphMsgHandler_RoutingMessageHandler_handle_channel_announcement,
246 handle_channel_update: NetGraphMsgHandler_RoutingMessageHandler_handle_channel_update,
247 handle_htlc_fail_channel_update: NetGraphMsgHandler_RoutingMessageHandler_handle_htlc_fail_channel_update,
248 get_next_channel_announcements: NetGraphMsgHandler_RoutingMessageHandler_get_next_channel_announcements,
249 get_next_node_announcements: NetGraphMsgHandler_RoutingMessageHandler_get_next_node_announcements,
250 sync_routing_table: NetGraphMsgHandler_RoutingMessageHandler_sync_routing_table,
251 handle_reply_channel_range: NetGraphMsgHandler_RoutingMessageHandler_handle_reply_channel_range,
252 handle_reply_short_channel_ids_end: NetGraphMsgHandler_RoutingMessageHandler_handle_reply_short_channel_ids_end,
253 handle_query_channel_range: NetGraphMsgHandler_RoutingMessageHandler_handle_query_channel_range,
254 handle_query_short_channel_ids: NetGraphMsgHandler_RoutingMessageHandler_handle_query_short_channel_ids,
255 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider {
256 this_arg: unsafe { (*this_arg).inner as *mut c_void },
258 get_and_clear_pending_msg_events: NetGraphMsgHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events,
264 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 {
265 let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_node_announcement(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, unsafe { &*msg.inner });
266 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() };
270 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 {
271 let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_channel_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() };
275 extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_htlc_fail_channel_update(this_arg: *const c_void, update: &crate::lightning::ln::msgs::HTLCFailChannelUpdate) {
276 <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_htlc_fail_channel_update(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, &update.to_native())
279 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 {
280 let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, unsafe { &*msg.inner });
281 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() };
285 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 {
286 let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::get_next_channel_announcements(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, starting_point, batch_amount);
287 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 }); };
291 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 {
292 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();
293 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);
294 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 } }); };
297 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) {
298 <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 })
301 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 {
302 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()) });
303 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() };
307 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 {
308 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()) });
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_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 {
314 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()) });
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_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 {
320 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()) });
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 impl From<nativeNetGraphMsgHandler> for crate::lightning::util::events::MessageSendEventsProvider {
326 fn from(obj: nativeNetGraphMsgHandler) -> Self {
327 let mut rust_obj = NetGraphMsgHandler { inner: Box::into_raw(Box::new(obj)), is_owned: true };
328 let mut ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&rust_obj);
329 // 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
330 rust_obj.inner = std::ptr::null_mut();
331 ret.free = Some(NetGraphMsgHandler_free_void);
335 /// Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg.
336 /// This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is
338 pub extern "C" fn NetGraphMsgHandler_as_MessageSendEventsProvider(this_arg: &NetGraphMsgHandler) -> crate::lightning::util::events::MessageSendEventsProvider {
339 crate::lightning::util::events::MessageSendEventsProvider {
340 this_arg: unsafe { (*this_arg).inner as *mut c_void },
342 get_and_clear_pending_msg_events: NetGraphMsgHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events,
347 extern "C" fn NetGraphMsgHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ {
348 let mut ret = <nativeNetGraphMsgHandler as lightning::util::events::MessageSendEventsProvider<>>::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, );
349 let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::util::events::MessageSendEvent::native_into(item) }); };
354 use lightning::routing::network_graph::DirectionalChannelInfo as nativeDirectionalChannelInfoImport;
355 type nativeDirectionalChannelInfo = nativeDirectionalChannelInfoImport;
357 /// Details about one direction of a channel. Received
358 /// within a channel update.
361 pub struct DirectionalChannelInfo {
362 /// A pointer to the opaque Rust object.
364 /// Nearly everywhere, inner must be non-null, however in places where
365 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
366 pub inner: *mut nativeDirectionalChannelInfo,
367 /// Indicates that this is the only struct which contains the same pointer.
369 /// Rust functions which take ownership of an object provided via an argument require
370 /// this to be true and invalidate the object pointed to by inner.
374 impl Drop for DirectionalChannelInfo {
376 if self.is_owned && !<*mut nativeDirectionalChannelInfo>::is_null(self.inner) {
377 let _ = unsafe { Box::from_raw(self.inner) };
381 /// Frees any resources used by the DirectionalChannelInfo, if is_owned is set and inner is non-NULL.
383 pub extern "C" fn DirectionalChannelInfo_free(this_obj: DirectionalChannelInfo) { }
385 /// Used only if an object of this type is returned as a trait impl by a method
386 extern "C" fn DirectionalChannelInfo_free_void(this_ptr: *mut c_void) {
387 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDirectionalChannelInfo); }
390 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
391 impl DirectionalChannelInfo {
392 pub(crate) fn take_inner(mut self) -> *mut nativeDirectionalChannelInfo {
393 assert!(self.is_owned);
394 let ret = self.inner;
395 self.inner = std::ptr::null_mut();
399 /// When the last update to the channel direction was issued.
400 /// Value is opaque, as set in the announcement.
402 pub extern "C" fn DirectionalChannelInfo_get_last_update(this_ptr: &DirectionalChannelInfo) -> u32 {
403 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.last_update;
406 /// When the last update to the channel direction was issued.
407 /// Value is opaque, as set in the announcement.
409 pub extern "C" fn DirectionalChannelInfo_set_last_update(this_ptr: &mut DirectionalChannelInfo, mut val: u32) {
410 unsafe { &mut *this_ptr.inner }.last_update = val;
412 /// Whether the channel can be currently used for payments (in this one direction).
414 pub extern "C" fn DirectionalChannelInfo_get_enabled(this_ptr: &DirectionalChannelInfo) -> bool {
415 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.enabled;
418 /// Whether the channel can be currently used for payments (in this one direction).
420 pub extern "C" fn DirectionalChannelInfo_set_enabled(this_ptr: &mut DirectionalChannelInfo, mut val: bool) {
421 unsafe { &mut *this_ptr.inner }.enabled = val;
423 /// The difference in CLTV values that you must have when routing through this channel.
425 pub extern "C" fn DirectionalChannelInfo_get_cltv_expiry_delta(this_ptr: &DirectionalChannelInfo) -> u16 {
426 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry_delta;
429 /// The difference in CLTV values that you must have when routing through this channel.
431 pub extern "C" fn DirectionalChannelInfo_set_cltv_expiry_delta(this_ptr: &mut DirectionalChannelInfo, mut val: u16) {
432 unsafe { &mut *this_ptr.inner }.cltv_expiry_delta = val;
434 /// The minimum value, which must be relayed to the next hop via the channel
436 pub extern "C" fn DirectionalChannelInfo_get_htlc_minimum_msat(this_ptr: &DirectionalChannelInfo) -> u64 {
437 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat;
440 /// The minimum value, which must be relayed to the next hop via the channel
442 pub extern "C" fn DirectionalChannelInfo_set_htlc_minimum_msat(this_ptr: &mut DirectionalChannelInfo, mut val: u64) {
443 unsafe { &mut *this_ptr.inner }.htlc_minimum_msat = val;
445 /// The maximum value which may be relayed to the next hop via the channel.
447 pub extern "C" fn DirectionalChannelInfo_get_htlc_maximum_msat(this_ptr: &DirectionalChannelInfo) -> crate::c_types::derived::COption_u64Z {
448 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_maximum_msat;
449 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()) } };
452 /// The maximum value which may be relayed to the next hop via the channel.
454 pub extern "C" fn DirectionalChannelInfo_set_htlc_maximum_msat(this_ptr: &mut DirectionalChannelInfo, mut val: crate::c_types::derived::COption_u64Z) {
455 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
456 unsafe { &mut *this_ptr.inner }.htlc_maximum_msat = local_val;
458 /// Fees charged when the channel is used for routing
460 pub extern "C" fn DirectionalChannelInfo_get_fees(this_ptr: &DirectionalChannelInfo) -> crate::lightning::routing::network_graph::RoutingFees {
461 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fees;
462 crate::lightning::routing::network_graph::RoutingFees { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
464 /// Fees charged when the channel is used for routing
466 pub extern "C" fn DirectionalChannelInfo_set_fees(this_ptr: &mut DirectionalChannelInfo, mut val: crate::lightning::routing::network_graph::RoutingFees) {
467 unsafe { &mut *this_ptr.inner }.fees = *unsafe { Box::from_raw(val.take_inner()) };
469 /// Most recent update for the channel received from the network
470 /// Mostly redundant with the data we store in fields explicitly.
471 /// Everything else is useful only for sending out for initial routing sync.
472 /// Not stored if contains excess data to prevent DoS.
474 pub extern "C" fn DirectionalChannelInfo_get_last_update_message(this_ptr: &DirectionalChannelInfo) -> crate::lightning::ln::msgs::ChannelUpdate {
475 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.last_update_message;
476 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 };
479 /// Most recent update for the channel received from the network
480 /// Mostly redundant with the data we store in fields explicitly.
481 /// Everything else is useful only for sending out for initial routing sync.
482 /// Not stored if contains excess data to prevent DoS.
484 pub extern "C" fn DirectionalChannelInfo_set_last_update_message(this_ptr: &mut DirectionalChannelInfo, mut val: crate::lightning::ln::msgs::ChannelUpdate) {
485 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
486 unsafe { &mut *this_ptr.inner }.last_update_message = local_val;
488 /// Constructs a new DirectionalChannelInfo given each field
491 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 {
492 let mut local_htlc_maximum_msat_arg = if htlc_maximum_msat_arg.is_some() { Some( { htlc_maximum_msat_arg.take() }) } else { None };
493 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()) } }) };
494 DirectionalChannelInfo { inner: Box::into_raw(Box::new(nativeDirectionalChannelInfo {
495 last_update: last_update_arg,
496 enabled: enabled_arg,
497 cltv_expiry_delta: cltv_expiry_delta_arg,
498 htlc_minimum_msat: htlc_minimum_msat_arg,
499 htlc_maximum_msat: local_htlc_maximum_msat_arg,
500 fees: *unsafe { Box::from_raw(fees_arg.take_inner()) },
501 last_update_message: local_last_update_message_arg,
502 })), is_owned: true }
504 impl Clone for DirectionalChannelInfo {
505 fn clone(&self) -> Self {
507 inner: if <*mut nativeDirectionalChannelInfo>::is_null(self.inner) { std::ptr::null_mut() } else {
508 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
514 /// Used only if an object of this type is returned as a trait impl by a method
515 pub(crate) extern "C" fn DirectionalChannelInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
516 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDirectionalChannelInfo)).clone() })) as *mut c_void
519 /// Creates a copy of the DirectionalChannelInfo
520 pub extern "C" fn DirectionalChannelInfo_clone(orig: &DirectionalChannelInfo) -> DirectionalChannelInfo {
524 /// Serialize the DirectionalChannelInfo object into a byte array which can be read by DirectionalChannelInfo_read
525 pub extern "C" fn DirectionalChannelInfo_write(obj: &DirectionalChannelInfo) -> crate::c_types::derived::CVec_u8Z {
526 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
529 pub(crate) extern "C" fn DirectionalChannelInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
530 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeDirectionalChannelInfo) })
533 /// Read a DirectionalChannelInfo from a byte array, created by DirectionalChannelInfo_write
534 pub extern "C" fn DirectionalChannelInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_DirectionalChannelInfoDecodeErrorZ {
535 let res = crate::c_types::deserialize_obj(ser);
536 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() };
540 use lightning::routing::network_graph::ChannelInfo as nativeChannelInfoImport;
541 type nativeChannelInfo = nativeChannelInfoImport;
543 /// Details about a channel (both directions).
544 /// Received within a channel announcement.
547 pub struct ChannelInfo {
548 /// A pointer to the opaque Rust object.
550 /// Nearly everywhere, inner must be non-null, however in places where
551 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
552 pub inner: *mut nativeChannelInfo,
553 /// Indicates that this is the only struct which contains the same pointer.
555 /// Rust functions which take ownership of an object provided via an argument require
556 /// this to be true and invalidate the object pointed to by inner.
560 impl Drop for ChannelInfo {
562 if self.is_owned && !<*mut nativeChannelInfo>::is_null(self.inner) {
563 let _ = unsafe { Box::from_raw(self.inner) };
567 /// Frees any resources used by the ChannelInfo, if is_owned is set and inner is non-NULL.
569 pub extern "C" fn ChannelInfo_free(this_obj: ChannelInfo) { }
571 /// Used only if an object of this type is returned as a trait impl by a method
572 extern "C" fn ChannelInfo_free_void(this_ptr: *mut c_void) {
573 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelInfo); }
576 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
578 pub(crate) fn take_inner(mut self) -> *mut nativeChannelInfo {
579 assert!(self.is_owned);
580 let ret = self.inner;
581 self.inner = std::ptr::null_mut();
585 /// Protocol features of a channel communicated during its announcement
587 pub extern "C" fn ChannelInfo_get_features(this_ptr: &ChannelInfo) -> crate::lightning::ln::features::ChannelFeatures {
588 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features;
589 crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
591 /// Protocol features of a channel communicated during its announcement
593 pub extern "C" fn ChannelInfo_set_features(this_ptr: &mut ChannelInfo, mut val: crate::lightning::ln::features::ChannelFeatures) {
594 unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) };
596 /// Source node of the first direction of a channel
598 pub extern "C" fn ChannelInfo_get_node_one(this_ptr: &ChannelInfo) -> crate::c_types::PublicKey {
599 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_one;
600 crate::c_types::PublicKey::from_rust(&inner_val)
602 /// Source node of the first direction of a channel
604 pub extern "C" fn ChannelInfo_set_node_one(this_ptr: &mut ChannelInfo, mut val: crate::c_types::PublicKey) {
605 unsafe { &mut *this_ptr.inner }.node_one = val.into_rust();
607 /// Details about the first direction of a channel
609 pub extern "C" fn ChannelInfo_get_one_to_two(this_ptr: &ChannelInfo) -> crate::lightning::routing::network_graph::DirectionalChannelInfo {
610 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.one_to_two;
611 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 };
614 /// Details about the first direction of a channel
616 pub extern "C" fn ChannelInfo_set_one_to_two(this_ptr: &mut ChannelInfo, mut val: crate::lightning::routing::network_graph::DirectionalChannelInfo) {
617 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
618 unsafe { &mut *this_ptr.inner }.one_to_two = local_val;
620 /// Source node of the second direction of a channel
622 pub extern "C" fn ChannelInfo_get_node_two(this_ptr: &ChannelInfo) -> crate::c_types::PublicKey {
623 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_two;
624 crate::c_types::PublicKey::from_rust(&inner_val)
626 /// Source node of the second direction of a channel
628 pub extern "C" fn ChannelInfo_set_node_two(this_ptr: &mut ChannelInfo, mut val: crate::c_types::PublicKey) {
629 unsafe { &mut *this_ptr.inner }.node_two = val.into_rust();
631 /// Details about the second direction of a channel
633 pub extern "C" fn ChannelInfo_get_two_to_one(this_ptr: &ChannelInfo) -> crate::lightning::routing::network_graph::DirectionalChannelInfo {
634 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.two_to_one;
635 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 };
638 /// Details about the second direction of a channel
640 pub extern "C" fn ChannelInfo_set_two_to_one(this_ptr: &mut ChannelInfo, mut val: crate::lightning::routing::network_graph::DirectionalChannelInfo) {
641 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
642 unsafe { &mut *this_ptr.inner }.two_to_one = local_val;
644 /// The channel capacity as seen on-chain, if chain lookup is available.
646 pub extern "C" fn ChannelInfo_get_capacity_sats(this_ptr: &ChannelInfo) -> crate::c_types::derived::COption_u64Z {
647 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.capacity_sats;
648 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { { crate::c_types::derived::COption_u64Z::Some(inner_val.unwrap()) } };
651 /// The channel capacity as seen on-chain, if chain lookup is available.
653 pub extern "C" fn ChannelInfo_set_capacity_sats(this_ptr: &mut ChannelInfo, mut val: crate::c_types::derived::COption_u64Z) {
654 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
655 unsafe { &mut *this_ptr.inner }.capacity_sats = local_val;
657 /// An initial announcement of the channel
658 /// Mostly redundant with the data we store in fields explicitly.
659 /// Everything else is useful only for sending out for initial routing sync.
660 /// Not stored if contains excess data to prevent DoS.
662 pub extern "C" fn ChannelInfo_get_announcement_message(this_ptr: &ChannelInfo) -> crate::lightning::ln::msgs::ChannelAnnouncement {
663 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.announcement_message;
664 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 };
667 /// An initial announcement of the channel
668 /// Mostly redundant with the data we store in fields explicitly.
669 /// Everything else is useful only for sending out for initial routing sync.
670 /// Not stored if contains excess data to prevent DoS.
672 pub extern "C" fn ChannelInfo_set_announcement_message(this_ptr: &mut ChannelInfo, mut val: crate::lightning::ln::msgs::ChannelAnnouncement) {
673 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
674 unsafe { &mut *this_ptr.inner }.announcement_message = local_val;
676 /// Constructs a new ChannelInfo given each field
679 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 {
680 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()) } }) };
681 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()) } }) };
682 let mut local_capacity_sats_arg = if capacity_sats_arg.is_some() { Some( { capacity_sats_arg.take() }) } else { None };
683 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()) } }) };
684 ChannelInfo { inner: Box::into_raw(Box::new(nativeChannelInfo {
685 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
686 node_one: node_one_arg.into_rust(),
687 one_to_two: local_one_to_two_arg,
688 node_two: node_two_arg.into_rust(),
689 two_to_one: local_two_to_one_arg,
690 capacity_sats: local_capacity_sats_arg,
691 announcement_message: local_announcement_message_arg,
692 })), is_owned: true }
694 impl Clone for ChannelInfo {
695 fn clone(&self) -> Self {
697 inner: if <*mut nativeChannelInfo>::is_null(self.inner) { std::ptr::null_mut() } else {
698 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
704 /// Used only if an object of this type is returned as a trait impl by a method
705 pub(crate) extern "C" fn ChannelInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
706 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelInfo)).clone() })) as *mut c_void
709 /// Creates a copy of the ChannelInfo
710 pub extern "C" fn ChannelInfo_clone(orig: &ChannelInfo) -> ChannelInfo {
714 /// Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read
715 pub extern "C" fn ChannelInfo_write(obj: &ChannelInfo) -> crate::c_types::derived::CVec_u8Z {
716 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
719 pub(crate) extern "C" fn ChannelInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
720 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelInfo) })
723 /// Read a ChannelInfo from a byte array, created by ChannelInfo_write
724 pub extern "C" fn ChannelInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelInfoDecodeErrorZ {
725 let res = crate::c_types::deserialize_obj(ser);
726 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() };
730 use lightning::routing::network_graph::RoutingFees as nativeRoutingFeesImport;
731 type nativeRoutingFees = nativeRoutingFeesImport;
733 /// Fees for routing via a given channel or a node
736 pub struct RoutingFees {
737 /// A pointer to the opaque Rust object.
739 /// Nearly everywhere, inner must be non-null, however in places where
740 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
741 pub inner: *mut nativeRoutingFees,
742 /// Indicates that this is the only struct which contains the same pointer.
744 /// Rust functions which take ownership of an object provided via an argument require
745 /// this to be true and invalidate the object pointed to by inner.
749 impl Drop for RoutingFees {
751 if self.is_owned && !<*mut nativeRoutingFees>::is_null(self.inner) {
752 let _ = unsafe { Box::from_raw(self.inner) };
756 /// Frees any resources used by the RoutingFees, if is_owned is set and inner is non-NULL.
758 pub extern "C" fn RoutingFees_free(this_obj: RoutingFees) { }
760 /// Used only if an object of this type is returned as a trait impl by a method
761 extern "C" fn RoutingFees_free_void(this_ptr: *mut c_void) {
762 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRoutingFees); }
765 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
767 pub(crate) fn take_inner(mut self) -> *mut nativeRoutingFees {
768 assert!(self.is_owned);
769 let ret = self.inner;
770 self.inner = std::ptr::null_mut();
774 /// Flat routing fee in satoshis
776 pub extern "C" fn RoutingFees_get_base_msat(this_ptr: &RoutingFees) -> u32 {
777 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.base_msat;
780 /// Flat routing fee in satoshis
782 pub extern "C" fn RoutingFees_set_base_msat(this_ptr: &mut RoutingFees, mut val: u32) {
783 unsafe { &mut *this_ptr.inner }.base_msat = val;
785 /// Liquidity-based routing fee in millionths of a routed amount.
786 /// In other words, 10000 is 1%.
788 pub extern "C" fn RoutingFees_get_proportional_millionths(this_ptr: &RoutingFees) -> u32 {
789 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.proportional_millionths;
792 /// Liquidity-based routing fee in millionths of a routed amount.
793 /// In other words, 10000 is 1%.
795 pub extern "C" fn RoutingFees_set_proportional_millionths(this_ptr: &mut RoutingFees, mut val: u32) {
796 unsafe { &mut *this_ptr.inner }.proportional_millionths = val;
798 /// Constructs a new RoutingFees given each field
801 pub extern "C" fn RoutingFees_new(mut base_msat_arg: u32, mut proportional_millionths_arg: u32) -> RoutingFees {
802 RoutingFees { inner: Box::into_raw(Box::new(nativeRoutingFees {
803 base_msat: base_msat_arg,
804 proportional_millionths: proportional_millionths_arg,
805 })), is_owned: true }
807 impl Clone for RoutingFees {
808 fn clone(&self) -> Self {
810 inner: if <*mut nativeRoutingFees>::is_null(self.inner) { std::ptr::null_mut() } else {
811 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
817 /// Used only if an object of this type is returned as a trait impl by a method
818 pub(crate) extern "C" fn RoutingFees_clone_void(this_ptr: *const c_void) -> *mut c_void {
819 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRoutingFees)).clone() })) as *mut c_void
822 /// Creates a copy of the RoutingFees
823 pub extern "C" fn RoutingFees_clone(orig: &RoutingFees) -> RoutingFees {
827 /// Read a RoutingFees from a byte array, created by RoutingFees_write
828 pub extern "C" fn RoutingFees_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RoutingFeesDecodeErrorZ {
829 let res = crate::c_types::deserialize_obj(ser);
830 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() };
834 /// Serialize the RoutingFees object into a byte array which can be read by RoutingFees_read
835 pub extern "C" fn RoutingFees_write(obj: &RoutingFees) -> crate::c_types::derived::CVec_u8Z {
836 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
839 pub(crate) extern "C" fn RoutingFees_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
840 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRoutingFees) })
843 use lightning::routing::network_graph::NodeAnnouncementInfo as nativeNodeAnnouncementInfoImport;
844 type nativeNodeAnnouncementInfo = nativeNodeAnnouncementInfoImport;
846 /// Information received in the latest node_announcement from this node.
849 pub struct NodeAnnouncementInfo {
850 /// A pointer to the opaque Rust object.
852 /// Nearly everywhere, inner must be non-null, however in places where
853 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
854 pub inner: *mut nativeNodeAnnouncementInfo,
855 /// Indicates that this is the only struct which contains the same pointer.
857 /// Rust functions which take ownership of an object provided via an argument require
858 /// this to be true and invalidate the object pointed to by inner.
862 impl Drop for NodeAnnouncementInfo {
864 if self.is_owned && !<*mut nativeNodeAnnouncementInfo>::is_null(self.inner) {
865 let _ = unsafe { Box::from_raw(self.inner) };
869 /// Frees any resources used by the NodeAnnouncementInfo, if is_owned is set and inner is non-NULL.
871 pub extern "C" fn NodeAnnouncementInfo_free(this_obj: NodeAnnouncementInfo) { }
873 /// Used only if an object of this type is returned as a trait impl by a method
874 extern "C" fn NodeAnnouncementInfo_free_void(this_ptr: *mut c_void) {
875 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAnnouncementInfo); }
878 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
879 impl NodeAnnouncementInfo {
880 pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncementInfo {
881 assert!(self.is_owned);
882 let ret = self.inner;
883 self.inner = std::ptr::null_mut();
887 /// Protocol features the node announced support for
889 pub extern "C" fn NodeAnnouncementInfo_get_features(this_ptr: &NodeAnnouncementInfo) -> crate::lightning::ln::features::NodeFeatures {
890 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features;
891 crate::lightning::ln::features::NodeFeatures { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
893 /// Protocol features the node announced support for
895 pub extern "C" fn NodeAnnouncementInfo_set_features(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::lightning::ln::features::NodeFeatures) {
896 unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) };
898 /// When the last known update to the node state was issued.
899 /// Value is opaque, as set in the announcement.
901 pub extern "C" fn NodeAnnouncementInfo_get_last_update(this_ptr: &NodeAnnouncementInfo) -> u32 {
902 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.last_update;
905 /// When the last known update to the node state was issued.
906 /// Value is opaque, as set in the announcement.
908 pub extern "C" fn NodeAnnouncementInfo_set_last_update(this_ptr: &mut NodeAnnouncementInfo, mut val: u32) {
909 unsafe { &mut *this_ptr.inner }.last_update = val;
911 /// Color assigned to the node
913 pub extern "C" fn NodeAnnouncementInfo_get_rgb(this_ptr: &NodeAnnouncementInfo) -> *const [u8; 3] {
914 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.rgb;
917 /// Color assigned to the node
919 pub extern "C" fn NodeAnnouncementInfo_set_rgb(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::c_types::ThreeBytes) {
920 unsafe { &mut *this_ptr.inner }.rgb = val.data;
922 /// Moniker assigned to the node.
923 /// May be invalid or malicious (eg control chars),
924 /// should not be exposed to the user.
926 pub extern "C" fn NodeAnnouncementInfo_get_alias(this_ptr: &NodeAnnouncementInfo) -> *const [u8; 32] {
927 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.alias;
930 /// Moniker assigned to the node.
931 /// May be invalid or malicious (eg control chars),
932 /// should not be exposed to the user.
934 pub extern "C" fn NodeAnnouncementInfo_set_alias(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::c_types::ThirtyTwoBytes) {
935 unsafe { &mut *this_ptr.inner }.alias = val.data;
937 /// Internet-level addresses via which one can connect to the node
939 pub extern "C" fn NodeAnnouncementInfo_set_addresses(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::c_types::derived::CVec_NetAddressZ) {
940 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
941 unsafe { &mut *this_ptr.inner }.addresses = local_val;
943 /// An initial announcement of the node
944 /// Mostly redundant with the data we store in fields explicitly.
945 /// Everything else is useful only for sending out for initial routing sync.
946 /// Not stored if contains excess data to prevent DoS.
948 pub extern "C" fn NodeAnnouncementInfo_get_announcement_message(this_ptr: &NodeAnnouncementInfo) -> crate::lightning::ln::msgs::NodeAnnouncement {
949 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.announcement_message;
950 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 };
953 /// An initial announcement of the node
954 /// Mostly redundant with the data we store in fields explicitly.
955 /// Everything else is useful only for sending out for initial routing sync.
956 /// Not stored if contains excess data to prevent DoS.
958 pub extern "C" fn NodeAnnouncementInfo_set_announcement_message(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::lightning::ln::msgs::NodeAnnouncement) {
959 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
960 unsafe { &mut *this_ptr.inner }.announcement_message = local_val;
962 /// Constructs a new NodeAnnouncementInfo given each field
965 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 {
966 let mut local_addresses_arg = Vec::new(); for mut item in addresses_arg.into_rust().drain(..) { local_addresses_arg.push( { item.into_native() }); };
967 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()) } }) };
968 NodeAnnouncementInfo { inner: Box::into_raw(Box::new(nativeNodeAnnouncementInfo {
969 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
970 last_update: last_update_arg,
972 alias: alias_arg.data,
973 addresses: local_addresses_arg,
974 announcement_message: local_announcement_message_arg,
975 })), is_owned: true }
977 impl Clone for NodeAnnouncementInfo {
978 fn clone(&self) -> Self {
980 inner: if <*mut nativeNodeAnnouncementInfo>::is_null(self.inner) { std::ptr::null_mut() } else {
981 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
987 /// Used only if an object of this type is returned as a trait impl by a method
988 pub(crate) extern "C" fn NodeAnnouncementInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
989 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncementInfo)).clone() })) as *mut c_void
992 /// Creates a copy of the NodeAnnouncementInfo
993 pub extern "C" fn NodeAnnouncementInfo_clone(orig: &NodeAnnouncementInfo) -> NodeAnnouncementInfo {
997 /// Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read
998 pub extern "C" fn NodeAnnouncementInfo_write(obj: &NodeAnnouncementInfo) -> crate::c_types::derived::CVec_u8Z {
999 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
1002 pub(crate) extern "C" fn NodeAnnouncementInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1003 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncementInfo) })
1006 /// Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write
1007 pub extern "C" fn NodeAnnouncementInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementInfoDecodeErrorZ {
1008 let res = crate::c_types::deserialize_obj(ser);
1009 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() };
1013 use lightning::routing::network_graph::NodeInfo as nativeNodeInfoImport;
1014 type nativeNodeInfo = nativeNodeInfoImport;
1016 /// Details about a node in the network, known from the network announcement.
1019 pub struct NodeInfo {
1020 /// A pointer to the opaque Rust object.
1022 /// Nearly everywhere, inner must be non-null, however in places where
1023 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1024 pub inner: *mut nativeNodeInfo,
1025 /// Indicates that this is the only struct which contains the same pointer.
1027 /// Rust functions which take ownership of an object provided via an argument require
1028 /// this to be true and invalidate the object pointed to by inner.
1032 impl Drop for NodeInfo {
1033 fn drop(&mut self) {
1034 if self.is_owned && !<*mut nativeNodeInfo>::is_null(self.inner) {
1035 let _ = unsafe { Box::from_raw(self.inner) };
1039 /// Frees any resources used by the NodeInfo, if is_owned is set and inner is non-NULL.
1041 pub extern "C" fn NodeInfo_free(this_obj: NodeInfo) { }
1043 /// Used only if an object of this type is returned as a trait impl by a method
1044 extern "C" fn NodeInfo_free_void(this_ptr: *mut c_void) {
1045 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeInfo); }
1048 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1050 pub(crate) fn take_inner(mut self) -> *mut nativeNodeInfo {
1051 assert!(self.is_owned);
1052 let ret = self.inner;
1053 self.inner = std::ptr::null_mut();
1057 /// All valid channels a node has announced
1059 pub extern "C" fn NodeInfo_set_channels(this_ptr: &mut NodeInfo, mut val: crate::c_types::derived::CVec_u64Z) {
1060 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
1061 unsafe { &mut *this_ptr.inner }.channels = local_val;
1063 /// Lowest fees enabling routing via any of the enabled, known channels to a node.
1064 /// The two fields (flat and proportional fee) are independent,
1065 /// meaning they don't have to refer to the same channel.
1067 pub extern "C" fn NodeInfo_get_lowest_inbound_channel_fees(this_ptr: &NodeInfo) -> crate::lightning::routing::network_graph::RoutingFees {
1068 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.lowest_inbound_channel_fees;
1069 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 };
1072 /// Lowest fees enabling routing via any of the enabled, known channels to a node.
1073 /// The two fields (flat and proportional fee) are independent,
1074 /// meaning they don't have to refer to the same channel.
1076 pub extern "C" fn NodeInfo_set_lowest_inbound_channel_fees(this_ptr: &mut NodeInfo, mut val: crate::lightning::routing::network_graph::RoutingFees) {
1077 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1078 unsafe { &mut *this_ptr.inner }.lowest_inbound_channel_fees = local_val;
1080 /// More information about a node from node_announcement.
1081 /// Optional because we store a Node entry after learning about it from
1082 /// a channel announcement, but before receiving a node announcement.
1084 pub extern "C" fn NodeInfo_get_announcement_info(this_ptr: &NodeInfo) -> crate::lightning::routing::network_graph::NodeAnnouncementInfo {
1085 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.announcement_info;
1086 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 };
1089 /// More information about a node from node_announcement.
1090 /// Optional because we store a Node entry after learning about it from
1091 /// a channel announcement, but before receiving a node announcement.
1093 pub extern "C" fn NodeInfo_set_announcement_info(this_ptr: &mut NodeInfo, mut val: crate::lightning::routing::network_graph::NodeAnnouncementInfo) {
1094 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1095 unsafe { &mut *this_ptr.inner }.announcement_info = local_val;
1097 /// Constructs a new NodeInfo given each field
1100 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 {
1101 let mut local_channels_arg = Vec::new(); for mut item in channels_arg.into_rust().drain(..) { local_channels_arg.push( { item }); };
1102 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()) } }) };
1103 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()) } }) };
1104 NodeInfo { inner: Box::into_raw(Box::new(nativeNodeInfo {
1105 channels: local_channels_arg,
1106 lowest_inbound_channel_fees: local_lowest_inbound_channel_fees_arg,
1107 announcement_info: local_announcement_info_arg,
1108 })), is_owned: true }
1110 impl Clone for NodeInfo {
1111 fn clone(&self) -> Self {
1113 inner: if <*mut nativeNodeInfo>::is_null(self.inner) { std::ptr::null_mut() } else {
1114 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1120 /// Used only if an object of this type is returned as a trait impl by a method
1121 pub(crate) extern "C" fn NodeInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
1122 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeInfo)).clone() })) as *mut c_void
1125 /// Creates a copy of the NodeInfo
1126 pub extern "C" fn NodeInfo_clone(orig: &NodeInfo) -> NodeInfo {
1130 /// Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read
1131 pub extern "C" fn NodeInfo_write(obj: &NodeInfo) -> crate::c_types::derived::CVec_u8Z {
1132 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
1135 pub(crate) extern "C" fn NodeInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1136 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeInfo) })
1139 /// Read a NodeInfo from a byte array, created by NodeInfo_write
1140 pub extern "C" fn NodeInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeInfoDecodeErrorZ {
1141 let res = crate::c_types::deserialize_obj(ser);
1142 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() };
1146 /// Serialize the NetworkGraph object into a byte array which can be read by NetworkGraph_read
1147 pub extern "C" fn NetworkGraph_write(obj: &NetworkGraph) -> crate::c_types::derived::CVec_u8Z {
1148 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
1151 pub(crate) extern "C" fn NetworkGraph_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1152 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNetworkGraph) })
1155 /// Read a NetworkGraph from a byte array, created by NetworkGraph_write
1156 pub extern "C" fn NetworkGraph_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NetworkGraphDecodeErrorZ {
1157 let res = crate::c_types::deserialize_obj(ser);
1158 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() };
1161 /// Creates a new, empty, network graph.
1164 pub extern "C" fn NetworkGraph_new(mut genesis_hash: crate::c_types::ThirtyTwoBytes) -> crate::lightning::routing::network_graph::NetworkGraph {
1165 let mut ret = lightning::routing::network_graph::NetworkGraph::new(::bitcoin::hash_types::BlockHash::from_slice(&genesis_hash.data[..]).unwrap());
1166 crate::lightning::routing::network_graph::NetworkGraph { inner: Box::into_raw(Box::new(ret)), is_owned: true }
1169 /// For an already known node (from channel announcements), update its stored properties from a
1170 /// given node announcement.
1172 /// You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's
1173 /// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
1174 /// routing messages from a source using a protocol other than the lightning P2P protocol.
1177 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 {
1178 let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_node_from_announcement(unsafe { &*msg.inner }, secp256k1::SECP256K1);
1179 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() };
1183 /// For an already known node (from channel announcements), update its stored properties from a
1184 /// given node announcement without verifying the associated signatures. Because we aren't
1185 /// given the associated signatures here we cannot relay the node announcement to any of our
1189 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 {
1190 let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_node_from_unsigned_announcement(unsafe { &*msg.inner });
1191 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() };
1195 /// Store or update channel info from a channel announcement.
1197 /// You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's
1198 /// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
1199 /// routing messages from a source using a protocol other than the lightning P2P protocol.
1201 /// If a `chain::Access` object is provided via `chain_access`, it will be called to verify
1202 /// the corresponding UTXO exists on chain and is correctly-formatted.
1205 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 {
1206 let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) };
1207 let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_channel_from_announcement(unsafe { &*msg.inner }, &local_chain_access, secp256k1::SECP256K1);
1208 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() };
1212 /// Store or update channel info from a channel announcement without verifying the associated
1213 /// signatures. Because we aren't given the associated signatures here we cannot relay the
1214 /// channel announcement to any of our peers.
1216 /// If a `chain::Access` object is provided via `chain_access`, it will be called to verify
1217 /// the corresponding UTXO exists on chain and is correctly-formatted.
1220 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 {
1221 let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) };
1222 let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_channel_from_unsigned_announcement(unsafe { &*msg.inner }, &local_chain_access);
1223 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() };
1227 /// Close a channel if a corresponding HTLC fail was sent.
1228 /// If permanent, removes a channel from the local storage.
1229 /// May cause the removal of nodes too, if this was their last channel.
1230 /// If not permanent, makes channels unavailable for routing.
1232 pub extern "C" fn NetworkGraph_close_channel_from_update(this_arg: &mut NetworkGraph, mut short_channel_id: u64, mut is_permanent: bool) {
1233 unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.close_channel_from_update(short_channel_id, is_permanent)
1236 /// For an already known (from announcement) channel, update info about one of the directions
1239 /// You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's
1240 /// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
1241 /// routing messages from a source using a protocol other than the lightning P2P protocol.
1244 pub extern "C" fn NetworkGraph_update_channel(this_arg: &mut NetworkGraph, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
1245 let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_channel(unsafe { &*msg.inner }, secp256k1::SECP256K1);
1246 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() };
1250 /// For an already known (from announcement) channel, update info about one of the directions
1251 /// of the channel without verifying the associated signatures. Because we aren't given the
1252 /// associated signatures here we cannot relay the channel update to any of our peers.
1255 pub extern "C" fn NetworkGraph_update_channel_unsigned(this_arg: &mut NetworkGraph, msg: &crate::lightning::ln::msgs::UnsignedChannelUpdate) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
1256 let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_channel_unsigned(unsafe { &*msg.inner });
1257 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() };