Update auto-generated bindings with new NetworkGraph API
[rust-lightning] / lightning-c-bindings / src / routing / network_graph.rs
index ba872b30dfe6c07260f96ed67c5aaf8f9ddced55..b4c8de585c55dd57450f91c5d300a21de35aa0b8 100644 (file)
@@ -12,7 +12,7 @@ type nativeNetworkGraph = nativeNetworkGraphImport;
 #[must_use]
 #[repr(C)]
 pub struct NetworkGraph {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// Nearly everywhere, inner must be non-null, however in places where
        /// the Rust equivalent takes an Option, it may be set to null to indicate None.
        pub inner: *mut nativeNetworkGraph,
        pub is_owned: bool,
@@ -52,7 +52,7 @@ type nativeLockedNetworkGraph = nativeLockedNetworkGraphImport<'static>;
 #[must_use]
 #[repr(C)]
 pub struct LockedNetworkGraph {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// Nearly everywhere, inner must be non-null, however in places where
        /// the Rust equivalent takes an Option, it may be set to null to indicate None.
        pub inner: *mut nativeLockedNetworkGraph,
        pub is_owned: bool,
@@ -94,7 +94,7 @@ type nativeNetGraphMsgHandler = nativeNetGraphMsgHandlerImport<crate::chain::Acc
 #[must_use]
 #[repr(C)]
 pub struct NetGraphMsgHandler {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// Nearly everywhere, inner must be non-null, however in places where
        /// the Rust equivalent takes an Option, it may be set to null to indicate None.
        pub inner: *mut nativeNetGraphMsgHandler,
        pub is_owned: bool,
@@ -230,7 +230,7 @@ type nativeDirectionalChannelInfo = nativeDirectionalChannelInfoImport;
 #[must_use]
 #[repr(C)]
 pub struct DirectionalChannelInfo {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// Nearly everywhere, inner must be non-null, however in places where
        /// the Rust equivalent takes an Option, it may be set to null to indicate None.
        pub inner: *mut nativeDirectionalChannelInfo,
        pub is_owned: bool,
@@ -346,7 +346,7 @@ type nativeChannelInfo = nativeChannelInfoImport;
 #[must_use]
 #[repr(C)]
 pub struct ChannelInfo {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// Nearly everywhere, inner must be non-null, however in places where
        /// the Rust equivalent takes an Option, it may be set to null to indicate None.
        pub inner: *mut nativeChannelInfo,
        pub is_owned: bool,
@@ -474,7 +474,7 @@ type nativeRoutingFees = nativeRoutingFeesImport;
 #[must_use]
 #[repr(C)]
 pub struct RoutingFees {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// Nearly everywhere, inner must be non-null, however in places where
        /// the Rust equivalent takes an Option, it may be set to null to indicate None.
        pub inner: *mut nativeRoutingFees,
        pub is_owned: bool,
@@ -517,6 +517,10 @@ impl Clone for RoutingFees {
 pub(crate) extern "C" fn RoutingFees_clone_void(this_ptr: *const c_void) -> *mut c_void {
        Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRoutingFees)).clone() })) as *mut c_void
 }
+#[no_mangle]
+pub extern "C" fn RoutingFees_clone(orig: &RoutingFees) -> RoutingFees {
+       RoutingFees { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
+}
 /// Flat routing fee in satoshis
 #[no_mangle]
 pub extern "C" fn RoutingFees_get_base_msat(this_ptr: &RoutingFees) -> u32 {
@@ -569,7 +573,7 @@ type nativeNodeAnnouncementInfo = nativeNodeAnnouncementInfoImport;
 #[must_use]
 #[repr(C)]
 pub struct NodeAnnouncementInfo {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// Nearly everywhere, inner must be non-null, however in places where
        /// the Rust equivalent takes an Option, it may be set to null to indicate None.
        pub inner: *mut nativeNodeAnnouncementInfo,
        pub is_owned: bool,
@@ -708,7 +712,7 @@ type nativeNodeInfo = nativeNodeInfoImport;
 #[must_use]
 #[repr(C)]
 pub struct NodeInfo {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// Nearly everywhere, inner must be non-null, however in places where
        /// the Rust equivalent takes an Option, it may be set to null to indicate None.
        pub inner: *mut nativeNodeInfo,
        pub is_owned: bool,
@@ -822,6 +826,64 @@ pub extern "C" fn NetworkGraph_new() -> crate::routing::network_graph::NetworkGr
        crate::routing::network_graph::NetworkGraph { inner: Box::into_raw(Box::new(ret)), is_owned: true }
 }
 
+/// For an already known node (from channel announcements), update its stored properties from a
+/// given node announcement.
+///
+/// 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.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn NetworkGraph_update_node_from_announcement(this_arg: &mut NetworkGraph, msg: &crate::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
+       let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_node_from_announcement(unsafe { &*msg.inner }, &bitcoin::secp256k1::Secp256k1::new());
+       let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
+       local_ret
+}
+
+/// For an already known node (from channel announcements), update its stored properties from a
+/// given node announcement without verifying the associated signatures. Because we aren't
+/// given the associated signatures here we cannot relay the node announcement to any of our
+/// peers.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn NetworkGraph_update_node_from_unsigned_announcement(this_arg: &mut NetworkGraph, msg: &crate::ln::msgs::UnsignedNodeAnnouncement) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
+       let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_node_from_unsigned_announcement(unsafe { &*msg.inner });
+       let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
+       local_ret
+}
+
+/// Store or update channel info from a channel announcement.
+///
+/// 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 a `chain::Access` object is provided via `chain_access`, it will be called to verify
+/// the corresponding UTXO exists on chain and is correctly-formatted.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn NetworkGraph_update_channel_from_announcement(this_arg: &mut NetworkGraph, msg: &crate::ln::msgs::ChannelAnnouncement, chain_access: *mut crate::chain::Access) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
+       let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) };
+       let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_channel_from_announcement(unsafe { &*msg.inner }, &local_chain_access, &bitcoin::secp256k1::Secp256k1::new());
+       let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
+       local_ret
+}
+
+/// Store or update channel info from a channel announcement without verifying the associated
+/// signatures. Because we aren't given the associated signatures here we cannot relay the
+/// channel announcement to any of our peers.
+///
+/// If a `chain::Access` object is provided via `chain_access`, it will be called to verify
+/// the corresponding UTXO exists on chain and is correctly-formatted.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn NetworkGraph_update_channel_from_unsigned_announcement(this_arg: &mut NetworkGraph, msg: &crate::ln::msgs::UnsignedChannelAnnouncement, chain_access: *mut crate::chain::Access) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
+       let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) };
+       let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_channel_from_unsigned_announcement(unsafe { &*msg.inner }, &local_chain_access);
+       let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
+       local_ret
+}
+
 /// Close a channel if a corresponding HTLC fail was sent.
 /// If permanent, removes a channel from the local storage.
 /// May cause the removal of nodes too, if this was their last channel.
@@ -831,3 +893,28 @@ pub extern "C" fn NetworkGraph_close_channel_from_update(this_arg: &mut NetworkG
        unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.close_channel_from_update(short_channel_id, is_permanent)
 }
 
+/// 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.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn NetworkGraph_update_channel(this_arg: &mut NetworkGraph, msg: &crate::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
+       let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_channel(unsafe { &*msg.inner }, &bitcoin::secp256k1::Secp256k1::new());
+       let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
+       local_ret
+}
+
+/// 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.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn NetworkGraph_update_channel_unsigned(this_arg: &mut NetworkGraph, msg: &crate::ln::msgs::UnsignedChannelUpdate) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
+       let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeNetworkGraph)) }.update_channel_unsigned(unsafe { &*msg.inner });
+       let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
+       local_ret
+}
+