]> git.bitcoin.ninja Git - ldk-java/commitdiff
Bindings updates
authorMatt Corallo <git@bluematt.me>
Thu, 28 Jan 2021 23:12:43 +0000 (18:12 -0500)
committerMatt Corallo <git@bluematt.me>
Thu, 28 Jan 2021 23:12:43 +0000 (18:12 -0500)
src/main/java/org/ldk/impl/bindings.java
src/main/java/org/ldk/structs/ChannelMonitor.java
src/main/java/org/ldk/structs/CommonBase.java
src/main/jni/bindings.c
src/main/jni/org_ldk_impl_bindings.h
ts/bindings.c
ts/bindings.ts
ts/structs/ChannelMonitor.ts

index f9d99ca5a4b6d028a978c89d817588f31caf74ce..f3b8dfd7b2016888630ec4fa82c8eb888a0140c0 100644 (file)
@@ -706,6 +706,8 @@ public class bindings {
        public static native void Transaction_free(byte[] _res);
        // void TxOut_free(struct LDKTxOut _res);
        public static native void TxOut_free(long _res);
+       // struct LDKTxOut TxOut_clone(const struct LDKTxOut *NONNULL_PTR orig);
+       public static native long TxOut_clone(long orig);
        // void CVec_SpendableOutputDescriptorZ_free(struct LDKCVec_SpendableOutputDescriptorZ _res);
        public static native void CVec_SpendableOutputDescriptorZ_free(long[] _res);
        // void CVec_MessageSendEventZ_free(struct LDKCVec_MessageSendEventZ _res);
@@ -788,18 +790,24 @@ public class bindings {
        public static native long CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
        // void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res);
        public static native void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(long _res);
+       // struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(const struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR orig);
+       public static native long CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(long orig);
        // struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_ok(struct LDKSignature o);
        public static native long CResult_SignatureNoneZ_ok(byte[] o);
        // struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_err(void);
        public static native long CResult_SignatureNoneZ_err();
        // void CResult_SignatureNoneZ_free(struct LDKCResult_SignatureNoneZ _res);
        public static native void CResult_SignatureNoneZ_free(long _res);
+       // struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_clone(const struct LDKCResult_SignatureNoneZ *NONNULL_PTR orig);
+       public static native long CResult_SignatureNoneZ_clone(long orig);
        // struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_ok(struct LDKCVec_SignatureZ o);
        public static native long CResult_CVec_SignatureZNoneZ_ok(byte[][] o);
        // struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_err(void);
        public static native long CResult_CVec_SignatureZNoneZ_err();
        // void CResult_CVec_SignatureZNoneZ_free(struct LDKCResult_CVec_SignatureZNoneZ _res);
        public static native void CResult_CVec_SignatureZNoneZ_free(long _res);
+       // struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_clone(const struct LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR orig);
+       public static native long CResult_CVec_SignatureZNoneZ_clone(long orig);
        // struct LDKCResult_ChanKeySignerDecodeErrorZ CResult_ChanKeySignerDecodeErrorZ_ok(struct LDKChannelKeys o);
        public static native long CResult_ChanKeySignerDecodeErrorZ_ok(long o);
        // struct LDKCResult_ChanKeySignerDecodeErrorZ CResult_ChanKeySignerDecodeErrorZ_err(struct LDKDecodeError e);
index 5ace2c3668acaad0b123cf3e14924b37a842ac10..22011661185b0b080faa70e067bd9fc25ab92635 100644 (file)
@@ -83,7 +83,7 @@ public class ChannelMonitor extends CommonBase {
                        for (int a = 0; a < arr_conv_46_b.length; a++) {
                                long arr_conv_26 = arr_conv_46_b[a];
                                int arr_conv_26_a = bindings.LDKC2Tuple_u32TxOutZ_get_a(arr_conv_26);
-                               long arr_conv_26_b = bindings.LDKC2Tuple_u32TxOutZ_get_b(arr_conv_26);
+                               long arr_conv_26_b = bindings.TxOut_clone(bindings.LDKC2Tuple_u32TxOutZ_get_b(arr_conv_26));
                                TxOut arr_conv_26_b_conv = new TxOut(null, arr_conv_26_b);;
                                TwoTuple<Integer, TxOut> arr_conv_26_conv = new TwoTuple<Integer, TxOut>(arr_conv_26_a, arr_conv_26_b_conv);
                                arr_conv_26_arr[a] = arr_conv_26_conv;
index acff6661da49875fe3379c8c4dab9052827246ab..42971b3f35b3e36f04d0946f96cf47921c4b5af7 100644 (file)
@@ -1,7 +1,7 @@
 package org.ldk.structs;
 import java.util.LinkedList;
 class CommonBase {
-       long ptr;
+       final long ptr;
        LinkedList<Object> ptrs_to = new LinkedList();
        protected CommonBase(long ptr) { this.ptr = ptr; }
        public long _test_only_get_ptr() { return this.ptr; }
index 0250b692285dc66e220a02900270476bf57c645d..3a878484cb197611b08d4411eb84da7136c2d050 100644 (file)
@@ -1305,6 +1305,13 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1new(
        ret->b = b_conv;
        return (long)ret;
 }
+static inline LDKC2Tuple_u32TxOutZ C2Tuple_u32TxOutZ_clone(const LDKC2Tuple_u32TxOutZ *orig) {
+       LDKC2Tuple_u32TxOutZ ret = {
+               .a = orig->a,
+               .b = TxOut_clone(&orig->b),
+       };
+       return ret;
+}
 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
        LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)ptr;
        return tuple->a;
@@ -1332,6 +1339,13 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32TxOutZ
        }
        return (long)ret;
 }
+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;
+}
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
        LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
        LDKThirtyTwoBytes a_ref;
@@ -1355,6 +1369,13 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tup
        ret->b = b_constr;
        return (long)ret;
 }
