bindings updates
[ldk-java] / src / main / jni / bindings.c
index 81d87d3d5acf16de6e1d2bef75d84864ca6fd119..9c42cc38745a8489d1aea8e0d244f7051613175b 100644 (file)
@@ -119,6 +119,7 @@ JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclas
        CHECK(arr_of_B_clz != NULL);
        arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz);
 }
+static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
 
 static jmethodID ordinal_meth = NULL;
 static jmethodID slicedef_meth = NULL;
@@ -471,12 +472,24 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u8Z_1new(JNIEnv *env
        }
        return (long)ret;
 }
+static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
+       LDKCVec_u8Z ret = { .data = MALLOC(sizeof(jbyte) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
+       memcpy(ret.data, orig->data, sizeof(jbyte) * ret.datalen);
+       return ret;
+}
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u64u64Z_1new(JNIEnv *_env, jclass _b, jlong a, jlong b) {
        LDKC2Tuple_u64u64Z* ret = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
        ret->a = a;
        ret->b = b;
        return (long)ret;
 }
+static inline LDKC2Tuple_u64u64Z C2Tuple_u64u64Z_clone(const LDKC2Tuple_u64u64Z *orig) {
+       LDKC2Tuple_u64u64Z ret = {
+               .a = orig->a,
+               .b = orig->b,
+       };
+       return ret;
+}
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u64u64Z_1get_1a(JNIEnv *_env, jclass _b, jlong ptr) {
        LDKC2Tuple_u64u64Z *tuple = (LDKC2Tuple_u64u64Z*)ptr;
        return tuple->a;
@@ -566,6 +579,13 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1SpendableOutputDescr
        }
        return (long)ret;
 }
+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;
+}
 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
 static jclass LDKErrorAction_IgnoreError_class = NULL;
@@ -964,6 +984,13 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MessageSendEventZ_1n
        }
        return (long)ret;
 }
+static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
+       LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
+       for (size_t i = 0; i < ret.datalen; i++) {
+               ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
+       }
+       return ret;
+}
 static jclass LDKEvent_FundingGenerationReady_class = NULL;
 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
 static jclass LDKEvent_FundingBroadcastSafe_class = NULL;
@@ -1089,6 +1116,13 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1EventZ_1new(JNIEnv *
        }
        return (long)ret;
 }
+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;
+}
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1new(JNIEnv *_env, jclass _b, jlong a, jbyteArray b) {
        LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
        ret->a = a;
@@ -1147,6 +1181,17 @@ JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonit
        jclass err_conv = LDKChannelMonitorUpdateErr_to_java(_env, (*val->contents.err));
        return err_conv;
 }
+static inline LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_clone(const LDKCResult_NoneChannelMonitorUpdateErrZ *orig) {
+       LDKCResult_NoneChannelMonitorUpdateErrZ res = { .result_ok = orig->result_ok };
+       if (orig->result_ok) {
+               res.contents.result = NULL;
+       } else {
+               LDKChannelMonitorUpdateErr* contents = MALLOC(sizeof(LDKChannelMonitorUpdateErr), "LDKChannelMonitorUpdateErr result Err clone");
+               *contents = ChannelMonitorUpdateErr_clone(orig->contents.err);
+               res.contents.err = contents;
+       }
+       return res;
+}
 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MonitorEventZ_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
        LDKCVec_MonitorEventZ *vec = (LDKCVec_MonitorEventZ*)ptr;
        jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
@@ -1179,6 +1224,13 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MonitorEventZ_1new(J
        }
        return (long)ret;
 }
+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;
+}
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
        return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
 }
@@ -1232,6 +1284,13 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1
        ret->b = b_ref;
        return (long)ret;
 }
+static inline LDKC2Tuple_OutPointScriptZ C2Tuple_OutPointScriptZ_clone(const LDKC2Tuple_OutPointScriptZ *orig) {
+       LDKC2Tuple_OutPointScriptZ ret = {
+               .a = OutPoint_clone(&orig->a),
+               .b = CVec_u8Z_clone(&orig->b),
+       };
+       return ret;
+}
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *_env, jclass _b, jlong ptr) {
        LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)ptr;
        LDKOutPoint a_var = tuple->a;
