Update auto-generated bindings to 0.0.113
[ldk-c-bindings] / lightning-c-bindings / src / lightning / routing / gossip.rs
index 7587e8e066007d6dec613d8924454ce3460e4fd6..a035af6871e94f2bf8f756cd92eb76da40b771db 100644 (file)
@@ -49,7 +49,7 @@ 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
 pub(crate) extern "C" fn NodeId_free_void(this_ptr: *mut c_void) {
-       unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeId); }
+       let _ = unsafe { Box::from_raw(this_ptr as *mut nativeNodeId) };
 }
 #[allow(unused)]
 impl NodeId {
@@ -126,7 +126,7 @@ pub(crate) extern "C" fn NodeId_write_void(obj: *const c_void) -> crate::c_types
 /// 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: Result<lightning::routing::gossip::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::gossip::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() };
+       let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::gossip::NodeId { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
        local_res
 }
 
@@ -162,7 +162,7 @@ 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
 pub(crate) extern "C" fn NetworkGraph_free_void(this_ptr: *mut c_void) {
-       unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNetworkGraph); }
+       let _ = unsafe { Box::from_raw(this_ptr as *mut nativeNetworkGraph) };
 }
 #[allow(unused)]
 impl NetworkGraph {
@@ -213,7 +213,7 @@ 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
 pub(crate) extern "C" fn ReadOnlyNetworkGraph_free_void(this_ptr: *mut c_void) {
-       unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReadOnlyNetworkGraph); }
+       let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReadOnlyNetworkGraph) };
 }
 #[allow(unused)]
 impl ReadOnlyNetworkGraph {
@@ -255,7 +255,7 @@ pub enum NetworkUpdate {
                is_permanent: bool,
        },
        /// An error indicating that a node failed to route a payment, which should be applied via
-       /// [`NetworkGraph::node_failed`].
+       /// [`NetworkGraph::node_failed_permanent`] if permanent.
        NodeFailure {
                /// The node id of the failed node.
                node_id: crate::c_types::PublicKey,
@@ -272,22 +272,22 @@ impl NetworkUpdate {
        pub(crate) fn to_native(&self) -> nativeNetworkUpdate {
                match self {
                        NetworkUpdate::ChannelUpdateMessage {ref msg, } => {
-                               let mut msg_nonref = (*msg).clone();
+                               let mut msg_nonref = Clone::clone(msg);
                                nativeNetworkUpdate::ChannelUpdateMessage {
                                        msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
                                }
                        },
                        NetworkUpdate::ChannelFailure {ref short_channel_id, ref is_permanent, } => {
-                               let mut short_channel_id_nonref = (*short_channel_id).clone();
-                               let mut is_permanent_nonref = (*is_permanent).clone();
+                               let mut short_channel_id_nonref = Clone::clone(short_channel_id);
+                               let mut is_permanent_nonref = Clone::clone(is_permanent);
                                nativeNetworkUpdate::ChannelFailure {
                                        short_channel_id: short_channel_id_nonref,
                                        is_permanent: is_permanent_nonref,
                                }
                        },
                        NetworkUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
-                               let mut node_id_nonref = (*node_id).clone();
-                               let mut is_permanent_nonref = (*is_permanent).clone();
+                               let mut node_id_nonref = Clone::clone(node_id);
+                               let mut is_permanent_nonref = Clone::clone(is_permanent);
                                nativeNetworkUpdate::NodeFailure {
                                        node_id: node_id_nonref.into_rust(),
                                        is_permanent: is_permanent_nonref,
@@ -321,22 +321,22 @@ impl NetworkUpdate {
        pub(crate) fn from_native(native: &nativeNetworkUpdate) -> Self {
                match native {
                        nativeNetworkUpdate::ChannelUpdateMessage {ref msg, } => {
-                               let mut msg_nonref = (*msg).clone();
+                               let mut msg_nonref = Clone::clone(msg);
                                NetworkUpdate::ChannelUpdateMessage {
                                        msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
                                }
                        },
                        nativeNetworkUpdate::ChannelFailure {ref short_channel_id, ref is_permanent, } => {
-                               let mut short_channel_id_nonref = (*short_channel_id).clone();
-                               let mut is_permanent_nonref = (*is_permanent).clone();
+                               let mut short_channel_id_nonref = Clone::clone(short_channel_id);
+                               let mut is_permanent_nonref = Clone::clone(is_permanent);
                                NetworkUpdate::ChannelFailure {
                                        short_channel_id: short_channel_id_nonref,
                                        is_permanent: is_permanent_nonref,
                                }
                        },
                        nativeNetworkUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
-                               let mut node_id_nonref = (*node_id).clone();
-                               let mut is_permanent_nonref = (*is_permanent).clone();
+                               let mut node_id_nonref = Clone::clone(node_id);
+                               let mut is_permanent_nonref = Clone::clone(is_permanent);
                                NetworkUpdate::NodeFailure {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
                                        is_permanent: is_permanent_nonref,
@@ -398,6 +398,12 @@ pub extern "C" fn NetworkUpdate_node_failure(node_id: crate::c_types::PublicKey,
                is_permanent,
        }
 }
+/// Checks if two NetworkUpdates contain equal inner contents.
+/// This ignores pointers and is_owned flags and looks at the values in fields.
+#[no_mangle]
+pub extern "C" fn NetworkUpdate_eq(a: &NetworkUpdate, b: &NetworkUpdate) -> bool {
+       if &a.to_native() == &b.to_native() { true } else { false }
+}
 #[no_mangle]
 /// Serialize the NetworkUpdate object into a byte array which can be read by NetworkUpdate_read
 pub extern "C" fn NetworkUpdate_write(obj: &crate::lightning::routing::gossip::NetworkUpdate) -> crate::c_types::derived::CVec_u8Z {
@@ -407,7 +413,7 @@ pub extern "C" fn NetworkUpdate_write(obj: &crate::lightning::routing::gossip::N
 /// 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::gossip::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::gossip::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() };
+       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::gossip::NetworkUpdate::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
        local_res
 }
 
@@ -419,9 +425,6 @@ pub(crate) type nativeP2PGossipSync = nativeP2PGossipSyncImport<&'static lightni
 /// This network graph is then used for routing payments.
 /// Provides interface to help with initial routing sync by
 /// serving historical announcements.
-///
-/// Serves as an [`EventHandler`] for applying updates from [`Event::PaymentPathFailed`] to the
-/// [`NetworkGraph`].
 #[must_use]
 #[repr(C)]
 pub struct P2PGossipSync {
@@ -450,7 +453,7 @@ pub extern "C" fn P2PGossipSync_free(this_obj: P2PGossipSync) { }
 #[allow(unused)]
 /// Used only if an object of this type is returned as a trait impl by a method
 pub(crate) extern "C" fn P2PGossipSync_free_void(this_ptr: *mut c_void) {
-       unsafe { let _ = Box::from_raw(this_ptr as *mut nativeP2PGossipSync); }
+       let _ = unsafe { Box::from_raw(this_ptr as *mut nativeP2PGossipSync) };
 }
 #[allow(unused)]
 impl P2PGossipSync {
@@ -490,29 +493,12 @@ pub extern "C" fn P2PGossipSync_add_chain_access(this_arg: &mut crate::lightning
        unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::gossip::nativeP2PGossipSync)) }.add_chain_access(local_chain_access)
 }
 
-impl From<nativeNetworkGraph> for crate::lightning::util::events::EventHandler {
-       fn from(obj: nativeNetworkGraph) -> Self {
-               let mut rust_obj = NetworkGraph { inner: ObjOps::heap_alloc(obj), is_owned: true };
-               let mut ret = NetworkGraph_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 = core::ptr::null_mut();
-               ret.free = Some(NetworkGraph_free_void);
-               ret
-       }
-}
-/// Constructs a new EventHandler which calls the relevant methods on this_arg.
-/// This copies the `inner` pointer in this_arg and thus the returned EventHandler must be freed before this_arg is
+/// Handles any network updates originating from [`Event`]s.
+///
+/// [`Event`]: crate::util::events::Event
 #[no_mangle]
-pub extern "C" fn NetworkGraph_as_EventHandler(this_arg: &NetworkGraph) -> crate::lightning::util::events::EventHandler {
-       crate::lightning::util::events::EventHandler {
-               this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
-               free: None,
-               handle_event: NetworkGraph_EventHandler_handle_event,
-       }
-}
-
-extern "C" fn NetworkGraph_EventHandler_handle_event(this_arg: *const c_void, event: &crate::lightning::util::events::Event) {
-       <nativeNetworkGraph as lightning::util::events::EventHandler<>>::handle_event(unsafe { &mut *(this_arg as *mut nativeNetworkGraph) }, &event.to_native())
+pub extern "C" fn NetworkGraph_handle_network_update(this_arg: &crate::lightning::routing::gossip::NetworkGraph, network_update: &crate::lightning::routing::gossip::NetworkUpdate) {
+       unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.handle_network_update(&network_update.to_native())
 }
 
 impl From<nativeP2PGossipSync> for crate::lightning::ln::msgs::RoutingMessageHandler {
@@ -583,8 +569,11 @@ extern "C" fn P2PGossipSync_RoutingMessageHandler_get_next_node_announcement(thi
        let mut local_ret = crate::lightning::ln::msgs::NodeAnnouncement { inner: if ret.is_none() { core::ptr::null_mut() } else {  { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true };
        local_ret
 }
-extern "C" fn P2PGossipSync_RoutingMessageHandler_peer_connected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init) {
-       <nativeP2PGossipSync as lightning::ln::msgs::RoutingMessageHandler<>>::peer_connected(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, &their_node_id.into_rust(), init.get_native_ref())
+#[must_use]
+extern "C" fn P2PGossipSync_RoutingMessageHandler_peer_connected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init) -> crate::c_types::derived::CResult_NoneNoneZ {
+       let mut ret = <nativeP2PGossipSync as lightning::ln::msgs::RoutingMessageHandler<>>::peer_connected(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, &their_node_id.into_rust(), init.get_native_ref());
+       let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
+       local_ret
 }
 #[must_use]
 extern "C" fn P2PGossipSync_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 {
@@ -682,7 +671,7 @@ pub extern "C" fn ChannelUpdateInfo_free(this_obj: ChannelUpdateInfo) { }
 #[allow(unused)]
 /// Used only if an object of this type is returned as a trait impl by a method
 pub(crate) extern "C" fn ChannelUpdateInfo_free_void(this_ptr: *mut c_void) {
-       unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelUpdateInfo); }
+       let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelUpdateInfo) };
 }
 #[allow(unused)]
 impl ChannelUpdateInfo {
@@ -825,6 +814,15 @@ pub(crate) extern "C" fn ChannelUpdateInfo_clone_void(this_ptr: *const c_void) -
 pub extern "C" fn ChannelUpdateInfo_clone(orig: &ChannelUpdateInfo) -> ChannelUpdateInfo {
        orig.clone()
 }
+/// Checks if two ChannelUpdateInfos contain equal inner contents.
+/// This ignores pointers and is_owned flags and looks at the values in fields.
+/// Two objects with NULL inner values will be considered "equal" here.
+#[no_mangle]
+pub extern "C" fn ChannelUpdateInfo_eq(a: &ChannelUpdateInfo, b: &ChannelUpdateInfo) -> bool {
+       if a.inner == b.inner { return true; }
+       if a.inner.is_null() || b.inner.is_null() { return false; }
+       if a.get_native_ref() == b.get_native_ref() { true } else { false }
+}
 #[no_mangle]
 /// Serialize the ChannelUpdateInfo object into a byte array which can be read by ChannelUpdateInfo_read
 pub extern "C" fn ChannelUpdateInfo_write(obj: &crate::lightning::routing::gossip::ChannelUpdateInfo) -> crate::c_types::derived::CVec_u8Z {
@@ -838,7 +836,7 @@ pub(crate) extern "C" fn ChannelUpdateInfo_write_void(obj: *const c_void) -> cra
 /// Read a ChannelUpdateInfo from a byte array, created by ChannelUpdateInfo_write
 pub extern "C" fn ChannelUpdateInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateInfoDecodeErrorZ {
        let res: Result<lightning::routing::gossip::ChannelUpdateInfo, 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::gossip::ChannelUpdateInfo { 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() };
+       let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::gossip::ChannelUpdateInfo { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
        local_res
 }
 
@@ -875,7 +873,7 @@ 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
 pub(crate) extern "C" fn ChannelInfo_free_void(this_ptr: *mut c_void) {
-       unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelInfo); }
+       let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelInfo) };
 }
 #[allow(unused)]
 impl ChannelInfo {
@@ -1015,6 +1013,15 @@ pub(crate) extern "C" fn ChannelInfo_clone_void(this_ptr: *const c_void) -> *mut
 pub extern "C" fn ChannelInfo_clone(orig: &ChannelInfo) -> ChannelInfo {
        orig.clone()
 }
+/// Checks if two ChannelInfos contain equal inner contents.
+/// This ignores pointers and is_owned flags and looks at the values in fields.
+/// Two objects with NULL inner values will be considered "equal" here.
+#[no_mangle]
+pub extern "C" fn ChannelInfo_eq(a: &ChannelInfo, b: &ChannelInfo) -> bool {
+       if a.inner == b.inner { return true; }
+       if a.inner.is_null() || b.inner.is_null() { return false; }
+       if a.get_native_ref() == b.get_native_ref() { true } else { false }
+}
 /// Returns a [`ChannelUpdateInfo`] based on the direction implied by the channel_flag.
 ///
 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
@@ -1039,7 +1046,7 @@ pub(crate) extern "C" fn ChannelInfo_write_void(obj: *const c_void) -> crate::c_
 /// 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: Result<lightning::routing::gossip::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::gossip::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() };
+       let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::gossip::ChannelInfo { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
        local_res
 }
 
@@ -1076,7 +1083,7 @@ pub extern "C" fn DirectedChannelInfo_free(this_obj: DirectedChannelInfo) { }
 #[allow(unused)]
 /// Used only if an object of this type is returned as a trait impl by a method
 pub(crate) extern "C" fn DirectedChannelInfo_free_void(this_ptr: *mut c_void) {
-       unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDirectedChannelInfo); }
+       let _ = unsafe { Box::from_raw(this_ptr as *mut nativeDirectedChannelInfo) };
 }
 #[allow(unused)]
 impl DirectedChannelInfo {
@@ -1121,17 +1128,6 @@ pub extern "C" fn DirectedChannelInfo_channel(this_arg: &crate::lightning::routi
        crate::lightning::routing::gossip::ChannelInfo { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::routing::gossip::ChannelInfo<>) as *mut _) }, is_owned: false }
 }
 
-/// Returns information for the direction.
-///
-/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
-#[must_use]
-#[no_mangle]
-pub extern "C" fn DirectedChannelInfo_direction(this_arg: &crate::lightning::routing::gossip::DirectedChannelInfo) -> crate::lightning::routing::gossip::ChannelUpdateInfo {
-       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.direction();
-       let mut local_ret = crate::lightning::routing::gossip::ChannelUpdateInfo { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::routing::gossip::ChannelUpdateInfo<>) as *mut _ }, is_owned: false };
-       local_ret
-}
-
 /// Returns the maximum HTLC amount allowed over the channel in the direction.
 #[must_use]
 #[no_mangle]
@@ -1177,7 +1173,7 @@ pub enum EffectiveCapacity {
                /// The funding amount denominated in millisatoshi.
                capacity_msat: u64,
                /// The maximum HTLC amount denominated in millisatoshi.
-               htlc_maximum_msat: crate::c_types::derived::COption_u64Z,
+               htlc_maximum_msat: u64,
        },
        /// A capacity sufficient to route any payment, typically used for private channels provided by
        /// an invoice.
@@ -1194,24 +1190,23 @@ impl EffectiveCapacity {
        pub(crate) fn to_native(&self) -> nativeEffectiveCapacity {
                match self {
                        EffectiveCapacity::ExactLiquidity {ref liquidity_msat, } => {
-                               let mut liquidity_msat_nonref = (*liquidity_msat).clone();
+                               let mut liquidity_msat_nonref = Clone::clone(liquidity_msat);
                                nativeEffectiveCapacity::ExactLiquidity {
                                        liquidity_msat: liquidity_msat_nonref,
                                }
                        },
                        EffectiveCapacity::MaximumHTLC {ref amount_msat, } => {
-                               let mut amount_msat_nonref = (*amount_msat).clone();
+                               let mut amount_msat_nonref = Clone::clone(amount_msat);
                                nativeEffectiveCapacity::MaximumHTLC {
                                        amount_msat: amount_msat_nonref,
                                }
                        },
                        EffectiveCapacity::Total {ref capacity_msat, ref htlc_maximum_msat, } => {
-                               let mut capacity_msat_nonref = (*capacity_msat).clone();
-                               let mut htlc_maximum_msat_nonref = (*htlc_maximum_msat).clone();
-                               let mut local_htlc_maximum_msat_nonref = if htlc_maximum_msat_nonref.is_some() { Some( { htlc_maximum_msat_nonref.take() }) } else { None };
+                               let mut capacity_msat_nonref = Clone::clone(capacity_msat);
+                               let mut htlc_maximum_msat_nonref = Clone::clone(htlc_maximum_msat);
                                nativeEffectiveCapacity::Total {
                                        capacity_msat: capacity_msat_nonref,
-                                       htlc_maximum_msat: local_htlc_maximum_msat_nonref,
+                                       htlc_maximum_msat: htlc_maximum_msat_nonref,
                                }
                        },
                        EffectiveCapacity::Infinite => nativeEffectiveCapacity::Infinite,
@@ -1232,10 +1227,9 @@ impl EffectiveCapacity {
                                }
                        },
                        EffectiveCapacity::Total {mut capacity_msat, mut htlc_maximum_msat, } => {
-                               let mut local_htlc_maximum_msat = if htlc_maximum_msat.is_some() { Some( { htlc_maximum_msat.take() }) } else { None };
                                nativeEffectiveCapacity::Total {
                                        capacity_msat: capacity_msat,
-                                       htlc_maximum_msat: local_htlc_maximum_msat,
+                                       htlc_maximum_msat: htlc_maximum_msat,
                                }
                        },
                        EffectiveCapacity::Infinite => nativeEffectiveCapacity::Infinite,
@@ -1246,24 +1240,23 @@ impl EffectiveCapacity {
        pub(crate) fn from_native(native: &nativeEffectiveCapacity) -> Self {
                match native {
                        nativeEffectiveCapacity::ExactLiquidity {ref liquidity_msat, } => {
-                               let mut liquidity_msat_nonref = (*liquidity_msat).clone();
+                               let mut liquidity_msat_nonref = Clone::clone(liquidity_msat);
                                EffectiveCapacity::ExactLiquidity {
                                        liquidity_msat: liquidity_msat_nonref,
                                }
                        },
                        nativeEffectiveCapacity::MaximumHTLC {ref amount_msat, } => {
-                               let mut amount_msat_nonref = (*amount_msat).clone();
+                               let mut amount_msat_nonref = Clone::clone(amount_msat);
                                EffectiveCapacity::MaximumHTLC {
                                        amount_msat: amount_msat_nonref,
                                }
                        },
                        nativeEffectiveCapacity::Total {ref capacity_msat, ref htlc_maximum_msat, } => {
-                               let mut capacity_msat_nonref = (*capacity_msat).clone();
-                               let mut htlc_maximum_msat_nonref = (*htlc_maximum_msat).clone();
-                               let mut local_htlc_maximum_msat_nonref = if htlc_maximum_msat_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { htlc_maximum_msat_nonref.unwrap() }) };
+                               let mut capacity_msat_nonref = Clone::clone(capacity_msat);
+                               let mut htlc_maximum_msat_nonref = Clone::clone(htlc_maximum_msat);
                                EffectiveCapacity::Total {
                                        capacity_msat: capacity_msat_nonref,
-                                       htlc_maximum_msat: local_htlc_maximum_msat_nonref,
+                                       htlc_maximum_msat: htlc_maximum_msat_nonref,
                                }
                        },
                        nativeEffectiveCapacity::Infinite => EffectiveCapacity::Infinite,
@@ -1284,10 +1277,9 @@ impl EffectiveCapacity {
                                }
                        },
                        nativeEffectiveCapacity::Total {mut capacity_msat, mut htlc_maximum_msat, } => {
-                               let mut local_htlc_maximum_msat = if htlc_maximum_msat.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { htlc_maximum_msat.unwrap() }) };
                                EffectiveCapacity::Total {
                                        capacity_msat: capacity_msat,
-                                       htlc_maximum_msat: local_htlc_maximum_msat,
+                                       htlc_maximum_msat: htlc_maximum_msat,
                                }
                        },
                        nativeEffectiveCapacity::Infinite => EffectiveCapacity::Infinite,
@@ -1319,7 +1311,7 @@ pub extern "C" fn EffectiveCapacity_maximum_htlc(amount_msat: u64) -> EffectiveC
 }
 #[no_mangle]
 /// Utility method to constructs a new Total-variant EffectiveCapacity
-pub extern "C" fn EffectiveCapacity_total(capacity_msat: u64, htlc_maximum_msat: crate::c_types::derived::COption_u64Z) -> EffectiveCapacity {
+pub extern "C" fn EffectiveCapacity_total(capacity_msat: u64, htlc_maximum_msat: u64) -> EffectiveCapacity {
        EffectiveCapacity::Total {
                capacity_msat,
                htlc_maximum_msat,
@@ -1379,7 +1371,7 @@ 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
 pub(crate) extern "C" fn RoutingFees_free_void(this_ptr: *mut c_void) {
-       unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRoutingFees); }
+       let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRoutingFees) };
 }
 #[allow(unused)]
 impl RoutingFees {
@@ -1481,7 +1473,7 @@ pub(crate) extern "C" fn RoutingFees_write_void(obj: *const c_void) -> crate::c_
 /// 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: Result<lightning::routing::gossip::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::gossip::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() };
+       let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::gossip::RoutingFees { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
        local_res
 }
 
@@ -1517,7 +1509,7 @@ 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
 pub(crate) extern "C" fn NodeAnnouncementInfo_free_void(this_ptr: *mut c_void) {
-       unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAnnouncementInfo); }
+       let _ = unsafe { Box::from_raw(this_ptr as *mut nativeNodeAnnouncementInfo) };
 }
 #[allow(unused)]
 impl NodeAnnouncementInfo {
@@ -1657,6 +1649,15 @@ pub(crate) extern "C" fn NodeAnnouncementInfo_clone_void(this_ptr: *const c_void
 pub extern "C" fn NodeAnnouncementInfo_clone(orig: &NodeAnnouncementInfo) -> NodeAnnouncementInfo {
        orig.clone()
 }
+/// Checks if two NodeAnnouncementInfos contain equal inner contents.
+/// This ignores pointers and is_owned flags and looks at the values in fields.
+/// Two objects with NULL inner values will be considered "equal" here.
+#[no_mangle]
+pub extern "C" fn NodeAnnouncementInfo_eq(a: &NodeAnnouncementInfo, b: &NodeAnnouncementInfo) -> bool {
+       if a.inner == b.inner { return true; }
+       if a.inner.is_null() || b.inner.is_null() { return false; }
+       if a.get_native_ref() == b.get_native_ref() { true } else { false }
+}
 #[no_mangle]
 /// Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read
 pub extern "C" fn NodeAnnouncementInfo_write(obj: &crate::lightning::routing::gossip::NodeAnnouncementInfo) -> crate::c_types::derived::CVec_u8Z {
@@ -1670,7 +1671,7 @@ pub(crate) extern "C" fn NodeAnnouncementInfo_write_void(obj: *const c_void) ->
 /// 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: Result<lightning::routing::gossip::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::gossip::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() };
+       let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::gossip::NodeAnnouncementInfo { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
        local_res
 }
 
@@ -1709,7 +1710,7 @@ pub extern "C" fn NodeAlias_free(this_obj: NodeAlias) { }
 #[allow(unused)]
 /// Used only if an object of this type is returned as a trait impl by a method
 pub(crate) extern "C" fn NodeAlias_free_void(this_ptr: *mut c_void) {
-       unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAlias); }
+       let _ = unsafe { Box::from_raw(this_ptr as *mut nativeNodeAlias) };
 }
 #[allow(unused)]
 impl NodeAlias {
@@ -1763,6 +1764,15 @@ pub(crate) extern "C" fn NodeAlias_clone_void(this_ptr: *const c_void) -> *mut c
 pub extern "C" fn NodeAlias_clone(orig: &NodeAlias) -> NodeAlias {
        orig.clone()
 }
+/// Checks if two NodeAliass contain equal inner contents.
+/// This ignores pointers and is_owned flags and looks at the values in fields.
+/// Two objects with NULL inner values will be considered "equal" here.
+#[no_mangle]
+pub extern "C" fn NodeAlias_eq(a: &NodeAlias, b: &NodeAlias) -> bool {
+       if a.inner == b.inner { return true; }
+       if a.inner.is_null() || b.inner.is_null() { return false; }
+       if a.get_native_ref() == b.get_native_ref() { true } else { false }
+}
 #[no_mangle]
 /// Serialize the NodeAlias object into a byte array which can be read by NodeAlias_read
 pub extern "C" fn NodeAlias_write(obj: &crate::lightning::routing::gossip::NodeAlias) -> crate::c_types::derived::CVec_u8Z {
@@ -1776,7 +1786,7 @@ pub(crate) extern "C" fn NodeAlias_write_void(obj: *const c_void) -> crate::c_ty
 /// Read a NodeAlias from a byte array, created by NodeAlias_write
 pub extern "C" fn NodeAlias_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAliasDecodeErrorZ {
        let res: Result<lightning::routing::gossip::NodeAlias, 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::gossip::NodeAlias { 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() };
+       let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::gossip::NodeAlias { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
        local_res
 }
 
@@ -1812,7 +1822,7 @@ 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
 pub(crate) extern "C" fn NodeInfo_free_void(this_ptr: *mut c_void) {
-       unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeInfo); }
+       let _ = unsafe { Box::from_raw(this_ptr as *mut nativeNodeInfo) };
 }
 #[allow(unused)]
 impl NodeInfo {
@@ -1919,6 +1929,15 @@ pub(crate) extern "C" fn NodeInfo_clone_void(this_ptr: *const c_void) -> *mut c_
 pub extern "C" fn NodeInfo_clone(orig: &NodeInfo) -> NodeInfo {
        orig.clone()
 }
+/// Checks if two NodeInfos contain equal inner contents.
+/// This ignores pointers and is_owned flags and looks at the values in fields.
+/// Two objects with NULL inner values will be considered "equal" here.
+#[no_mangle]
+pub extern "C" fn NodeInfo_eq(a: &NodeInfo, b: &NodeInfo) -> bool {
+       if a.inner == b.inner { return true; }
+       if a.inner.is_null() || b.inner.is_null() { return false; }
+       if a.get_native_ref() == b.get_native_ref() { true } else { false }
+}
 #[no_mangle]
 /// Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read
 pub extern "C" fn NodeInfo_write(obj: &crate::lightning::routing::gossip::NodeInfo) -> crate::c_types::derived::CVec_u8Z {
@@ -1932,7 +1951,7 @@ pub(crate) extern "C" fn NodeInfo_write_void(obj: *const c_void) -> crate::c_typ
 /// 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: Result<lightning::routing::gossip::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::gossip::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() };
+       let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::gossip::NodeInfo { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
        local_res
 }
 #[no_mangle]
@@ -1949,7 +1968,7 @@ pub(crate) extern "C" fn NetworkGraph_write_void(obj: *const c_void) -> crate::c
 pub extern "C" fn NetworkGraph_read(ser: crate::c_types::u8slice, arg: crate::lightning::util::logger::Logger) -> crate::c_types::derived::CResult_NetworkGraphDecodeErrorZ {
        let arg_conv = arg;
        let res: Result<lightning::routing::gossip::NetworkGraph<crate::lightning::util::logger::Logger>, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj_arg(ser, arg_conv);
-       let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::gossip::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() };
+       let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::gossip::NetworkGraph { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
        local_res
 }
 /// Creates a new, empty, network graph.
@@ -2066,10 +2085,11 @@ pub extern "C" fn NetworkGraph_channel_failed(this_arg: &crate::lightning::routi
        unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel_failed(short_channel_id, is_permanent)
 }
 
-/// Marks a node in the graph as failed.
+/// Marks a node in the graph as permanently failed, effectively removing it and its channels
+/// from local storage.
 #[no_mangle]
-pub extern "C" fn NetworkGraph_node_failed(this_arg: &crate::lightning::routing::gossip::NetworkGraph, mut _node_id: crate::c_types::PublicKey, mut is_permanent: bool) {
-       unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.node_failed(&_node_id.into_rust(), is_permanent)
+pub extern "C" fn NetworkGraph_node_failed_permanent(this_arg: &crate::lightning::routing::gossip::NetworkGraph, mut node_id: crate::c_types::PublicKey) {
+       unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.node_failed_permanent(&node_id.into_rust())
 }
 
 /// Removes information about channels that we haven't heard any updates about in some time.
@@ -2083,11 +2103,14 @@ pub extern "C" fn NetworkGraph_node_failed(this_arg: &crate::lightning::routing:
 /// Note that for users of the `lightning-background-processor` crate this method may be
 /// automatically called regularly for you.
 ///
+/// This method will also cause us to stop tracking removed nodes and channels if they have been
+/// in the map for a while so that these can be resynced from gossip in the future.
+///
 /// This method is only available with the `std` feature. See
-/// [`NetworkGraph::remove_stale_channels_with_time`] for `no-std` use.
+/// [`NetworkGraph::remove_stale_channels_and_tracking_with_time`] for `no-std` use.
 #[no_mangle]
-pub extern "C" fn NetworkGraph_remove_stale_channels(this_arg: &crate::lightning::routing::gossip::NetworkGraph) {
-       unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.remove_stale_channels()
+pub extern "C" fn NetworkGraph_remove_stale_channels_and_tracking(this_arg: &crate::lightning::routing::gossip::NetworkGraph) {
+       unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.remove_stale_channels_and_tracking()
 }
 
 /// Removes information about channels that we haven't heard any updates about in some time.
@@ -2098,11 +2121,14 @@ pub extern "C" fn NetworkGraph_remove_stale_channels(this_arg: &crate::lightning
 /// 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 method will also cause us to stop tracking removed nodes and channels if they have been
+/// in the map for a while so that these can be resynced from gossip in the future.
+///
 /// This function takes the current unix time as an argument. For users with the `std` feature
-/// enabled, [`NetworkGraph::remove_stale_channels`] may be preferable.
+/// enabled, [`NetworkGraph::remove_stale_channels_and_tracking`] may be preferable.
 #[no_mangle]
-pub extern "C" fn NetworkGraph_remove_stale_channels_with_time(this_arg: &crate::lightning::routing::gossip::NetworkGraph, mut current_time_unix: u64) {
-       unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.remove_stale_channels_with_time(current_time_unix)
+pub extern "C" fn NetworkGraph_remove_stale_channels_and_tracking_with_time(this_arg: &crate::lightning::routing::gossip::NetworkGraph, mut current_time_unix: u64) {
+       unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.remove_stale_channels_and_tracking_with_time(current_time_unix)
 }
 
 /// For an already known (from announcement) channel, update info about one of the directions