+static inline LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(const LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *orig) {
+       LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ ret = {
+               .a = ThirtyTwoBytes_clone(&orig->a),
+               .b = CVec_C2Tuple_u32TxOutZZ_clone(&orig->b),
+       };
+       return ret;
+}
 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
        LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)ptr;
        int8_tArray a_arr = (*env)->NewByteArray(env, 32);
@@ -1391,6 +1412,13 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_
        }
        return (long)ret;
 }
+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;
+}
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
        LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
        LDKSignature a_ref;
@@ -1539,7 +1567,7 @@ LDKC2Tuple_u64u64Z key_derivation_params_jcall(const void* this_arg) {
        CHECK(obj != NULL);
        LDKC2Tuple_u64u64Z* ret = (LDKC2Tuple_u64u64Z*)(*env)->CallLongMethod(env, obj, j_calls->key_derivation_params_meth);
        LDKC2Tuple_u64u64Z ret_conv = *(LDKC2Tuple_u64u64Z*)ret;
-       FREE((void*)ret);
+       ret_conv = C2Tuple_u64u64Z_clone((LDKC2Tuple_u64u64Z*)ret);
        return ret_conv;
 }
 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
@@ -1559,7 +1587,7 @@ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_j
        CHECK(obj != NULL);
        LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
        LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)ret;
-       FREE((void*)ret);
+       ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)ret);
        return ret_conv;
 }
 LDKCResult_SignatureNoneZ sign_holder_commitment_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
@@ -1579,7 +1607,7 @@ LDKCResult_SignatureNoneZ sign_holder_commitment_jcall(const void* this_arg, con
        CHECK(obj != NULL);
        LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_meth, commitment_tx_ref);
        LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)ret;
-       FREE((void*)ret);
+       ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
        return ret_conv;
 }
 LDKCResult_CVec_SignatureZNoneZ sign_holder_commitment_htlc_transactions_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
@@ -1599,7 +1627,7 @@ LDKCResult_CVec_SignatureZNoneZ sign_holder_commitment_htlc_transactions_jcall(c
        CHECK(obj != NULL);
        LDKCResult_CVec_SignatureZNoneZ* ret = (LDKCResult_CVec_SignatureZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_htlc_transactions_meth, commitment_tx_ref);
        LDKCResult_CVec_SignatureZNoneZ ret_conv = *(LDKCResult_CVec_SignatureZNoneZ*)ret;
-       FREE((void*)ret);
+       ret_conv = CResult_CVec_SignatureZNoneZ_clone((LDKCResult_CVec_SignatureZNoneZ*)ret);
        return ret_conv;
 }
 LDKCResult_SignatureNoneZ sign_justice_transaction_jcall(const void* this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (* per_commitment_key)[32], const LDKHTLCOutputInCommitment * htlc) {
@@ -1625,7 +1653,7 @@ LDKCResult_SignatureNoneZ sign_justice_transaction_jcall(const void* this_arg, L
        CHECK(obj != NULL);
        LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_justice_transaction_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
        LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)ret;
-       FREE((void*)ret);
+       ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
        return ret_conv;
 }
 LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_jcall(const void* this_arg, LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, LDKPublicKey per_commitment_point, const LDKHTLCOutputInCommitment * htlc) {
@@ -1651,7 +1679,7 @@ LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_jcall(const void* t
        CHECK(obj != NULL);
        LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref);
        LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)ret;
-       FREE((void*)ret);
+       ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
        return ret_conv;
 }
 LDKCResult_SignatureNoneZ sign_closing_transaction_jcall(const void* this_arg, LDKTransaction closing_tx) {
@@ -1666,7 +1694,7 @@ LDKCResult_SignatureNoneZ sign_closing_transaction_jcall(const void* this_arg, L
        CHECK(obj != NULL);
        LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_arr);
        LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)ret;
-       FREE((void*)ret);
+       ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
        return ret_conv;
 }
 LDKCResult_SignatureNoneZ sign_channel_announcement_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
@@ -1686,7 +1714,7 @@ LDKCResult_SignatureNoneZ sign_channel_announcement_jcall(const void* this_arg,
        CHECK(obj != NULL);
        LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
        LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)ret;
-       FREE((void*)ret);
+       ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
        return ret_conv;
 }
 void ready_channel_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
@@ -2050,6 +2078,19 @@ JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessError
        jclass err_conv = LDKAccessError_to_java(env, (*val->contents.err));
        return err_conv;
 }