@@ -2106,6 +2165,17 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1ge
        long err_ref = (long)&(*val->contents.err);
        return err_ref;
 }
+static inline LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_clone(const LDKCResult_NoneAPIErrorZ *orig) {
+       LDKCResult_NoneAPIErrorZ res = { .result_ok = orig->result_ok };
+       if (orig->result_ok) {
+               res.contents.result = NULL;
+       } else {
+               LDKAPIError* contents = MALLOC(sizeof(LDKAPIError), "LDKAPIError result Err clone");
+               *contents = APIError_clone(orig->contents.err);
+               res.contents.err = contents;
+       }
+       return res;
+}
 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelDetailsZ_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
        LDKCVec_ChannelDetailsZ *vec = (LDKCVec_ChannelDetailsZ*)ptr;
        jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
@@ -2138,6 +2208,13 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelDetailsZ_1new
        }
        return (long)ret;
 }
+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;
+}
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
        return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
 }
@@ -2233,6 +2310,13 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NetAddressZ_1new(JNI
        }
        return (long)ret;
 }
+static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
+       LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
+       for (size_t i = 0; i < ret.datalen; i++) {
+               ret.data[i] = NetAddress_clone(&orig->data[i]);
+       }
+       return ret;
+}
 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelMonitorZ_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
        LDKCVec_ChannelMonitorZ *vec = (LDKCVec_ChannelMonitorZ*)ptr;
        jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
@@ -2884,6 +2968,19 @@ JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1ge
        CHECK(!val->result_ok);
        return *val->contents.err;
 }
+static inline LDKCResult_NetAddressu8Z CResult_NetAddressu8Z_clone(const LDKCResult_NetAddressu8Z *orig) {
+       LDKCResult_NetAddressu8Z res = { .result_ok = orig->result_ok };
+       if (orig->result_ok) {
+               LDKNetAddress* contents = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress result OK clone");
+               *contents = NetAddress_clone(orig->contents.result);
+               res.contents.result = contents;
+       } else {
+               jbyte* contents = MALLOC(sizeof(jbyte), "jbyte result Err clone");
+               *contents = *orig->contents.err;
+               res.contents.err = contents;
+       }
+       return res;
+}
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
        return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
 }
@@ -2892,6 +2989,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddre
        CHECK(val->result_ok);
        LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
        *res_conv = (*val->contents.result);
+       *res_conv = CResult_NetAddressu8Z_clone(res_conv);
        return (long)res_conv;
 }
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
@@ -2922,6 +3020,11 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u64Z_1new(JNIEnv *en
        }
        return (long)ret;
 }
+static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
+       LDKCVec_u64Z ret = { .data = MALLOC(sizeof(jlong) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
+       memcpy(ret.data, orig->data, sizeof(jlong) * ret.datalen);
+       return ret;
+}
 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateAddHTLCZ_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
        LDKCVec_UpdateAddHTLCZ *vec = (LDKCVec_UpdateAddHTLCZ*)ptr;
        jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
@@ -2954,6 +3057,13 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateAddHTLCZ_1new(
        }
        return (long)ret;
 }
+static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
+       LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
+       for (size_t i = 0; i < ret.datalen; i++) {
+               ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
+       }
+       return ret;
+}
 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFulfillHTLCZ_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
        LDKCVec_UpdateFulfillHTLCZ *vec = (LDKCVec_UpdateFulfillHTLCZ*)ptr;
        jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
@@ -2986,6 +3096,13 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFulfillHTLCZ_1
        }
        return (long)ret;
 }
+static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
+       LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
+       for (size_t i = 0; i < ret.datalen; i++) {
+               ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
+       }
+       return ret;
+}
 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailHTLCZ_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
        LDKCVec_UpdateFailHTLCZ *vec = (LDKCVec_UpdateFailHTLCZ*)ptr;
        jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
@@ -3018,6 +3135,13 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailHTLCZ_1new
        }
        return (long)ret;
 }
+static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
+       LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
+       for (size_t i = 0; i < ret.datalen; i++) {
+               ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
+       }
+       return ret;
+}
 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailMalformedHTLCZ_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
        LDKCVec_UpdateFailMalformedHTLCZ *vec = (LDKCVec_UpdateFailMalformedHTLCZ*)ptr;
        jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
