From: Matt Corallo Date: Thu, 31 Dec 2020 16:42:14 +0000 (-0500) Subject: - bindings updates X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=f15dbc1b1a73c1ff7a571cf362adfba9923ad4f3;p=rust-lightning - bindings updates --- diff --git a/lightning-c-bindings/include/lightning.h b/lightning-c-bindings/include/lightning.h index 17b62a338..a653b5a82 100644 --- a/lightning-c-bindings/include/lightning.h +++ b/lightning-c-bindings/include/lightning.h @@ -2715,6 +2715,28 @@ typedef struct MUST_USE_STRUCT LDKDataLossProtect { bool is_owned; } LDKDataLossProtect; +typedef union LDKCResultPtr_NetAddress__u8 { + struct LDKNetAddress *result; + uint8_t *err; +} LDKCResultPtr_NetAddress__u8; + +typedef struct LDKCResultTempl_NetAddress__u8 { + union LDKCResultPtr_NetAddress__u8 contents; + bool result_ok; +} LDKCResultTempl_NetAddress__u8; + +typedef union LDKCResultPtr_CResultTempl_NetAddress__u8_____DecodeError { + struct LDKCResultTempl_NetAddress__u8 *result; + struct LDKDecodeError *err; +} LDKCResultPtr_CResultTempl_NetAddress__u8_____DecodeError; + +typedef struct LDKCResultTempl_CResultTempl_NetAddress__u8_____DecodeError { + union LDKCResultPtr_CResultTempl_NetAddress__u8_____DecodeError contents; + bool result_ok; +} LDKCResultTempl_CResultTempl_NetAddress__u8_____DecodeError; + +typedef struct LDKCResultTempl_CResultTempl_NetAddress__u8_____DecodeError LDKCResult_CResult_NetAddressu8ZDecodeErrorZ; + /** @@ -3574,6 +3596,8 @@ typedef struct LDKCResultTempl_NetworkGraph__DecodeError { typedef struct LDKCResultTempl_NetworkGraph__DecodeError LDKCResult_NetworkGraphDecodeErrorZ; +typedef struct LDKCResultTempl_NetAddress__u8 LDKCResult_NetAddressu8Z; + typedef struct LDKCVecTempl_RouteHop LDKCVec_RouteHopZ; extern const void (*CVec_SpendableOutputDescriptorZ_free)(LDKCVec_SpendableOutputDescriptorZ); @@ -3686,6 +3710,18 @@ extern const LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ (*CResult_C extern const LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ (*CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err)(struct LDKDecodeError); +extern const void (*CResult_NetAddressu8Z_free)(LDKCResult_NetAddressu8Z); + +extern const LDKCResult_NetAddressu8Z (*CResult_NetAddressu8Z_ok)(struct LDKNetAddress); + +extern const LDKCResult_NetAddressu8Z (*CResult_NetAddressu8Z_err)(uint8_t); + +extern const void (*CResult_CResult_NetAddressu8ZDecodeErrorZ_free)(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ); + +extern const LDKCResult_CResult_NetAddressu8ZDecodeErrorZ (*CResult_CResult_NetAddressu8ZDecodeErrorZ_ok)(LDKCResult_NetAddressu8Z); + +extern const LDKCResult_CResult_NetAddressu8ZDecodeErrorZ (*CResult_CResult_NetAddressu8ZDecodeErrorZ_err)(struct LDKDecodeError); + extern const void (*CVec_u64Z_free)(LDKCVec_u64Z); extern const void (*CVec_UpdateAddHTLCZ_free)(LDKCVec_UpdateAddHTLCZ); @@ -4494,6 +4530,8 @@ struct LDKHTLCUpdate HTLCUpdate_read(struct LDKu8slice ser); void ChannelMonitor_free(struct LDKChannelMonitor this_ptr); +LDKCVec_u8Z ChannelMonitor_write(const struct LDKChannelMonitor *obj); + /** * Updates a ChannelMonitor on the basis of some new information provided by the Channel * itself. @@ -5130,6 +5168,8 @@ void ChannelManager_block_disconnected(const struct LDKChannelManager *this_arg, struct LDKChannelMessageHandler ChannelManager_as_ChannelMessageHandler(const struct LDKChannelManager *this_arg); +LDKCVec_u8Z ChannelManager_write(const struct LDKChannelManager *obj); + void ChannelManagerReadArgs_free(struct LDKChannelManagerReadArgs this_ptr); /** @@ -6154,6 +6194,8 @@ struct LDKNetAddress NetAddress_clone(const struct LDKNetAddress *orig); LDKCVec_u8Z NetAddress_write(const struct LDKNetAddress *obj); +LDKCResult_CResult_NetAddressu8ZDecodeErrorZ Result_read(struct LDKu8slice ser); + void UnsignedNodeAnnouncement_free(struct LDKUnsignedNodeAnnouncement this_ptr); struct LDKUnsignedNodeAnnouncement UnsignedNodeAnnouncement_clone(const struct LDKUnsignedNodeAnnouncement *orig); diff --git a/lightning-c-bindings/include/lightningpp.hpp b/lightning-c-bindings/include/lightningpp.hpp index b68fa06d9..346484908 100644 --- a/lightning-c-bindings/include/lightningpp.hpp +++ b/lightning-c-bindings/include/lightningpp.hpp @@ -2054,6 +2054,20 @@ public: const LDKCResult_SpendableOutputDescriptorDecodeErrorZ* operator &() const { return &self; } const LDKCResult_SpendableOutputDescriptorDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_NetAddressu8Z { +private: + LDKCResult_NetAddressu8Z self; +public: + CResult_NetAddressu8Z(const CResult_NetAddressu8Z&) = delete; + ~CResult_NetAddressu8Z() { CResult_NetAddressu8Z_free(self); } + CResult_NetAddressu8Z(CResult_NetAddressu8Z&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NetAddressu8Z)); } + CResult_NetAddressu8Z(LDKCResult_NetAddressu8Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NetAddressu8Z)); } + operator LDKCResult_NetAddressu8Z() { LDKCResult_NetAddressu8Z res = self; memset(&self, 0, sizeof(LDKCResult_NetAddressu8Z)); return res; } + LDKCResult_NetAddressu8Z* operator &() { return &self; } + LDKCResult_NetAddressu8Z* operator ->() { return &self; } + const LDKCResult_NetAddressu8Z* operator &() const { return &self; } + const LDKCResult_NetAddressu8Z* operator ->() const { return &self; } +}; class CVec_UpdateFailMalformedHTLCZ { private: LDKCVec_UpdateFailMalformedHTLCZ self; @@ -2334,6 +2348,20 @@ public: const LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_CResult_NetAddressu8ZDecodeErrorZ { +private: + LDKCResult_CResult_NetAddressu8ZDecodeErrorZ self; +public: + CResult_CResult_NetAddressu8ZDecodeErrorZ(const CResult_CResult_NetAddressu8ZDecodeErrorZ&) = delete; + ~CResult_CResult_NetAddressu8ZDecodeErrorZ() { CResult_CResult_NetAddressu8ZDecodeErrorZ_free(self); } + CResult_CResult_NetAddressu8ZDecodeErrorZ(CResult_CResult_NetAddressu8ZDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CResult_NetAddressu8ZDecodeErrorZ)); } + CResult_CResult_NetAddressu8ZDecodeErrorZ(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ)); } + operator LDKCResult_CResult_NetAddressu8ZDecodeErrorZ() { LDKCResult_CResult_NetAddressu8ZDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ)); return res; } + LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* operator &() { return &self; } + LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* operator ->() const { return &self; } +}; class CVec_ChannelDetailsZ { private: LDKCVec_ChannelDetailsZ self; diff --git a/lightning-c-bindings/src/c_types/derived.rs b/lightning-c-bindings/src/c_types/derived.rs index ba9397be1..092c5d5d4 100644 --- a/lightning-c-bindings/src/c_types/derived.rs +++ b/lightning-c-bindings/src/c_types/derived.rs @@ -271,6 +271,28 @@ pub static CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok: extern "C" f pub static CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err: extern "C" fn (crate::ln::msgs::DecodeError) -> CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ = crate::c_types::CResultTempl::, crate::ln::msgs::DecodeError>::err; +pub type CResult_NetAddressu8Z = crate::c_types::CResultTempl; +#[no_mangle] +pub static CResult_NetAddressu8Z_free: extern "C" fn(CResult_NetAddressu8Z) = crate::c_types::CResultTempl_free::; +#[no_mangle] +pub static CResult_NetAddressu8Z_ok: extern "C" fn (crate::ln::msgs::NetAddress) -> CResult_NetAddressu8Z = + crate::c_types::CResultTempl::::ok; + +#[no_mangle] +pub static CResult_NetAddressu8Z_err: extern "C" fn (u8) -> CResult_NetAddressu8Z = + crate::c_types::CResultTempl::::err; + +pub type CResult_CResult_NetAddressu8ZDecodeErrorZ = crate::c_types::CResultTempl, crate::ln::msgs::DecodeError>; +#[no_mangle] +pub static CResult_CResult_NetAddressu8ZDecodeErrorZ_free: extern "C" fn(CResult_CResult_NetAddressu8ZDecodeErrorZ) = crate::c_types::CResultTempl_free::, crate::ln::msgs::DecodeError>; +#[no_mangle] +pub static CResult_CResult_NetAddressu8ZDecodeErrorZ_ok: extern "C" fn (CResult_NetAddressu8Z) -> CResult_CResult_NetAddressu8ZDecodeErrorZ = + crate::c_types::CResultTempl::, crate::ln::msgs::DecodeError>::ok; + +#[no_mangle] +pub static CResult_CResult_NetAddressu8ZDecodeErrorZ_err: extern "C" fn (crate::ln::msgs::DecodeError) -> CResult_CResult_NetAddressu8ZDecodeErrorZ = + crate::c_types::CResultTempl::, crate::ln::msgs::DecodeError>::err; + pub type CVec_u64Z = crate::c_types::CVecTempl; #[no_mangle] pub static CVec_u64Z_free: extern "C" fn(CVec_u64Z) = crate::c_types::CVecTempl_free::; diff --git a/lightning-c-bindings/src/chain/channelmonitor.rs b/lightning-c-bindings/src/chain/channelmonitor.rs index 8c2e40c0c..ae3645556 100644 --- a/lightning-c-bindings/src/chain/channelmonitor.rs +++ b/lightning-c-bindings/src/chain/channelmonitor.rs @@ -447,6 +447,14 @@ impl ChannelMonitor { ret } } +#[no_mangle] +pub extern "C" fn ChannelMonitor_write(obj: *const ChannelMonitor) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn ChannelMonitor_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelMonitor) }) +} /// Updates a ChannelMonitor on the basis of some new information provided by the Channel /// itself. /// diff --git a/lightning-c-bindings/src/ln/channelmanager.rs b/lightning-c-bindings/src/ln/channelmanager.rs index 99a73e321..4d18ea1a1 100644 --- a/lightning-c-bindings/src/ln/channelmanager.rs +++ b/lightning-c-bindings/src/ln/channelmanager.rs @@ -731,6 +731,14 @@ extern "C" fn ChannelManager_ChannelMessageHandler_get_and_clear_pending_msg_eve local_ret.into() } +#[no_mangle] +pub extern "C" fn ChannelManager_write(obj: *const ChannelManager) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) +} +#[no_mangle] +pub(crate) extern "C" fn ChannelManager_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelManager) }) +} use lightning::ln::channelmanager::ChannelManagerReadArgs as nativeChannelManagerReadArgsImport; type nativeChannelManagerReadArgs = nativeChannelManagerReadArgsImport<'static, crate::chain::keysinterface::ChannelKeys, crate::chain::Watch, crate::chain::chaininterface::BroadcasterInterface, crate::chain::keysinterface::KeysInterface, crate::chain::chaininterface::FeeEstimator, crate::util::logger::Logger>; diff --git a/lightning-c-bindings/src/ln/msgs.rs b/lightning-c-bindings/src/ln/msgs.rs index b8567500d..23520c4b6 100644 --- a/lightning-c-bindings/src/ln/msgs.rs +++ b/lightning-c-bindings/src/ln/msgs.rs @@ -2411,6 +2411,12 @@ pub extern "C" fn NetAddress_clone(orig: &NetAddress) -> NetAddress { pub extern "C" fn NetAddress_write(obj: *const NetAddress) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) } +#[no_mangle] +pub extern "C" fn Result_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CResult_NetAddressu8ZDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = match o { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::NetAddress::native_into(o) }), Err(mut e) => crate::c_types::CResultTempl::err( { e }) }; local_res_0 }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) }; + local_res +} use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport; type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;