+static inline LDKCResult_TxOutAccessErrorZ CResult_TxOutAccessErrorZ_clone(const LDKCResult_TxOutAccessErrorZ *orig) {
+       LDKCResult_TxOutAccessErrorZ res = { .result_ok = orig->result_ok };
+       if (orig->result_ok) {
+               LDKTxOut* contents = MALLOC(sizeof(LDKTxOut), "LDKTxOut result OK clone");
+               *contents = TxOut_clone(orig->contents.result);
+               res.contents.result = contents;
+       } else {
+               LDKAccessError* contents = MALLOC(sizeof(LDKAccessError), "LDKAccessError result Err clone");
+               *contents = AccessError_clone(orig->contents.err);
+               res.contents.err = contents;
+       }
+       return res;
+}
 static jclass LDKAPIError_APIMisuseError_class = NULL;
 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
@@ -2329,7 +2370,7 @@ LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_jcall(const void* this_arg
        CHECK(obj != NULL);
        LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
        LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)ret;
-       FREE((void*)ret);
+       ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
        return ret_conv;
 }
 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
@@ -2354,7 +2395,7 @@ LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_jcall(const void* this_ar
        CHECK(obj != NULL);
        LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
        LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)ret;
-       FREE((void*)ret);
+       ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
        return ret_conv;
 }
 LDKCVec_MonitorEventZ release_pending_monitor_events_jcall(const void* this_arg) {
@@ -2624,7 +2665,7 @@ LDKCResult_ChanKeySignerDecodeErrorZ read_chan_signer_jcall(const void* this_arg
        CHECK(obj != NULL);
        LDKCResult_ChanKeySignerDecodeErrorZ* ret = (LDKCResult_ChanKeySignerDecodeErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
        LDKCResult_ChanKeySignerDecodeErrorZ ret_conv = *(LDKCResult_ChanKeySignerDecodeErrorZ*)ret;
-       FREE((void*)ret);
+       // Warning: we may need a move here but can't do a full clone!
        return ret_conv;
 }
 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
@@ -3962,7 +4003,7 @@ LDKCResult_TxOutAccessErrorZ get_utxo_jcall(const void* this_arg, const uint8_t
        CHECK(obj != NULL);
        LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
        LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)ret;
-       FREE((void*)ret);
+       ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)ret);
        return ret_conv;
 }
 static void* LDKAccess_JCalls_clone(const void* this_arg) {
@@ -4146,7 +4187,7 @@ LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_jcall(const void* th
        CHECK(obj != NULL);
        LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, id_ref, data_ref);
        LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)ret;
-       FREE((void*)ret);
+       ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
        return ret_conv;
 }
 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
@@ -4181,7 +4222,7 @@ LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_jcall(const voi
        CHECK(obj != NULL);
        LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
        LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)ret;
-       FREE((void*)ret);
+       ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
        return ret_conv;
 }
 static void* LDKPersist_JCalls_clone(const void* this_arg) {
@@ -4988,7 +5029,7 @@ LDKCResult_boolLightningErrorZ handle_node_announcement_jcall(const void* this_a
        CHECK(obj != NULL);
        LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
        LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)ret;
-       FREE((void*)ret);
+       // Warning: we may need a move here but can't do a full clone!
        return ret_conv;
 }
 LDKCResult_boolLightningErrorZ handle_channel_announcement_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
@@ -5008,7 +5049,7 @@ LDKCResult_boolLightningErrorZ handle_channel_announcement_jcall(const void* thi
        CHECK(obj != NULL);
        LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
        LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)ret;
-       FREE((void*)ret);
+       // Warning: we may need a move here but can't do a full clone!
        return ret_conv;
 }
 LDKCResult_boolLightningErrorZ handle_channel_update_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
@@ -5028,7 +5069,7 @@ LDKCResult_boolLightningErrorZ handle_channel_update_jcall(const void* this_arg,
        CHECK(obj != NULL);
        LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
        LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)ret;
-       FREE((void*)ret);
+       // Warning: we may need a move here but can't do a full clone!
        return ret_conv;
 }
 void handle_htlc_fail_channel_update_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
@@ -5127,7 +5168,7 @@ LDKCResult_NoneLightningErrorZ handle_reply_channel_range_jcall(const void* this
        CHECK(obj != NULL);
        LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
        LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)ret;
-       FREE((void*)ret);
+       // Warning: we may need a move here but can't do a full clone!
        return ret_conv;
 }
 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
@@ -5147,7 +5188,7 @@ LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_jcall(const vo
        CHECK(obj != NULL);
        LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
        LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)ret;
-       FREE((void*)ret);
+       // Warning: we may need a move here but can't do a full clone!
        return ret_conv;
 }
 LDKCResult_NoneLightningErrorZ handle_query_channel_range_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
@@ -5167,7 +5208,7 @@ LDKCResult_NoneLightningErrorZ handle_query_channel_range_jcall(const void* this
        CHECK(obj != NULL);
        LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
        LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)ret;
-       FREE((void*)ret);
+       // Warning: we may need a move here but can't do a full clone!
        return ret_conv;
 }
 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
