Update auto-generated bindings
[ldk-c-bindings] / lightning-c-bindings / src / lightning / routing / network_graph.rs
index 425a0001363f7510bd2fc8149fe50199688cf83c..15fd9c46fe99678f0c7170007307a5ce53a914e9 100644 (file)
@@ -8,15 +8,17 @@
 
 //! The top-level network map tracking logic lives here.
 
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
 use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
 
 
 use lightning::routing::network_graph::NodeId as nativeNodeIdImport;
-type nativeNodeId = nativeNodeIdImport;
+pub(crate) type nativeNodeId = nativeNodeIdImport;
 
 /// Represents the compressed public key of a node
 #[must_use]
@@ -46,7 +48,7 @@ impl Drop for NodeId {
 pub extern "C" fn NodeId_free(this_obj: NodeId) { }
 #[allow(unused)]
 /// Used only if an object of this type is returned as a trait impl by a method
-extern "C" fn NodeId_free_void(this_ptr: *mut c_void) {
+pub(crate) extern "C" fn NodeId_free_void(this_ptr: *mut c_void) {
        unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeId); }
 }
 #[allow(unused)]
@@ -61,14 +63,14 @@ impl NodeId {
        pub(crate) fn take_inner(mut self) -> *mut nativeNodeId {
                assert!(self.is_owned);
                let ret = ObjOps::untweak_ptr(self.inner);
-               self.inner = std::ptr::null_mut();
+               self.inner = core::ptr::null_mut();
                ret
        }
 }
 impl Clone for NodeId {
        fn clone(&self) -> Self {
                Self {
-                       inner: if <*mut nativeNodeId>::is_null(self.inner) { std::ptr::null_mut() } else {
+                       inner: if <*mut nativeNodeId>::is_null(self.inner) { core::ptr::null_mut() } else {
                                ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
                        is_owned: true,
                }
@@ -105,11 +107,11 @@ pub extern "C" fn NodeId_as_slice(this_arg: &NodeId) -> crate::c_types::u8slice
 #[no_mangle]
 pub extern "C" fn NodeId_hash(o: &NodeId) -> u64 {
        if o.inner.is_null() { return 0; }
-       // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+       // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
        #[allow(deprecated)]
        let mut hasher = core::hash::SipHasher::new();
-       std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
-       std::hash::Hasher::finish(&hasher)
+       core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+       core::hash::Hasher::finish(&hasher)
 }
 #[no_mangle]
 /// Serialize the NodeId object into a byte array which can be read by NodeId_read
@@ -123,13 +125,13 @@ pub(crate) extern "C" fn NodeId_write_void(obj: *const c_void) -> crate::c_types
 #[no_mangle]
 /// Read a NodeId from a byte array, created by NodeId_write
 pub extern "C" fn NodeId_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeIdDecodeErrorZ {
-       let res = crate::c_types::deserialize_obj(ser);
+       let res: Result<lightning::routing::network_graph::NodeId, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
        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() };
        local_res
 }
 
 use lightning::routing::network_graph::NetworkGraph as nativeNetworkGraphImport;
-type nativeNetworkGraph = nativeNetworkGraphImport;
+pub(crate) type nativeNetworkGraph = nativeNetworkGraphImport;
 
 /// Represents the network as nodes and channels between them
 #[must_use]
@@ -159,7 +161,7 @@ impl Drop for NetworkGraph {
 pub extern "C" fn NetworkGraph_free(this_obj: NetworkGraph) { }
 #[allow(unused)]
 /// Used only if an object of this type is returned as a trait impl by a method
-extern "C" fn NetworkGraph_free_void(this_ptr: *mut c_void) {
+pub(crate) extern "C" fn NetworkGraph_free_void(this_ptr: *mut c_void) {
        unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNetworkGraph); }
 }
 #[allow(unused)]
@@ -174,14 +176,14 @@ impl NetworkGraph {
        pub(crate) fn take_inner(mut self) -> *mut nativeNetworkGraph {
                assert!(self.is_owned);
                let ret = ObjOps::untweak_ptr(self.inner);
-               self.inner = std::ptr::null_mut();
+               self.inner = core::ptr::null_mut();
                ret
        }
 }
 impl Clone for NetworkGraph {
        fn clone(&self) -> Self {
                Self {
-                       inner: if <*mut nativeNetworkGraph>::is_null(self.inner) { std::ptr::null_mut() } else {
+                       inner: if <*mut nativeNetworkGraph>::is_null(self.inner) { core::ptr::null_mut() } else {
                                ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
                        is_owned: true,
                }
@@ -199,7 +201,7 @@ pub extern "C" fn NetworkGraph_clone(orig: &NetworkGraph) -> NetworkGraph {
 }
 
 use lightning::routing::network_graph::ReadOnlyNetworkGraph as nativeReadOnlyNetworkGraphImport;
-type nativeReadOnlyNetworkGraph = nativeReadOnlyNetworkGraphImport<'static>;
+pub(crate) type nativeReadOnlyNetworkGraph = nativeReadOnlyNetworkGraphImport<'static>;
 
 /// A read-only view of [`NetworkGraph`].
 #[must_use]
@@ -229,7 +231,7 @@ impl Drop for ReadOnlyNetworkGraph {
 pub extern "C" fn ReadOnlyNetworkGraph_free(this_obj: ReadOnlyNetworkGraph) { }
 #[allow(unused)]
 /// Used only if an object of this type is returned as a trait impl by a method
-extern "C" fn ReadOnlyNetworkGraph_free_void(this_ptr: *mut c_void) {
+pub(crate) extern "C" fn ReadOnlyNetworkGraph_free_void(this_ptr: *mut c_void) {
        unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReadOnlyNetworkGraph); }
 }
 #[allow(unused)]
@@ -244,7 +246,7 @@ impl ReadOnlyNetworkGraph {
        pub(crate) fn take_inner(mut self) -> *mut nativeReadOnlyNetworkGraph {
                assert!(self.is_owned);
                let ret = ObjOps::untweak_ptr(self.inner);
-               self.inner = std::ptr::null_mut();
+               self.inner = core::ptr::null_mut();
                ret
        }
 }
@@ -418,12 +420,19 @@ pub extern "C" fn NetworkUpdate_node_failure(node_id: crate::c_types::PublicKey,
 pub extern "C" fn NetworkUpdate_write(obj: &NetworkUpdate) -> crate::c_types::derived::CVec_u8Z {
        crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
 }
+#[no_mangle]
+/// Read a NetworkUpdate from a byte array, created by NetworkUpdate_write
+pub extern "C" fn NetworkUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_NetworkUpdateZDecodeErrorZ {
+       let res: Result<Option<lightning::routing::network_graph::NetworkUpdate>, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser);
+       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() };
+       local_res
+}
 impl From<nativeNetGraphMsgHandler> for crate::lightning::util::events::EventHandler {
        fn from(obj: nativeNetGraphMsgHandler) -> Self {
                let mut rust_obj = NetGraphMsgHandler { inner: ObjOps::heap_alloc(obj), is_owned: true };
                let mut ret = NetGraphMsgHandler_as_EventHandler(&rust_obj);
                // 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
-               rust_obj.inner = std::ptr::null_mut();
+               rust_obj.inner = core::ptr::null_mut();
                ret.free = Some(NetGraphMsgHandler_free_void);
                ret
        }
@@ -445,7 +454,7 @@ extern "C" fn NetGraphMsgHandler_EventHandler_handle_event(this_arg: *const c_vo
 
 
 use lightning::routing::network_graph::NetGraphMsgHandler as nativeNetGraphMsgHandlerImport;
-type nativeNetGraphMsgHandler = nativeNetGraphMsgHandlerImport<crate::lightning::chain::Access, crate::lightning::util::logger::Logger>;
+pub(crate) type nativeNetGraphMsgHandler = nativeNetGraphMsgHandlerImport<&'static lightning::routing::network_graph::NetworkGraph, crate::lightning::chain::Access, crate::lightning::util::logger::Logger>;
 
 /// Receives and validates network updates from peers,
 /// stores authentic and relevant data as a network graph.
@@ -482,7 +491,7 @@ impl Drop for NetGraphMsgHandler {
 pub extern "C" fn NetGraphMsgHandler_free(this_obj: NetGraphMsgHandler) { }
 #[allow(unused)]
 /// Used only if an object of this type is returned as a trait impl by a method
-extern "C" fn NetGraphMsgHandler_free_void(this_ptr: *mut c_void) {
+pub(crate) extern "C" fn NetGraphMsgHandler_free_void(this_ptr: *mut c_void) {
        unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNetGraphMsgHandler); }
 }
 #[allow(unused)]
@@ -497,21 +506,10 @@ impl NetGraphMsgHandler {
        pub(crate) fn take_inner(mut self) -> *mut nativeNetGraphMsgHandler {
                assert!(self.is_owned);
                let ret = ObjOps::untweak_ptr(self.inner);
-               self.inner = std::ptr::null_mut();
+               self.inner = core::ptr::null_mut();
                ret
        }
 }
-/// Representation of the payment channel network
-#[no_mangle]
-pub extern "C" fn NetGraphMsgHandler_get_network_graph(this_ptr: &NetGraphMsgHandler) -> crate::lightning::routing::network_graph::NetworkGraph {
-       let mut inner_val = &mut this_ptr.get_native_mut_ref().network_graph;
-       crate::lightning::routing::network_graph::NetworkGraph { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
-}
-/// Representation of the payment channel network
-#[no_mangle]
-pub extern "C" fn NetGraphMsgHandler_set_network_graph(this_ptr: &mut NetGraphMsgHandler, mut val: crate::lightning::routing::network_graph::NetworkGraph) {
-       unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.network_graph = *unsafe { Box::from_raw(val.take_inner()) };
-}
 /// Creates a new tracker of the actual state of the network of channels and nodes,
 /// assuming an existing Network Graph.
 /// Chain monitor is used to make sure announced channels exist on-chain,
@@ -519,9 +517,9 @@ pub extern "C" fn NetGraphMsgHandler_set_network_graph(this_ptr: &mut NetGraphMs
 /// channel owners' keys.
 #[must_use]
 #[no_mangle]
-pub extern "C" fn NetGraphMsgHandler_new(mut 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 {
+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 {
        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() }) } };
-       let mut ret = lightning::routing::network_graph::NetGraphMsgHandler::new(*unsafe { Box::from_raw(network_graph.take_inner()) }, local_chain_access, logger);
+       let mut ret = lightning::routing::network_graph::NetGraphMsgHandler::new(network_graph.get_native_ref(), local_chain_access, logger);
        NetGraphMsgHandler { inner: ObjOps::heap_alloc(ret), is_owned: true }
 }
 
@@ -539,7 +537,7 @@ impl From<nativeNetGraphMsgHandler> for crate::lightning::ln::msgs::RoutingMessa
                let mut rust_obj = NetGraphMsgHandler { inner: ObjOps::heap_alloc(obj), is_owned: true };
                let mut ret = NetGraphMsgHandler_as_RoutingMessageHandler(&rust_obj);
                // 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
-               rust_obj.inner = std::ptr::null_mut();
+               rust_obj.inner = core::ptr::null_mut();
                ret.free = Some(NetGraphMsgHandler_free_void);
                ret
        }
@@ -590,7 +588,7 @@ extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_channel_update(thi
 #[must_use]
 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 {
        let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::get_next_channel_announcements(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, starting_point, batch_amount);
-       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 {  { 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() { std::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 }); };
+       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 }); };
        local_ret.into()
 }
 #[must_use]
@@ -633,7 +631,7 @@ impl From<nativeNetGraphMsgHandler> for crate::lightning::util::events::MessageS
                let mut rust_obj = NetGraphMsgHandler { inner: ObjOps::heap_alloc(obj), is_owned: true };
                let mut ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&rust_obj);
                // 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
-               rust_obj.inner = std::ptr::null_mut();
+               rust_obj.inner = core::ptr::null_mut();
                ret.free = Some(NetGraphMsgHandler_free_void);
                ret
        }
@@ -658,7 +656,7 @@ extern "C" fn NetGraphMsgHandler_MessageSendEventsProvider_get_and_clear_pending
 
 
 use lightning::routing::network_graph::DirectionalChannelInfo as nativeDirectionalChannelInfoImport;
-type nativeDirectionalChannelInfo = nativeDirectionalChannelInfoImport;
+pub(crate) type nativeDirectionalChannelInfo = nativeDirectionalChannelInfoImport;
 
 /// Details about one direction of a channel. Received
 /// within a channel update.
@@ -689,7 +687,7 @@ impl Drop for DirectionalChannelInfo {
 pub extern "C" fn DirectionalChannelInfo_free(this_obj: DirectionalChannelInfo) { }
 #[allow(unused)]
 /// Used only if an object of this type is returned as a trait impl by a method
-extern "C" fn DirectionalChannelInfo_free_void(this_ptr: *mut c_void) {
+pub(crate) extern "C" fn DirectionalChannelInfo_free_void(this_ptr: *mut c_void) {
        unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDirectionalChannelInfo); }
 }
 #[allow(unused)]
@@ -704,7 +702,7 @@ impl DirectionalChannelInfo {
        pub(crate) fn take_inner(mut self) -> *mut nativeDirectionalChannelInfo {
                assert!(self.is_owned);
                let ret = ObjOps::untweak_ptr(self.inner);
-               self.inner = std::ptr::null_mut();
+               self.inner = core::ptr::null_mut();
                ret
        }
 }
@@ -771,7 +769,7 @@ pub extern "C" fn DirectionalChannelInfo_set_htlc_maximum_msat(this_ptr: &mut Di
 #[no_mangle]
 pub extern "C" fn DirectionalChannelInfo_get_fees(this_ptr: &DirectionalChannelInfo) -> crate::lightning::routing::network_graph::RoutingFees {
        let mut inner_val = &mut this_ptr.get_native_mut_ref().fees;
-       crate::lightning::routing::network_graph::RoutingFees { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
+       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 }
 }
 /// Fees charged when the channel is used for routing
 #[no_mangle]
@@ -787,7 +785,7 @@ pub extern "C" fn DirectionalChannelInfo_set_fees(this_ptr: &mut DirectionalChan
 #[no_mangle]
 pub extern "C" fn DirectionalChannelInfo_get_last_update_message(this_ptr: &DirectionalChannelInfo) -> crate::lightning::ln::msgs::ChannelUpdate {
        let mut inner_val = &mut this_ptr.get_native_mut_ref().last_update_message;
-       let mut local_inner_val = crate::lightning::ln::msgs::ChannelUpdate { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const _) as *mut _ }, is_owned: false };
+       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 };
        local_inner_val
 }
 /// Most recent update for the channel received from the network
@@ -820,7 +818,7 @@ pub extern "C" fn DirectionalChannelInfo_new(mut last_update_arg: u32, mut enabl
 impl Clone for DirectionalChannelInfo {
        fn clone(&self) -> Self {
                Self {
-                       inner: if <*mut nativeDirectionalChannelInfo>::is_null(self.inner) { std::ptr::null_mut() } else {
+                       inner: if <*mut nativeDirectionalChannelInfo>::is_null(self.inner) { core::ptr::null_mut() } else {
                                ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
                        is_owned: true,
                }
@@ -848,13 +846,13 @@ pub(crate) extern "C" fn DirectionalChannelInfo_write_void(obj: *const c_void) -
 #[no_mangle]
 /// Read a DirectionalChannelInfo from a byte array, created by DirectionalChannelInfo_write
 pub extern "C" fn DirectionalChannelInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_DirectionalChannelInfoDecodeErrorZ {
-       let res = crate::c_types::deserialize_obj(ser);
+       let res: Result<lightning::routing::network_graph::DirectionalChannelInfo, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
        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() };
        local_res
 }
 
 use lightning::routing::network_graph::ChannelInfo as nativeChannelInfoImport;
-type nativeChannelInfo = nativeChannelInfoImport;
+pub(crate) type nativeChannelInfo = nativeChannelInfoImport;
 
 /// Details about a channel (both directions).
 /// Received within a channel announcement.
@@ -885,7 +883,7 @@ impl Drop for ChannelInfo {
 pub extern "C" fn ChannelInfo_free(this_obj: ChannelInfo) { }
 #[allow(unused)]
 /// Used only if an object of this type is returned as a trait impl by a method
-extern "C" fn ChannelInfo_free_void(this_ptr: *mut c_void) {
+pub(crate) extern "C" fn ChannelInfo_free_void(this_ptr: *mut c_void) {
        unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelInfo); }
 }
 #[allow(unused)]
@@ -900,7 +898,7 @@ impl ChannelInfo {
        pub(crate) fn take_inner(mut self) -> *mut nativeChannelInfo {
                assert!(self.is_owned);
                let ret = ObjOps::untweak_ptr(self.inner);
-               self.inner = std::ptr::null_mut();
+               self.inner = core::ptr::null_mut();
                ret
        }
 }
@@ -908,7 +906,7 @@ impl ChannelInfo {
 #[no_mangle]
 pub extern "C" fn ChannelInfo_get_features(this_ptr: &ChannelInfo) -> crate::lightning::ln::features::ChannelFeatures {
        let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
-       crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
+       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 }
 }
 /// Protocol features of a channel communicated during its announcement
 #[no_mangle]
@@ -919,7 +917,7 @@ pub extern "C" fn ChannelInfo_set_features(this_ptr: &mut ChannelInfo, mut val:
 #[no_mangle]
 pub extern "C" fn ChannelInfo_get_node_one(this_ptr: &ChannelInfo) -> crate::lightning::routing::network_graph::NodeId {
        let mut inner_val = &mut this_ptr.get_native_mut_ref().node_one;
-       crate::lightning::routing::network_graph::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
+       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 }
 }
 /// Source node of the first direction of a channel
 #[no_mangle]
@@ -932,7 +930,7 @@ pub extern "C" fn ChannelInfo_set_node_one(this_ptr: &mut ChannelInfo, mut val:
 #[no_mangle]
 pub extern "C" fn ChannelInfo_get_one_to_two(this_ptr: &ChannelInfo) -> crate::lightning::routing::network_graph::DirectionalChannelInfo {
        let mut inner_val = &mut this_ptr.get_native_mut_ref().one_to_two;
-       let mut local_inner_val = crate::lightning::routing::network_graph::DirectionalChannelInfo { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const _) as *mut _ }, is_owned: false };
+       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 };
        local_inner_val
 }
 /// Details about the first direction of a channel
@@ -947,7 +945,7 @@ pub extern "C" fn ChannelInfo_set_one_to_two(this_ptr: &mut ChannelInfo, mut val
 #[no_mangle]
 pub extern "C" fn ChannelInfo_get_node_two(this_ptr: &ChannelInfo) -> crate::lightning::routing::network_graph::NodeId {
        let mut inner_val = &mut this_ptr.get_native_mut_ref().node_two;
-       crate::lightning::routing::network_graph::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
+       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 }
 }
 /// Source node of the second direction of a channel
 #[no_mangle]
@@ -960,7 +958,7 @@ pub extern "C" fn ChannelInfo_set_node_two(this_ptr: &mut ChannelInfo, mut val:
 #[no_mangle]
 pub extern "C" fn ChannelInfo_get_two_to_one(this_ptr: &ChannelInfo) -> crate::lightning::routing::network_graph::DirectionalChannelInfo {
        let mut inner_val = &mut this_ptr.get_native_mut_ref().two_to_one;
-       let mut local_inner_val = crate::lightning::routing::network_graph::DirectionalChannelInfo { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const _) as *mut _ }, is_owned: false };
+       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 };
        local_inner_val
 }
 /// Details about the second direction of a channel
@@ -993,7 +991,7 @@ pub extern "C" fn ChannelInfo_set_capacity_sats(this_ptr: &mut ChannelInfo, mut
 #[no_mangle]
 pub extern "C" fn ChannelInfo_get_announcement_message(this_ptr: &ChannelInfo) -> crate::lightning::ln::msgs::ChannelAnnouncement {
        let mut inner_val = &mut this_ptr.get_native_mut_ref().announcement_message;
-       let mut local_inner_val = crate::lightning::ln::msgs::ChannelAnnouncement { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const _) as *mut _ }, is_owned: false };
+       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 };
        local_inner_val
 }
 /// An initial announcement of the channel