@@ -3050,6 +3174,13 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailMalformedH
        }
        return (long)ret;
 }
+static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
+       LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
+       for (size_t i = 0; i < ret.datalen; i++) {
+               ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
+       }
+       return ret;
+}
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
        return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
 }
@@ -3089,6 +3220,14 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnounceme
        ret->c = c_conv;
        return (long)ret;
 }
+static inline LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(const LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *orig) {
+       LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret = {
+               .a = ChannelAnnouncement_clone(&orig->a),
+               .b = ChannelUpdate_clone(&orig->b),
+               .c = ChannelUpdate_clone(&orig->c),
+       };
+       return ret;
+}
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *_env, jclass _b, jlong ptr) {
        LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)ptr;
        LDKChannelAnnouncement a_var = tuple->a;
@@ -3135,6 +3274,13 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C3Tuple_1ChannelAnno
        }
        return (long)ret;
 }
+static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
+       LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
+       for (size_t i = 0; i < ret.datalen; i++) {
+               ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
+       }
+       return ret;
+}
 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NodeAnnouncementZ_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
        LDKCVec_NodeAnnouncementZ *vec = (LDKCVec_NodeAnnouncementZ*)ptr;
        jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
@@ -3167,6 +3313,13 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NodeAnnouncementZ_1n
        }
        return (long)ret;
 }
+static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
+       LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
+       for (size_t i = 0; i < ret.datalen; i++) {
+               ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
+       }
+       return ret;
+}
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
        return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
 }
@@ -3614,10 +3767,24 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHopZ_1new(JNIEn
        }
        return (long)ret;
 }
+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;
+}
 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVec_1CVec_1RouteHopZZ_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
        LDKCVec_CVec_RouteHopZZ *vec = (LDKCVec_CVec_RouteHopZZ*)ptr;
        return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKCVec_RouteHopZ));
 }
+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;
+}
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
        return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
 }
@@ -3671,6 +3838,13 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintZ_1new(JNIE
        }
        return (long)ret;
 }
+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;
+}
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
        return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
 }
@@ -3853,7 +4027,7 @@ JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvide
        jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
        for (size_t s = 0; s < ret_var.datalen; s++) {
                LDKMessageSendEvent *arr_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
-               *arr_conv_18_copy = ret_var.data[s];
+               *arr_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
                long arr_conv_18_ref = (long)arr_conv_18_copy;
                ret_arr_ptr[s] = arr_conv_18_ref;
        }
@@ -3939,7 +4113,7 @@ JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_EventsProvider_1get_1and
        jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
        for (size_t h = 0; h < ret_var.datalen; h++) {
                LDKEvent *arr_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
-               *arr_conv_7_copy = ret_var.data[h];
+               *arr_conv_7_copy = Event_clone(&ret_var.data[h]);
                long arr_conv_7_ref = (long)arr_conv_7_copy;
                ret_arr_ptr[h] = arr_conv_7_ref;
        }
@@ -5330,6 +5504,9 @@ JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1g
        for (size_t l = 0; l < ret_var.datalen; l++) {
                LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arr_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
                *arr_conv_63_ref = ret_var.data[l];
+               arr_conv_63_ref->a = ChannelAnnouncement_clone(&arr_conv_63_ref->a);
+               arr_conv_63_ref->b = ChannelUpdate_clone(&arr_conv_63_ref->b);
+               arr_conv_63_ref->c = ChannelUpdate_clone(&arr_conv_63_ref->c);
                ret_arr_ptr[l] = (long)arr_conv_63_ref;
        }
        (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
@@ -5564,13 +5741,6 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv * _env, jcl
        TxOut_free(_res_conv);
 }
 
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv * _env, jclass _b, jlong 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 _b, jlongArray _res) {
        LDKCVec_SpendableOutputDescriptorZ _res_constr;
        _res_constr.datalen = (*_env)->GetArrayLength (_env, _res);
@@ -5639,6 +5809,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1n
        b_ref.data_is_owned = true;
        LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
        *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
+       // XXX: We likely need to clone here, but no _clone fn is available for byte[]
        return (long)ret_ref;
 }
 
@@ -5765,6 +5936,8 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new
        (*_env)->GetByteArrayRegion(_env, b, 0, b_ref.datalen, b_ref.data);
        LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
        *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