@@ -5187,7 +5228,7 @@ LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_jcall(const void*
        CHECK(obj != NULL);
        LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
        LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)ret;
-       FREE((void*)ret);
+       // Warning: we may need a move here but can't do a full clone!
        return ret_conv;
 }
 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
@@ -5526,6 +5567,13 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclas
        TxOut_free(_res_conv);
 }
 
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKTxOut* orig_conv = (LDKTxOut*)orig;
+       LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
+       *ret_ref = TxOut_clone(orig_conv);
+       return (long)ret_ref;
+}
+
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
        LDKCVec_SpendableOutputDescriptorZ _res_constr;
        _res_constr.datalen = (*env)->GetArrayLength(env, _res);
@@ -5756,7 +5804,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNI
        FREE((void*)b);
        LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
        *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
-       // XXX: We likely need to clone here, but no _clone fn is available for TxOut
+       ret_ref->b = TxOut_clone(&ret_ref->b);
        return (long)ret_ref;
 }
 
@@ -5805,7 +5853,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_
        LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
        *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
        ret_ref->a = ThirtyTwoBytes_clone(&ret_ref->a);
-       // XXX: We likely need to clone here, but no _clone fn is available for TwoTuple<Integer, TxOut>[]
+       ret_ref->b = CVec_C2Tuple_u32TxOutZZ_clone(&ret_ref->b);
        return (long)ret_ref;
 }
 
@@ -5975,6 +6023,13 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVe
        CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
 }
 
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)orig;
+       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
+       *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
+       return (long)ret_conv;
+}
+
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
        LDKSignature o_ref;
        CHECK((*env)->GetArrayLength(env, o) == 64);
@@ -5996,6 +6051,13 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(
        CResult_SignatureNoneZ_free(_res_conv);
 }
 
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)orig;
+       LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
+       *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
+       return (long)ret_conv;
+}
+
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
        LDKCVec_SignatureZ o_constr;
        o_constr.datalen = (*env)->GetArrayLength(env, o);
@@ -6027,6 +6089,13 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ
        CResult_CVec_SignatureZNoneZ_free(_res_conv);
 }
 
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)orig;
+       LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
+       *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
+       return (long)ret_conv;
+}
+
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChanKeySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
        LDKChannelKeys o_conv = *(LDKChannelKeys*)o;
        if (o_conv.free == LDKChannelKeys_JCalls_free) {
@@ -8293,7 +8362,7 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1block_
                LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arr_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
                *arr_conv_46_ref = ret_var.data[u];
                arr_conv_46_ref->a = ThirtyTwoBytes_clone(&arr_conv_46_ref->a);
-               // XXX: We likely need to clone here, but no _clone fn is available for TwoTuple<Integer, TxOut>[]
+               arr_conv_46_ref->b = CVec_C2Tuple_u32TxOutZZ_clone(&arr_conv_46_ref->b);
                ret_arr_ptr[u] = (long)arr_conv_46_ref;
        }
        (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
index ee3cbdae6ee1f432b37ddd32e8a97b380b63fb69..eb34b84aa3b6b4b9b51a3042100b5597a07e6c8c 100644 (file)
@@ -2247,6 +2247,14 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free
   (JNIEnv *, jclass, jlong);
 
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    TxOut_clone
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxOut_1clone
+  (JNIEnv *, jclass, jlong);
+
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    CVec_SpendableOutputDescriptorZ_free
@@ -2575,6 +2583,14 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCV
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free
   (JNIEnv *, jclass, jlong);
 
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone
+  (JNIEnv *, jclass, jlong);
+
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    CResult_SignatureNoneZ_ok
@@ -2599,6 +2615,14 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free
   (JNIEnv *, jclass, jlong);
 
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    CResult_SignatureNoneZ_clone
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone
+  (JNIEnv *, jclass, jlong);
+
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    CResult_CVec_SignatureZNoneZ_ok
@@ -2623,6 +2647,14 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNone
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free
   (JNIEnv *, jclass, jlong);
 
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    CResult_CVec_SignatureZNoneZ_clone
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone
+  (JNIEnv *, jclass, jlong);
+
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    CResult_ChanKeySignerDecodeErrorZ_ok
index 02371f495ec9aae9be36c28462872a239e569675..54ab899b0bf16926b5393973a517b4e14a1cbcd8 100644 (file)
@@ -108,10 +108,6 @@ _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen),
 
 _Static_assert(sizeof(void*) == 4, "Pointers mut be 32 bits");
 
-//typedef struct int64_tArray { uint32_t *len; /* len + 1 is data */ } int64_tArray;
-//typedef struct uint32_tArray { uint32_t *len; /* len + 1 is data */ } uint32_tArray;
-//typedef struct ptrArray { uint32_t *len; /* len + 1 is data */ } ptrArray;
-//typedef struct int8_tArray { uint32_t *len; /* len + 1 is data */ } int8_tArray;
 typedef uint32_t int64_tArray;
 typedef uint32_t int8_tArray;
 typedef uint32_t uint32_tArray;
