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 alloc::str::FromStr;
12 use core::ffi::c_void;
13 use core::convert::Infallible;
14 use bitcoin::hashes::Hash;
15 use crate::c_types::*;
16 #[cfg(feature="no-std")]
17 use alloc::{vec::Vec, boxed::Box};
20 use lightning::routing::network_graph::NodeId as nativeNodeIdImport;
21 pub(crate) type nativeNodeId = nativeNodeIdImport;
23 /// Represents the compressed public key of a node
27 /// A pointer to the opaque Rust object.
29 /// Nearly everywhere, inner must be non-null, however in places where
30 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
31 pub inner: *mut nativeNodeId,
32 /// Indicates that this is the only struct which contains the same pointer.
34 /// Rust functions which take ownership of an object provided via an argument require
35 /// this to be true and invalidate the object pointed to by inner.
39 impl Drop for NodeId {
41 if self.is_owned && !<*mut nativeNodeId>::is_null(self.inner) {
42 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
46 /// Frees any resources used by the NodeId, if is_owned is set and inner is non-NULL.
48 pub extern "C" fn NodeId_free(this_obj: NodeId) { }
50 /// Used only if an object of this type is returned as a trait impl by a method
51 pub(crate) extern "C" fn NodeId_free_void(this_ptr: *mut c_void) {
52 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeId); }
56 pub(crate) fn get_native_ref(&self) -> &'static nativeNodeId {
57 unsafe { &*ObjOps::untweak_ptr(self.inner) }
59 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeId {
60 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
62 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
63 pub(crate) fn take_inner(mut self) -> *mut nativeNodeId {
64 assert!(self.is_owned);
65 let ret = ObjOps::untweak_ptr(self.inner);
66 self.inner = core::ptr::null_mut();
70 impl Clone for NodeId {
71 fn clone(&self) -> Self {
73 inner: if <*mut nativeNodeId>::is_null(self.inner) { core::ptr::null_mut() } else {
74 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
80 /// Used only if an object of this type is returned as a trait impl by a method
81 pub(crate) extern "C" fn NodeId_clone_void(this_ptr: *const c_void) -> *mut c_void {
82 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeId)).clone() })) as *mut c_void
85 /// Creates a copy of the NodeId
86 pub extern "C" fn NodeId_clone(orig: &NodeId) -> NodeId {
89 /// Create a new NodeId from a public key
92 pub extern "C" fn NodeId_from_pubkey(mut pubkey: crate::c_types::PublicKey) -> NodeId {
93 let mut ret = lightning::routing::network_graph::NodeId::from_pubkey(&pubkey.into_rust());
94 NodeId { inner: ObjOps::heap_alloc(ret), is_owned: true }
97 /// Get the public key slice from this NodeId
100 pub extern "C" fn NodeId_as_slice(this_arg: &NodeId) -> crate::c_types::u8slice {
101 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.as_slice();
102 let mut local_ret = crate::c_types::u8slice::from_slice(ret);
106 /// Checks if two NodeIds contain equal inner contents.
108 pub extern "C" fn NodeId_hash(o: &NodeId) -> u64 {
109 if o.inner.is_null() { return 0; }
110 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
112 let mut hasher = core::hash::SipHasher::new();
113 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
114 core::hash::Hasher::finish(&hasher)
117 /// Serialize the NodeId object into a byte array which can be read by NodeId_read
118 pub extern "C" fn NodeId_write(obj: &NodeId) -> crate::c_types::derived::CVec_u8Z {
119 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
122 pub(crate) extern "C" fn NodeId_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
123 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeId) })
126 /// Read a NodeId from a byte array, created by NodeId_write
127 pub extern "C" fn NodeId_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeIdDecodeErrorZ {
128 let res: Result<lightning::routing::network_graph::NodeId, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
129 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::network_graph::NodeId { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
133 use lightning::routing::network_graph::NetworkGraph as nativeNetworkGraphImport;
134 pub(crate) type nativeNetworkGraph = nativeNetworkGraphImport;
136 /// Represents the network as nodes and channels between them
139 pub struct NetworkGraph {
140 /// A pointer to the opaque Rust object.
142 /// Nearly everywhere, inner must be non-null, however in places where
143 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
144 pub inner: *mut nativeNetworkGraph,
145 /// Indicates that this is the only struct which contains the same pointer.
147 /// Rust functions which take ownership of an object provided via an argument require
148 /// this to be true and invalidate the object pointed to by inner.
152 impl Drop for NetworkGraph {
154 if self.is_owned && !<*mut nativeNetworkGraph>::is_null(self.inner) {
155 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
159 /// Frees any resources used by the NetworkGraph, if is_owned is set and inner is non-NULL.
161 pub extern "C" fn NetworkGraph_free(this_obj: NetworkGraph) { }
163 /// Used only if an object of this type is returned as a trait impl by a method
164 pub(crate) extern "C" fn NetworkGraph_free_void(this_ptr: *mut c_void) {
165 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNetworkGraph); }
169 pub(crate) fn get_native_ref(&self) -> &'static nativeNetworkGraph {
170 unsafe { &*ObjOps::untweak_ptr(self.inner) }
172 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNetworkGraph {
173 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
175 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
176 pub(crate) fn take_inner(mut self) -> *mut nativeNetworkGraph {
177 assert!(self.is_owned);
178 let ret = ObjOps::untweak_ptr(self.inner);
179 self.inner = core::ptr::null_mut();
183 impl Clone for NetworkGraph {
184 fn clone(&self) -> Self {
186 inner: if <*mut nativeNetworkGraph>::is_null(self.inner) { core::ptr::null_mut() } else {
187 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
193 /// Used only if an object of this type is returned as a trait impl by a method
194 pub(crate) extern "C" fn NetworkGraph_clone_void(this_ptr: *const c_void) -> *mut c_void {
195 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNetworkGraph)).clone() })) as *mut c_void
198 /// Creates a copy of the NetworkGraph
199 pub extern "C" fn NetworkGraph_clone(orig: &NetworkGraph) -> NetworkGraph {
203 use lightning::routing::network_graph::ReadOnlyNetworkGraph as nativeReadOnlyNetworkGraphImport;
204 pub(crate) type nativeReadOnlyNetworkGraph = nativeReadOnlyNetworkGraphImport<'static>;
206 /// A read-only view of [`NetworkGraph`].
209 pub struct ReadOnlyNetworkGraph {
210 /// A pointer to the opaque Rust object.
212 /// Nearly everywhere, inner must be non-null, however in places where
213 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
214 pub inner: *mut nativeReadOnlyNetworkGraph,
215 /// Indicates that this is the only struct which contains the same pointer.
217 /// Rust functions which take ownership of an object provided via an argument require
218 /// this to be true and invalidate the object pointed to by inner.
222 impl Drop for ReadOnlyNetworkGraph {
224 if self.is_owned && !<*mut nativeReadOnlyNetworkGraph>::is_null(self.inner) {
225 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
229 /// Frees any resources used by the ReadOnlyNetworkGraph, if is_owned is set and inner is non-NULL.
231 pub extern "C" fn ReadOnlyNetworkGraph_free(this_obj: ReadOnlyNetworkGraph) { }
233 /// Used only if an object of this type is returned as a trait impl by a method
234 pub(crate) extern "C" fn ReadOnlyNetworkGraph_free_void(this_ptr: *mut c_void) {
235 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReadOnlyNetworkGraph); }
238 impl ReadOnlyNetworkGraph {
239 pub(crate) fn get_native_ref(&self) -> &'static nativeReadOnlyNetworkGraph {
240 unsafe { &*ObjOps::untweak_ptr(self.inner) }
242 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReadOnlyNetworkGraph {
243 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
245 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
246 pub(crate) fn take_inner(mut self) -> *mut nativeReadOnlyNetworkGraph {
247 assert!(self.is_owned);
248 let ret = ObjOps::untweak_ptr(self.inner);
249 self.inner = core::ptr::null_mut();
253 /// Update to the [`NetworkGraph`] based on payment failure information conveyed via the Onion
254 /// return packet by a node along the route. See [BOLT #4] for details.
256 /// [BOLT #4]: https://github.com/lightningnetwork/lightning-rfc/blob/master/04-onion-routing.md
260 pub enum NetworkUpdate {
261 /// An error indicating a `channel_update` messages should be applied via
262 /// [`NetworkGraph::update_channel`].
263 ChannelUpdateMessage {
264 /// The update to apply via [`NetworkGraph::update_channel`].
265 msg: crate::lightning::ln::msgs::ChannelUpdate,
267 /// An error indicating only that a channel has been closed, which should be applied via
268 /// [`NetworkGraph::close_channel_from_update`].
270 /// The short channel id of the closed channel.
271 short_channel_id: u64,
272 /// Whether the channel should be permanently removed or temporarily disabled until a new
273 /// `channel_update` message is received.
276 /// An error indicating only that a node has failed, which should be applied via
277 /// [`NetworkGraph::fail_node`].
279 /// The node id of the failed node.
280 node_id: crate::c_types::PublicKey,
281 /// Whether the node should be permanently removed from consideration or can be restored
282 /// when a new `channel_update` message is received.
286 use lightning::routing::network_graph::NetworkUpdate as nativeNetworkUpdate;
289 pub(crate) fn to_native(&self) -> nativeNetworkUpdate {
291 NetworkUpdate::ChannelUpdateMessage {ref msg, } => {
292 let mut msg_nonref = (*msg).clone();
293 nativeNetworkUpdate::ChannelUpdateMessage {
294 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
297 NetworkUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
298 let mut short_channel_id_nonref = (*short_channel_id).clone();
299 let mut is_permanent_nonref = (*is_permanent).clone();
300 nativeNetworkUpdate::ChannelClosed {
301 short_channel_id: short_channel_id_nonref,
302 is_permanent: is_permanent_nonref,
305 NetworkUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
306 let mut node_id_nonref = (*node_id).clone();
307 let mut is_permanent_nonref = (*is_permanent).clone();
308 nativeNetworkUpdate::NodeFailure {
309 node_id: node_id_nonref.into_rust(),
310 is_permanent: is_permanent_nonref,
316 pub(crate) fn into_native(self) -> nativeNetworkUpdate {
318 NetworkUpdate::ChannelUpdateMessage {mut msg, } => {
319 nativeNetworkUpdate::ChannelUpdateMessage {
320 msg: *unsafe { Box::from_raw(msg.take_inner()) },
323 NetworkUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
324 nativeNetworkUpdate::ChannelClosed {
325 short_channel_id: short_channel_id,
326 is_permanent: is_permanent,
329 NetworkUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
330 nativeNetworkUpdate::NodeFailure {
331 node_id: node_id.into_rust(),
332 is_permanent: is_permanent,
338 pub(crate) fn from_native(native: &nativeNetworkUpdate) -> Self {
340 nativeNetworkUpdate::ChannelUpdateMessage {ref msg, } => {
341 let mut msg_nonref = (*msg).clone();
342 NetworkUpdate::ChannelUpdateMessage {
343 msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
346 nativeNetworkUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
347 let mut short_channel_id_nonref = (*short_channel_id).clone();
348 let mut is_permanent_nonref = (*is_permanent).clone();
349 NetworkUpdate::ChannelClosed {
350 short_channel_id: short_channel_id_nonref,
351 is_permanent: is_permanent_nonref,
354 nativeNetworkUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
355 let mut node_id_nonref = (*node_id).clone();
356 let mut is_permanent_nonref = (*is_permanent).clone();
357 NetworkUpdate::NodeFailure {
358 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
359 is_permanent: is_permanent_nonref,
365 pub(crate) fn native_into(native: nativeNetworkUpdate) -> Self {
367 nativeNetworkUpdate::ChannelUpdateMessage {mut msg, } => {
368 NetworkUpdate::ChannelUpdateMessage {
369 msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg), is_owned: true },
372 nativeNetworkUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
373 NetworkUpdate::ChannelClosed {
374 short_channel_id: short_channel_id,
375 is_permanent: is_permanent,
378 nativeNetworkUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
379 NetworkUpdate::NodeFailure {
380 node_id: crate::c_types::PublicKey::from_rust(&node_id),
381 is_permanent: is_permanent,
387 /// Frees any resources used by the NetworkUpdate
389 pub extern "C" fn NetworkUpdate_free(this_ptr: NetworkUpdate) { }
390 /// Creates a copy of the NetworkUpdate
392 pub extern "C" fn NetworkUpdate_clone(orig: &NetworkUpdate) -> NetworkUpdate {
396 /// Utility method to constructs a new ChannelUpdateMessage-variant NetworkUpdate
397 pub extern "C" fn NetworkUpdate_channel_update_message(msg: crate::lightning::ln::msgs::ChannelUpdate) -> NetworkUpdate {
398 NetworkUpdate::ChannelUpdateMessage {
403 /// Utility method to constructs a new ChannelClosed-variant NetworkUpdate
404 pub extern "C" fn NetworkUpdate_channel_closed(short_channel_id: u64, is_permanent: bool) -> NetworkUpdate {
405 NetworkUpdate::ChannelClosed {
411 /// Utility method to constructs a new NodeFailure-variant NetworkUpdate
412 pub extern "C" fn NetworkUpdate_node_failure(node_id: crate::c_types::PublicKey, is_permanent: bool) -> NetworkUpdate {
413 NetworkUpdate::NodeFailure {
419 /// Serialize the NetworkUpdate object into a byte array which can be read by NetworkUpdate_read
420 pub extern "C" fn NetworkUpdate_write(obj: &NetworkUpdate) -> crate::c_types::derived::CVec_u8Z {
421 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
424 /// Read a NetworkUpdate from a byte array, created by NetworkUpdate_write
425 pub extern "C" fn NetworkUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_NetworkUpdateZDecodeErrorZ {
426 let res: Result<Option<lightning::routing::network_graph::NetworkUpdate>, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser);
427 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_NetworkUpdateZ::None } else { crate::c_types::derived::COption_NetworkUpdateZ::Some( { crate::lightning::routing::network_graph::NetworkUpdate::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
430 impl From<nativeNetGraphMsgHandler> for crate::lightning::util::events::EventHandler {
431 fn from(obj: nativeNetGraphMsgHandler) -> Self {
432 let mut rust_obj = NetGraphMsgHandler { inner: ObjOps::heap_alloc(obj), is_owned: true };
433 let mut ret = NetGraphMsgHandler_as_EventHandler(&rust_obj);
434 // 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
435 rust_obj.inner = core::ptr::null_mut();
436 ret.free = Some(NetGraphMsgHandler_free_void);
440 /// Constructs a new EventHandler which calls the relevant methods on this_arg.
441 /// This copies the `inner` pointer in this_arg and thus the returned EventHandler must be freed before this_arg is
443 pub extern "C" fn NetGraphMsgHandler_as_EventHandler(this_arg: &NetGraphMsgHandler) -> crate::lightning::util::events::EventHandler {
444 crate::lightning::util::events::EventHandler {
445 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
447 handle_event: NetGraphMsgHandler_EventHandler_handle_event,
451 extern "C" fn NetGraphMsgHandler_EventHandler_handle_event(this_arg: *const c_void, event: &crate::lightning::util::events::Event) {
452 <nativeNetGraphMsgHandler as lightning::util::events::EventHandler<>>::handle_event(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, &event.to_native())
456 use lightning::routing::network_graph::NetGraphMsgHandler as nativeNetGraphMsgHandlerImport;
457 pub(crate) type nativeNetGraphMsgHandler = nativeNetGraphMsgHandlerImport<&'static lightning::routing::network_graph::NetworkGraph, crate::lightning::chain::Access, crate::lightning::util::logger::Logger>;
459 /// Receives and validates network updates from peers,
460 /// stores authentic and relevant data as a network graph.
461 /// This network graph is then used for routing payments.
462 /// Provides interface to help with initial routing sync by
463 /// serving historical announcements.
465 /// Serves as an [`EventHandler`] for applying updates from [`Event::PaymentPathFailed`] to the
466 /// [`NetworkGraph`].
469 pub struct NetGraphMsgHandler {
470 /// A pointer to the opaque Rust object.
472 /// Nearly everywhere, inner must be non-null, however in places where
473 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
474 pub inner: *mut nativeNetGraphMsgHandler,
475 /// Indicates that this is the only struct which contains the same pointer.
477 /// Rust functions which take ownership of an object provided via an argument require
478 /// this to be true and invalidate the object pointed to by inner.
482 impl Drop for NetGraphMsgHandler {
484 if self.is_owned && !<*mut nativeNetGraphMsgHandler>::is_null(self.inner) {
485 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
489 /// Frees any resources used by the NetGraphMsgHandler, if is_owned is set and inner is non-NULL.
491 pub extern "C" fn NetGraphMsgHandler_free(this_obj: NetGraphMsgHandler) { }
493 /// Used only if an object of this type is returned as a trait impl by a method
494 pub(crate) extern "C" fn NetGraphMsgHandler_free_void(this_ptr: *mut c_void) {
495 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNetGraphMsgHandler); }
498 impl NetGraphMsgHandler {
499 pub(crate) fn get_native_ref(&self) -> &'static nativeNetGraphMsgHandler {
500 unsafe { &*ObjOps::untweak_ptr(self.inner) }
502 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNetGraphMsgHandler {
503 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
505 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
506 pub(crate) fn take_inner(mut self) -> *mut nativeNetGraphMsgHandler {
507 assert!(self.is_owned);
508 let ret = ObjOps::untweak_ptr(self.inner);
509 self.inner = core::ptr::null_mut();
513 /// Creates a new tracker of the actual state of the network of channels and nodes,
514 /// assuming an existing Network Graph.
515 /// Chain monitor is used to make sure announced channels exist on-chain,
516 /// channel data is correct, and that the announcement is signed with
517 /// channel owners' keys.
520 pub extern "C" fn NetGraphMsgHandler_new(network_graph: &crate::lightning::routing::network_graph::NetworkGraph, mut chain_access: crate::c_types::derived::COption_AccessZ, mut logger: crate::lightning::util::logger::Logger) -> NetGraphMsgHandler {
521 let mut local_chain_access = { /* chain_access*/ let chain_access_opt = chain_access; { } if chain_access_opt.is_none() { None } else { Some({ chain_access_opt.take() }) } };
522 let mut ret = lightning::routing::network_graph::NetGraphMsgHandler::new(network_graph.get_native_ref(), local_chain_access, logger);
523 NetGraphMsgHandler { inner: ObjOps::heap_alloc(ret), is_owned: true }
526 /// Adds a provider used to check new announcements. Does not affect
527 /// existing announcements unless they are updated.
528 /// Add, update or remove the provider would replace the current one.
530 pub extern "C" fn NetGraphMsgHandler_add_chain_access(this_arg: &mut NetGraphMsgHandler, mut chain_access: crate::c_types::derived::COption_AccessZ) {
531 let mut local_chain_access = { /* chain_access*/ let chain_access_opt = chain_access; { } if chain_access_opt.is_none() { None } else { Some({ chain_access_opt.take() }) } };
532 unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut nativeNetGraphMsgHandler)) }.add_chain_access(local_chain_access)
535 impl From<nativeNetGraphMsgHandler> for crate::lightning::ln::msgs::RoutingMessageHandler {
536 fn from(obj: nativeNetGraphMsgHandler) -> Self {
537 let mut rust_obj = NetGraphMsgHandler { inner: ObjOps::heap_alloc(obj), is_owned: true };
538 let mut ret = NetGraphMsgHandler_as_RoutingMessageHandler(&rust_obj);
539 // 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
540 rust_obj.inner = core::ptr::null_mut();
541 ret.free = Some(NetGraphMsgHandler_free_void);
545 /// Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg.
546 /// This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is
548 pub extern "C" fn NetGraphMsgHandler_as_RoutingMessageHandler(this_arg: &NetGraphMsgHandler) -> crate::lightning::ln::msgs::RoutingMessageHandler {
549 crate::lightning::ln::msgs::RoutingMessageHandler {
550 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
552 handle_node_announcement: NetGraphMsgHandler_RoutingMessageHandler_handle_node_announcement,
553 handle_channel_announcement: NetGraphMsgHandler_RoutingMessageHandler_handle_channel_announcement,
554 handle_channel_update: NetGraphMsgHandler_RoutingMessageHandler_handle_channel_update,
555 get_next_channel_announcements: NetGraphMsgHandler_RoutingMessageHandler_get_next_channel_announcements,
556 get_next_node_announcements: NetGraphMsgHandler_RoutingMessageHandler_get_next_node_announcements,
557 sync_routing_table: NetGraphMsgHandler_RoutingMessageHandler_sync_routing_table,
558 handle_reply_channel_range: NetGraphMsgHandler_RoutingMessageHandler_handle_reply_channel_range,
559 handle_reply_short_channel_ids_end: NetGraphMsgHandler_RoutingMessageHandler_handle_reply_short_channel_ids_end,
560 handle_query_channel_range: NetGraphMsgHandler_RoutingMessageHandler_handle_query_channel_range,
561 handle_query_short_channel_ids: NetGraphMsgHandler_RoutingMessageHandler_handle_query_short_channel_ids,
562 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider {
563 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
565 get_and_clear_pending_msg_events: NetGraphMsgHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events,
571 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 {
572 let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_node_announcement(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, msg.get_native_ref());
573 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: ObjOps::heap_alloc(e), is_owned: true } }).into() };
577 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 {
578 let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_channel_announcement(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, msg.get_native_ref());
579 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: ObjOps::heap_alloc(e), is_owned: true } }).into() };
583 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 {
584 let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, msg.get_native_ref());
585 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: ObjOps::heap_alloc(e), is_owned: true } }).into() };
589 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 {
590 let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::get_next_channel_announcements(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, starting_point, batch_amount);
591 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() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((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() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((orig_ret_0_2.unwrap())) } }, is_owned: true }; let mut local_ret_0 = (crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(orig_ret_0_0), is_owned: true }, local_orig_ret_0_1, local_orig_ret_0_2).into(); local_ret_0 }); };
595 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 {
596 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();
597 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);
598 let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
601 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) {
602 <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::sync_routing_table(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, &their_node_id.into_rust(), init_msg.get_native_ref())
605 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 {
606 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()) });
607 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: ObjOps::heap_alloc(e), is_owned: true } }).into() };
611 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 {
612 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()) });
613 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: ObjOps::heap_alloc(e), is_owned: true } }).into() };
617 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 {
618 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()) });
619 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: ObjOps::heap_alloc(e), is_owned: true } }).into() };
623 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 {
624 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()) });
625 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: ObjOps::heap_alloc(e), is_owned: true } }).into() };
629 impl From<nativeNetGraphMsgHandler> for crate::lightning::util::events::MessageSendEventsProvider {
630 fn from(obj: nativeNetGraphMsgHandler) -> Self {
631 let mut rust_obj = NetGraphMsgHandler { inner: ObjOps::heap_alloc(obj), is_owned: true };
632 let mut ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&rust_obj);
633 // 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
634 rust_obj.inner = core::ptr::null_mut();
635 ret.free = Some(NetGraphMsgHandler_free_void);
639 /// Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg.
640 /// This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is
642 pub extern "C" fn NetGraphMsgHandler_as_MessageSendEventsProvider(this_arg: &NetGraphMsgHandler) -> crate::lightning::util::events::MessageSendEventsProvider {
643 crate::lightning::util::events::MessageSendEventsProvider {
644 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
646 get_and_clear_pending_msg_events: NetGraphMsgHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events,
651 extern "C" fn NetGraphMsgHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ {
652 let mut ret = <nativeNetGraphMsgHandler as lightning::util::events::MessageSendEventsProvider<>>::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, );
653 let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::util::events::MessageSendEvent::native_into(item) }); };
658 use lightning::routing::network_graph::DirectionalChannelInfo as nativeDirectionalChannelInfoImport;
659 pub(crate) type nativeDirectionalChannelInfo = nativeDirectionalChannelInfoImport;
661 /// Details about one direction of a channel. Received
662 /// within a channel update.
665 pub struct DirectionalChannelInfo {
666 /// A pointer to the opaque Rust object.
668 /// Nearly everywhere, inner must be non-null, however in places where
669 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
670 pub inner: *mut nativeDirectionalChannelInfo,
671 /// Indicates that this is the only struct which contains the same pointer.
673 /// Rust functions which take ownership of an object provided via an argument require
674 /// this to be true and invalidate the object pointed to by inner.
678 impl Drop for DirectionalChannelInfo {
680 if self.is_owned && !<*mut nativeDirectionalChannelInfo>::is_null(self.inner) {
681 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
685 /// Frees any resources used by the DirectionalChannelInfo, if is_owned is set and inner is non-NULL.
687 pub extern "C" fn DirectionalChannelInfo_free(this_obj: DirectionalChannelInfo) { }
689 /// Used only if an object of this type is returned as a trait impl by a method
690 pub(crate) extern "C" fn DirectionalChannelInfo_free_void(this_ptr: *mut c_void) {
691 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDirectionalChannelInfo); }
694 impl DirectionalChannelInfo {
695 pub(crate) fn get_native_ref(&self) -> &'static nativeDirectionalChannelInfo {
696 unsafe { &*ObjOps::untweak_ptr(self.inner) }
698 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeDirectionalChannelInfo {
699 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
701 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
702 pub(crate) fn take_inner(mut self) -> *mut nativeDirectionalChannelInfo {
703 assert!(self.is_owned);
704 let ret = ObjOps::untweak_ptr(self.inner);
705 self.inner = core::ptr::null_mut();
709 /// When the last update to the channel direction was issued.
710 /// Value is opaque, as set in the announcement.
712 pub extern "C" fn DirectionalChannelInfo_get_last_update(this_ptr: &DirectionalChannelInfo) -> u32 {
713 let mut inner_val = &mut this_ptr.get_native_mut_ref().last_update;
716 /// When the last update to the channel direction was issued.
717 /// Value is opaque, as set in the announcement.
719 pub extern "C" fn DirectionalChannelInfo_set_last_update(this_ptr: &mut DirectionalChannelInfo, mut val: u32) {
720 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.last_update = val;
722 /// Whether the channel can be currently used for payments (in this one direction).
724 pub extern "C" fn DirectionalChannelInfo_get_enabled(this_ptr: &DirectionalChannelInfo) -> bool {
725 let mut inner_val = &mut this_ptr.get_native_mut_ref().enabled;
728 /// Whether the channel can be currently used for payments (in this one direction).
730 pub extern "C" fn DirectionalChannelInfo_set_enabled(this_ptr: &mut DirectionalChannelInfo, mut val: bool) {
731 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.enabled = val;
733 /// The difference in CLTV values that you must have when routing through this channel.
735 pub extern "C" fn DirectionalChannelInfo_get_cltv_expiry_delta(this_ptr: &DirectionalChannelInfo) -> u16 {
736 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
739 /// The difference in CLTV values that you must have when routing through this channel.
741 pub extern "C" fn DirectionalChannelInfo_set_cltv_expiry_delta(this_ptr: &mut DirectionalChannelInfo, mut val: u16) {
742 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
744 /// The minimum value, which must be relayed to the next hop via the channel
746 pub extern "C" fn DirectionalChannelInfo_get_htlc_minimum_msat(this_ptr: &DirectionalChannelInfo) -> u64 {
747 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
750 /// The minimum value, which must be relayed to the next hop via the channel
752 pub extern "C" fn DirectionalChannelInfo_set_htlc_minimum_msat(this_ptr: &mut DirectionalChannelInfo, mut val: u64) {
753 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
755 /// The maximum value which may be relayed to the next hop via the channel.
757 pub extern "C" fn DirectionalChannelInfo_get_htlc_maximum_msat(this_ptr: &DirectionalChannelInfo) -> crate::c_types::derived::COption_u64Z {
758 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat;
759 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() }) };
762 /// The maximum value which may be relayed to the next hop via the channel.
764 pub extern "C" fn DirectionalChannelInfo_set_htlc_maximum_msat(this_ptr: &mut DirectionalChannelInfo, mut val: crate::c_types::derived::COption_u64Z) {
765 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
766 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = local_val;
768 /// Fees charged when the channel is used for routing
770 pub extern "C" fn DirectionalChannelInfo_get_fees(this_ptr: &DirectionalChannelInfo) -> crate::lightning::routing::network_graph::RoutingFees {
771 let mut inner_val = &mut this_ptr.get_native_mut_ref().fees;
772 crate::lightning::routing::network_graph::RoutingFees { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::network_graph::RoutingFees<>) as *mut _) }, is_owned: false }
774 /// Fees charged when the channel is used for routing
776 pub extern "C" fn DirectionalChannelInfo_set_fees(this_ptr: &mut DirectionalChannelInfo, mut val: crate::lightning::routing::network_graph::RoutingFees) {
777 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fees = *unsafe { Box::from_raw(val.take_inner()) };
779 /// Most recent update for the channel received from the network
780 /// Mostly redundant with the data we store in fields explicitly.
781 /// Everything else is useful only for sending out for initial routing sync.
782 /// Not stored if contains excess data to prevent DoS.
784 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
786 pub extern "C" fn DirectionalChannelInfo_get_last_update_message(this_ptr: &DirectionalChannelInfo) -> crate::lightning::ln::msgs::ChannelUpdate {
787 let mut inner_val = &mut this_ptr.get_native_mut_ref().last_update_message;
788 let mut local_inner_val = crate::lightning::ln::msgs::ChannelUpdate { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::ChannelUpdate<>) as *mut _ }, is_owned: false };
791 /// Most recent update for the channel received from the network
792 /// Mostly redundant with the data we store in fields explicitly.
793 /// Everything else is useful only for sending out for initial routing sync.
794 /// Not stored if contains excess data to prevent DoS.
796 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
798 pub extern "C" fn DirectionalChannelInfo_set_last_update_message(this_ptr: &mut DirectionalChannelInfo, mut val: crate::lightning::ln::msgs::ChannelUpdate) {
799 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
800 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.last_update_message = local_val;
802 /// Constructs a new DirectionalChannelInfo given each field
805 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 {
806 let mut local_htlc_maximum_msat_arg = if htlc_maximum_msat_arg.is_some() { Some( { htlc_maximum_msat_arg.take() }) } else { None };
807 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()) } }) };
808 DirectionalChannelInfo { inner: ObjOps::heap_alloc(nativeDirectionalChannelInfo {
809 last_update: last_update_arg,
810 enabled: enabled_arg,
811 cltv_expiry_delta: cltv_expiry_delta_arg,
812 htlc_minimum_msat: htlc_minimum_msat_arg,
813 htlc_maximum_msat: local_htlc_maximum_msat_arg,
814 fees: *unsafe { Box::from_raw(fees_arg.take_inner()) },
815 last_update_message: local_last_update_message_arg,
818 impl Clone for DirectionalChannelInfo {
819 fn clone(&self) -> Self {
821 inner: if <*mut nativeDirectionalChannelInfo>::is_null(self.inner) { core::ptr::null_mut() } else {
822 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
828 /// Used only if an object of this type is returned as a trait impl by a method
829 pub(crate) extern "C" fn DirectionalChannelInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
830 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDirectionalChannelInfo)).clone() })) as *mut c_void
833 /// Creates a copy of the DirectionalChannelInfo
834 pub extern "C" fn DirectionalChannelInfo_clone(orig: &DirectionalChannelInfo) -> DirectionalChannelInfo {
838 /// Serialize the DirectionalChannelInfo object into a byte array which can be read by DirectionalChannelInfo_read
839 pub extern "C" fn DirectionalChannelInfo_write(obj: &DirectionalChannelInfo) -> crate::c_types::derived::CVec_u8Z {
840 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
843 pub(crate) extern "C" fn DirectionalChannelInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
844 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeDirectionalChannelInfo) })
847 /// Read a DirectionalChannelInfo from a byte array, created by DirectionalChannelInfo_write
848 pub extern "C" fn DirectionalChannelInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_DirectionalChannelInfoDecodeErrorZ {
849 let res: Result<lightning::routing::network_graph::DirectionalChannelInfo, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
850 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::network_graph::DirectionalChannelInfo { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
854 use lightning::routing::network_graph::ChannelInfo as nativeChannelInfoImport;
855 pub(crate) type nativeChannelInfo = nativeChannelInfoImport;
857 /// Details about a channel (both directions).
858 /// Received within a channel announcement.
861 pub struct ChannelInfo {
862 /// A pointer to the opaque Rust object.
864 /// Nearly everywhere, inner must be non-null, however in places where
865 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
866 pub inner: *mut nativeChannelInfo,
867 /// Indicates that this is the only struct which contains the same pointer.
869 /// Rust functions which take ownership of an object provided via an argument require
870 /// this to be true and invalidate the object pointed to by inner.
874 impl Drop for ChannelInfo {
876 if self.is_owned && !<*mut nativeChannelInfo>::is_null(self.inner) {
877 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
881 /// Frees any resources used by the ChannelInfo, if is_owned is set and inner is non-NULL.
883 pub extern "C" fn ChannelInfo_free(this_obj: ChannelInfo) { }
885 /// Used only if an object of this type is returned as a trait impl by a method
886 pub(crate) extern "C" fn ChannelInfo_free_void(this_ptr: *mut c_void) {
887 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelInfo); }
891 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelInfo {
892 unsafe { &*ObjOps::untweak_ptr(self.inner) }
894 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelInfo {
895 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
897 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
898 pub(crate) fn take_inner(mut self) -> *mut nativeChannelInfo {
899 assert!(self.is_owned);
900 let ret = ObjOps::untweak_ptr(self.inner);
901 self.inner = core::ptr::null_mut();
905 /// Protocol features of a channel communicated during its announcement
907 pub extern "C" fn ChannelInfo_get_features(this_ptr: &ChannelInfo) -> crate::lightning::ln::features::ChannelFeatures {
908 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
909 crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::ChannelFeatures<>) as *mut _) }, is_owned: false }
911 /// Protocol features of a channel communicated during its announcement
913 pub extern "C" fn ChannelInfo_set_features(this_ptr: &mut ChannelInfo, mut val: crate::lightning::ln::features::ChannelFeatures) {
914 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
916 /// Source node of the first direction of a channel
918 pub extern "C" fn ChannelInfo_get_node_one(this_ptr: &ChannelInfo) -> crate::lightning::routing::network_graph::NodeId {
919 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_one;
920 crate::lightning::routing::network_graph::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::network_graph::NodeId<>) as *mut _) }, is_owned: false }
922 /// Source node of the first direction of a channel
924 pub extern "C" fn ChannelInfo_set_node_one(this_ptr: &mut ChannelInfo, mut val: crate::lightning::routing::network_graph::NodeId) {
925 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_one = *unsafe { Box::from_raw(val.take_inner()) };
927 /// Details about the first direction of a channel
929 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
931 pub extern "C" fn ChannelInfo_get_one_to_two(this_ptr: &ChannelInfo) -> crate::lightning::routing::network_graph::DirectionalChannelInfo {
932 let mut inner_val = &mut this_ptr.get_native_mut_ref().one_to_two;
933 let mut local_inner_val = crate::lightning::routing::network_graph::DirectionalChannelInfo { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::routing::network_graph::DirectionalChannelInfo<>) as *mut _ }, is_owned: false };
936 /// Details about the first direction of a channel
938 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
940 pub extern "C" fn ChannelInfo_set_one_to_two(this_ptr: &mut ChannelInfo, mut val: crate::lightning::routing::network_graph::DirectionalChannelInfo) {
941 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
942 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.one_to_two = local_val;
944 /// Source node of the second direction of a channel
946 pub extern "C" fn ChannelInfo_get_node_two(this_ptr: &ChannelInfo) -> crate::lightning::routing::network_graph::NodeId {
947 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_two;
948 crate::lightning::routing::network_graph::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::network_graph::NodeId<>) as *mut _) }, is_owned: false }
950 /// Source node of the second direction of a channel
952 pub extern "C" fn ChannelInfo_set_node_two(this_ptr: &mut ChannelInfo, mut val: crate::lightning::routing::network_graph::NodeId) {
953 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_two = *unsafe { Box::from_raw(val.take_inner()) };
955 /// Details about the second direction of a channel
957 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
959 pub extern "C" fn ChannelInfo_get_two_to_one(this_ptr: &ChannelInfo) -> crate::lightning::routing::network_graph::DirectionalChannelInfo {
960 let mut inner_val = &mut this_ptr.get_native_mut_ref().two_to_one;
961 let mut local_inner_val = crate::lightning::routing::network_graph::DirectionalChannelInfo { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::routing::network_graph::DirectionalChannelInfo<>) as *mut _ }, is_owned: false };
964 /// Details about the second direction of a channel
966 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
968 pub extern "C" fn ChannelInfo_set_two_to_one(this_ptr: &mut ChannelInfo, mut val: crate::lightning::routing::network_graph::DirectionalChannelInfo) {
969 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
970 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.two_to_one = local_val;
972 /// The channel capacity as seen on-chain, if chain lookup is available.
974 pub extern "C" fn ChannelInfo_get_capacity_sats(this_ptr: &ChannelInfo) -> crate::c_types::derived::COption_u64Z {
975 let mut inner_val = &mut this_ptr.get_native_mut_ref().capacity_sats;
976 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() }) };
979 /// The channel capacity as seen on-chain, if chain lookup is available.
981 pub extern "C" fn ChannelInfo_set_capacity_sats(this_ptr: &mut ChannelInfo, mut val: crate::c_types::derived::COption_u64Z) {
982 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
983 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.capacity_sats = local_val;
985 /// An initial announcement of the channel
986 /// Mostly redundant with the data we store in fields explicitly.
987 /// Everything else is useful only for sending out for initial routing sync.
988 /// Not stored if contains excess data to prevent DoS.
990 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
992 pub extern "C" fn ChannelInfo_get_announcement_message(this_ptr: &ChannelInfo) -> crate::lightning::ln::msgs::ChannelAnnouncement {
993 let mut inner_val = &mut this_ptr.get_native_mut_ref().announcement_message;
994 let mut local_inner_val = crate::lightning::ln::msgs::ChannelAnnouncement { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::ChannelAnnouncement<>) as *mut _ }, is_owned: false };
997 /// An initial announcement of the channel
998 /// Mostly redundant with the data we store in fields explicitly.
999 /// Everything else is useful only for sending out for initial routing sync.
1000 /// Not stored if contains excess data to prevent DoS.
1002 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1004 pub extern "C" fn ChannelInfo_set_announcement_message(this_ptr: &mut ChannelInfo, mut val: crate::lightning::ln::msgs::ChannelAnnouncement) {
1005 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1006 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.announcement_message = local_val;
1008 impl Clone for ChannelInfo {
1009 fn clone(&self) -> Self {
1011 inner: if <*mut nativeChannelInfo>::is_null(self.inner) { core::ptr::null_mut() } else {
1012 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1018 /// Used only if an object of this type is returned as a trait impl by a method
1019 pub(crate) extern "C" fn ChannelInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
1020 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelInfo)).clone() })) as *mut c_void
1023 /// Creates a copy of the ChannelInfo
1024 pub extern "C" fn ChannelInfo_clone(orig: &ChannelInfo) -> ChannelInfo {
1028 /// Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read
1029 pub extern "C" fn ChannelInfo_write(obj: &ChannelInfo) -> crate::c_types::derived::CVec_u8Z {
1030 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1033 pub(crate) extern "C" fn ChannelInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1034 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelInfo) })
1037 /// Read a ChannelInfo from a byte array, created by ChannelInfo_write
1038 pub extern "C" fn ChannelInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelInfoDecodeErrorZ {
1039 let res: Result<lightning::routing::network_graph::ChannelInfo, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
1040 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::network_graph::ChannelInfo { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
1044 use lightning::routing::network_graph::RoutingFees as nativeRoutingFeesImport;
1045 pub(crate) type nativeRoutingFees = nativeRoutingFeesImport;
1047 /// Fees for routing via a given channel or a node
1050 pub struct RoutingFees {
1051 /// A pointer to the opaque Rust object.
1053 /// Nearly everywhere, inner must be non-null, however in places where
1054 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1055 pub inner: *mut nativeRoutingFees,
1056 /// Indicates that this is the only struct which contains the same pointer.
1058 /// Rust functions which take ownership of an object provided via an argument require
1059 /// this to be true and invalidate the object pointed to by inner.
1063 impl Drop for RoutingFees {
1064 fn drop(&mut self) {
1065 if self.is_owned && !<*mut nativeRoutingFees>::is_null(self.inner) {
1066 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1070 /// Frees any resources used by the RoutingFees, if is_owned is set and inner is non-NULL.
1072 pub extern "C" fn RoutingFees_free(this_obj: RoutingFees) { }
1074 /// Used only if an object of this type is returned as a trait impl by a method
1075 pub(crate) extern "C" fn RoutingFees_free_void(this_ptr: *mut c_void) {
1076 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRoutingFees); }
1080 pub(crate) fn get_native_ref(&self) -> &'static nativeRoutingFees {
1081 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1083 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRoutingFees {
1084 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1086 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1087 pub(crate) fn take_inner(mut self) -> *mut nativeRoutingFees {
1088 assert!(self.is_owned);
1089 let ret = ObjOps::untweak_ptr(self.inner);
1090 self.inner = core::ptr::null_mut();
1094 /// Flat routing fee in satoshis
1096 pub extern "C" fn RoutingFees_get_base_msat(this_ptr: &RoutingFees) -> u32 {
1097 let mut inner_val = &mut this_ptr.get_native_mut_ref().base_msat;
1100 /// Flat routing fee in satoshis
1102 pub extern "C" fn RoutingFees_set_base_msat(this_ptr: &mut RoutingFees, mut val: u32) {
1103 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.base_msat = val;
1105 /// Liquidity-based routing fee in millionths of a routed amount.
1106 /// In other words, 10000 is 1%.
1108 pub extern "C" fn RoutingFees_get_proportional_millionths(this_ptr: &RoutingFees) -> u32 {
1109 let mut inner_val = &mut this_ptr.get_native_mut_ref().proportional_millionths;
1112 /// Liquidity-based routing fee in millionths of a routed amount.
1113 /// In other words, 10000 is 1%.
1115 pub extern "C" fn RoutingFees_set_proportional_millionths(this_ptr: &mut RoutingFees, mut val: u32) {
1116 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.proportional_millionths = val;
1118 /// Constructs a new RoutingFees given each field
1121 pub extern "C" fn RoutingFees_new(mut base_msat_arg: u32, mut proportional_millionths_arg: u32) -> RoutingFees {
1122 RoutingFees { inner: ObjOps::heap_alloc(nativeRoutingFees {
1123 base_msat: base_msat_arg,
1124 proportional_millionths: proportional_millionths_arg,
1125 }), is_owned: true }
1127 /// Checks if two RoutingFeess contain equal inner contents.
1128 /// This ignores pointers and is_owned flags and looks at the values in fields.
1129 /// Two objects with NULL inner values will be considered "equal" here.
1131 pub extern "C" fn RoutingFees_eq(a: &RoutingFees, b: &RoutingFees) -> bool {
1132 if a.inner == b.inner { return true; }
1133 if a.inner.is_null() || b.inner.is_null() { return false; }
1134 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1136 impl Clone for RoutingFees {
1137 fn clone(&self) -> Self {
1139 inner: if <*mut nativeRoutingFees>::is_null(self.inner) { core::ptr::null_mut() } else {
1140 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1146 /// Used only if an object of this type is returned as a trait impl by a method
1147 pub(crate) extern "C" fn RoutingFees_clone_void(this_ptr: *const c_void) -> *mut c_void {
1148 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRoutingFees)).clone() })) as *mut c_void
1151 /// Creates a copy of the RoutingFees
1152 pub extern "C" fn RoutingFees_clone(orig: &RoutingFees) -> RoutingFees {
1155 /// Checks if two RoutingFeess contain equal inner contents.
1157 pub extern "C" fn RoutingFees_hash(o: &RoutingFees) -> u64 {
1158 if o.inner.is_null() { return 0; }
1159 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1160 #[allow(deprecated)]
1161 let mut hasher = core::hash::SipHasher::new();
1162 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1163 core::hash::Hasher::finish(&hasher)
1166 /// Serialize the RoutingFees object into a byte array which can be read by RoutingFees_read
1167 pub extern "C" fn RoutingFees_write(obj: &RoutingFees) -> crate::c_types::derived::CVec_u8Z {
1168 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1171 pub(crate) extern "C" fn RoutingFees_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1172 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRoutingFees) })
1175 /// Read a RoutingFees from a byte array, created by RoutingFees_write
1176 pub extern "C" fn RoutingFees_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RoutingFeesDecodeErrorZ {
1177 let res: Result<lightning::routing::network_graph::RoutingFees, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
1178 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::network_graph::RoutingFees { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
1182 use lightning::routing::network_graph::NodeAnnouncementInfo as nativeNodeAnnouncementInfoImport;
1183 pub(crate) type nativeNodeAnnouncementInfo = nativeNodeAnnouncementInfoImport;
1185 /// Information received in the latest node_announcement from this node.
1188 pub struct NodeAnnouncementInfo {
1189 /// A pointer to the opaque Rust object.
1191 /// Nearly everywhere, inner must be non-null, however in places where
1192 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1193 pub inner: *mut nativeNodeAnnouncementInfo,
1194 /// Indicates that this is the only struct which contains the same pointer.
1196 /// Rust functions which take ownership of an object provided via an argument require
1197 /// this to be true and invalidate the object pointed to by inner.
1201 impl Drop for NodeAnnouncementInfo {
1202 fn drop(&mut self) {
1203 if self.is_owned && !<*mut nativeNodeAnnouncementInfo>::is_null(self.inner) {
1204 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1208 /// Frees any resources used by the NodeAnnouncementInfo, if is_owned is set and inner is non-NULL.
1210 pub extern "C" fn NodeAnnouncementInfo_free(this_obj: NodeAnnouncementInfo) { }
1212 /// Used only if an object of this type is returned as a trait impl by a method
1213 pub(crate) extern "C" fn NodeAnnouncementInfo_free_void(this_ptr: *mut c_void) {
1214 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAnnouncementInfo); }
1217 impl NodeAnnouncementInfo {
1218 pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncementInfo {
1219 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1221 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncementInfo {
1222 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1224 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1225 pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncementInfo {
1226 assert!(self.is_owned);
1227 let ret = ObjOps::untweak_ptr(self.inner);
1228 self.inner = core::ptr::null_mut();
1232 /// Protocol features the node announced support for
1234 pub extern "C" fn NodeAnnouncementInfo_get_features(this_ptr: &NodeAnnouncementInfo) -> crate::lightning::ln::features::NodeFeatures {
1235 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
1236 crate::lightning::ln::features::NodeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::NodeFeatures<>) as *mut _) }, is_owned: false }
1238 /// Protocol features the node announced support for
1240 pub extern "C" fn NodeAnnouncementInfo_set_features(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::lightning::ln::features::NodeFeatures) {
1241 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
1243 /// When the last known update to the node state was issued.
1244 /// Value is opaque, as set in the announcement.
1246 pub extern "C" fn NodeAnnouncementInfo_get_last_update(this_ptr: &NodeAnnouncementInfo) -> u32 {
1247 let mut inner_val = &mut this_ptr.get_native_mut_ref().last_update;
1250 /// When the last known update to the node state was issued.
1251 /// Value is opaque, as set in the announcement.
1253 pub extern "C" fn NodeAnnouncementInfo_set_last_update(this_ptr: &mut NodeAnnouncementInfo, mut val: u32) {
1254 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.last_update = val;
1256 /// Color assigned to the node
1258 pub extern "C" fn NodeAnnouncementInfo_get_rgb(this_ptr: &NodeAnnouncementInfo) -> *const [u8; 3] {
1259 let mut inner_val = &mut this_ptr.get_native_mut_ref().rgb;
1262 /// Color assigned to the node
1264 pub extern "C" fn NodeAnnouncementInfo_set_rgb(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::c_types::ThreeBytes) {
1265 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.rgb = val.data;
1267 /// Moniker assigned to the node.
1268 /// May be invalid or malicious (eg control chars),
1269 /// should not be exposed to the user.
1271 pub extern "C" fn NodeAnnouncementInfo_get_alias(this_ptr: &NodeAnnouncementInfo) -> *const [u8; 32] {
1272 let mut inner_val = &mut this_ptr.get_native_mut_ref().alias;
1275 /// Moniker assigned to the node.
1276 /// May be invalid or malicious (eg control chars),
1277 /// should not be exposed to the user.
1279 pub extern "C" fn NodeAnnouncementInfo_set_alias(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::c_types::ThirtyTwoBytes) {
1280 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = val.data;
1282 /// Internet-level addresses via which one can connect to the node
1284 pub extern "C" fn NodeAnnouncementInfo_set_addresses(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::c_types::derived::CVec_NetAddressZ) {
1285 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
1286 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.addresses = local_val;
1288 /// An initial announcement of the node
1289 /// Mostly redundant with the data we store in fields explicitly.
1290 /// Everything else is useful only for sending out for initial routing sync.
1291 /// Not stored if contains excess data to prevent DoS.
1293 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1295 pub extern "C" fn NodeAnnouncementInfo_get_announcement_message(this_ptr: &NodeAnnouncementInfo) -> crate::lightning::ln::msgs::NodeAnnouncement {
1296 let mut inner_val = &mut this_ptr.get_native_mut_ref().announcement_message;
1297 let mut local_inner_val = crate::lightning::ln::msgs::NodeAnnouncement { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::NodeAnnouncement<>) as *mut _ }, is_owned: false };
1300 /// An initial announcement of the node
1301 /// Mostly redundant with the data we store in fields explicitly.
1302 /// Everything else is useful only for sending out for initial routing sync.
1303 /// Not stored if contains excess data to prevent DoS.
1305 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1307 pub extern "C" fn NodeAnnouncementInfo_set_announcement_message(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::lightning::ln::msgs::NodeAnnouncement) {
1308 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1309 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.announcement_message = local_val;
1311 /// Constructs a new NodeAnnouncementInfo given each field
1314 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 {
1315 let mut local_addresses_arg = Vec::new(); for mut item in addresses_arg.into_rust().drain(..) { local_addresses_arg.push( { item.into_native() }); };
1316 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()) } }) };
1317 NodeAnnouncementInfo { inner: ObjOps::heap_alloc(nativeNodeAnnouncementInfo {
1318 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
1319 last_update: last_update_arg,
1321 alias: alias_arg.data,
1322 addresses: local_addresses_arg,
1323 announcement_message: local_announcement_message_arg,
1324 }), is_owned: true }
1326 impl Clone for NodeAnnouncementInfo {
1327 fn clone(&self) -> Self {
1329 inner: if <*mut nativeNodeAnnouncementInfo>::is_null(self.inner) { core::ptr::null_mut() } else {
1330 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1336 /// Used only if an object of this type is returned as a trait impl by a method
1337 pub(crate) extern "C" fn NodeAnnouncementInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
1338 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncementInfo)).clone() })) as *mut c_void
1341 /// Creates a copy of the NodeAnnouncementInfo
1342 pub extern "C" fn NodeAnnouncementInfo_clone(orig: &NodeAnnouncementInfo) -> NodeAnnouncementInfo {
1346 /// Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read
1347 pub extern "C" fn NodeAnnouncementInfo_write(obj: &NodeAnnouncementInfo) -> crate::c_types::derived::CVec_u8Z {
1348 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1351 pub(crate) extern "C" fn NodeAnnouncementInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1352 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncementInfo) })
1355 /// Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write
1356 pub extern "C" fn NodeAnnouncementInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementInfoDecodeErrorZ {
1357 let res: Result<lightning::routing::network_graph::NodeAnnouncementInfo, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
1358 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::network_graph::NodeAnnouncementInfo { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
1362 use lightning::routing::network_graph::NodeInfo as nativeNodeInfoImport;
1363 pub(crate) type nativeNodeInfo = nativeNodeInfoImport;
1365 /// Details about a node in the network, known from the network announcement.
1368 pub struct NodeInfo {
1369 /// A pointer to the opaque Rust object.
1371 /// Nearly everywhere, inner must be non-null, however in places where
1372 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1373 pub inner: *mut nativeNodeInfo,
1374 /// Indicates that this is the only struct which contains the same pointer.
1376 /// Rust functions which take ownership of an object provided via an argument require
1377 /// this to be true and invalidate the object pointed to by inner.
1381 impl Drop for NodeInfo {
1382 fn drop(&mut self) {
1383 if self.is_owned && !<*mut nativeNodeInfo>::is_null(self.inner) {
1384 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1388 /// Frees any resources used by the NodeInfo, if is_owned is set and inner is non-NULL.
1390 pub extern "C" fn NodeInfo_free(this_obj: NodeInfo) { }
1392 /// Used only if an object of this type is returned as a trait impl by a method
1393 pub(crate) extern "C" fn NodeInfo_free_void(this_ptr: *mut c_void) {
1394 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeInfo); }
1398 pub(crate) fn get_native_ref(&self) -> &'static nativeNodeInfo {
1399 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1401 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeInfo {
1402 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1404 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1405 pub(crate) fn take_inner(mut self) -> *mut nativeNodeInfo {
1406 assert!(self.is_owned);
1407 let ret = ObjOps::untweak_ptr(self.inner);
1408 self.inner = core::ptr::null_mut();
1412 /// All valid channels a node has announced
1414 pub extern "C" fn NodeInfo_set_channels(this_ptr: &mut NodeInfo, mut val: crate::c_types::derived::CVec_u64Z) {
1415 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
1416 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channels = local_val;
1418 /// Lowest fees enabling routing via any of the enabled, known channels to a node.
1419 /// The two fields (flat and proportional fee) are independent,
1420 /// meaning they don't have to refer to the same channel.
1422 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1424 pub extern "C" fn NodeInfo_get_lowest_inbound_channel_fees(this_ptr: &NodeInfo) -> crate::lightning::routing::network_graph::RoutingFees {
1425 let mut inner_val = &mut this_ptr.get_native_mut_ref().lowest_inbound_channel_fees;
1426 let mut local_inner_val = crate::lightning::routing::network_graph::RoutingFees { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::routing::network_graph::RoutingFees<>) as *mut _ }, is_owned: false };
1429 /// Lowest fees enabling routing via any of the enabled, known channels to a node.
1430 /// The two fields (flat and proportional fee) are independent,
1431 /// meaning they don't have to refer to the same channel.
1433 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1435 pub extern "C" fn NodeInfo_set_lowest_inbound_channel_fees(this_ptr: &mut NodeInfo, mut val: crate::lightning::routing::network_graph::RoutingFees) {
1436 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1437 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.lowest_inbound_channel_fees = local_val;
1439 /// More information about a node from node_announcement.
1440 /// Optional because we store a Node entry after learning about it from
1441 /// a channel announcement, but before receiving a node announcement.
1443 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1445 pub extern "C" fn NodeInfo_get_announcement_info(this_ptr: &NodeInfo) -> crate::lightning::routing::network_graph::NodeAnnouncementInfo {
1446 let mut inner_val = &mut this_ptr.get_native_mut_ref().announcement_info;
1447 let mut local_inner_val = crate::lightning::routing::network_graph::NodeAnnouncementInfo { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::routing::network_graph::NodeAnnouncementInfo<>) as *mut _ }, is_owned: false };
1450 /// More information about a node from node_announcement.
1451 /// Optional because we store a Node entry after learning about it from
1452 /// a channel announcement, but before receiving a node announcement.
1454 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1456 pub extern "C" fn NodeInfo_set_announcement_info(this_ptr: &mut NodeInfo, mut val: crate::lightning::routing::network_graph::NodeAnnouncementInfo) {
1457 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1458 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.announcement_info = local_val;
1460 /// Constructs a new NodeInfo given each field
1463 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 {
1464 let mut local_channels_arg = Vec::new(); for mut item in channels_arg.into_rust().drain(..) { local_channels_arg.push( { item }); };
1465 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()) } }) };
1466 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()) } }) };
1467 NodeInfo { inner: ObjOps::heap_alloc(nativeNodeInfo {
1468 channels: local_channels_arg,
1469 lowest_inbound_channel_fees: local_lowest_inbound_channel_fees_arg,
1470 announcement_info: local_announcement_info_arg,
1471 }), is_owned: true }
1473 impl Clone for NodeInfo {
1474 fn clone(&self) -> Self {
1476 inner: if <*mut nativeNodeInfo>::is_null(self.inner) { core::ptr::null_mut() } else {
1477 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1483 /// Used only if an object of this type is returned as a trait impl by a method
1484 pub(crate) extern "C" fn NodeInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
1485 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeInfo)).clone() })) as *mut c_void
1488 /// Creates a copy of the NodeInfo
1489 pub extern "C" fn NodeInfo_clone(orig: &NodeInfo) -> NodeInfo {
1493 /// Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read
1494 pub extern "C" fn NodeInfo_write(obj: &NodeInfo) -> crate::c_types::derived::CVec_u8Z {
1495 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1498 pub(crate) extern "C" fn NodeInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1499 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeInfo) })
1502 /// Read a NodeInfo from a byte array, created by NodeInfo_write
1503 pub extern "C" fn NodeInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeInfoDecodeErrorZ {
1504 let res: Result<lightning::routing::network_graph::NodeInfo, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
1505 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::network_graph::NodeInfo { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
1509 /// Serialize the NetworkGraph object into a byte array which can be read by NetworkGraph_read
1510 pub extern "C" fn NetworkGraph_write(obj: &NetworkGraph) -> crate::c_types::derived::CVec_u8Z {
1511 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1514 pub(crate) extern "C" fn NetworkGraph_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1515 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNetworkGraph) })
1518 /// Read a NetworkGraph from a byte array, created by NetworkGraph_write
1519 pub extern "C" fn NetworkGraph_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NetworkGraphDecodeErrorZ {
1520 let res: Result<lightning::routing::network_graph::NetworkGraph, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
1521 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::network_graph::NetworkGraph { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
1524 /// Creates a new, empty, network graph.
1527 pub extern "C" fn NetworkGraph_new(mut genesis_hash: crate::c_types::ThirtyTwoBytes) -> crate::lightning::routing::network_graph::NetworkGraph {
1528 let mut ret = lightning::routing::network_graph::NetworkGraph::new(::bitcoin::hash_types::BlockHash::from_slice(&genesis_hash.data[..]).unwrap());
1529 crate::lightning::routing::network_graph::NetworkGraph { inner: ObjOps::heap_alloc(ret), is_owned: true }
1532 /// Returns a read-only view of the network graph.
1535 pub extern "C" fn NetworkGraph_read_only(this_arg: &NetworkGraph) -> crate::lightning::routing::network_graph::ReadOnlyNetworkGraph {
1536 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.read_only();
1537 crate::lightning::routing::network_graph::ReadOnlyNetworkGraph { inner: ObjOps::heap_alloc(ret), is_owned: true }
1540 /// For an already known node (from channel announcements), update its stored properties from a
1541 /// given node announcement.
1543 /// You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's
1544 /// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
1545 /// routing messages from a source using a protocol other than the lightning P2P protocol.
1548 pub extern "C" fn NetworkGraph_update_node_from_announcement(this_arg: &NetworkGraph, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
1549 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_node_from_announcement(msg.get_native_ref(), secp256k1::SECP256K1);
1550 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: ObjOps::heap_alloc(e), is_owned: true } }).into() };
1554 /// For an already known node (from channel announcements), update its stored properties from a
1555 /// given node announcement without verifying the associated signatures. Because we aren't
1556 /// given the associated signatures here we cannot relay the node announcement to any of our
1560 pub extern "C" fn NetworkGraph_update_node_from_unsigned_announcement(this_arg: &NetworkGraph, msg: &crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
1561 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_node_from_unsigned_announcement(msg.get_native_ref());
1562 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: ObjOps::heap_alloc(e), is_owned: true } }).into() };
1566 /// Store or update channel info from a channel announcement.
1568 /// You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's
1569 /// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
1570 /// routing messages from a source using a protocol other than the lightning P2P protocol.
1572 /// If a `chain::Access` object is provided via `chain_access`, it will be called to verify
1573 /// the corresponding UTXO exists on chain and is correctly-formatted.
1576 pub extern "C" fn NetworkGraph_update_channel_from_announcement(this_arg: &NetworkGraph, msg: &crate::lightning::ln::msgs::ChannelAnnouncement, mut chain_access: crate::c_types::derived::COption_AccessZ) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
1577 let mut local_chain_access = { /* chain_access*/ let chain_access_opt = chain_access; { } if chain_access_opt.is_none() { None } else { Some({ chain_access_opt.take() }) } };
1578 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_channel_from_announcement(msg.get_native_ref(), &local_chain_access, secp256k1::SECP256K1);
1579 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: ObjOps::heap_alloc(e), is_owned: true } }).into() };
1583 /// Store or update channel info from a channel announcement without verifying the associated
1584 /// signatures. Because we aren't given the associated signatures here we cannot relay the
1585 /// channel announcement to any of our peers.
1587 /// If a `chain::Access` object is provided via `chain_access`, it will be called to verify
1588 /// the corresponding UTXO exists on chain and is correctly-formatted.
1591 pub extern "C" fn NetworkGraph_update_channel_from_unsigned_announcement(this_arg: &NetworkGraph, msg: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement, mut chain_access: crate::c_types::derived::COption_AccessZ) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
1592 let mut local_chain_access = { /* chain_access*/ let chain_access_opt = chain_access; { } if chain_access_opt.is_none() { None } else { Some({ chain_access_opt.take() }) } };
1593 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_channel_from_unsigned_announcement(msg.get_native_ref(), &local_chain_access);
1594 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: ObjOps::heap_alloc(e), is_owned: true } }).into() };
1598 /// Close a channel if a corresponding HTLC fail was sent.
1599 /// If permanent, removes a channel from the local storage.
1600 /// May cause the removal of nodes too, if this was their last channel.
1601 /// If not permanent, makes channels unavailable for routing.
1603 pub extern "C" fn NetworkGraph_close_channel_from_update(this_arg: &NetworkGraph, mut short_channel_id: u64, mut is_permanent: bool) {
1604 unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.close_channel_from_update(short_channel_id, is_permanent)
1607 /// Marks a node in the graph as failed.
1609 pub extern "C" fn NetworkGraph_fail_node(this_arg: &NetworkGraph, mut _node_id: crate::c_types::PublicKey, mut is_permanent: bool) {
1610 unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fail_node(&_node_id.into_rust(), is_permanent)
1613 /// Removes information about channels that we haven't heard any updates about in some time.
1614 /// This can be used regularly to prune the network graph of channels that likely no longer
1617 /// While there is no formal requirement that nodes regularly re-broadcast their channel
1618 /// updates every two weeks, the non-normative section of BOLT 7 currently suggests that
1619 /// pruning occur for updates which are at least two weeks old, which we implement here.
1621 /// This function takes the current unix time as an argument. For users with the `std` feature
1622 /// enabled, [`NetworkGraph::remove_stale_channels`] may be preferable.
1624 pub extern "C" fn NetworkGraph_remove_stale_channels_with_time(this_arg: &NetworkGraph, mut current_time_unix: u64) {
1625 unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.remove_stale_channels_with_time(current_time_unix)
1628 /// For an already known (from announcement) channel, update info about one of the directions
1631 /// You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's
1632 /// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
1633 /// routing messages from a source using a protocol other than the lightning P2P protocol.
1635 /// If built with `no-std`, any updates with a timestamp more than two weeks in the past or
1636 /// materially in the future will be rejected.
1639 pub extern "C" fn NetworkGraph_update_channel(this_arg: &NetworkGraph, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
1640 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_channel(msg.get_native_ref(), secp256k1::SECP256K1);
1641 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: ObjOps::heap_alloc(e), is_owned: true } }).into() };
1645 /// For an already known (from announcement) channel, update info about one of the directions
1646 /// of the channel without verifying the associated signatures. Because we aren't given the
1647 /// associated signatures here we cannot relay the channel update to any of our peers.
1649 /// If built with `no-std`, any updates with a timestamp more than two weeks in the past or
1650 /// materially in the future will be rejected.
1653 pub extern "C" fn NetworkGraph_update_channel_unsigned(this_arg: &NetworkGraph, msg: &crate::lightning::ln::msgs::UnsignedChannelUpdate) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
1654 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_channel_unsigned(msg.get_native_ref());
1655 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: ObjOps::heap_alloc(e), is_owned: true } }).into() };
1659 /// Get network addresses by node id.
1660 /// Returns None if the requested node is completely unknown,
1661 /// or if node announcement for the node was never received.
1664 pub extern "C" fn ReadOnlyNetworkGraph_get_addresses(this_arg: &ReadOnlyNetworkGraph, mut pubkey: crate::c_types::PublicKey) -> crate::c_types::derived::COption_CVec_NetAddressZZ {
1665 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_addresses(&pubkey.into_rust());
1666 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_CVec_NetAddressZZ::None } else { crate::c_types::derived::COption_CVec_NetAddressZZ::Some( { let mut local_ret_0 = Vec::new(); for mut item in ret.unwrap().drain(..) { local_ret_0.push( { crate::lightning::ln::msgs::NetAddress::native_into(item) }); }; local_ret_0.into() }) };