@@ -1007,28 +1005,10 @@ pub extern "C" fn ChannelInfo_set_announcement_message(this_ptr: &mut ChannelInf
        let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
        unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.announcement_message = local_val;
 }
-/// Constructs a new ChannelInfo given each field
-#[must_use]
-#[no_mangle]
-pub extern "C" fn ChannelInfo_new(mut features_arg: crate::lightning::ln::features::ChannelFeatures, mut node_one_arg: crate::lightning::routing::network_graph::NodeId, mut one_to_two_arg: crate::lightning::routing::network_graph::DirectionalChannelInfo, mut node_two_arg: crate::lightning::routing::network_graph::NodeId, 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 {
-       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()) } }) };
-       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()) } }) };
-       let mut local_capacity_sats_arg = if capacity_sats_arg.is_some() { Some( { capacity_sats_arg.take() }) } else { None };
-       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()) } }) };
-       ChannelInfo { inner: ObjOps::heap_alloc(nativeChannelInfo {
-               features: *unsafe { Box::from_raw(features_arg.take_inner()) },
-               node_one: *unsafe { Box::from_raw(node_one_arg.take_inner()) },
-               one_to_two: local_one_to_two_arg,
-               node_two: *unsafe { Box::from_raw(node_two_arg.take_inner()) },
-               two_to_one: local_two_to_one_arg,
-               capacity_sats: local_capacity_sats_arg,
-               announcement_message: local_announcement_message_arg,
-       }), is_owned: true }
-}
 impl Clone for ChannelInfo {
        fn clone(&self) -> Self {
                Self {
-                       inner: if <*mut nativeChannelInfo>::is_null(self.inner) { std::ptr::null_mut() } else {
+                       inner: if <*mut nativeChannelInfo>::is_null(self.inner) { core::ptr::null_mut() } else {
                                ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
                        is_owned: true,
                }
@@ -1056,13 +1036,13 @@ pub(crate) extern "C" fn ChannelInfo_write_void(obj: *const c_void) -> crate::c_
 #[no_mangle]
 /// Read a ChannelInfo from a byte array, created by ChannelInfo_write
 pub extern "C" fn ChannelInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelInfoDecodeErrorZ {
-       let res = crate::c_types::deserialize_obj(ser);
+       let res: Result<lightning::routing::network_graph::ChannelInfo, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
        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() };
        local_res
 }
 
 use lightning::routing::network_graph::RoutingFees as nativeRoutingFeesImport;
-type nativeRoutingFees = nativeRoutingFeesImport;
+pub(crate) type nativeRoutingFees = nativeRoutingFeesImport;
 
 /// Fees for routing via a given channel or a node
 #[must_use]
@@ -1092,7 +1072,7 @@ impl Drop for RoutingFees {
 pub extern "C" fn RoutingFees_free(this_obj: RoutingFees) { }
 #[allow(unused)]
 /// Used only if an object of this type is returned as a trait impl by a method
-extern "C" fn RoutingFees_free_void(this_ptr: *mut c_void) {
+pub(crate) extern "C" fn RoutingFees_free_void(this_ptr: *mut c_void) {
        unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRoutingFees); }
 }
 #[allow(unused)]
@@ -1107,7 +1087,7 @@ impl RoutingFees {
        pub(crate) fn take_inner(mut self) -> *mut nativeRoutingFees {
                assert!(self.is_owned);
                let ret = ObjOps::untweak_ptr(self.inner);
-               self.inner = std::ptr::null_mut();
+               self.inner = core::ptr::null_mut();
                ret
        }
 }
@@ -1156,7 +1136,7 @@ pub extern "C" fn RoutingFees_eq(a: &RoutingFees, b: &RoutingFees) -> bool {
 impl Clone for RoutingFees {
        fn clone(&self) -> Self {
                Self {
-                       inner: if <*mut nativeRoutingFees>::is_null(self.inner) { std::ptr::null_mut() } else {
+                       inner: if <*mut nativeRoutingFees>::is_null(self.inner) { core::ptr::null_mut() } else {
                                ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
                        is_owned: true,
                }
@@ -1176,11 +1156,11 @@ pub extern "C" fn RoutingFees_clone(orig: &RoutingFees) -> RoutingFees {
 #[no_mangle]
 pub extern "C" fn RoutingFees_hash(o: &RoutingFees) -> u64 {
        if o.inner.is_null() { return 0; }
-       // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+       // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
        #[allow(deprecated)]
        let mut hasher = core::hash::SipHasher::new();
-       std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
-       std::hash::Hasher::finish(&hasher)
+       core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+       core::hash::Hasher::finish(&hasher)
 }
 #[no_mangle]
 /// Serialize the RoutingFees object into a byte array which can be read by RoutingFees_read
@@ -1194,13 +1174,13 @@ pub(crate) extern "C" fn RoutingFees_write_void(obj: *const c_void) -> crate::c_
 #[no_mangle]
 /// Read a RoutingFees from a byte array, created by RoutingFees_write
 pub extern "C" fn RoutingFees_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RoutingFeesDecodeErrorZ {
-       let res = crate::c_types::deserialize_obj(ser);
+       let res: Result<lightning::routing::network_graph::RoutingFees, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
        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() };
        local_res
 }
 
 use lightning::routing::network_graph::NodeAnnouncementInfo as nativeNodeAnnouncementInfoImport;
-type nativeNodeAnnouncementInfo = nativeNodeAnnouncementInfoImport;
+pub(crate) type nativeNodeAnnouncementInfo = nativeNodeAnnouncementInfoImport;
 
 /// Information received in the latest node_announcement from this node.
 #[must_use]
@@ -1230,7 +1210,7 @@ impl Drop for NodeAnnouncementInfo {
 pub extern "C" fn NodeAnnouncementInfo_free(this_obj: NodeAnnouncementInfo) { }
 #[allow(unused)]
 /// Used only if an object of this type is returned as a trait impl by a method
-extern "C" fn NodeAnnouncementInfo_free_void(this_ptr: *mut c_void) {
+pub(crate) extern "C" fn NodeAnnouncementInfo_free_void(this_ptr: *mut c_void) {
        unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAnnouncementInfo); }
 }
 #[allow(unused)]
@@ -1245,7 +1225,7 @@ impl NodeAnnouncementInfo {
        pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncementInfo {
                assert!(self.is_owned);
                let ret = ObjOps::untweak_ptr(self.inner);
-               self.inner = std::ptr::null_mut();
+               self.inner = core::ptr::null_mut();
                ret
        }
 }
@@ -1253,7 +1233,7 @@ impl NodeAnnouncementInfo {
 #[no_mangle]
 pub extern "C" fn NodeAnnouncementInfo_get_features(this_ptr: &NodeAnnouncementInfo) -> crate::lightning::ln::features::NodeFeatures {
        let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
-       crate::lightning::ln::features::NodeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
+       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 }
 }
 /// Protocol features the node announced support for
 #[no_mangle]
@@ -1314,7 +1294,7 @@ pub extern "C" fn NodeAnnouncementInfo_set_addresses(this_ptr: &mut NodeAnnounce
 #[no_mangle]
 pub extern "C" fn NodeAnnouncementInfo_get_announcement_message(this_ptr: &NodeAnnouncementInfo) -> crate::lightning::ln::msgs::NodeAnnouncement {
        let mut inner_val = &mut this_ptr.get_native_mut_ref().announcement_message;
-       let mut local_inner_val = crate::lightning::ln::msgs::NodeAnnouncement { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const _) as *mut _ }, is_owned: false };
+       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 };
        local_inner_val
 }
 /// An initial announcement of the node
@@ -1346,7 +1326,7 @@ pub extern "C" fn NodeAnnouncementInfo_new(mut features_arg: crate::lightning::l
 impl Clone for NodeAnnouncementInfo {
        fn clone(&self) -> Self {
                Self {
-                       inner: if <*mut nativeNodeAnnouncementInfo>::is_null(self.inner) { std::ptr::null_mut() } else {
+                       inner: if <*mut nativeNodeAnnouncementInfo>::is_null(self.inner) { core::ptr::null_mut() } else {
                                ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
                        is_owned: true,
                }
@@ -1374,13 +1354,13 @@ pub(crate) extern "C" fn NodeAnnouncementInfo_write_void(obj: *const c_void) ->
 #[no_mangle]
 /// Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write
 pub extern "C" fn NodeAnnouncementInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementInfoDecodeErrorZ {
-       let res = crate::c_types::deserialize_obj(ser);
+       let res: Result<lightning::routing::network_graph::NodeAnnouncementInfo, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
        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() };
        local_res
 }
 
 use lightning::routing::network_graph::NodeInfo as nativeNodeInfoImport;
-type nativeNodeInfo = nativeNodeInfoImport;
+pub(crate) type nativeNodeInfo = nativeNodeInfoImport;
 
 /// Details about a node in the network, known from the network announcement.
 #[must_use]
@@ -1410,7 +1390,7 @@ impl Drop for NodeInfo {
 pub extern "C" fn NodeInfo_free(this_obj: NodeInfo) { }
 #[allow(unused)]
 /// Used only if an object of this type is returned as a trait impl by a method
-extern "C" fn NodeInfo_free_void(this_ptr: *mut c_void) {
+pub(crate) extern "C" fn NodeInfo_free_void(this_ptr: *mut c_void) {
        unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeInfo); }
 }
 #[allow(unused)]
@@ -1425,7 +1405,7 @@ impl NodeInfo {
        pub(crate) fn take_inner(mut self) -> *mut nativeNodeInfo {
                assert!(self.is_owned);
                let ret = ObjOps::untweak_ptr(self.inner);
-               self.inner = std::ptr::null_mut();
+               self.inner = core::ptr::null_mut();
                ret
        }
 }
@@ -1443,7 +1423,7 @@ pub extern "C" fn NodeInfo_set_channels(this_ptr: &mut NodeInfo, mut val: crate:
 #[no_mangle]
 pub extern "C" fn NodeInfo_get_lowest_inbound_channel_fees(this_ptr: &NodeInfo) -> crate::lightning::routing::network_graph::RoutingFees {
        let mut inner_val = &mut this_ptr.get_native_mut_ref().lowest_inbound_channel_fees;
-       let mut local_inner_val = crate::lightning::routing::network_graph::RoutingFees { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const _) as *mut _ }, is_owned: false };
+       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 };
        local_inner_val
 }
 /// Lowest fees enabling routing via any of the enabled, known channels to a node.
@@ -1464,7 +1444,7 @@ pub extern "C" fn NodeInfo_set_lowest_inbound_channel_fees(this_ptr: &mut NodeIn
 #[no_mangle]
 pub extern "C" fn NodeInfo_get_announcement_info(this_ptr: &NodeInfo) -> crate::lightning::routing::network_graph::NodeAnnouncementInfo {
        let mut inner_val = &mut this_ptr.get_native_mut_ref().announcement_info;
-       let mut local_inner_val = crate::lightning::routing::network_graph::NodeAnnouncementInfo { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const _) as *mut _ }, is_owned: false };
+       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 };
        local_inner_val
 }
 /// More information about a node from node_announcement.
@@ -1493,7 +1473,7 @@ pub extern "C" fn NodeInfo_new(mut channels_arg: crate::c_types::derived::CVec_u
 impl Clone for NodeInfo {
        fn clone(&self) -> Self {
                Self {
-                       inner: if <*mut nativeNodeInfo>::is_null(self.inner) { std::ptr::null_mut() } else {
+                       inner: if <*mut nativeNodeInfo>::is_null(self.inner) { core::ptr::null_mut() } else {
                                ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
                        is_owned: true,
                }
@@ -1521,7 +1501,7 @@ pub(crate) extern "C" fn NodeInfo_write_void(obj: *const c_void) -> crate::c_typ
 #[no_mangle]
 /// Read a NodeInfo from a byte array, created by NodeInfo_write
 pub extern "C" fn NodeInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeInfoDecodeErrorZ {
-       let res = crate::c_types::deserialize_obj(ser);
+       let res: Result<lightning::routing::network_graph::NodeInfo, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
        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() };
        local_res
 }
@@ -1537,7 +1517,7 @@ pub(crate) extern "C" fn NetworkGraph_write_void(obj: *const c_void) -> crate::c
 #[no_mangle]
 /// Read a NetworkGraph from a byte array, created by NetworkGraph_write
 pub extern "C" fn NetworkGraph_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NetworkGraphDecodeErrorZ {
-       let res = crate::c_types::deserialize_obj(ser);
+       let res: Result<lightning::routing::network_graph::NetworkGraph, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
        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() };
        local_res
 }
@@ -1630,12 +1610,30 @@ pub extern "C" fn NetworkGraph_fail_node(this_arg: &NetworkGraph, mut _node_id:
        unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fail_node(&_node_id.into_rust(), is_permanent)
 }
 
+/// Removes information about channels that we haven't heard any updates about in some time.
+/// This can be used regularly to prune the network graph of channels that likely no longer
+/// exist.
+///
+/// While there is no formal requirement that nodes regularly re-broadcast their channel
+/// updates every two weeks, the non-normative section of BOLT 7 currently suggests that
+/// pruning occur for updates which are at least two weeks old, which we implement here.
+///
+/// This function takes the current unix time as an argument. For users with the `std` feature
+/// enabled, [`NetworkGraph::remove_stale_channels`] may be preferable.
+#[no_mangle]
+pub extern "C" fn NetworkGraph_remove_stale_channels_with_time(this_arg: &NetworkGraph, mut current_time_unix: u64) {
+       unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.remove_stale_channels_with_time(current_time_unix)
+}
+
 /// For an already known (from announcement) channel, update info about one of the directions
 /// of the channel.
 ///
 /// You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's
 /// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
 /// routing messages from a source using a protocol other than the lightning P2P protocol.
+///
+/// If built with `no-std`, any updates with a timestamp more than two weeks in the past or
+/// materially in the future will be rejected.
 #[must_use]
 #[no_mangle]
 pub extern "C" fn NetworkGraph_update_channel(this_arg: &NetworkGraph, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
@@ -1647,6 +1645,9 @@ pub extern "C" fn NetworkGraph_update_channel(this_arg: &NetworkGraph, msg: &cra
 /// For an already known (from announcement) channel, update info about one of the directions
 /// of the channel without verifying the associated signatures. Because we aren't given the
 /// associated signatures here we cannot relay the channel update to any of our peers.
+///
+/// If built with `no-std`, any updates with a timestamp more than two weeks in the past or
+/// materially in the future will be rejected.
 #[must_use]
 #[no_mangle]
 pub extern "C" fn NetworkGraph_update_channel_unsigned(this_arg: &NetworkGraph, msg: &crate::lightning::ln::msgs::UnsignedChannelUpdate) -> crate::c_types::derived::CResult_NoneLightningErrorZ {