@@ -133,6 +129,12 @@ jstring str_ref_to_ts(const char* chars, size_t len) {
 
 typedef bool jboolean;
 
+uint32_t __attribute__((visibility("default"))) TS_malloc(uint32_t size) {
+       return (uint32_t)MALLOC(size, "JS-Called malloc");
+}
+void __attribute__((visibility("default"))) TS_free(uint32_t ptr) {
+       FREE((void*)ptr);
+}
 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
 static inline LDKAccessError LDKAccessError_from_js(int32_t ord) {
        switch (ord) {
@@ -819,6 +821,13 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_new(int
        ret->b = b_conv;
        return (long)ret;
 }
+static inline LDKC2Tuple_u32TxOutZ C2Tuple_u32TxOutZ_clone(const LDKC2Tuple_u32TxOutZ *orig) {
+       LDKC2Tuple_u32TxOutZ ret = {
+               .a = orig->a,
+               .b = TxOut_clone(&orig->b),
+       };
+       return ret;
+}
 int32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_get_a(uint32_t ptr) {
        LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)ptr;
        return tuple->a;
@@ -845,6 +854,13 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32TxOutZZ_n
        }
        return (long)ret;
 }
+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;
+}
 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
        LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
        LDKThirtyTwoBytes a_ref;
@@ -867,6 +883,13 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_
        ret->b = b_constr;
        return (long)ret;
 }
+static inline LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(const LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *orig) {
+       LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ ret = {
+               .a = ThirtyTwoBytes_clone(&orig->a),
+               .b = CVec_C2Tuple_u32TxOutZZ_clone(&orig->b),
+       };
+       return ret;
+}
 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t ptr) {
        LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)ptr;
        int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
@@ -901,6 +924,13 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2T
        }
        return (long)ret;
 }
+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;
+}
 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
        LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
        LDKSignature a_ref;
@@ -1045,7 +1075,7 @@ LDKC2Tuple_u64u64Z key_derivation_params_jcall(const void* this_arg) {
        LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
        LDKC2Tuple_u64u64Z* ret = (LDKC2Tuple_u64u64Z*)js_invoke_function_0(j_calls->key_derivation_params_meth);
        LDKC2Tuple_u64u64Z ret_conv = *(LDKC2Tuple_u64u64Z*)ret;
-       FREE((void*)ret);
+       ret_conv = C2Tuple_u64u64Z_clone((LDKC2Tuple_u64u64Z*)ret);
        return ret_conv;
 }
 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
@@ -1061,7 +1091,7 @@ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_j
        }
        LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)js_invoke_function_1(j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
        LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)ret;
-       FREE((void*)ret);
+       ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)ret);
        return ret_conv;
 }
 LDKCResult_SignatureNoneZ sign_holder_commitment_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
@@ -1077,7 +1107,7 @@ LDKCResult_SignatureNoneZ sign_holder_commitment_jcall(const void* this_arg, con
        }
        LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_1(j_calls->sign_holder_commitment_meth, commitment_tx_ref);
        LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)ret;
-       FREE((void*)ret);
+       ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
        return ret_conv;
 }
 LDKCResult_CVec_SignatureZNoneZ sign_holder_commitment_htlc_transactions_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
@@ -1093,7 +1123,7 @@ LDKCResult_CVec_SignatureZNoneZ sign_holder_commitment_htlc_transactions_jcall(c
        }
        LDKCResult_CVec_SignatureZNoneZ* ret = (LDKCResult_CVec_SignatureZNoneZ*)js_invoke_function_1(j_calls->sign_holder_commitment_htlc_transactions_meth, commitment_tx_ref);
        LDKCResult_CVec_SignatureZNoneZ ret_conv = *(LDKCResult_CVec_SignatureZNoneZ*)ret;
-       FREE((void*)ret);
+       ret_conv = CResult_CVec_SignatureZNoneZ_clone((LDKCResult_CVec_SignatureZNoneZ*)ret);
        return ret_conv;
 }
 LDKCResult_SignatureNoneZ sign_justice_transaction_jcall(const void* this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (* per_commitment_key)[32], const LDKHTLCOutputInCommitment * htlc) {
@@ -1115,7 +1145,7 @@ LDKCResult_SignatureNoneZ sign_justice_transaction_jcall(const void* this_arg, L
        }
        LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_5(j_calls->sign_justice_transaction_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
        LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)ret;
-       FREE((void*)ret);
+       ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
        return ret_conv;
 }
 LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_jcall(const void* this_arg, LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, LDKPublicKey per_commitment_point, const LDKHTLCOutputInCommitment * htlc) {
@@ -1137,7 +1167,7 @@ LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_jcall(const void* t
        }
        LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_5(j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref);
        LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)ret;
-       FREE((void*)ret);
+       ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
        return ret_conv;
 }
 LDKCResult_SignatureNoneZ sign_closing_transaction_jcall(const void* this_arg, LDKTransaction closing_tx) {
@@ -1148,7 +1178,7 @@ LDKCResult_SignatureNoneZ sign_closing_transaction_jcall(const void* this_arg, L
        Transaction_free(closing_tx_var);
        LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_1(j_calls->sign_closing_transaction_meth, closing_tx_arr);
        LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)ret;
-       FREE((void*)ret);
+       ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
        return ret_conv;
 }
 LDKCResult_SignatureNoneZ sign_channel_announcement_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