+       ret_ref->a = OutPoint_clone(&ret_ref->a);
+       ret_ref->b = CVec_u8Z_clone(&ret_ref->b);
        return (long)ret_ref;
 }
 
@@ -5798,6 +5971,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEn
        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
        return (long)ret_ref;
 }
 
@@ -5845,6 +6019,8 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u
        (*_env)->ReleaseLongArrayElements (_env, b, b_vals, 0);
        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>[]
        return (long)ret_ref;
 }
 
@@ -5882,6 +6058,8 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMoni
        // Warning: we may need a move here but can't clone!
        LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
        *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
+       ret_ref->a = ThirtyTwoBytes_clone(&ret_ref->a);
+       // XXX: We likely need to clone here, but no _clone fn is available for ChannelMonitor
        return (long)ret_ref;
 }
 
@@ -5987,6 +6165,8 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1Signa
        }
        LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
        *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
+       // XXX: We likely need to clone here, but no _clone fn is available for byte[]
+       // XXX: We likely need to clone here, but no _clone fn is available for byte[][]
        return (long)ret_ref;
 }
 
@@ -6251,6 +6431,8 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMana
        // Warning: we may need a move here but can't clone!
        LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
        *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
+       ret_ref->a = ThirtyTwoBytes_clone(&ret_ref->a);
+       // XXX: We likely need to clone here, but no _clone fn is available for ChannelManager
        return (long)ret_ref;
 }
 
@@ -6460,6 +6642,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementC
                c_conv = ChannelUpdate_clone(&c_conv);
        LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
        *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
+       ret_ref->a = ChannelAnnouncement_clone(&ret_ref->a);
+       ret_ref->b = ChannelUpdate_clone(&ret_ref->b);
+       ret_ref->c = ChannelUpdate_clone(&ret_ref->c);
        return (long)ret_ref;
 }
 
@@ -8215,6 +8400,8 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_
        this_arg_conv.is_owned = false;
        LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
        *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
+       ret_ref->a = OutPoint_clone(&ret_ref->a);
+       ret_ref->b = CVec_u8Z_clone(&ret_ref->b);
        return (long)ret_ref;
 }
 
@@ -8249,7 +8436,7 @@ JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and
        jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
        for (size_t h = 0; h < ret_var.datalen; h++) {
                LDKEvent *arr_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
-               *arr_conv_7_copy = ret_var.data[h];
+               *arr_conv_7_copy = Event_clone(&ret_var.data[h]);
                long arr_conv_7_ref = (long)arr_conv_7_copy;
                ret_arr_ptr[h] = arr_conv_7_ref;
        }
@@ -8319,6 +8506,8 @@ JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1block_1c
        for (size_t u = 0; u < ret_var.datalen; u++) {
                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>[]
                ret_arr_ptr[u] = (long)arr_conv_46_ref;
        }
        (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
@@ -9513,6 +9702,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1new(J
                LDKChannelMonitor arr_conv_16_conv;
                arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
                arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
+               // Warning: we may need a move here but can't clone!
                channel_monitors_constr.data[q] = arr_conv_16_conv;
        }
        (*_env)->ReleaseLongArrayElements (_env, channel_monitors, channel_monitors_vals, 0);
@@ -12995,6 +13185,8 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_
                LDKUpdateAddHTLC arr_conv_15_conv;
                arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1));
                arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0);
+               if (arr_conv_15_conv.inner != NULL)
+                       arr_conv_15_conv = UpdateAddHTLC_clone(&arr_conv_15_conv);
                val_constr.data[p] = arr_conv_15_conv;
        }
        (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
@@ -13017,6 +13209,8 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_
                LDKUpdateFulfillHTLC arr_conv_19_conv;
                arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1));
                arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0);
+               if (arr_conv_19_conv.inner != NULL)
+                       arr_conv_19_conv = UpdateFulfillHTLC_clone(&arr_conv_19_conv);
                val_constr.data[t] = arr_conv_19_conv;
        }
        (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
@@ -13039,6 +13233,8 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_
                LDKUpdateFailHTLC arr_conv_16_conv;
                arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
                arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
+               if (arr_conv_16_conv.inner != NULL)
+                       arr_conv_16_conv = UpdateFailHTLC_clone(&arr_conv_16_conv);
                val_constr.data[q] = arr_conv_16_conv;
        }
        (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
@@ -13061,6 +13257,8 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_
                LDKUpdateFailMalformedHTLC arr_conv_25_conv;
                arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1));
                arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0);
