+
+static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return BuiltCommitmentTransaction_clone(&*owner->contents.result);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
+ LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
+ LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
+ LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKTrustedClosingTransaction *CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return &*owner->contents.result;
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_TrustedClosingTransactionNoneZ_get_ok(uint32_t owner) {
+ LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
+ LDKTrustedClosingTransaction ret_var = *CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner & ~1;
+ return ret_ref;
+}
+
+static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return *owner->contents.err;
+}
+void __attribute__((visibility("default"))) TS_CResult_TrustedClosingTransactionNoneZ_get_err(uint32_t owner) {
+ LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
+ CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
+}
+
+static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return CommitmentTransaction_clone(&*owner->contents.result);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
+ LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
+ LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
+ LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKTrustedCommitmentTransaction *CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return &*owner->contents.result;
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_ok(uint32_t owner) {
+ LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
+ LDKTrustedCommitmentTransaction ret_var = *CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner & ~1;
+ return ret_ref;
+}
+
+static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return *owner->contents.err;
+}
+void __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t owner) {
+ LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
+ CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
+}
+
+static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return *owner->contents.result;
+}
+ptrArray __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_get_ok(uint32_t owner) {
+ LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
+ LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
+ ptrArray ret_arr = NULL;
+ ret_arr = init_ptrArray(ret_var.datalen);
+ int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
+ for (size_t m = 0; m < ret_var.datalen; m++) {
+ int8_tArray ret_conv_12_arr = init_int8_tArray(64);
+ memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
+ ret_arr_ptr[m] = ret_conv_12_arr;
+ }
+
+ FREE(ret_var.data);
+ return ret_arr;
+}
+
+static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return *owner->contents.err;
+}
+void __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_get_err(uint32_t owner) {
+ LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
+ CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
+}
+
+static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return ShutdownScript_clone(&*owner->contents.result);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_ok(uint32_t owner) {
+ LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
+ LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_err(uint32_t owner) {
+ LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return ShutdownScript_clone(&*owner->contents.result);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(uint32_t owner) {
+ LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
+ LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return InvalidShutdownScript_clone(&*owner->contents.err);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(uint32_t owner) {
+ LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
+ LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+typedef struct LDKType_JCalls {
+ atomic_size_t refcnt;
+ uint32_t type_id_meth;
+ uint32_t debug_str_meth;
+ uint32_t write_meth;
+} LDKType_JCalls;
+static void LDKType_JCalls_free(void* this_arg) {
+ LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ js_free_function_ptr(j_calls->type_id_meth);
+ js_free_function_ptr(j_calls->debug_str_meth);
+ js_free_function_ptr(j_calls->write_meth);
+ FREE(j_calls);
+ }
+}
+uint16_t type_id_LDKType_jcall(const void* this_arg) {
+ LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
+ return js_invoke_function_0(j_calls->type_id_meth);
+}
+LDKStr debug_str_LDKType_jcall(const void* this_arg) {
+ LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
+ jstring ret = (jstring)js_invoke_function_0(j_calls->debug_str_meth);
+ LDKStr ret_conv = str_ref_to_owned_c(ret);
+ return ret_conv;
+}
+LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
+ LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
+ int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->write_meth);
+ LDKCVec_u8Z ret_ref;
+ ret_ref.datalen = ret->arr_len;
+ ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
+ memcpy(ret_ref.data, ret->elems, ret_ref.datalen);
+ return ret_ref;
+}
+static void LDKType_JCalls_cloned(LDKType* new_obj) {
+ LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKType LDKType_init (/*TODO: JS Object Reference */void* o) {
+ LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ //TODO: Assign calls->o from o
+
+ LDKType ret = {
+ .this_arg = (void*) calls,
+ .type_id = type_id_LDKType_jcall,
+ .debug_str = debug_str_LDKType_jcall,
+ .write = write_LDKType_jcall,
+ .cloned = LDKType_JCalls_cloned,
+ .free = LDKType_JCalls_free,
+ };
+ return ret;
+}
+long __attribute__((visibility("default"))) TS_LDKType_new(/*TODO: JS Object Reference */void* o) {
+ LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
+ *res_ptr = LDKType_init(o);
+ return (long)res_ptr;
+}
+int16_t __attribute__((visibility("default"))) TS_Type_type_id(uint32_t this_arg) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
+ int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg);
+ return ret_val;
+}
+
+jstring __attribute__((visibility("default"))) TS_Type_debug_str(uint32_t this_arg) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
+ LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
+ jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
+ Str_free(ret_str);
+ return ret_conv;
+}
+
+int8_tArray __attribute__((visibility("default"))) TS_Type_write(uint32_t this_arg) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
+ LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
+ int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
+ memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
+ CVec_u8Z_free(ret_var);
+ return ret_arr;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_LDKCOption_TypeZ_ref_from_ptr(uint32_t ptr) {
+ LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKCOption_TypeZ_Some: {
+ LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
+ *some_ret = Type_clone(&obj->some);
+ return 0 /* LDKCOption_TypeZ - Some */; (void) (uint64_t)some_ret;
+ }
+ case LDKCOption_TypeZ_None: {
+ return 0 /* LDKCOption_TypeZ - None */;
+ }
+ default: abort();
+ }
+}
+static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return COption_TypeZ_clone(&*owner->contents.result);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_get_ok(uint32_t owner) {
+ LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
+ LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
+ *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
+ uint64_t ret_ref = (uint64_t)ret_copy;
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_get_err(uint32_t owner) {
+ LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return *owner->contents.result;
+}
+jstring __attribute__((visibility("default"))) TS_CResult_StringErrorZ_get_ok(uint32_t owner) {
+ LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
+ LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
+ jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
+ Str_free(ret_str);
+ return ret_conv;
+}
+
+static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return *owner->contents.err;
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_StringErrorZ_get_err(uint32_t owner) {
+ LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
+ uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_StringErrorZ_get_err(owner_conv));
+ return ret_conv;
+}
+
+static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return ChannelMonitorUpdate_clone(&*owner->contents.result);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t owner) {
+ LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
+ LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t owner) {
+ LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_LDKMonitorEvent_ref_from_ptr(uint32_t ptr) {
+ LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKMonitorEvent_HTLCEvent: {
+ LDKHTLCUpdate htlc_event_var = obj->htlc_event;
+ uint64_t htlc_event_ref = 0;
+ CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
+ htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
+ return 0 /* LDKMonitorEvent - HTLCEvent */; (void) htlc_event_ref;
+ }
+ case LDKMonitorEvent_CommitmentTxConfirmed: {
+ LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
+ uint64_t commitment_tx_confirmed_ref = 0;
+ CHECK((((uint64_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
+ commitment_tx_confirmed_ref = (uint64_t)commitment_tx_confirmed_var.inner & ~1;
+ return 0 /* LDKMonitorEvent - CommitmentTxConfirmed */; (void) commitment_tx_confirmed_ref;
+ }
+ case LDKMonitorEvent_UpdateCompleted: {
+ LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
+ uint64_t funding_txo_ref = 0;
+ CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
+ funding_txo_ref = (uint64_t)funding_txo_var.inner & ~1;
+ return 0 /* LDKMonitorEvent - UpdateCompleted */; (void) funding_txo_ref; (void) obj->update_completed.monitor_update_id;
+ }
+ case LDKMonitorEvent_UpdateFailed: {
+ LDKOutPoint update_failed_var = obj->update_failed;
+ uint64_t update_failed_ref = 0;
+ CHECK((((uint64_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
+ update_failed_ref = (uint64_t)update_failed_var.inner & ~1;
+ return 0 /* LDKMonitorEvent - UpdateFailed */; (void) update_failed_ref;
+ }
+ default: abort();
+ }
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCOption_MonitorEventZ_ref_from_ptr(uint32_t ptr) {
+ LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKCOption_MonitorEventZ_Some: {
+ uint64_t some_ref = ((uint64_t)&obj->some) | 1;
+ return 0 /* LDKCOption_MonitorEventZ - Some */; (void) some_ref;
+ }
+ case LDKCOption_MonitorEventZ_None: {
+ return 0 /* LDKCOption_MonitorEventZ - None */;
+ }
+ default: abort();
+ }
+}
+static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return COption_MonitorEventZ_clone(&*owner->contents.result);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok(uint32_t owner) {
+ LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
+ LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
+ *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
+ uint64_t ret_ref = (uint64_t)ret_copy;
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err(uint32_t owner) {
+ LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return HTLCUpdate_clone(&*owner->contents.result);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t owner) {
+ LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
+ LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t owner) {
+ LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return *owner->contents.result;
+}
+void __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_get_ok(uint32_t owner) {
+ LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
+ CResult_NoneNoneZ_get_ok(owner_conv);
+}
+
+static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return *owner->contents.err;
+}
+void __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_get_err(uint32_t owner) {
+ LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
+ CResult_NoneNoneZ_get_err(owner_conv);
+}
+
+static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
+ return OutPoint_clone(&owner->a);
+}
+uint32_t __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_get_a(uint32_t owner) {
+ LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
+ LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
+ return CVec_u8Z_clone(&owner->b);
+}
+int8_tArray __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_get_b(uint32_t owner) {
+ LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
+ LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
+ int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
+ memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
+ CVec_u8Z_free(ret_var);
+ return ret_arr;
+}
+
+static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
+ return owner->a;
+}
+int32_t __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_get_a(uint32_t owner) {
+ LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
+ int32_t ret_val = C2Tuple_u32ScriptZ_get_a(owner_conv);
+ return ret_val;
+}
+
+static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
+ return CVec_u8Z_clone(&owner->b);
+}
+int8_tArray __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_get_b(uint32_t owner) {
+ LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
+ LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
+ int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
+ memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
+ CVec_u8Z_free(ret_var);
+ return ret_arr;
+}
+
+static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
+ return ThirtyTwoBytes_clone(&owner->a);
+}
+int8_tArray __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t owner) {
+ LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
+ int8_tArray ret_arr = init_int8_tArray(32);
+ memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data, 32);
+ return ret_arr;
+}
+
+static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
+ return owner->b;
+}
+uint32_tArray __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t owner) {
+ LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
+ LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
+ uint32_tArray ret_arr = NULL;
+ ret_arr = init_uint32_tArray(ret_var.datalen);
+ uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
+ for (size_t v = 0; v < ret_var.datalen; v++) {
+ LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
+ *ret_conv_21_conv = ret_var.data[v];
+ ret_arr_ptr[v] = ((uint64_t)ret_conv_21_conv);
+ }
+
+ FREE(ret_var.data);
+ return ret_arr;
+}
+
+static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
+ LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = MonitorEvent_clone(&orig->data[i]);
+ }
+ return ret;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKPaymentPurpose_ref_from_ptr(uint32_t ptr) {
+ LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKPaymentPurpose_InvoicePayment: {
+ int8_tArray payment_preimage_arr = init_int8_tArray(32);
+ memcpy(payment_preimage_arr->elems, obj->invoice_payment.payment_preimage.data, 32);
+ int8_tArray payment_secret_arr = init_int8_tArray(32);
+ memcpy(payment_secret_arr->elems, obj->invoice_payment.payment_secret.data, 32);
+ return 0 /* LDKPaymentPurpose - InvoicePayment */; (void) payment_preimage_arr; (void) payment_secret_arr;
+ }
+ case LDKPaymentPurpose_SpontaneousPayment: {
+ int8_tArray spontaneous_payment_arr = init_int8_tArray(32);
+ memcpy(spontaneous_payment_arr->elems, obj->spontaneous_payment.data, 32);
+ return 0 /* LDKPaymentPurpose - SpontaneousPayment */; (void) spontaneous_payment_arr;
+ }
+ default: abort();
+ }
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u64Z_ref_from_ptr(uint32_t ptr) {
+ LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKCOption_u64Z_Some: {
+ return 0 /* LDKCOption_u64Z - Some */; (void) obj->some;
+ }
+ case LDKCOption_u64Z_None: {
+ return 0 /* LDKCOption_u64Z - None */;
+ }
+ default: abort();
+ }
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKNetworkUpdate_ref_from_ptr(uint32_t ptr) {
+ LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKNetworkUpdate_ChannelUpdateMessage: {
+ LDKChannelUpdate msg_var = obj->channel_update_message.msg;
+ uint64_t msg_ref = 0;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKNetworkUpdate - ChannelUpdateMessage */; (void) msg_ref;
+ }
+ case LDKNetworkUpdate_ChannelClosed: {
+ return 0 /* LDKNetworkUpdate - ChannelClosed */; (void) obj->channel_closed.short_channel_id; (void) obj->channel_closed.is_permanent;
+ }
+ case LDKNetworkUpdate_NodeFailure: {
+ int8_tArray node_id_arr = init_int8_tArray(33);
+ memcpy(node_id_arr->elems, obj->node_failure.node_id.compressed_form, 33);
+ return 0 /* LDKNetworkUpdate - NodeFailure */; (void) node_id_arr; (void) obj->node_failure.is_permanent;
+ }
+ default: abort();
+ }
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCOption_NetworkUpdateZ_ref_from_ptr(uint32_t ptr) {
+ LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKCOption_NetworkUpdateZ_Some: {
+ uint64_t some_ref = ((uint64_t)&obj->some) | 1;
+ return 0 /* LDKCOption_NetworkUpdateZ - Some */; (void) some_ref;
+ }
+ case LDKCOption_NetworkUpdateZ_None: {
+ return 0 /* LDKCOption_NetworkUpdateZ - None */;
+ }
+ default: abort();
+ }
+}
+static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
+ LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = RouteHop_clone(&orig->data[i]);
+ }
+ return ret;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKSpendableOutputDescriptor_ref_from_ptr(uint32_t ptr) {
+ LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKSpendableOutputDescriptor_StaticOutput: {
+ LDKOutPoint outpoint_var = obj->static_output.outpoint;
+ uint64_t outpoint_ref = 0;
+ CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
+ outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
+ uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
+ return 0 /* LDKSpendableOutputDescriptor - StaticOutput */; (void) outpoint_ref; (void) (uint64_t)output_ref;
+ }
+ case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
+ LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
+ uint64_t delayed_payment_output_ref = 0;
+ CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
+ delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
+ return 0 /* LDKSpendableOutputDescriptor - DelayedPaymentOutput */; (void) delayed_payment_output_ref;
+ }
+ case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
+ LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
+ uint64_t static_payment_output_ref = 0;
+ CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
+ static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
+ return 0 /* LDKSpendableOutputDescriptor - StaticPaymentOutput */; (void) static_payment_output_ref;
+ }
+ default: abort();
+ }
+}
+static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
+ LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
+ }
+ return ret;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKClosureReason_ref_from_ptr(uint32_t ptr) {
+ LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKClosureReason_CounterpartyForceClosed: {
+ LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
+ jstring peer_msg_conv = str_ref_to_ts(peer_msg_str.chars, peer_msg_str.len);
+ return 0 /* LDKClosureReason - CounterpartyForceClosed */; (void) peer_msg_conv;
+ }
+ case LDKClosureReason_HolderForceClosed: {
+ return 0 /* LDKClosureReason - HolderForceClosed */;
+ }
+ case LDKClosureReason_CooperativeClosure: {
+ return 0 /* LDKClosureReason - CooperativeClosure */;
+ }
+ case LDKClosureReason_CommitmentTxConfirmed: {
+ return 0 /* LDKClosureReason - CommitmentTxConfirmed */;
+ }
+ case LDKClosureReason_FundingTimedOut: {
+ return 0 /* LDKClosureReason - FundingTimedOut */;
+ }
+ case LDKClosureReason_ProcessingError: {
+ LDKStr err_str = obj->processing_error.err;
+ jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
+ return 0 /* LDKClosureReason - ProcessingError */; (void) err_conv;
+ }
+ case LDKClosureReason_DisconnectedPeer: {
+ return 0 /* LDKClosureReason - DisconnectedPeer */;
+ }
+ case LDKClosureReason_OutdatedChannelManager: {
+ return 0 /* LDKClosureReason - OutdatedChannelManager */;
+ }
+ default: abort();
+ }
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKEvent_ref_from_ptr(uint32_t ptr) {
+ LDKEvent *obj = (LDKEvent*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKEvent_FundingGenerationReady: {
+ int8_tArray temporary_channel_id_arr = init_int8_tArray(32);
+ memcpy(temporary_channel_id_arr->elems, obj->funding_generation_ready.temporary_channel_id.data, 32);
+ LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
+ int8_tArray output_script_arr = init_int8_tArray(output_script_var.datalen);
+ memcpy(output_script_arr->elems, output_script_var.data, output_script_var.datalen);
+ return 0 /* LDKEvent - FundingGenerationReady */; (void) temporary_channel_id_arr; (void) obj->funding_generation_ready.channel_value_satoshis; (void) output_script_arr; (void) obj->funding_generation_ready.user_channel_id;
+ }
+ case LDKEvent_PaymentReceived: {
+ int8_tArray payment_hash_arr = init_int8_tArray(32);
+ memcpy(payment_hash_arr->elems, obj->payment_received.payment_hash.data, 32);
+ uint64_t purpose_ref = ((uint64_t)&obj->payment_received.purpose) | 1;
+ return 0 /* LDKEvent - PaymentReceived */; (void) payment_hash_arr; (void) obj->payment_received.amt; (void) purpose_ref;
+ }
+ case LDKEvent_PaymentSent: {
+ int8_tArray payment_id_arr = init_int8_tArray(32);
+ memcpy(payment_id_arr->elems, obj->payment_sent.payment_id.data, 32);
+ int8_tArray payment_preimage_arr = init_int8_tArray(32);
+ memcpy(payment_preimage_arr->elems, obj->payment_sent.payment_preimage.data, 32);
+ int8_tArray payment_hash_arr = init_int8_tArray(32);
+ memcpy(payment_hash_arr->elems, obj->payment_sent.payment_hash.data, 32);
+ uint64_t fee_paid_msat_ref = ((uint64_t)&obj->payment_sent.fee_paid_msat) | 1;
+ return 0 /* LDKEvent - PaymentSent */; (void) payment_id_arr; (void) payment_preimage_arr; (void) payment_hash_arr; (void) fee_paid_msat_ref;
+ }
+ case LDKEvent_PaymentPathFailed: {
+ int8_tArray payment_id_arr = init_int8_tArray(32);
+ memcpy(payment_id_arr->elems, obj->payment_path_failed.payment_id.data, 32);
+ int8_tArray payment_hash_arr = init_int8_tArray(32);
+ memcpy(payment_hash_arr->elems, obj->payment_path_failed.payment_hash.data, 32);
+ uint64_t network_update_ref = ((uint64_t)&obj->payment_path_failed.network_update) | 1;
+ LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
+ uint32_tArray path_arr = NULL;
+ path_arr = init_uint32_tArray(path_var.datalen);
+ uint32_t *path_arr_ptr = (uint32_t*)(path_arr + 4);
+ for (size_t k = 0; k < path_var.datalen; k++) {
+ LDKRouteHop path_conv_10_var = path_var.data[k];
+ uint64_t path_conv_10_ref = 0;
+ CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
+ path_conv_10_ref = (uint64_t)path_conv_10_var.inner & ~1;
+ path_arr_ptr[k] = path_conv_10_ref;
+ }
+
+ uint64_t short_channel_id_ref = ((uint64_t)&obj->payment_path_failed.short_channel_id) | 1;
+ LDKRouteParameters retry_var = obj->payment_path_failed.retry;
+ uint64_t retry_ref = 0;
+ if ((uint64_t)retry_var.inner > 4096) {
+ CHECK((((uint64_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
+ retry_ref = (uint64_t)retry_var.inner & ~1;
+ }
+ return 0 /* LDKEvent - PaymentPathFailed */; (void) payment_id_arr; (void) payment_hash_arr; (void) obj->payment_path_failed.rejected_by_dest; (void) network_update_ref; (void) obj->payment_path_failed.all_paths_failed; (void) path_arr; (void) short_channel_id_ref; (void) retry_ref;
+ }
+ case LDKEvent_PaymentFailed: {
+ int8_tArray payment_id_arr = init_int8_tArray(32);
+ memcpy(payment_id_arr->elems, obj->payment_failed.payment_id.data, 32);
+ int8_tArray payment_hash_arr = init_int8_tArray(32);
+ memcpy(payment_hash_arr->elems, obj->payment_failed.payment_hash.data, 32);
+ return 0 /* LDKEvent - PaymentFailed */; (void) payment_id_arr; (void) payment_hash_arr;
+ }
+ case LDKEvent_PendingHTLCsForwardable: {
+ return 0 /* LDKEvent - PendingHTLCsForwardable */; (void) obj->pending_htl_cs_forwardable.time_forwardable;
+ }
+ case LDKEvent_SpendableOutputs: {
+ LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
+ uint32_tArray outputs_arr = NULL;
+ outputs_arr = init_uint32_tArray(outputs_var.datalen);
+ uint32_t *outputs_arr_ptr = (uint32_t*)(outputs_arr + 4);
+ for (size_t b = 0; b < outputs_var.datalen; b++) {
+ uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
+ outputs_arr_ptr[b] = outputs_conv_27_ref;
+ }
+
+ return 0 /* LDKEvent - SpendableOutputs */; (void) outputs_arr;
+ }
+ case LDKEvent_PaymentForwarded: {
+ uint64_t fee_earned_msat_ref = ((uint64_t)&obj->payment_forwarded.fee_earned_msat) | 1;
+ return 0 /* LDKEvent - PaymentForwarded */; (void) fee_earned_msat_ref; (void) obj->payment_forwarded.claim_from_onchain_tx;
+ }
+ case LDKEvent_ChannelClosed: {
+ int8_tArray channel_id_arr = init_int8_tArray(32);
+ memcpy(channel_id_arr->elems, obj->channel_closed.channel_id.data, 32);
+ uint64_t reason_ref = ((uint64_t)&obj->channel_closed.reason) | 1;
+ return 0 /* LDKEvent - ChannelClosed */; (void) channel_id_arr; (void) obj->channel_closed.user_channel_id; (void) reason_ref;
+ }
+ case LDKEvent_DiscardFunding: {
+ int8_tArray channel_id_arr = init_int8_tArray(32);
+ memcpy(channel_id_arr->elems, obj->discard_funding.channel_id.data, 32);
+ LDKTransaction transaction_var = obj->discard_funding.transaction;
+ int8_tArray transaction_arr = init_int8_tArray(transaction_var.datalen);
+ memcpy(transaction_arr->elems, transaction_var.data, transaction_var.datalen);
+ return 0 /* LDKEvent - DiscardFunding */; (void) channel_id_arr; (void) transaction_arr;
+ }
+ case LDKEvent_PaymentPathSuccessful: {
+ int8_tArray payment_id_arr = init_int8_tArray(32);
+ memcpy(payment_id_arr->elems, obj->payment_path_successful.payment_id.data, 32);
+ int8_tArray payment_hash_arr = init_int8_tArray(32);
+ memcpy(payment_hash_arr->elems, obj->payment_path_successful.payment_hash.data, 32);
+ LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
+ uint32_tArray path_arr = NULL;
+ path_arr = init_uint32_tArray(path_var.datalen);
+ uint32_t *path_arr_ptr = (uint32_t*)(path_arr + 4);
+ for (size_t k = 0; k < path_var.datalen; k++) {
+ LDKRouteHop path_conv_10_var = path_var.data[k];
+ uint64_t path_conv_10_ref = 0;
+ CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
+ path_conv_10_ref = (uint64_t)path_conv_10_var.inner & ~1;
+ path_arr_ptr[k] = path_conv_10_ref;
+ }
+
+ return 0 /* LDKEvent - PaymentPathSuccessful */; (void) payment_id_arr; (void) payment_hash_arr; (void) path_arr;
+ }
+ default: abort();
+ }
+}
+static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
+ LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = Event_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
+ return owner->a;
+}
+int64_t __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_get_a(uint32_t owner) {
+ LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
+ int64_t ret_val = C2Tuple_usizeTransactionZ_get_a(owner_conv);
+ return ret_val;
+}
+
+static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
+ return owner->b;
+}
+int8_tArray __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_get_b(uint32_t owner) {
+ LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
+ LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
+ int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
+ memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
+ Transaction_free(ret_var);
+ return ret_arr;
+}
+
+static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
+ LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
+ return owner->a;
+}
+int32_t __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_get_a(uint32_t owner) {
+ LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
+ int32_t ret_val = C2Tuple_u32TxOutZ_get_a(owner_conv);
+ return ret_val;
+}
+
+static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
+ return TxOut_clone(&owner->b);
+}
+uint32_t __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_get_b(uint32_t owner) {
+ LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
+ LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
+ *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
+ return (uint64_t)ret_ref;
+}
+
+static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
+ LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
+ return ThirtyTwoBytes_clone(&owner->a);
+}
+int8_tArray __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t owner) {
+ LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
+ int8_tArray ret_arr = init_int8_tArray(32);
+ memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data, 32);
+ return ret_arr;
+}
+
+static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
+ return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
+}
+uint32_tArray __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t owner) {
+ LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
+ LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
+ uint32_tArray ret_arr = NULL;
+ ret_arr = init_uint32_tArray(ret_var.datalen);
+ uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
+ for (size_t u = 0; u < ret_var.datalen; u++) {
+ LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
+ *ret_conv_20_conv = ret_var.data[u];
+ ret_arr_ptr[u] = ((uint64_t)ret_conv_20_conv);
+ }
+
+ FREE(ret_var.data);
+ return ret_arr;
+}
+
+static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
+ LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * orig->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
+ LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
+ }
+ return ret;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKBalance_ref_from_ptr(uint32_t ptr) {
+ LDKBalance *obj = (LDKBalance*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKBalance_ClaimableOnChannelClose: {
+ return 0 /* LDKBalance - ClaimableOnChannelClose */; (void) obj->claimable_on_channel_close.claimable_amount_satoshis;
+ }
+ case LDKBalance_ClaimableAwaitingConfirmations: {
+ return 0 /* LDKBalance - ClaimableAwaitingConfirmations */; (void) obj->claimable_awaiting_confirmations.claimable_amount_satoshis; (void) obj->claimable_awaiting_confirmations.confirmation_height;
+ }
+ case LDKBalance_ContentiousClaimable: {
+ return 0 /* LDKBalance - ContentiousClaimable */; (void) obj->contentious_claimable.claimable_amount_satoshis; (void) obj->contentious_claimable.timeout_height;
+ }
+ case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: {
+ return 0 /* LDKBalance - MaybeClaimableHTLCAwaitingTimeout */; (void) obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis; (void) obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
+ }
+ default: abort();
+ }
+}
+static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
+ LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = Balance_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
+ return owner->a;
+}
+int8_tArray __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t owner) {
+ LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
+ int8_tArray ret_arr = init_int8_tArray(64);
+ memcpy(ret_arr->elems, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form, 64);
+ return ret_arr;
+}
+
+static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
+ return owner->b;
+}
+ptrArray __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t owner) {
+ LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
+ LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
+ ptrArray ret_arr = NULL;
+ ret_arr = init_ptrArray(ret_var.datalen);
+ int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
+ for (size_t m = 0; m < ret_var.datalen; m++) {
+ int8_tArray ret_conv_12_arr = init_int8_tArray(64);
+ memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
+ ret_arr_ptr[m] = ret_conv_12_arr;
+ }
+
+ FREE(ret_var.data);
+ return ret_arr;
+}
+
+static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t owner) {
+ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
+ LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
+ *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
+ return ((uint64_t)ret_conv);
+}
+
+static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return *owner->contents.err;
+}
+void __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t owner) {
+ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
+ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
+}
+
+static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return *owner->contents.result;
+}
+int8_tArray __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_get_ok(uint32_t owner) {
+ LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
+ int8_tArray ret_arr = init_int8_tArray(64);
+ memcpy(ret_arr->elems, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form, 64);
+ return ret_arr;
+}
+
+static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return *owner->contents.err;
+}
+void __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_get_err(uint32_t owner) {
+ LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
+ CResult_SignatureNoneZ_get_err(owner_conv);
+}
+
+typedef struct LDKBaseSign_JCalls {
+ atomic_size_t refcnt;
+ uint32_t get_per_commitment_point_meth;
+ uint32_t release_commitment_secret_meth;
+ uint32_t validate_holder_commitment_meth;
+ uint32_t channel_keys_id_meth;
+ uint32_t sign_counterparty_commitment_meth;
+ uint32_t validate_counterparty_revocation_meth;
+ uint32_t sign_holder_commitment_and_htlcs_meth;
+ uint32_t sign_justice_revoked_output_meth;
+ uint32_t sign_justice_revoked_htlc_meth;
+ uint32_t sign_counterparty_htlc_transaction_meth;
+ uint32_t sign_closing_transaction_meth;
+ uint32_t sign_channel_announcement_meth;
+ uint32_t ready_channel_meth;
+} LDKBaseSign_JCalls;
+static void LDKBaseSign_JCalls_free(void* this_arg) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ js_free_function_ptr(j_calls->get_per_commitment_point_meth);
+ js_free_function_ptr(j_calls->release_commitment_secret_meth);
+ js_free_function_ptr(j_calls->validate_holder_commitment_meth);
+ js_free_function_ptr(j_calls->channel_keys_id_meth);
+ js_free_function_ptr(j_calls->sign_counterparty_commitment_meth);
+ js_free_function_ptr(j_calls->validate_counterparty_revocation_meth);
+ js_free_function_ptr(j_calls->sign_holder_commitment_and_htlcs_meth);
+ js_free_function_ptr(j_calls->sign_justice_revoked_output_meth);
+ js_free_function_ptr(j_calls->sign_justice_revoked_htlc_meth);
+ js_free_function_ptr(j_calls->sign_counterparty_htlc_transaction_meth);
+ js_free_function_ptr(j_calls->sign_closing_transaction_meth);
+ js_free_function_ptr(j_calls->sign_channel_announcement_meth);
+ js_free_function_ptr(j_calls->ready_channel_meth);
+ FREE(j_calls);
+ }
+}
+LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ int8_tArray ret = (int8_tArray)js_invoke_function_1(j_calls->get_per_commitment_point_meth, (uint32_t)idx);
+ LDKPublicKey ret_ref;
+ CHECK(ret->arr_len == 33);
+ memcpy(ret_ref.compressed_form, ret->elems, 33);
+ return ret_ref;
+}
+LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ int8_tArray ret = (int8_tArray)js_invoke_function_1(j_calls->release_commitment_secret_meth, (uint32_t)idx);
+ LDKThirtyTwoBytes ret_ref;
+ CHECK(ret->arr_len == 32);
+ memcpy(ret_ref.data, ret->elems, 32);
+ return ret_ref;
+}
+LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
+ uint64_t holder_tx_ref = 0;
+ holder_tx_var = HolderCommitmentTransaction_clone(holder_tx);
+ CHECK((((uint64_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
+ holder_tx_ref = (uint64_t)holder_tx_var.inner;
+ if (holder_tx_var.is_owned) {
+ holder_tx_ref |= 1;
+ }
+ uint32_t ret = js_invoke_function_1(j_calls->validate_holder_commitment_meth, (uint32_t)holder_tx_ref);
+ void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
+ FREE((void*)ret);
+ return ret_conv;
+}
+LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->channel_keys_id_meth);
+ LDKThirtyTwoBytes ret_ref;
+ CHECK(ret->arr_len == 32);
+ memcpy(ret_ref.data, ret->elems, 32);
+ return ret_ref;
+}
+LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
+ uint64_t commitment_tx_ref = 0;
+ commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
+ CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
+ commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
+ if (commitment_tx_var.is_owned) {
+ commitment_tx_ref |= 1;
+ }
+ uint32_t ret = js_invoke_function_1(j_calls->sign_counterparty_commitment_meth, (uint32_t)commitment_tx_ref);
+ void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
+ FREE((void*)ret);
+ return ret_conv;
+}
+LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ int8_tArray secret_arr = init_int8_tArray(32);
+ memcpy(secret_arr->elems, *secret, 32);
+ uint32_t ret = js_invoke_function_2(j_calls->validate_counterparty_revocation_meth, (uint32_t)idx, (uint32_t)secret_arr);
+ void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
+ FREE((void*)ret);
+ return ret_conv;
+}
+LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
+ uint64_t commitment_tx_ref = 0;
+ commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
+ CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
+ commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
+ if (commitment_tx_var.is_owned) {
+ commitment_tx_ref |= 1;
+ }
+ uint32_t ret = js_invoke_function_1(j_calls->sign_holder_commitment_and_htlcs_meth, (uint32_t)commitment_tx_ref);
+ void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
+ FREE((void*)ret);
+ return ret_conv;
+}
+LDKCResult_SignatureNoneZ sign_justice_revoked_output_LDKBaseSign_jcall(const void* this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (* per_commitment_key)[32]) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ LDKTransaction justice_tx_var = justice_tx;
+ int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen);
+ memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
+ Transaction_free(justice_tx_var);
+ int8_tArray per_commitment_key_arr = init_int8_tArray(32);
+ memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
+ uint32_t ret = js_invoke_function_4(j_calls->sign_justice_revoked_output_meth, (uint32_t)justice_tx_arr, (uint32_t)input, (uint32_t)amount, (uint32_t)per_commitment_key_arr);
+ void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
+ FREE((void*)ret);
+ return ret_conv;
+}
+LDKCResult_SignatureNoneZ sign_justice_revoked_htlc_LDKBaseSign_jcall(const void* this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (* per_commitment_key)[32], const LDKHTLCOutputInCommitment * htlc) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ LDKTransaction justice_tx_var = justice_tx;
+ int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen);
+ memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
+ Transaction_free(justice_tx_var);
+ int8_tArray per_commitment_key_arr = init_int8_tArray(32);
+ memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
+ LDKHTLCOutputInCommitment htlc_var = *htlc;
+ uint64_t htlc_ref = 0;
+ htlc_var = HTLCOutputInCommitment_clone(htlc);
+ CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
+ htlc_ref = (uint64_t)htlc_var.inner;
+ if (htlc_var.is_owned) {
+ htlc_ref |= 1;
+ }
+ uint32_t ret = js_invoke_function_5(j_calls->sign_justice_revoked_htlc_meth, (uint32_t)justice_tx_arr, (uint32_t)input, (uint32_t)amount, (uint32_t)per_commitment_key_arr, (uint32_t)htlc_ref);
+ void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
+ FREE((void*)ret);
+ return ret_conv;
+}
+LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, LDKPublicKey per_commitment_point, const LDKHTLCOutputInCommitment * htlc) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ LDKTransaction htlc_tx_var = htlc_tx;
+ int8_tArray htlc_tx_arr = init_int8_tArray(htlc_tx_var.datalen);
+ memcpy(htlc_tx_arr->elems, htlc_tx_var.data, htlc_tx_var.datalen);
+ Transaction_free(htlc_tx_var);
+ int8_tArray per_commitment_point_arr = init_int8_tArray(33);
+ memcpy(per_commitment_point_arr->elems, per_commitment_point.compressed_form, 33);
+ LDKHTLCOutputInCommitment htlc_var = *htlc;
+ uint64_t htlc_ref = 0;
+ htlc_var = HTLCOutputInCommitment_clone(htlc);
+ CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
+ htlc_ref = (uint64_t)htlc_var.inner;
+ if (htlc_var.is_owned) {
+ htlc_ref |= 1;
+ }
+ uint32_t ret = js_invoke_function_5(j_calls->sign_counterparty_htlc_transaction_meth, (uint32_t)htlc_tx_arr, (uint32_t)input, (uint32_t)amount, (uint32_t)per_commitment_point_arr, (uint32_t)htlc_ref);
+ void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
+ FREE((void*)ret);
+ return ret_conv;
+}
+LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ LDKClosingTransaction closing_tx_var = *closing_tx;
+ uint64_t closing_tx_ref = 0;
+ closing_tx_var = ClosingTransaction_clone(closing_tx);
+ CHECK((((uint64_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
+ closing_tx_ref = (uint64_t)closing_tx_var.inner;
+ if (closing_tx_var.is_owned) {
+ closing_tx_ref |= 1;
+ }
+ uint32_t ret = js_invoke_function_1(j_calls->sign_closing_transaction_meth, (uint32_t)closing_tx_ref);
+ void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
+ FREE((void*)ret);
+ return ret_conv;
+}
+LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ LDKUnsignedChannelAnnouncement msg_var = *msg;
+ uint64_t msg_ref = 0;
+ msg_var = UnsignedChannelAnnouncement_clone(msg);
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uint64_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ uint32_t ret = js_invoke_function_1(j_calls->sign_channel_announcement_meth, (uint32_t)msg_ref);
+ void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
+ FREE((void*)ret);
+ return ret_conv;
+}
+void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
+ uint64_t channel_parameters_ref = 0;
+ channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
+ CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
+ channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
+ if (channel_parameters_var.is_owned) {
+ channel_parameters_ref |= 1;
+ }
+ js_invoke_function_1(j_calls->ready_channel_meth, (uint32_t)channel_parameters_ref);
+}
+static void LDKBaseSign_JCalls_cloned(LDKBaseSign* new_obj) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKBaseSign LDKBaseSign_init (/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
+ LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ //TODO: Assign calls->o from o
+
+ LDKChannelPublicKeys pubkeys_conv;
+ pubkeys_conv.inner = (void*)(pubkeys & (~1));
+ pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
+
+ LDKBaseSign ret = {
+ .this_arg = (void*) calls,
+ .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
+ .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
+ .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
+ .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
+ .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
+ .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
+ .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
+ .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
+ .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
+ .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
+ .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
+ .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
+ .ready_channel = ready_channel_LDKBaseSign_jcall,
+ .free = LDKBaseSign_JCalls_free,
+ .pubkeys = pubkeys_conv,
+ .set_pubkeys = NULL,
+ };
+ return ret;
+}
+long __attribute__((visibility("default"))) TS_LDKBaseSign_new(/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
+ LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
+ *res_ptr = LDKBaseSign_init(o, pubkeys);
+ return (long)res_ptr;
+}
+int8_tArray __attribute__((visibility("default"))) TS_BaseSign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ int8_tArray ret_arr = init_int8_tArray(33);
+ memcpy(ret_arr->elems, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
+ return ret_arr;
+}
+
+int8_tArray __attribute__((visibility("default"))) TS_BaseSign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ int8_tArray ret_arr = init_int8_tArray(32);
+ memcpy(ret_arr->elems, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
+ return ret_arr;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_BaseSign_validate_holder_commitment(uint32_t this_arg, uint32_t holder_tx) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ LDKHolderCommitmentTransaction holder_tx_conv;
+ holder_tx_conv.inner = (void*)(holder_tx & (~1));
+ holder_tx_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
+ LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
+ *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv);
+ return (uint64_t)ret_conv;
+}
+
+int8_tArray __attribute__((visibility("default"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ int8_tArray ret_arr = init_int8_tArray(32);
+ memcpy(ret_arr->elems, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
+ return ret_arr;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_BaseSign_sign_counterparty_commitment(uint32_t this_arg, uint32_t commitment_tx) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ LDKCommitmentTransaction commitment_tx_conv;
+ commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
+ commitment_tx_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
+ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
+ *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_BaseSign_validate_counterparty_revocation(uint32_t this_arg, int64_t idx, int8_tArray secret) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ unsigned char secret_arr[32];
+ CHECK(secret->arr_len == 32);
+ memcpy(secret_arr, secret->elems, 32);
+ unsigned char (*secret_ref)[32] = &secret_arr;
+ LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
+ *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_BaseSign_sign_holder_commitment_and_htlcs(uint32_t this_arg, uint32_t commitment_tx) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ LDKHolderCommitmentTransaction commitment_tx_conv;
+ commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
+ commitment_tx_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
+ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
+ *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_BaseSign_sign_justice_revoked_output(uint32_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ LDKTransaction justice_tx_ref;
+ justice_tx_ref.datalen = justice_tx->arr_len;
+ justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
+ memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen);
+ justice_tx_ref.data_is_owned = true;
+ unsigned char per_commitment_key_arr[32];
+ CHECK(per_commitment_key->arr_len == 32);
+ memcpy(per_commitment_key_arr, per_commitment_key->elems, 32);
+ unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
+ LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
+ *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_BaseSign_sign_justice_revoked_htlc(uint32_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key, uint32_t htlc) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ LDKTransaction justice_tx_ref;
+ justice_tx_ref.datalen = justice_tx->arr_len;
+ justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
+ memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen);
+ justice_tx_ref.data_is_owned = true;
+ unsigned char per_commitment_key_arr[32];
+ CHECK(per_commitment_key->arr_len == 32);
+ memcpy(per_commitment_key_arr, per_commitment_key->elems, 32);
+ unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
+ LDKHTLCOutputInCommitment htlc_conv;
+ htlc_conv.inner = (void*)(htlc & (~1));
+ htlc_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
+ LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
+ *ret_conv = (this_arg_conv->sign_justice_revoked_htlc)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref, &htlc_conv);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_BaseSign_sign_counterparty_htlc_transaction(uint32_t this_arg, int8_tArray htlc_tx, int64_t input, int64_t amount, int8_tArray per_commitment_point, uint32_t htlc) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ LDKTransaction htlc_tx_ref;
+ htlc_tx_ref.datalen = htlc_tx->arr_len;
+ htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
+ memcpy(htlc_tx_ref.data, htlc_tx->elems, htlc_tx_ref.datalen);
+ htlc_tx_ref.data_is_owned = true;
+ LDKPublicKey per_commitment_point_ref;
+ CHECK(per_commitment_point->arr_len == 33);
+ memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33);
+ LDKHTLCOutputInCommitment htlc_conv;
+ htlc_conv.inner = (void*)(htlc & (~1));
+ htlc_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
+ LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
+ *ret_conv = (this_arg_conv->sign_counterparty_htlc_transaction)(this_arg_conv->this_arg, htlc_tx_ref, input, amount, per_commitment_point_ref, &htlc_conv);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, uint32_t closing_tx) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ LDKClosingTransaction closing_tx_conv;
+ closing_tx_conv.inner = (void*)(closing_tx & (~1));
+ closing_tx_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
+ LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
+ *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_BaseSign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ LDKUnsignedChannelAnnouncement msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
+ LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
+ *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
+ return (uint64_t)ret_conv;
+}
+
+void __attribute__((visibility("default"))) TS_BaseSign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ LDKChannelTransactionParameters channel_parameters_conv;
+ channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
+ channel_parameters_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
+ (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
+}
+
+LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
+ if (this_arg->set_pubkeys != NULL)
+ this_arg->set_pubkeys(this_arg);
+ return this_arg->pubkeys;
+}
+uint32_t __attribute__((visibility("default"))) TS_BaseSign_get_pubkeys(uint32_t this_arg) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+typedef struct LDKSign_JCalls {
+ atomic_size_t refcnt;
+ LDKBaseSign_JCalls* BaseSign;
+ uint32_t write_meth;
+} LDKSign_JCalls;
+static void LDKSign_JCalls_free(void* this_arg) {
+ LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ js_free_function_ptr(j_calls->write_meth);
+ FREE(j_calls);
+ }
+}
+LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
+ LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
+ int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->write_meth);
+ LDKCVec_u8Z ret_ref;
+ ret_ref.datalen = ret->arr_len;
+ ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
+ memcpy(ret_ref.data, ret->elems, ret_ref.datalen);
+ return ret_ref;
+}
+static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
+ LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+ atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
+}
+static inline LDKSign LDKSign_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* BaseSign, uint32_t pubkeys) {
+ LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ //TODO: Assign calls->o from o
+
+ LDKChannelPublicKeys pubkeys_conv;
+ pubkeys_conv.inner = (void*)(pubkeys & (~1));
+ pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
+
+ LDKSign ret = {
+ .this_arg = (void*) calls,
+ .write = write_LDKSign_jcall,
+ .cloned = LDKSign_JCalls_cloned,
+ .free = LDKSign_JCalls_free,
+ .BaseSign = LDKBaseSign_init(BaseSign, pubkeys),
+ };
+ calls->BaseSign = ret.BaseSign.this_arg;
+ return ret;
+}
+long __attribute__((visibility("default"))) TS_LDKSign_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* BaseSign, uint32_t pubkeys) {
+ LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
+ *res_ptr = LDKSign_init(o, BaseSign, pubkeys);
+ return (long)res_ptr;
+}
+int8_tArray __attribute__((visibility("default"))) TS_Sign_write(uint32_t this_arg) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
+ LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
+ int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
+ memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
+ CVec_u8Z_free(ret_var);
+ return ret_arr;
+}
+
+static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
+ return ThirtyTwoBytes_clone(&owner->a);
+}
+int8_tArray __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t owner) {
+ LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
+ int8_tArray ret_arr = init_int8_tArray(32);
+ memcpy(ret_arr->elems, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data, 32);
+ return ret_arr;
+}
+
+static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
+ return ChannelMonitor_clone(&owner->b);
+}
+uint32_t __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t owner) {
+ LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
+ LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t owner) {
+ LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
+ LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
+ *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
+ return ((uint64_t)ret_conv);
+}
+
+static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t owner) {
+ LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return RouteHop_clone(&*owner->contents.result);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_get_ok(uint32_t owner) {
+ LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
+ LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_get_err(uint32_t owner) {
+ LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
+ LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return Route_clone(&*owner->contents.result);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_get_ok(uint32_t owner) {
+ LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
+ LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_get_err(uint32_t owner) {
+ LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_RouteDecodeErrorZ_get_err(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return RouteParameters_clone(&*owner->contents.result);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_RouteParametersDecodeErrorZ_get_ok(uint32_t owner) {
+ LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
+ LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_RouteParametersDecodeErrorZ_get_err(uint32_t owner) {
+ LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
+ LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = RouteHint_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline struct LDKPayee CResult_PayeeDecodeErrorZ_get_ok(LDKCResult_PayeeDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return Payee_clone(&*owner->contents.result);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_PayeeDecodeErrorZ_get_ok(uint32_t owner) {
+ LDKCResult_PayeeDecodeErrorZ* owner_conv = (LDKCResult_PayeeDecodeErrorZ*)(owner & ~1);
+ LDKPayee ret_var = CResult_PayeeDecodeErrorZ_get_ok(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_PayeeDecodeErrorZ_get_err(LDKCResult_PayeeDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_PayeeDecodeErrorZ_get_err(uint32_t owner) {
+ LDKCResult_PayeeDecodeErrorZ* owner_conv = (LDKCResult_PayeeDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_PayeeDecodeErrorZ_get_err(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
+ LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = RouteHintHop_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return RouteHint_clone(&*owner->contents.result);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_RouteHintDecodeErrorZ_get_ok(uint32_t owner) {
+ LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
+ LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_RouteHintDecodeErrorZ_get_err(uint32_t owner) {
+ LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return RouteHintHop_clone(&*owner->contents.result);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_RouteHintHopDecodeErrorZ_get_ok(uint32_t owner) {
+ LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
+ LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_RouteHintHopDecodeErrorZ_get_err(uint32_t owner) {
+ LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
+ LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = ChannelDetails_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return Route_clone(&*owner->contents.result);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_get_ok(uint32_t owner) {
+ LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
+ LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return LightningError_clone(&*owner->contents.err);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_get_err(uint32_t owner) {
+ LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
+ LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return *owner->contents.result;
+}
+void __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_get_ok(uint32_t owner) {
+ LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
+ CResult_NoneLightningErrorZ_get_ok(owner_conv);
+}
+
+static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return LightningError_clone(&*owner->contents.err);
+}
+uint32_t __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_get_err(uint32_t owner) {
+ LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
+ LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
+ return owner->a;
+}
+int8_tArray __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_get_a(uint32_t owner) {
+ LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
+ int8_tArray ret_arr = init_int8_tArray(33);
+ memcpy(ret_arr->elems, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form, 33);
+ return ret_arr;
+}
+
+static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
+ return Type_clone(&owner->b);
+}
+uint32_t __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_get_b(uint32_t owner) {
+ LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
+ LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
+ *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
+ return (uint64_t)ret_ret;
+}
+
+static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
+ LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
+ }
+ return ret;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKErrorAction_ref_from_ptr(uint32_t ptr) {
+ LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKErrorAction_DisconnectPeer: {
+ LDKErrorMessage msg_var = obj->disconnect_peer.msg;
+ uint64_t msg_ref = 0;
+ if ((uint64_t)msg_var.inner > 4096) {
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ }
+ return 0 /* LDKErrorAction - DisconnectPeer */; (void) msg_ref;
+ }
+ case LDKErrorAction_IgnoreError: {
+ return 0 /* LDKErrorAction - IgnoreError */;
+ }
+ case LDKErrorAction_IgnoreAndLog: {
+ uint32_t ignore_and_log_conv = LDKLevel_to_js(obj->ignore_and_log);
+ return 0 /* LDKErrorAction - IgnoreAndLog */; (void) ignore_and_log_conv;
+ }
+ case LDKErrorAction_IgnoreDuplicateGossip: {
+ return 0 /* LDKErrorAction - IgnoreDuplicateGossip */;
+ }
+ case LDKErrorAction_SendErrorMessage: {
+ LDKErrorMessage msg_var = obj->send_error_message.msg;
+ uint64_t msg_ref = 0;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKErrorAction - SendErrorMessage */; (void) msg_ref;
+ }
+ default: abort();
+ }
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKMessageSendEvent_ref_from_ptr(uint32_t ptr) {
+ LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKMessageSendEvent_SendAcceptChannel: {
+ int8_tArray node_id_arr = init_int8_tArray(33);
+ memcpy(node_id_arr->elems, obj->send_accept_channel.node_id.compressed_form, 33);
+ LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
+ uint64_t msg_ref = 0;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendAcceptChannel */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_SendOpenChannel: {
+ int8_tArray node_id_arr = init_int8_tArray(33);
+ memcpy(node_id_arr->elems, obj->send_open_channel.node_id.compressed_form, 33);
+ LDKOpenChannel msg_var = obj->send_open_channel.msg;
+ uint64_t msg_ref = 0;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendOpenChannel */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_SendFundingCreated: {
+ int8_tArray node_id_arr = init_int8_tArray(33);
+ memcpy(node_id_arr->elems, obj->send_funding_created.node_id.compressed_form, 33);
+ LDKFundingCreated msg_var = obj->send_funding_created.msg;
+ uint64_t msg_ref = 0;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendFundingCreated */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_SendFundingSigned: {
+ int8_tArray node_id_arr = init_int8_tArray(33);
+ memcpy(node_id_arr->elems, obj->send_funding_signed.node_id.compressed_form, 33);
+ LDKFundingSigned msg_var = obj->send_funding_signed.msg;
+ uint64_t msg_ref = 0;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendFundingSigned */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_SendFundingLocked: {
+ int8_tArray node_id_arr = init_int8_tArray(33);
+ memcpy(node_id_arr->elems, obj->send_funding_locked.node_id.compressed_form, 33);
+ LDKFundingLocked msg_var = obj->send_funding_locked.msg;
+ uint64_t msg_ref = 0;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendFundingLocked */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_SendAnnouncementSignatures: {
+ int8_tArray node_id_arr = init_int8_tArray(33);
+ memcpy(node_id_arr->elems, obj->send_announcement_signatures.node_id.compressed_form, 33);
+ LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
+ uint64_t msg_ref = 0;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendAnnouncementSignatures */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_UpdateHTLCs: {
+ int8_tArray node_id_arr = init_int8_tArray(33);
+ memcpy(node_id_arr->elems, obj->update_htl_cs.node_id.compressed_form, 33);
+ LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
+ uint64_t updates_ref = 0;
+ CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
+ updates_ref = (uint64_t)updates_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - UpdateHTLCs */; (void) node_id_arr; (void) updates_ref;
+ }
+ case LDKMessageSendEvent_SendRevokeAndACK: {
+ int8_tArray node_id_arr = init_int8_tArray(33);
+ memcpy(node_id_arr->elems, obj->send_revoke_and_ack.node_id.compressed_form, 33);
+ LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
+ uint64_t msg_ref = 0;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendRevokeAndACK */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_SendClosingSigned: {
+ int8_tArray node_id_arr = init_int8_tArray(33);
+ memcpy(node_id_arr->elems, obj->send_closing_signed.node_id.compressed_form, 33);
+ LDKClosingSigned msg_var = obj->send_closing_signed.msg;
+ uint64_t msg_ref = 0;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendClosingSigned */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_SendShutdown: {
+ int8_tArray node_id_arr = init_int8_tArray(33);
+ memcpy(node_id_arr->elems, obj->send_shutdown.node_id.compressed_form, 33);
+ LDKShutdown msg_var = obj->send_shutdown.msg;