@@ -1164,7 +1194,7 @@ LDKCResult_SignatureNoneZ sign_channel_announcement_jcall(const void* this_arg,
        }
        LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_1(j_calls->sign_channel_announcement_meth, msg_ref);
        LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)ret;
-       FREE((void*)ret);
+       ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
        return ret_conv;
 }
 void ready_channel_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
@@ -1493,6 +1523,19 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ
        uint32_t err_conv = LDKAccessError_to_js((*val->contents.err));
        return err_conv;
 }
+static inline LDKCResult_TxOutAccessErrorZ CResult_TxOutAccessErrorZ_clone(const LDKCResult_TxOutAccessErrorZ *orig) {
+       LDKCResult_TxOutAccessErrorZ res = { .result_ok = orig->result_ok };
+       if (orig->result_ok) {
+               LDKTxOut* contents = MALLOC(sizeof(LDKTxOut), "LDKTxOut result OK clone");
+               *contents = TxOut_clone(orig->contents.result);
+               res.contents.result = contents;
+       } else {
+               LDKAccessError* contents = MALLOC(sizeof(LDKAccessError), "LDKAccessError result Err clone");
+               *contents = AccessError_clone(orig->contents.err);
+               res.contents.err = contents;
+       }
+       return res;
+}
 uint32_t __attribute__((visibility("default"))) TS_LDKAPIError_ref_from_ptr(uint32_t ptr) {
        LDKAPIError *obj = (LDKAPIError*)ptr;
        switch(obj->tag) {
@@ -1696,7 +1739,7 @@ LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_jcall(const void* this_arg
        }
        LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
        LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)ret;
-       FREE((void*)ret);
+       ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
        return ret_conv;
 }
 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
@@ -1717,7 +1760,7 @@ LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_jcall(const void* this_ar
        }
        LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->update_channel_meth, funding_txo_ref, update_ref);
        LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)ret;
-       FREE((void*)ret);
+       ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
        return ret_conv;
 }
 LDKCVec_MonitorEventZ release_pending_monitor_events_jcall(const void* this_arg) {
@@ -1936,7 +1979,7 @@ LDKCResult_ChanKeySignerDecodeErrorZ read_chan_signer_jcall(const void* this_arg
        memcpy((uint8_t*)(reader_arr + 4), reader_var.data, reader_var.datalen);
        LDKCResult_ChanKeySignerDecodeErrorZ* ret = (LDKCResult_ChanKeySignerDecodeErrorZ*)js_invoke_function_1(j_calls->read_chan_signer_meth, reader_arr);
        LDKCResult_ChanKeySignerDecodeErrorZ ret_conv = *(LDKCResult_ChanKeySignerDecodeErrorZ*)ret;
-       FREE((void*)ret);
+       // Warning: we may need a move here but can't do a full clone!
        return ret_conv;
 }
 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
@@ -3185,7 +3228,7 @@ LDKCResult_TxOutAccessErrorZ get_utxo_jcall(const void* this_arg, const uint8_t
        memcpy((uint8_t*)(genesis_hash_arr + 4), *genesis_hash, 32);
        LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)js_invoke_function_2(j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
        LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)ret;
-       FREE((void*)ret);
+       ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)ret);
        return ret_conv;
 }
 static void* LDKAccess_JCalls_clone(const void* this_arg) {
@@ -3337,7 +3380,7 @@ LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_jcall(const void* th
        }
        LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->persist_new_channel_meth, id_ref, data_ref);
        LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)ret;
-       FREE((void*)ret);
+       ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
        return ret_conv;
 }
 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
@@ -3368,7 +3411,7 @@ LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_jcall(const voi
        }
        LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_3(j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
        LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)ret;
-       FREE((void*)ret);
+       ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
        return ret_conv;
 }
 static void* LDKPersist_JCalls_clone(const void* this_arg) {
@@ -4067,7 +4110,7 @@ LDKCResult_boolLightningErrorZ handle_node_announcement_jcall(const void* this_a
        }
        LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_node_announcement_meth, msg_ref);
        LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)ret;
-       FREE((void*)ret);
+       // Warning: we may need a move here but can't do a full clone!
        return ret_conv;
 }
 LDKCResult_boolLightningErrorZ handle_channel_announcement_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
@@ -4083,7 +4126,7 @@ LDKCResult_boolLightningErrorZ handle_channel_announcement_jcall(const void* thi
        }
        LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_channel_announcement_meth, msg_ref);
        LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)ret;
-       FREE((void*)ret);
+       // Warning: we may need a move here but can't do a full clone!
        return ret_conv;
 }
 LDKCResult_boolLightningErrorZ handle_channel_update_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
@@ -4099,7 +4142,7 @@ LDKCResult_boolLightningErrorZ handle_channel_update_jcall(const void* this_arg,
        }
        LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_channel_update_meth, msg_ref);
        LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)ret;
-       FREE((void*)ret);
+       // Warning: we may need a move here but can't do a full clone!
        return ret_conv;
 }
 void handle_htlc_fail_channel_update_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
