Update auto-generated bindings with new NetworkGraph API 2020-11-bindings-fix
authorMatt Corallo <git@bluematt.me>
Tue, 24 Nov 2020 18:41:06 +0000 (13:41 -0500)
committerMatt Corallo <git@bluematt.me>
Tue, 24 Nov 2020 21:45:36 +0000 (16:45 -0500)
lightning-c-bindings/include/lightning.h
lightning-c-bindings/include/lightningpp.hpp
lightning-c-bindings/src/c_types/derived.rs
lightning-c-bindings/src/routing/network_graph.rs

index 45e4fa3ab6b72a601f0313dd0a9ced1816b233a0..6154802268679a02df0a1e93031d226e91d4125b 100644 (file)
@@ -586,6 +586,32 @@ typedef struct LDKC2TupleTempl_HTLCOutputInCommitment__Signature {
 
 typedef LDKC2TupleTempl_HTLCOutputInCommitment__Signature LDKC2Tuple_HTLCOutputInCommitmentSignatureZ;
 
+
+
+/**
+ * An Err type for failure to process messages.
+ */
+typedef struct MUST_USE_STRUCT LDKLightningError {
+   /**
+    * 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.
+    */
+   LDKnativeLightningError *inner;
+   bool is_owned;
+} LDKLightningError;
+
+typedef union LDKCResultPtr_u8__LightningError {
+   uint8_t *result;
+   LDKLightningError *err;
+} LDKCResultPtr_u8__LightningError;
+
+typedef struct LDKCResultTempl_u8__LightningError {
+   LDKCResultPtr_u8__LightningError contents;
+   bool result_ok;
+} LDKCResultTempl_u8__LightningError;
+
+typedef LDKCResultTempl_u8__LightningError LDKCResult_NoneLightningErrorZ;
+
 typedef struct LDKPublicKey {
    uint8_t compressed_form[33];
 } LDKPublicKey;
@@ -2641,20 +2667,6 @@ typedef struct MUST_USE_STRUCT LDKGossipTimestampFilter {
    bool is_owned;
 } LDKGossipTimestampFilter;
 
-
-
-/**
- * An Err type for failure to process messages.
- */
-typedef struct MUST_USE_STRUCT LDKLightningError {
-   /**
-    * 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.
-    */
-   LDKnativeLightningError *inner;
-   bool is_owned;
-} LDKLightningError;
-
 typedef struct LDKCVecTempl_UpdateAddHTLC {
    LDKUpdateAddHTLC *data;
    uintptr_t datalen;
@@ -3153,6 +3165,10 @@ extern const LDKCResult_NoneChannelMonitorUpdateErrZ (*CResult_NoneChannelMonito
 
 extern const void (*CResult_NoneChannelMonitorUpdateErrZ_free)(LDKCResult_NoneChannelMonitorUpdateErrZ);
 
+extern const LDKCResult_NoneLightningErrorZ (*CResult_NoneLightningErrorZ_err)(LDKLightningError);
+
+extern const void (*CResult_NoneLightningErrorZ_free)(LDKCResult_NoneLightningErrorZ);
+
 extern const LDKCResult_NoneMonitorUpdateErrorZ (*CResult_NoneMonitorUpdateErrorZ_err)(LDKMonitorUpdateError);
 
 extern const void (*CResult_NoneMonitorUpdateErrorZ_free)(LDKCResult_NoneMonitorUpdateErrorZ);
@@ -3301,6 +3317,8 @@ LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_ok(void);
 
 LDKC2Tuple_HTLCOutputInCommitmentSignatureZ C2Tuple_HTLCOutputInCommitmentSignatureZ_new(LDKHTLCOutputInCommitment a, LDKSignature b);
 
+LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_ok(void);
+
 void Event_free(LDKEvent this_ptr);
 
 LDKEvent Event_clone(const LDKEvent *orig);
@@ -7262,6 +7280,46 @@ LDKNetworkGraph NetworkGraph_read(LDKu8slice ser);
  */
 MUST_USE_RES LDKNetworkGraph NetworkGraph_new(void);
 
+/**
+ * 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_RES LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_announcement(LDKNetworkGraph *this_arg, const LDKNodeAnnouncement *msg);
+
+/**
+ * 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_RES LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_unsigned_announcement(LDKNetworkGraph *this_arg, const LDKUnsignedNodeAnnouncement *msg);
+
+/**
+ * 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_RES LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_announcement(LDKNetworkGraph *this_arg, const LDKChannelAnnouncement *msg, LDKAccess *chain_access);
+
+/**
+ * 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_RES LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_unsigned_announcement(LDKNetworkGraph *this_arg, const LDKUnsignedChannelAnnouncement *msg, LDKAccess *chain_access);
+
 /**
  * Close a channel if a corresponding HTLC fail was sent.
  * If permanent, removes a channel from the local storage.
@@ -7270,4 +7328,21 @@ MUST_USE_RES LDKNetworkGraph NetworkGraph_new(void);
  */
 void NetworkGraph_close_channel_from_update(LDKNetworkGraph *this_arg, uint64_t short_channel_id, bool 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_RES LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel(LDKNetworkGraph *this_arg, const LDKChannelUpdate *msg);
+
+/**
+ * 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_RES LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_unsigned(LDKNetworkGraph *this_arg, const LDKUnsignedChannelUpdate *msg);
+
 /* Text to put at the end of the generated file */
index 49e78e3841eae605119575fd28880e188a2dd327..5f8b77f3f6e6dded34a149a189c37d179ca2a4cb 100644 (file)
@@ -1830,6 +1830,20 @@ public:
        const LDKCResult_RouteLightningErrorZ* operator &() const { return &self; }
        const LDKCResult_RouteLightningErrorZ* operator ->() const { return &self; }
 };
+class CResult_NoneLightningErrorZ {
+private:
+       LDKCResult_NoneLightningErrorZ self;
+public:
+       CResult_NoneLightningErrorZ(const CResult_NoneLightningErrorZ&) = delete;
+       ~CResult_NoneLightningErrorZ() { CResult_NoneLightningErrorZ_free(self); }
+       CResult_NoneLightningErrorZ(CResult_NoneLightningErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneLightningErrorZ)); }
+       CResult_NoneLightningErrorZ(LDKCResult_NoneLightningErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneLightningErrorZ)); }
+       operator LDKCResult_NoneLightningErrorZ() { LDKCResult_NoneLightningErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneLightningErrorZ)); return res; }
+       LDKCResult_NoneLightningErrorZ* operator &() { return &self; }
+       LDKCResult_NoneLightningErrorZ* operator ->() { return &self; }
+       const LDKCResult_NoneLightningErrorZ* operator &() const { return &self; }
+       const LDKCResult_NoneLightningErrorZ* operator ->() const { return &self; }
+};
 class CResult_CVec_SignatureZNoneZ {
 private:
        LDKCResult_CVec_SignatureZNoneZ self;
index fd77e0d4cf11cbcba6777980a73e64ea97849f67..38139e0e0b9a64c9c95a3c23031f77fbe0e73875 100644 (file)
@@ -400,3 +400,16 @@ pub static CResult_RouteLightningErrorZ_ok: extern "C" fn (crate::routing::route
 pub static CResult_RouteLightningErrorZ_err: extern "C" fn (crate::ln::msgs::LightningError) -> CResult_RouteLightningErrorZ =
        crate::c_types::CResultTempl::<crate::routing::router::Route, crate::ln::msgs::LightningError>::err;
 
+#[no_mangle]
+pub type CResult_NoneLightningErrorZ = crate::c_types::CResultTempl<u8, crate::ln::msgs::LightningError>;
+#[no_mangle]
+pub static CResult_NoneLightningErrorZ_free: extern "C" fn(CResult_NoneLightningErrorZ) = crate::c_types::CResultTempl_free::<u8, crate::ln::msgs::LightningError>;
+#[no_mangle]
+pub extern "C" fn CResult_NoneLightningErrorZ_ok() -> CResult_NoneLightningErrorZ {
+       crate::c_types::CResultTempl::ok(0)
+}
+
+#[no_mangle]
+pub static CResult_NoneLightningErrorZ_err: extern "C" fn (crate::ln::msgs::LightningError) -> CResult_NoneLightningErrorZ =
+       crate::c_types::CResultTempl::<u8, crate::ln::msgs::LightningError>::err;
+
index 11eb92a363a1dca996418ee29399361feb3ab7a0..b4c8de585c55dd57450f91c5d300a21de35aa0b8 100644 (file)
@@ -826,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.
@@ -835,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
+}
+