+               if (arr_conv_25_conv.inner != NULL)
+                       arr_conv_25_conv = UpdateFailMalformedHTLC_clone(&arr_conv_25_conv);
                val_constr.data[z] = arr_conv_25_conv;
        }
        (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
@@ -13132,6 +13330,8 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1new(JNIEnv
                LDKUpdateAddHTLC arr_conv_15_conv;
                arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1));
                arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0);
+               if (arr_conv_15_conv.inner != NULL)
+                       arr_conv_15_conv = UpdateAddHTLC_clone(&arr_conv_15_conv);
                update_add_htlcs_arg_constr.data[p] = arr_conv_15_conv;
        }
        (*_env)->ReleaseLongArrayElements (_env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
@@ -13147,6 +13347,8 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1new(JNIEnv
                LDKUpdateFulfillHTLC arr_conv_19_conv;
                arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1));
                arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0);
+               if (arr_conv_19_conv.inner != NULL)
+                       arr_conv_19_conv = UpdateFulfillHTLC_clone(&arr_conv_19_conv);
                update_fulfill_htlcs_arg_constr.data[t] = arr_conv_19_conv;
        }
        (*_env)->ReleaseLongArrayElements (_env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
@@ -13162,6 +13364,8 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1new(JNIEnv
                LDKUpdateFailHTLC arr_conv_16_conv;
                arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
                arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
+               if (arr_conv_16_conv.inner != NULL)
+                       arr_conv_16_conv = UpdateFailHTLC_clone(&arr_conv_16_conv);
                update_fail_htlcs_arg_constr.data[q] = arr_conv_16_conv;
        }
        (*_env)->ReleaseLongArrayElements (_env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
@@ -13177,6 +13381,8 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1new(JNIEnv
                LDKUpdateFailMalformedHTLC arr_conv_25_conv;
                arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1));
                arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0);
+               if (arr_conv_25_conv.inner != NULL)
+                       arr_conv_25_conv = UpdateFailMalformedHTLC_clone(&arr_conv_25_conv);
                update_fail_malformed_htlcs_arg_constr.data[z] = arr_conv_25_conv;
        }
        (*_env)->ReleaseLongArrayElements (_env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
@@ -15867,6 +16073,8 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv * _en
                        LDKRouteHop arr_conv_10_conv;
                        arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
                        arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
+                       if (arr_conv_10_conv.inner != NULL)
+                               arr_conv_10_conv = RouteHop_clone(&arr_conv_10_conv);
                        arr_conv_12_constr.data[k] = arr_conv_10_conv;
                }
                (*_env)->ReleaseLongArrayElements (_env, arr_conv_12, arr_conv_12_vals, 0);
@@ -15896,6 +16104,8 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv * _env, jcl
                        LDKRouteHop arr_conv_10_conv;
                        arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
                        arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
+                       if (arr_conv_10_conv.inner != NULL)
+                               arr_conv_10_conv = RouteHop_clone(&arr_conv_10_conv);
                        arr_conv_12_constr.data[k] = arr_conv_10_conv;
                }
                (*_env)->ReleaseLongArrayElements (_env, arr_conv_12, arr_conv_12_vals, 0);
@@ -16099,6 +16309,8 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_get_1route(JNIEnv * _env, jcl
                LDKRouteHint arr_conv_11_conv;
                arr_conv_11_conv.inner = (void*)(arr_conv_11 & (~1));
                arr_conv_11_conv.is_owned = (arr_conv_11 & 1) || (arr_conv_11 == 0);
+               if (arr_conv_11_conv.inner != NULL)
+                       arr_conv_11_conv = RouteHint_clone(&arr_conv_11_conv);
                last_hops_constr.data[l] = arr_conv_11_conv;
        }
        (*_env)->ReleaseLongArrayElements (_env, last_hops, last_hops_vals, 0);