@@ -4176,7 +4219,7 @@ LDKCResult_NoneLightningErrorZ handle_reply_channel_range_jcall(const void* this
        }
        LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
        LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)ret;
-       FREE((void*)ret);
+       // Warning: we may need a move here but can't do a full clone!
        return ret_conv;
 }
 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
@@ -4192,7 +4235,7 @@ LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_jcall(const vo
        }
        LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
        LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)ret;
-       FREE((void*)ret);
+       // Warning: we may need a move here but can't do a full clone!
        return ret_conv;
 }
 LDKCResult_NoneLightningErrorZ handle_query_channel_range_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
@@ -4208,7 +4251,7 @@ LDKCResult_NoneLightningErrorZ handle_query_channel_range_jcall(const void* this
        }
        LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
        LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)ret;
-       FREE((void*)ret);
+       // Warning: we may need a move here but can't do a full clone!
        return ret_conv;
 }
 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
@@ -4224,7 +4267,7 @@ LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_jcall(const void*
        }
        LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
        LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)ret;
-       FREE((void*)ret);
+       // Warning: we may need a move here but can't do a full clone!
        return ret_conv;
 }
 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
@@ -4507,6 +4550,13 @@ void  __attribute__((visibility("default"))) TS_TxOut_free(uint32_t _res) {
        TxOut_free(_res_conv);
 }
 
+uint32_t  __attribute__((visibility("default"))) TS_TxOut_clone(uint32_t orig) {
+       LDKTxOut* orig_conv = (LDKTxOut*)orig;
+       LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
+       *ret_ref = TxOut_clone(orig_conv);
+       return (long)ret_ref;
+}
+
 void  __attribute__((visibility("default"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
        LDKCVec_SpendableOutputDescriptorZ _res_constr;
        _res_constr.datalen = *((uint32_t*)_res);
@@ -4733,7 +4783,7 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_new(int32_
        FREE((void*)b);
        LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
        *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
-       // XXX: We likely need to clone here, but no _clone fn is available for TxOut
+       ret_ref->b = TxOut_clone(&ret_ref->b);
        return (long)ret_ref;
 }
 
@@ -4780,7 +4830,7 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32
        LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
        *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
        ret_ref->a = ThirtyTwoBytes_clone(&ret_ref->a);
-       // XXX: We likely need to clone here, but no _clone fn is available for TwoTuple<Number, TxOut>[]
+       ret_ref->b = CVec_C2Tuple_u32TxOutZZ_clone(&ret_ref->b);
        return (long)ret_ref;
 }
 
@@ -4951,6 +5001,13 @@ void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_Si
        CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
 }
 
+uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
+       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)orig;
+       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
+       *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
+       return (long)ret_conv;
+}
+
 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
        LDKSignature o_ref;
        CHECK(*((uint32_t*)o) == 64);
@@ -4972,6 +5029,13 @@ void  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_free(uint
        CResult_SignatureNoneZ_free(_res_conv);
 }
 
+uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
+       LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)orig;
+       LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
+       *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
+       return (long)ret_conv;
+}
+
 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
        LDKCVec_SignatureZ o_constr;
        o_constr.datalen = *((uint32_t*)o);
@@ -5004,6 +5068,13 @@ void  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_fre
        CResult_CVec_SignatureZNoneZ_free(_res_conv);
 }
 
+uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
+       LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)orig;
+       LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
+       *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
+       return (long)ret_conv;
+}
+
 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChanKeySignerDecodeErrorZ_ok(uint32_t o) {
        LDKChannelKeys o_conv = *(LDKChannelKeys*)o;
        LDKCResult_ChanKeySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChanKeySignerDecodeErrorZ), "LDKCResult_ChanKeySignerDecodeErrorZ");
@@ -7220,7 +7291,7 @@ uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_block_co
                LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arr_conv_49_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
                *arr_conv_49_ref = ret_var.data[x];
                arr_conv_49_ref->a = ThirtyTwoBytes_clone(&arr_conv_49_ref->a);
-               // XXX: We likely need to clone here, but no _clone fn is available for TwoTuple<Number, TxOut>[]
+               arr_conv_49_ref->b = CVec_C2Tuple_u32TxOutZZ_clone(&arr_conv_49_ref->b);
                ret_arr_ptr[x] = (long)arr_conv_49_ref;
        }
        FREE(ret_var.data);
index ea1e7fbe14cecee87c5f3e7c5e5fa3f31ae07e25..330dde75fe5f18a14aea726191bdc8611d49882f 100644 (file)
@@ -27,9 +27,18 @@ const nextMultipleOfFour = (value: number) => {
     return Math.ceil(value / 4) * 4;
 }
 
-const encodeArray = (inputArray) => {
-       const cArrayPointer = wasm.wasm_malloc((inputArray.length + 1) * 4);
-       const arrayMemoryView = new Uint32Array(memory.buffer, cArrayPointer + 4, inputArray.length);
+const encodeUint8Array = (inputArray) => {
+       const cArrayPointer = wasm.TS_malloc(inputArray.length + 4);
+       const arrayLengthView = new Uint32Array(memory.buffer, cArrayPointer, 1);
+    arrayLengthView[0] = inputArray.length;
+       const arrayMemoryView = new Uint8Array(memory.buffer, cArrayPointer + 4, inputArray.length);
+       arrayMemoryView.set(inputArray);
+       return cArrayPointer;
+}
+
+const encodeUint32Array = (inputArray) => {
+       const cArrayPointer = wasm.TS_malloc((inputArray.length + 1) * 4);
+       const arrayMemoryView = new Uint32Array(memory.buffer, cArrayPointer, inputArray.length);
        arrayMemoryView.set(inputArray, 1);
     arrayMemoryView[0] = inputArray.length;
        return cArrayPointer;
@@ -54,7 +63,7 @@ const decodeUint8Array = (arrayPointer, free = true) => {
        // will free the underlying memory when it becomes unreachable instead of copying here.
        const actualArray = actualArrayViewer.slice(0, arraySize);
        if (free) {
-               wasm.free(arrayPointer);
+               wasm.TS_free(arrayPointer);
        }
        return actualArray;
 }
@@ -69,7 +78,7 @@ const decodeUint32Array = (arrayPointer, free = true) => {
        // will free the underlying memory when it becomes unreachable instead of copying here.
        const actualArray = actualArrayViewer.slice(0, arraySize);
        if (free) {
-               wasm.free(arrayPointer);
+               wasm.TS_free(arrayPointer);
        }
        return actualArray;
 }
@@ -77,7 +86,7 @@ const decodeUint32Array = (arrayPointer, free = true) => {
 const encodeString = (string) => {
     // make malloc count divisible by 4
     const memoryNeed = nextMultipleOfFour(string.length + 1);
-    const stringPointer = wasm.wasm_malloc(memoryNeed);
+    const stringPointer = wasm.TS_malloc(memoryNeed);
     const stringMemoryView = new Uint8Array(
         memory.buffer, // value
         stringPointer, // offset
@@ -1376,6 +1385,14 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.TxOut_free(_res);
                // debug statements here
        }
+       // struct LDKTxOut TxOut_clone(const struct LDKTxOut *NONNULL_PTR orig);
+       export function TxOut_clone(orig: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.TxOut_clone(orig);
+               return nativeResponseValue;
+       }
        // void CVec_SpendableOutputDescriptorZ_free(struct LDKCVec_SpendableOutputDescriptorZ _res);
        export function CVec_SpendableOutputDescriptorZ_free(_res: number[]): void {
                if(!isWasmInitialized) {
@@ -1704,6 +1721,14 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res);
                // debug statements here
        }
+       // struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(const struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR orig);
+       export function CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig);
+               return nativeResponseValue;
+       }
        // struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_ok(struct LDKSignature o);
        export function CResult_SignatureNoneZ_ok(o: Uint8Array): number {
                if(!isWasmInitialized) {
@@ -1728,6 +1753,14 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.CResult_SignatureNoneZ_free(_res);
                // debug statements here
        }
+       // struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_clone(const struct LDKCResult_SignatureNoneZ *NONNULL_PTR orig);
+       export function CResult_SignatureNoneZ_clone(orig: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.CResult_SignatureNoneZ_clone(orig);
+               return nativeResponseValue;
+       }
        // struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_ok(struct LDKCVec_SignatureZ o);
        export function CResult_CVec_SignatureZNoneZ_ok(o: Uint8Array[]): number {
                if(!isWasmInitialized) {
@@ -1752,6 +1785,14 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.CResult_CVec_SignatureZNoneZ_free(_res);
                // debug statements here
        }
+       // struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_clone(const struct LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR orig);
+       export function CResult_CVec_SignatureZNoneZ_clone(orig: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.CResult_CVec_SignatureZNoneZ_clone(orig);
+               return nativeResponseValue;
+       }
        // struct LDKCResult_ChanKeySignerDecodeErrorZ CResult_ChanKeySignerDecodeErrorZ_ok(struct LDKChannelKeys o);
        export function CResult_ChanKeySignerDecodeErrorZ_ok(o: number): number {
                if(!isWasmInitialized) {
index 9c3bc931c38090ebffef8134e28289e1e7064a48..96bf8c5bf1d5418d96e51d8b5ee2912aecd935fd 100644 (file)
@@ -87,7 +87,7 @@ import * as bindings from '../bindings' // TODO: figure out location
                        for (int z = 0; z < arr_conv_49_b.length; z++) {
                                number arr_conv_25 = arr_conv_49_b[z];
                                number arr_conv_25_a = bindings.LDKC2Tuple_u32TxOutZ_get_a(arr_conv_25);
-                               number arr_conv_25_b = bindings.LDKC2Tuple_u32TxOutZ_get_b(arr_conv_25);
+                               number arr_conv_25_b = bindings.TxOut_clone(bindings.LDKC2Tuple_u32TxOutZ_get_b(arr_conv_25));
                                TxOut arr_conv_25_b_conv = new TxOut(null, arr_conv_25_b);;
                                TwoTuple<Number, TxOut> arr_conv_25_conv = new TwoTuple<Number, TxOut>(arr_conv_25_a, arr_conv_25_b_conv);
                                arr_conv_25_arr[z] = arr_conv_25_conv;