X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjni%2Fbindings.c;h=dcbd2cc58b6527417349906e3d8286b749d328ac;hb=36e5154452d7583496053259e2c6b93b9baeaf8a;hp=d80311a7213edb4db36584366a418a709bbb4fa9;hpb=e5e14abada451cff0aa62e31942da61623f39826;p=ldk-java diff --git a/src/main/jni/bindings.c b/src/main/jni/bindings.c index d80311a7..dcbd2cc5 100644 --- a/src/main/jni/bindings.c +++ b/src/main/jni/bindings.c @@ -1,18 +1,107 @@ #include "org_ldk_impl_bindings.h" #include #include -#include #include #include +#include +#define DO_ASSERT(a) do { bool _assert_val = (a); assert(_assert_val); } while(0) + +#include +static mtx_t allocation_mtx; + +void __attribute__((constructor)) init_mtx() { + DO_ASSERT(mtx_init(&allocation_mtx, mtx_plain) == thrd_success); +} + +typedef struct allocation { + struct allocation* next; + void* ptr; + const char* struct_name; +} allocation; +static allocation* allocation_ll = NULL; + +void* MALLOC(size_t len, const char* struct_name) { + void* res = malloc(len); + allocation* new_alloc = malloc(sizeof(allocation)); + new_alloc->ptr = res; + new_alloc->struct_name = struct_name; + DO_ASSERT(mtx_lock(&allocation_mtx) == thrd_success); + new_alloc->next = allocation_ll; + allocation_ll = new_alloc; + DO_ASSERT(mtx_unlock(&allocation_mtx) == thrd_success); + return res; +} + +void FREE(void* ptr) { + allocation* p = NULL; + DO_ASSERT(mtx_lock(&allocation_mtx) == thrd_success); + allocation* it = allocation_ll; + while (it->ptr != ptr) { p = it; it = it->next; } + if (p) { p->next = it->next; } else { allocation_ll = it->next; } + DO_ASSERT(mtx_unlock(&allocation_mtx) == thrd_success); + DO_ASSERT(it->ptr == ptr); + free(it); + free(ptr); +} + +void __attribute__((destructor)) check_leaks() { + for (allocation* a = allocation_ll; a != NULL; a = a->next) { fprintf(stderr, "%s %p remains\n", a->struct_name, a->ptr); } + DO_ASSERT(allocation_ll == NULL); +} jmethodID ordinal_meth = NULL; JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class) { ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I"); - assert(ordinal_meth != NULL); + DO_ASSERT(ordinal_meth != NULL); } -#define MALLOC(a, _) malloc(a) -#define FREE free +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_deref_1bool (JNIEnv * env, jclass _a, jlong ptr) { + return *((bool*)ptr); +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_deref_1long (JNIEnv * env, jclass _a, jlong ptr) { + return *((long*)ptr); +} +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_free_1heap_1ptr (JNIEnv * env, jclass _a, jlong ptr) { + FREE((void*)ptr); +} +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes (JNIEnv * _env, jclass _b, jlong slice_ptr) { + LDKu8slice *slice = (LDKu8slice*)slice_ptr; + jbyteArray ret_arr = (*_env)->NewByteArray(_env, slice->datalen); + (*_env)->SetByteArrayRegion(_env, ret_arr, 0, slice->datalen, slice->data); + return ret_arr; +} +JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_bytes_1to_1u8_1vec (JNIEnv * _env, jclass _b, jbyteArray bytes) { + LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8"); + vec->datalen = (*_env)->GetArrayLength(_env, bytes); + vec->data = (uint8_t*)malloc(vec->datalen); // May be freed by rust, so don't track allocation + (*_env)->GetByteArrayRegion (_env, bytes, 0, vec->datalen, vec->data); + return (long)vec; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env, jclass _a, jlong ptr) { + // Check offsets of a few Vec types are all consistent as we're meant to be generic across types + _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_SignatureZ, datalen), "Vec<*> needs to be mapped identically"); + _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_MessageSendEventZ, datalen), "Vec<*> needs to be mapped identically"); + _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically"); + _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically"); + LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr; + return (long)vec->datalen; +} +JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * _env, jclass _b) { + // Check sizes of a few Vec types are all consistent as we're meant to be generic across types + _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically"); + _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically"); + _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically"); + _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically"); + LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec"); + vec->data = NULL; + vec->datalen = 0; + return (long)vec; +} + +// We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed) +_Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec and [u8] need to have been mapped identically"); +_Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec and [u8] need to have been mapped identically"); +_Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec and [u8] need to have been mapped identically"); JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKSecretKey_1new(JNIEnv * _env, jclass _b) { LDKSecretKey* key = (LDKSecretKey*)MALLOC(sizeof(LDKSecretKey), "LDKSecretKey"); @@ -23,24 +112,24 @@ static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass val) { case 0: return LDKAccessError_UnknownChain; case 1: return LDKAccessError_UnknownTx; } - assert(false); + abort(); } static inline jclass LDKAccessError_to_java(JNIEnv *env, LDKAccessError val) { // TODO: This is pretty inefficient, we really need to cache the field IDs and class jclass enum_class = (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAccessError;"); - assert(enum_class != NULL); + DO_ASSERT(enum_class != NULL); switch (val) { case LDKAccessError_UnknownChain: { jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKAccessError_UnknownChain", "Lorg/ldk/impl/bindings$LDKAccessError;"); - assert(field != NULL); + DO_ASSERT(field != NULL); return (*env)->GetStaticObjectField(env, enum_class, field); } case LDKAccessError_UnknownTx: { jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKAccessError_UnknownTx", "Lorg/ldk/impl/bindings$LDKAccessError;"); - assert(field != NULL); + DO_ASSERT(field != NULL); return (*env)->GetStaticObjectField(env, enum_class, field); } - default: assert(false); + default: abort(); } } @@ -49,24 +138,24 @@ static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_java(JN case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure; case 1: return LDKChannelMonitorUpdateErr_PermanentFailure; } - assert(false); + abort(); } static inline jclass LDKChannelMonitorUpdateErr_to_java(JNIEnv *env, LDKChannelMonitorUpdateErr val) { // TODO: This is pretty inefficient, we really need to cache the field IDs and class jclass enum_class = (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKChannelMonitorUpdateErr;"); - assert(enum_class != NULL); + DO_ASSERT(enum_class != NULL); switch (val) { case LDKChannelMonitorUpdateErr_TemporaryFailure: { jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKChannelMonitorUpdateErr_TemporaryFailure", "Lorg/ldk/impl/bindings$LDKChannelMonitorUpdateErr;"); - assert(field != NULL); + DO_ASSERT(field != NULL); return (*env)->GetStaticObjectField(env, enum_class, field); } case LDKChannelMonitorUpdateErr_PermanentFailure: { jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKChannelMonitorUpdateErr_PermanentFailure", "Lorg/ldk/impl/bindings$LDKChannelMonitorUpdateErr;"); - assert(field != NULL); + DO_ASSERT(field != NULL); return (*env)->GetStaticObjectField(env, enum_class, field); } - default: assert(false); + default: abort(); } } @@ -76,29 +165,29 @@ static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, case 1: return LDKConfirmationTarget_Normal; case 2: return LDKConfirmationTarget_HighPriority; } - assert(false); + abort(); } static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) { // TODO: This is pretty inefficient, we really need to cache the field IDs and class jclass enum_class = (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKConfirmationTarget;"); - assert(enum_class != NULL); + DO_ASSERT(enum_class != NULL); switch (val) { case LDKConfirmationTarget_Background: { jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKConfirmationTarget_Background", "Lorg/ldk/impl/bindings$LDKConfirmationTarget;"); - assert(field != NULL); + DO_ASSERT(field != NULL); return (*env)->GetStaticObjectField(env, enum_class, field); } case LDKConfirmationTarget_Normal: { jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/impl/bindings$LDKConfirmationTarget;"); - assert(field != NULL); + DO_ASSERT(field != NULL); return (*env)->GetStaticObjectField(env, enum_class, field); } case LDKConfirmationTarget_HighPriority: { jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/impl/bindings$LDKConfirmationTarget;"); - assert(field != NULL); + DO_ASSERT(field != NULL); return (*env)->GetStaticObjectField(env, enum_class, field); } - default: assert(false); + default: abort(); } } @@ -111,44 +200,44 @@ static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass val) { case 4: return LDKLevel_Debug; case 5: return LDKLevel_Trace; } - assert(false); + abort(); } static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) { // TODO: This is pretty inefficient, we really need to cache the field IDs and class jclass enum_class = (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKLevel;"); - assert(enum_class != NULL); + DO_ASSERT(enum_class != NULL); switch (val) { case LDKLevel_Off: { jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKLevel_Off", "Lorg/ldk/impl/bindings$LDKLevel;"); - assert(field != NULL); + DO_ASSERT(field != NULL); return (*env)->GetStaticObjectField(env, enum_class, field); } case LDKLevel_Error: { jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKLevel_Error", "Lorg/ldk/impl/bindings$LDKLevel;"); - assert(field != NULL); + DO_ASSERT(field != NULL); return (*env)->GetStaticObjectField(env, enum_class, field); } case LDKLevel_Warn: { jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKLevel_Warn", "Lorg/ldk/impl/bindings$LDKLevel;"); - assert(field != NULL); + DO_ASSERT(field != NULL); return (*env)->GetStaticObjectField(env, enum_class, field); } case LDKLevel_Info: { jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKLevel_Info", "Lorg/ldk/impl/bindings$LDKLevel;"); - assert(field != NULL); + DO_ASSERT(field != NULL); return (*env)->GetStaticObjectField(env, enum_class, field); } case LDKLevel_Debug: { jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKLevel_Debug", "Lorg/ldk/impl/bindings$LDKLevel;"); - assert(field != NULL); + DO_ASSERT(field != NULL); return (*env)->GetStaticObjectField(env, enum_class, field); } case LDKLevel_Trace: { jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKLevel_Trace", "Lorg/ldk/impl/bindings$LDKLevel;"); - assert(field != NULL); + DO_ASSERT(field != NULL); return (*env)->GetStaticObjectField(env, enum_class, field); } - default: assert(false); + default: abort(); } } @@ -158,29 +247,29 @@ static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass val) { case 1: return LDKNetwork_Testnet; case 2: return LDKNetwork_Regtest; } - assert(false); + abort(); } static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) { // TODO: This is pretty inefficient, we really need to cache the field IDs and class jclass enum_class = (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetwork;"); - assert(enum_class != NULL); + DO_ASSERT(enum_class != NULL); switch (val) { case LDKNetwork_Bitcoin: { jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKNetwork_Bitcoin", "Lorg/ldk/impl/bindings$LDKNetwork;"); - assert(field != NULL); + DO_ASSERT(field != NULL); return (*env)->GetStaticObjectField(env, enum_class, field); } case LDKNetwork_Testnet: { jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKNetwork_Testnet", "Lorg/ldk/impl/bindings$LDKNetwork;"); - assert(field != NULL); + DO_ASSERT(field != NULL); return (*env)->GetStaticObjectField(env, enum_class, field); } case LDKNetwork_Regtest: { jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKNetwork_Regtest", "Lorg/ldk/impl/bindings$LDKNetwork;"); - assert(field != NULL); + DO_ASSERT(field != NULL); return (*env)->GetStaticObjectField(env, enum_class, field); } - default: assert(false); + default: abort(); } } @@ -196,71 +285,253 @@ static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass case 7: return LDKSecp256k1Error_NotEnoughMemory; case 8: return LDKSecp256k1Error_CallbackPanicked; } - assert(false); + abort(); } static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) { // TODO: This is pretty inefficient, we really need to cache the field IDs and class jclass enum_class = (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSecp256k1Error;"); - assert(enum_class != NULL); + DO_ASSERT(enum_class != NULL); switch (val) { case LDKSecp256k1Error_IncorrectSignature: { jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/impl/bindings$LDKSecp256k1Error;"); - assert(field != NULL); + DO_ASSERT(field != NULL); return (*env)->GetStaticObjectField(env, enum_class, field); } case LDKSecp256k1Error_InvalidMessage: { jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/impl/bindings$LDKSecp256k1Error;"); - assert(field != NULL); + DO_ASSERT(field != NULL); return (*env)->GetStaticObjectField(env, enum_class, field); } case LDKSecp256k1Error_InvalidPublicKey: { jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/impl/bindings$LDKSecp256k1Error;"); - assert(field != NULL); + DO_ASSERT(field != NULL); return (*env)->GetStaticObjectField(env, enum_class, field); } case LDKSecp256k1Error_InvalidSignature: { jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/impl/bindings$LDKSecp256k1Error;"); - assert(field != NULL); + DO_ASSERT(field != NULL); return (*env)->GetStaticObjectField(env, enum_class, field); } case LDKSecp256k1Error_InvalidSecretKey: { jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/impl/bindings$LDKSecp256k1Error;"); - assert(field != NULL); + DO_ASSERT(field != NULL); return (*env)->GetStaticObjectField(env, enum_class, field); } case LDKSecp256k1Error_InvalidRecoveryId: { jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/impl/bindings$LDKSecp256k1Error;"); - assert(field != NULL); + DO_ASSERT(field != NULL); return (*env)->GetStaticObjectField(env, enum_class, field); } case LDKSecp256k1Error_InvalidTweak: { jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/impl/bindings$LDKSecp256k1Error;"); - assert(field != NULL); + DO_ASSERT(field != NULL); return (*env)->GetStaticObjectField(env, enum_class, field); } case LDKSecp256k1Error_NotEnoughMemory: { jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/impl/bindings$LDKSecp256k1Error;"); - assert(field != NULL); + DO_ASSERT(field != NULL); return (*env)->GetStaticObjectField(env, enum_class, field); } case LDKSecp256k1Error_CallbackPanicked: { jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKSecp256k1Error_CallbackPanicked", "Lorg/ldk/impl/bindings$LDKSecp256k1Error;"); - assert(field != NULL); + DO_ASSERT(field != NULL); return (*env)->GetStaticObjectField(env, enum_class, field); } - default: assert(false); + default: abort(); } } +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { + return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) { + if (((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok) { + return (long)((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->contents.result; + } else { + return (long)((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->contents.err; + } +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKMonitorUpdateError_1optional_1none (JNIEnv * env, jclass _a) { + LDKMonitorUpdateError *ret = MALLOC(sizeof(LDKMonitorUpdateError), "LDKMonitorUpdateError"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { + return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) { + if (((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok) { + return (long)((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->contents.result; + } else { + return (long)((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->contents.err; + } +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKOutPoint_1optional_1none (JNIEnv * env, jclass _a) { + LDKOutPoint *ret = MALLOC(sizeof(LDKOutPoint), "LDKOutPoint"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { + return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) { + if (((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok) { + return (long)((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->contents.result; + } else { + return (long)((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->contents.err; + } +} +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { + return ((LDKCResult_SignatureNoneZ*)arg)->result_ok; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) { + if (((LDKCResult_SignatureNoneZ*)arg)->result_ok) { + return (long)((LDKCResult_SignatureNoneZ*)arg)->contents.result; + } else { + return (long)((LDKCResult_SignatureNoneZ*)arg)->contents.err; + } +} +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { + return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) { + if (((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok) { + return (long)((LDKCResult_CVec_SignatureZNoneZ*)arg)->contents.result; + } else { + return (long)((LDKCResult_CVec_SignatureZNoneZ*)arg)->contents.err; + } +} +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { + return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) { + if (((LDKCResult_NoneAPIErrorZ*)arg)->result_ok) { + return (long)((LDKCResult_NoneAPIErrorZ*)arg)->contents.result; + } else { + return (long)((LDKCResult_NoneAPIErrorZ*)arg)->contents.err; + } +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1optional_1none (JNIEnv * env, jclass _a) { + LDKPaymentSendFailure *ret = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure"); + ret->inner = NULL; + return (long)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; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) { + if (((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok) { + return (long)((LDKCResult_NonePaymentSendFailureZ*)arg)->contents.result; + } else { + return (long)((LDKCResult_NonePaymentSendFailureZ*)arg)->contents.err; + } +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelAnnouncement_1optional_1none (JNIEnv * env, jclass _a) { + LDKChannelAnnouncement *ret = MALLOC(sizeof(LDKChannelAnnouncement), "LDKChannelAnnouncement"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelUpdate_1optional_1none (JNIEnv * env, jclass _a) { + LDKChannelUpdate *ret = MALLOC(sizeof(LDKChannelUpdate), "LDKChannelUpdate"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKPeerHandleError_1optional_1none (JNIEnv * env, jclass _a) { + LDKPeerHandleError *ret = MALLOC(sizeof(LDKPeerHandleError), "LDKPeerHandleError"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { + return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) { + if (((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok) { + return (long)((LDKCResult_NonePeerHandleErrorZ*)arg)->contents.result; + } else { + return (long)((LDKCResult_NonePeerHandleErrorZ*)arg)->contents.err; + } +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKHTLCOutputInCommitment_1optional_1none (JNIEnv * env, jclass _a) { + LDKHTLCOutputInCommitment *ret = MALLOC(sizeof(LDKHTLCOutputInCommitment), "LDKHTLCOutputInCommitment"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKAcceptChannel_1optional_1none (JNIEnv * env, jclass _a) { + LDKAcceptChannel *ret = MALLOC(sizeof(LDKAcceptChannel), "LDKAcceptChannel"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKOpenChannel_1optional_1none (JNIEnv * env, jclass _a) { + LDKOpenChannel *ret = MALLOC(sizeof(LDKOpenChannel), "LDKOpenChannel"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKFundingCreated_1optional_1none (JNIEnv * env, jclass _a) { + LDKFundingCreated *ret = MALLOC(sizeof(LDKFundingCreated), "LDKFundingCreated"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKFundingSigned_1optional_1none (JNIEnv * env, jclass _a) { + LDKFundingSigned *ret = MALLOC(sizeof(LDKFundingSigned), "LDKFundingSigned"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKFundingLocked_1optional_1none (JNIEnv * env, jclass _a) { + LDKFundingLocked *ret = MALLOC(sizeof(LDKFundingLocked), "LDKFundingLocked"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKAnnouncementSignatures_1optional_1none (JNIEnv * env, jclass _a) { + LDKAnnouncementSignatures *ret = MALLOC(sizeof(LDKAnnouncementSignatures), "LDKAnnouncementSignatures"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCommitmentUpdate_1optional_1none (JNIEnv * env, jclass _a) { + LDKCommitmentUpdate *ret = MALLOC(sizeof(LDKCommitmentUpdate), "LDKCommitmentUpdate"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKRevokeAndACK_1optional_1none (JNIEnv * env, jclass _a) { + LDKRevokeAndACK *ret = MALLOC(sizeof(LDKRevokeAndACK), "LDKRevokeAndACK"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKClosingSigned_1optional_1none (JNIEnv * env, jclass _a) { + LDKClosingSigned *ret = MALLOC(sizeof(LDKClosingSigned), "LDKClosingSigned"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKShutdown_1optional_1none (JNIEnv * env, jclass _a) { + LDKShutdown *ret = MALLOC(sizeof(LDKShutdown), "LDKShutdown"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelReestablish_1optional_1none (JNIEnv * env, jclass _a) { + LDKChannelReestablish *ret = MALLOC(sizeof(LDKChannelReestablish), "LDKChannelReestablish"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKNodeAnnouncement_1optional_1none (JNIEnv * env, jclass _a) { + LDKNodeAnnouncement *ret = MALLOC(sizeof(LDKNodeAnnouncement), "LDKNodeAnnouncement"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKErrorMessage_1optional_1none (JNIEnv * env, jclass _a) { + LDKErrorMessage *ret = MALLOC(sizeof(LDKErrorMessage), "LDKErrorMessage"); + ret->inner = NULL; + return (long)ret; +} typedef struct LDKMessageSendEventsProvider_JCalls { atomic_size_t refcnt; - JNIEnv *env; + JavaVM *vm; jobject o; jmethodID get_and_clear_pending_msg_events_meth; } LDKMessageSendEventsProvider_JCalls; LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_jcall(const void* this_arg) { LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg; - LDKCVec_MessageSendEventZ* ret = (LDKCVec_MessageSendEventZ*)(*j_calls->env)->CallLongMethod(j_calls->env, j_calls->o, j_calls->get_and_clear_pending_msg_events_meth); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + LDKCVec_MessageSendEventZ* ret = (LDKCVec_MessageSendEventZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->get_and_clear_pending_msg_events_meth); LDKCVec_MessageSendEventZ res = *ret; FREE(ret); return res; @@ -268,7 +539,9 @@ LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_jcall(const void* thi static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) { LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg; if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { - (*j_calls->env)->DeleteGlobalRef(j_calls->env, j_calls->o); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + (*env)->DeleteGlobalRef(env, j_calls->o); FREE(j_calls); } } @@ -279,13 +552,13 @@ static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) { } static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv * env, jclass _a, jobject o) { jclass c = (*env)->GetObjectClass(env, o); - assert(c != NULL); + DO_ASSERT(c != NULL); LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls"); atomic_init(&calls->refcnt, 1); - calls->env = env; + DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); calls->o = (*env)->NewGlobalRef(env, o); calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()J"); - assert(calls->get_and_clear_pending_msg_events_meth != NULL); + DO_ASSERT(calls->get_and_clear_pending_msg_events_meth != NULL); LDKMessageSendEventsProvider ret = { .this_arg = (void*) calls, @@ -299,15 +572,27 @@ JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1 *res_ptr = LDKMessageSendEventsProvider_init(env, _a, o); return (long)res_ptr; } +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) { + return ((LDKMessageSendEventsProvider_JCalls*)val)->o; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1call_1get_1and_1clear_1pending_1msg_1events(JNIEnv * _env, jclass _b, jlong arg) { + LDKMessageSendEventsProvider* arg_conv = (LDKMessageSendEventsProvider*)arg; + LDKCVec_MessageSendEventZ* ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ"); + *ret = (arg_conv->get_and_clear_pending_msg_events)(arg_conv->this_arg); + return (long)ret; +} + typedef struct LDKEventsProvider_JCalls { atomic_size_t refcnt; - JNIEnv *env; + JavaVM *vm; jobject o; jmethodID get_and_clear_pending_events_meth; } LDKEventsProvider_JCalls; LDKCVec_EventZ get_and_clear_pending_events_jcall(const void* this_arg) { LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg; - LDKCVec_EventZ* ret = (LDKCVec_EventZ*)(*j_calls->env)->CallLongMethod(j_calls->env, j_calls->o, j_calls->get_and_clear_pending_events_meth); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + LDKCVec_EventZ* ret = (LDKCVec_EventZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->get_and_clear_pending_events_meth); LDKCVec_EventZ res = *ret; FREE(ret); return res; @@ -315,7 +600,9 @@ LDKCVec_EventZ get_and_clear_pending_events_jcall(const void* this_arg) { static void LDKEventsProvider_JCalls_free(void* this_arg) { LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg; if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { - (*j_calls->env)->DeleteGlobalRef(j_calls->env, j_calls->o); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + (*env)->DeleteGlobalRef(env, j_calls->o); FREE(j_calls); } } @@ -326,13 +613,13 @@ static void* LDKEventsProvider_JCalls_clone(const void* this_arg) { } static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv * env, jclass _a, jobject o) { jclass c = (*env)->GetObjectClass(env, o); - assert(c != NULL); + DO_ASSERT(c != NULL); LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls"); atomic_init(&calls->refcnt, 1); - calls->env = env; + DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); calls->o = (*env)->NewGlobalRef(env, o); calls->get_and_clear_pending_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_events", "()J"); - assert(calls->get_and_clear_pending_events_meth != NULL); + DO_ASSERT(calls->get_and_clear_pending_events_meth != NULL); LDKEventsProvider ret = { .this_arg = (void*) calls, @@ -346,21 +633,35 @@ JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new (JNIEnv *res_ptr = LDKEventsProvider_init(env, _a, o); return (long)res_ptr; } +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) { + return ((LDKEventsProvider_JCalls*)val)->o; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1call_1get_1and_1clear_1pending_1events(JNIEnv * _env, jclass _b, jlong arg) { + LDKEventsProvider* arg_conv = (LDKEventsProvider*)arg; + LDKCVec_EventZ* ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ"); + *ret = (arg_conv->get_and_clear_pending_events)(arg_conv->this_arg); + return (long)ret; +} + typedef struct LDKLogger_JCalls { atomic_size_t refcnt; - JNIEnv *env; + JavaVM *vm; jobject o; jmethodID log_meth; } LDKLogger_JCalls; void log_jcall(const void* this_arg, const char *record) { LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg; - jstring record_conv = (*j_calls->env)->NewStringUTF(j_calls->env, record); - return (*j_calls->env)->CallVoidMethod(j_calls->env, j_calls->o, j_calls->log_meth, record_conv); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + jstring record_conv = (*env)->NewStringUTF(env, record); + return (*env)->CallVoidMethod(env, j_calls->o, j_calls->log_meth, record_conv); } static void LDKLogger_JCalls_free(void* this_arg) { LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg; if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { - (*j_calls->env)->DeleteGlobalRef(j_calls->env, j_calls->o); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + (*env)->DeleteGlobalRef(env, j_calls->o); FREE(j_calls); } } @@ -371,13 +672,13 @@ static void* LDKLogger_JCalls_clone(const void* this_arg) { } static inline LDKLogger LDKLogger_init (JNIEnv * env, jclass _a, jobject o) { jclass c = (*env)->GetObjectClass(env, o); - assert(c != NULL); + DO_ASSERT(c != NULL); LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls"); atomic_init(&calls->refcnt, 1); - calls->env = env; + DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); calls->o = (*env)->NewGlobalRef(env, o); calls->log_meth = (*env)->GetMethodID(env, c, "log", "(Ljava/lang/String;)V"); - assert(calls->log_meth != NULL); + DO_ASSERT(calls->log_meth != NULL); LDKLogger ret = { .this_arg = (void*) calls, @@ -391,17 +692,52 @@ JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new (JNIEnv * env, *res_ptr = LDKLogger_init(env, _a, o); return (long)res_ptr; } +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKLogger_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) { + return ((LDKLogger_JCalls*)val)->o; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelHandshakeConfig_1optional_1none (JNIEnv * env, jclass _a) { + LDKChannelHandshakeConfig *ret = MALLOC(sizeof(LDKChannelHandshakeConfig), "LDKChannelHandshakeConfig"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelHandshakeLimits_1optional_1none (JNIEnv * env, jclass _a) { + LDKChannelHandshakeLimits *ret = MALLOC(sizeof(LDKChannelHandshakeLimits), "LDKChannelHandshakeLimits"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelConfig_1optional_1none (JNIEnv * env, jclass _a) { + LDKChannelConfig *ret = MALLOC(sizeof(LDKChannelConfig), "LDKChannelConfig"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKUserConfig_1optional_1none (JNIEnv * env, jclass _a) { + LDKUserConfig *ret = MALLOC(sizeof(LDKUserConfig), "LDKUserConfig"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { + return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) { + if (((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok) { + return (long)((LDKCResult_TxOutAccessErrorZ*)arg)->contents.result; + } else { + return (long)((LDKCResult_TxOutAccessErrorZ*)arg)->contents.err; + } +} typedef struct LDKAccess_JCalls { atomic_size_t refcnt; - JNIEnv *env; + JavaVM *vm; jobject o; jmethodID get_utxo_meth; } LDKAccess_JCalls; LDKCResult_TxOutAccessErrorZ get_utxo_jcall(const void* this_arg, const uint8_t (*genesis_hash)[32], uint64_t short_channel_id) { LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg; - jbyteArray genesis_hash_arr = (*j_calls->env)->NewByteArray(j_calls->env, 32); - (*j_calls->env)->SetByteArrayRegion(j_calls->env, genesis_hash_arr, 0, 32, *genesis_hash); - LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)(*j_calls->env)->CallLongMethod(j_calls->env, j_calls->o, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + jbyteArray genesis_hash_arr = (*env)->NewByteArray(env, 32); + (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash); + LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id); LDKCResult_TxOutAccessErrorZ res = *ret; FREE(ret); return res; @@ -409,7 +745,9 @@ LDKCResult_TxOutAccessErrorZ get_utxo_jcall(const void* this_arg, const uint8_t static void LDKAccess_JCalls_free(void* this_arg) { LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg; if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { - (*j_calls->env)->DeleteGlobalRef(j_calls->env, j_calls->o); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + (*env)->DeleteGlobalRef(env, j_calls->o); FREE(j_calls); } } @@ -420,13 +758,13 @@ static void* LDKAccess_JCalls_clone(const void* this_arg) { } static inline LDKAccess LDKAccess_init (JNIEnv * env, jclass _a, jobject o) { jclass c = (*env)->GetObjectClass(env, o); - assert(c != NULL); + DO_ASSERT(c != NULL); LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls"); atomic_init(&calls->refcnt, 1); - calls->env = env; + DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); calls->o = (*env)->NewGlobalRef(env, o); calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J"); - assert(calls->get_utxo_meth != NULL); + DO_ASSERT(calls->get_utxo_meth != NULL); LDKAccess ret = { .this_arg = (void*) calls, @@ -440,9 +778,42 @@ JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new (JNIEnv * env, *res_ptr = LDKAccess_init(env, _a, o); return (long)res_ptr; } +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAccess_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) { + return ((LDKAccess_JCalls*)val)->o; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKAccess_1call_1get_1utxo(JNIEnv * _env, jclass _b, jlong arg, jbyteArray genesis_hash, jlong short_channel_id) { + LDKAccess* arg_conv = (LDKAccess*)arg; + unsigned char genesis_hash_arr[32]; + (*_env)->GetByteArrayRegion (_env, genesis_hash, 0, 32, genesis_hash_arr); + unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr; + LDKCResult_TxOutAccessErrorZ* ret = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ"); + *ret = (arg_conv->get_utxo)(arg_conv->this_arg, genesis_hash_ref, short_channel_id); + return (long)ret; +} + +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelPublicKeys_1optional_1none (JNIEnv * env, jclass _a) { + LDKChannelPublicKeys *ret = MALLOC(sizeof(LDKChannelPublicKeys), "LDKChannelPublicKeys"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKPreCalculatedTxCreationKeys_1optional_1none (JNIEnv * env, jclass _a) { + LDKPreCalculatedTxCreationKeys *ret = MALLOC(sizeof(LDKPreCalculatedTxCreationKeys), "LDKPreCalculatedTxCreationKeys"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKHolderCommitmentTransaction_1optional_1none (JNIEnv * env, jclass _a) { + LDKHolderCommitmentTransaction *ret = MALLOC(sizeof(LDKHolderCommitmentTransaction), "LDKHolderCommitmentTransaction"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKUnsignedChannelAnnouncement_1optional_1none (JNIEnv * env, jclass _a) { + LDKUnsignedChannelAnnouncement *ret = MALLOC(sizeof(LDKUnsignedChannelAnnouncement), "LDKUnsignedChannelAnnouncement"); + ret->inner = NULL; + return (long)ret; +} typedef struct LDKChannelKeys_JCalls { atomic_size_t refcnt; - JNIEnv *env; + JavaVM *vm; jobject o; jmethodID get_per_commitment_point_meth; jmethodID release_commitment_secret_meth; @@ -458,84 +829,114 @@ typedef struct LDKChannelKeys_JCalls { } LDKChannelKeys_JCalls; LDKPublicKey get_per_commitment_point_jcall(const void* this_arg, uint64_t idx) { LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg; - LDKPublicKey* ret = (LDKPublicKey*)(*j_calls->env)->CallLongMethod(j_calls->env, j_calls->o, j_calls->get_per_commitment_point_meth, idx); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + LDKPublicKey* ret = (LDKPublicKey*)(*env)->CallLongMethod(env, j_calls->o, j_calls->get_per_commitment_point_meth, idx); LDKPublicKey res = *ret; FREE(ret); return res; } LDKThirtyTwoBytes release_commitment_secret_jcall(const void* this_arg, uint64_t idx) { LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg; - LDKThirtyTwoBytes* ret = (LDKThirtyTwoBytes*)(*j_calls->env)->CallLongMethod(j_calls->env, j_calls->o, j_calls->release_commitment_secret_meth, idx); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + LDKThirtyTwoBytes* ret = (LDKThirtyTwoBytes*)(*env)->CallLongMethod(env, j_calls->o, j_calls->release_commitment_secret_meth, idx); LDKThirtyTwoBytes res = *ret; FREE(ret); return res; } LDKC2Tuple_u64u64Z key_derivation_params_jcall(const void* this_arg) { LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg; - LDKC2Tuple_u64u64Z* ret = (LDKC2Tuple_u64u64Z*)(*j_calls->env)->CallLongMethod(j_calls->env, j_calls->o, j_calls->key_derivation_params_meth); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + LDKC2Tuple_u64u64Z* ret = (LDKC2Tuple_u64u64Z*)(*env)->CallLongMethod(env, j_calls->o, j_calls->key_derivation_params_meth); LDKC2Tuple_u64u64Z res = *ret; FREE(ret); return res; } LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_jcall(const void* this_arg, uint32_t feerate_per_kw, LDKTransaction commitment_tx, const LDKPreCalculatedTxCreationKeys *keys, LDKCVec_HTLCOutputInCommitmentZ htlcs) { LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg; - LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*j_calls->env)->CallLongMethod(j_calls->env, j_calls->o, j_calls->sign_counterparty_commitment_meth, feerate_per_kw, commitment_tx, keys, htlcs); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + long commitment_tx_ref = (long)&commitment_tx; + long htlcs_ref = (long)&htlcs; + LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->sign_counterparty_commitment_meth, feerate_per_kw, commitment_tx_ref, keys, htlcs_ref); LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ res = *ret; FREE(ret); return res; } LDKCResult_SignatureNoneZ sign_holder_commitment_jcall(const void* this_arg, const LDKHolderCommitmentTransaction *holder_commitment_tx) { LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg; - LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*j_calls->env)->CallLongMethod(j_calls->env, j_calls->o, j_calls->sign_holder_commitment_meth, holder_commitment_tx); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->sign_holder_commitment_meth, holder_commitment_tx); LDKCResult_SignatureNoneZ res = *ret; FREE(ret); return res; } LDKCResult_CVec_SignatureZNoneZ sign_holder_commitment_htlc_transactions_jcall(const void* this_arg, const LDKHolderCommitmentTransaction *holder_commitment_tx) { LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg; - LDKCResult_CVec_SignatureZNoneZ* ret = (LDKCResult_CVec_SignatureZNoneZ*)(*j_calls->env)->CallLongMethod(j_calls->env, j_calls->o, j_calls->sign_holder_commitment_htlc_transactions_meth, holder_commitment_tx); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + LDKCResult_CVec_SignatureZNoneZ* ret = (LDKCResult_CVec_SignatureZNoneZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->sign_holder_commitment_htlc_transactions_meth, holder_commitment_tx); LDKCResult_CVec_SignatureZNoneZ res = *ret; FREE(ret); return res; } 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) { LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg; - jbyteArray per_commitment_key_arr = (*j_calls->env)->NewByteArray(j_calls->env, 32); - (*j_calls->env)->SetByteArrayRegion(j_calls->env, per_commitment_key_arr, 0, 32, *per_commitment_key); - LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*j_calls->env)->CallLongMethod(j_calls->env, j_calls->o, j_calls->sign_justice_transaction_meth, justice_tx, input, amount, per_commitment_key_arr, htlc); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + long justice_tx_ref = (long)&justice_tx; + jbyteArray per_commitment_key_arr = (*env)->NewByteArray(env, 32); + (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key); + LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->sign_justice_transaction_meth, justice_tx_ref, input, amount, per_commitment_key_arr, htlc); LDKCResult_SignatureNoneZ res = *ret; FREE(ret); return res; } 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) { LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg; - LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*j_calls->env)->CallLongMethod(j_calls->env, j_calls->o, j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx, input, amount, per_commitment_point, htlc); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + long htlc_tx_ref = (long)&htlc_tx; + long per_commitment_point_ref = (long)&per_commitment_point; + LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_ref, input, amount, per_commitment_point_ref, htlc); LDKCResult_SignatureNoneZ res = *ret; FREE(ret); return res; } LDKCResult_SignatureNoneZ sign_closing_transaction_jcall(const void* this_arg, LDKTransaction closing_tx) { LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg; - LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*j_calls->env)->CallLongMethod(j_calls->env, j_calls->o, j_calls->sign_closing_transaction_meth, closing_tx); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + long closing_tx_ref = (long)&closing_tx; + LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->sign_closing_transaction_meth, closing_tx_ref); LDKCResult_SignatureNoneZ res = *ret; FREE(ret); return res; } LDKCResult_SignatureNoneZ sign_channel_announcement_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement *msg) { LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg; - LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*j_calls->env)->CallLongMethod(j_calls->env, j_calls->o, j_calls->sign_channel_announcement_meth, msg); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->sign_channel_announcement_meth, msg); LDKCResult_SignatureNoneZ res = *ret; FREE(ret); return res; } void on_accept_jcall(void* this_arg, const LDKChannelPublicKeys *channel_points, uint16_t counterparty_selected_contest_delay, uint16_t holder_selected_contest_delay) { LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg; - return (*j_calls->env)->CallVoidMethod(j_calls->env, j_calls->o, j_calls->on_accept_meth, channel_points, counterparty_selected_contest_delay, holder_selected_contest_delay); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + return (*env)->CallVoidMethod(env, j_calls->o, j_calls->on_accept_meth, channel_points, counterparty_selected_contest_delay, holder_selected_contest_delay); } static void LDKChannelKeys_JCalls_free(void* this_arg) { LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg; if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { - (*j_calls->env)->DeleteGlobalRef(j_calls->env, j_calls->o); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + (*env)->DeleteGlobalRef(env, j_calls->o); FREE(j_calls); } } @@ -546,33 +947,33 @@ static void* LDKChannelKeys_JCalls_clone(const void* this_arg) { } static inline LDKChannelKeys LDKChannelKeys_init (JNIEnv * env, jclass _a, jobject o) { jclass c = (*env)->GetObjectClass(env, o); - assert(c != NULL); + DO_ASSERT(c != NULL); LDKChannelKeys_JCalls *calls = MALLOC(sizeof(LDKChannelKeys_JCalls), "LDKChannelKeys_JCalls"); atomic_init(&calls->refcnt, 1); - calls->env = env; + DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); calls->o = (*env)->NewGlobalRef(env, o); calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)J"); - assert(calls->get_per_commitment_point_meth != NULL); + DO_ASSERT(calls->get_per_commitment_point_meth != NULL); calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)J"); - assert(calls->release_commitment_secret_meth != NULL); + DO_ASSERT(calls->release_commitment_secret_meth != NULL); calls->key_derivation_params_meth = (*env)->GetMethodID(env, c, "key_derivation_params", "()J"); - assert(calls->key_derivation_params_meth != NULL); + DO_ASSERT(calls->key_derivation_params_meth != NULL); calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(IJJJ)J"); - assert(calls->sign_counterparty_commitment_meth != NULL); + DO_ASSERT(calls->sign_counterparty_commitment_meth != NULL); calls->sign_holder_commitment_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment", "(J)J"); - assert(calls->sign_holder_commitment_meth != NULL); + DO_ASSERT(calls->sign_holder_commitment_meth != NULL); calls->sign_holder_commitment_htlc_transactions_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_htlc_transactions", "(J)J"); - assert(calls->sign_holder_commitment_htlc_transactions_meth != NULL); + DO_ASSERT(calls->sign_holder_commitment_htlc_transactions_meth != NULL); calls->sign_justice_transaction_meth = (*env)->GetMethodID(env, c, "sign_justice_transaction", "(JJJ[BJ)J"); - assert(calls->sign_justice_transaction_meth != NULL); + DO_ASSERT(calls->sign_justice_transaction_meth != NULL); calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "(JJJJJ)J"); - assert(calls->sign_counterparty_htlc_transaction_meth != NULL); + DO_ASSERT(calls->sign_counterparty_htlc_transaction_meth != NULL); calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J"); - assert(calls->sign_closing_transaction_meth != NULL); + DO_ASSERT(calls->sign_closing_transaction_meth != NULL); calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J"); - assert(calls->sign_channel_announcement_meth != NULL); + DO_ASSERT(calls->sign_channel_announcement_meth != NULL); calls->on_accept_meth = (*env)->GetMethodID(env, c, "on_accept", "(JSS)V"); - assert(calls->on_accept_meth != NULL); + DO_ASSERT(calls->on_accept_meth != NULL); LDKChannelKeys ret = { .this_arg = (void*) calls, @@ -597,9 +998,124 @@ JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1new (JNIEnv * *res_ptr = LDKChannelKeys_init(env, _a, o); return (long)res_ptr; } +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) { + return ((LDKChannelKeys_JCalls*)val)->o; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1get_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong arg, jlong idx) { + LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg; + LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey"); + *ret = (arg_conv->get_per_commitment_point)(arg_conv->this_arg, idx); + return (long)ret; +} + +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1release_1commitment_1secret(JNIEnv * _env, jclass _b, jlong arg, jlong idx) { + LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg; + LDKThirtyTwoBytes* ret = MALLOC(sizeof(LDKThirtyTwoBytes), "LDKThirtyTwoBytes"); + *ret = (arg_conv->release_commitment_secret)(arg_conv->this_arg, idx); + return (long)ret; +} + +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1key_1derivation_1params(JNIEnv * _env, jclass _b, jlong arg) { + LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg; + LDKC2Tuple_u64u64Z* ret = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z"); + *ret = (arg_conv->key_derivation_params)(arg_conv->this_arg); + return (long)ret; +} + +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1sign_1counterparty_1commitment(JNIEnv * _env, jclass _b, jlong arg, jint feerate_per_kw, jlong commitment_tx, jlong keys, jlong htlcs) { + LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg; + LDKTransaction commitment_tx_conv = *(LDKTransaction*)commitment_tx; + FREE((void*)commitment_tx); + LDKPreCalculatedTxCreationKeys* keys_conv = (LDKPreCalculatedTxCreationKeys*)keys; + LDKCVec_HTLCOutputInCommitmentZ htlcs_conv = *(LDKCVec_HTLCOutputInCommitmentZ*)htlcs; + FREE((void*)htlcs); + LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ"); + *ret = (arg_conv->sign_counterparty_commitment)(arg_conv->this_arg, feerate_per_kw, commitment_tx_conv, keys_conv, htlcs_conv); + return (long)ret; +} + +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1sign_1holder_1commitment(JNIEnv * _env, jclass _b, jlong arg, jlong holder_commitment_tx) { + LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg; + LDKHolderCommitmentTransaction* holder_commitment_tx_conv = (LDKHolderCommitmentTransaction*)holder_commitment_tx; + LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ"); + *ret = (arg_conv->sign_holder_commitment)(arg_conv->this_arg, holder_commitment_tx_conv); + return (long)ret; +} + +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1sign_1holder_1commitment_1htlc_1transactions(JNIEnv * _env, jclass _b, jlong arg, jlong holder_commitment_tx) { + LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg; + LDKHolderCommitmentTransaction* holder_commitment_tx_conv = (LDKHolderCommitmentTransaction*)holder_commitment_tx; + LDKCResult_CVec_SignatureZNoneZ* ret = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ"); + *ret = (arg_conv->sign_holder_commitment_htlc_transactions)(arg_conv->this_arg, holder_commitment_tx_conv); + return (long)ret; +} + +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1sign_1justice_1transaction(JNIEnv * _env, jclass _b, jlong arg, jlong justice_tx, jlong input, jlong amount, jbyteArray per_commitment_key, jlong htlc) { + LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg; + LDKTransaction justice_tx_conv = *(LDKTransaction*)justice_tx; + FREE((void*)justice_tx); + unsigned char per_commitment_key_arr[32]; + (*_env)->GetByteArrayRegion (_env, per_commitment_key, 0, 32, per_commitment_key_arr); + unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr; + LDKHTLCOutputInCommitment* htlc_conv = (LDKHTLCOutputInCommitment*)htlc; + LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ"); + *ret = (arg_conv->sign_justice_transaction)(arg_conv->this_arg, justice_tx_conv, input, amount, per_commitment_key_ref, htlc_conv); + return (long)ret; +} + +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1sign_1counterparty_1htlc_1transaction(JNIEnv * _env, jclass _b, jlong arg, jlong htlc_tx, jlong input, jlong amount, jlong per_commitment_point, jlong htlc) { + LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg; + LDKTransaction htlc_tx_conv = *(LDKTransaction*)htlc_tx; + FREE((void*)htlc_tx); + LDKPublicKey per_commitment_point_conv = *(LDKPublicKey*)per_commitment_point; + FREE((void*)per_commitment_point); + LDKHTLCOutputInCommitment* htlc_conv = (LDKHTLCOutputInCommitment*)htlc; + LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ"); + *ret = (arg_conv->sign_counterparty_htlc_transaction)(arg_conv->this_arg, htlc_tx_conv, input, amount, per_commitment_point_conv, htlc_conv); + return (long)ret; +} + +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1sign_1closing_1transaction(JNIEnv * _env, jclass _b, jlong arg, jlong closing_tx) { + LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg; + LDKTransaction closing_tx_conv = *(LDKTransaction*)closing_tx; + FREE((void*)closing_tx); + LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ"); + *ret = (arg_conv->sign_closing_transaction)(arg_conv->this_arg, closing_tx_conv); + return (long)ret; +} + +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1sign_1channel_1announcement(JNIEnv * _env, jclass _b, jlong arg, jlong msg) { + LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg; + LDKUnsignedChannelAnnouncement* msg_conv = (LDKUnsignedChannelAnnouncement*)msg; + LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ"); + *ret = (arg_conv->sign_channel_announcement)(arg_conv->this_arg, msg_conv); + return (long)ret; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1on_1accept(JNIEnv * _env, jclass _b, jlong arg, jlong channel_points, jshort counterparty_selected_contest_delay, jshort holder_selected_contest_delay) { + LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg; + LDKChannelPublicKeys* channel_points_conv = (LDKChannelPublicKeys*)channel_points; + return (arg_conv->on_accept)(arg_conv->this_arg, channel_points_conv, counterparty_selected_contest_delay, holder_selected_contest_delay); +} + +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelMonitor_1optional_1none (JNIEnv * env, jclass _a) { + LDKChannelMonitor *ret = MALLOC(sizeof(LDKChannelMonitor), "LDKChannelMonitor"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelMonitorUpdate_1optional_1none (JNIEnv * env, jclass _a) { + LDKChannelMonitorUpdate *ret = MALLOC(sizeof(LDKChannelMonitorUpdate), "LDKChannelMonitorUpdate"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1optional_1none (JNIEnv * env, jclass _a) { + LDKMonitorEvent *ret = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent"); + ret->inner = NULL; + return (long)ret; +} typedef struct LDKWatch_JCalls { atomic_size_t refcnt; - JNIEnv *env; + JavaVM *vm; jobject o; jmethodID watch_channel_meth; jmethodID update_channel_meth; @@ -607,21 +1123,31 @@ typedef struct LDKWatch_JCalls { } LDKWatch_JCalls; LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) { LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg; - LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*j_calls->env)->CallLongMethod(j_calls->env, j_calls->o, j_calls->watch_channel_meth, funding_txo, monitor); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + long funding_txo_ref = (long)&funding_txo; + long monitor_ref = (long)&monitor; + LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref); LDKCResult_NoneChannelMonitorUpdateErrZ res = *ret; FREE(ret); return res; } LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) { LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg; - LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*j_calls->env)->CallLongMethod(j_calls->env, j_calls->o, j_calls->update_channel_meth, funding_txo, update); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + long funding_txo_ref = (long)&funding_txo; + long update_ref = (long)&update; + LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->update_channel_meth, funding_txo_ref, update_ref); LDKCResult_NoneChannelMonitorUpdateErrZ res = *ret; FREE(ret); return res; } LDKCVec_MonitorEventZ release_pending_monitor_events_jcall(const void* this_arg) { LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg; - LDKCVec_MonitorEventZ* ret = (LDKCVec_MonitorEventZ*)(*j_calls->env)->CallLongMethod(j_calls->env, j_calls->o, j_calls->release_pending_monitor_events_meth); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + LDKCVec_MonitorEventZ* ret = (LDKCVec_MonitorEventZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->release_pending_monitor_events_meth); LDKCVec_MonitorEventZ res = *ret; FREE(ret); return res; @@ -629,7 +1155,9 @@ LDKCVec_MonitorEventZ release_pending_monitor_events_jcall(const void* this_arg) static void LDKWatch_JCalls_free(void* this_arg) { LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg; if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { - (*j_calls->env)->DeleteGlobalRef(j_calls->env, j_calls->o); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + (*env)->DeleteGlobalRef(env, j_calls->o); FREE(j_calls); } } @@ -640,17 +1168,17 @@ static void* LDKWatch_JCalls_clone(const void* this_arg) { } static inline LDKWatch LDKWatch_init (JNIEnv * env, jclass _a, jobject o) { jclass c = (*env)->GetObjectClass(env, o); - assert(c != NULL); + DO_ASSERT(c != NULL); LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls"); atomic_init(&calls->refcnt, 1); - calls->env = env; + DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); calls->o = (*env)->NewGlobalRef(env, o); calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J"); - assert(calls->watch_channel_meth != NULL); + DO_ASSERT(calls->watch_channel_meth != NULL); calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J"); - assert(calls->update_channel_meth != NULL); + DO_ASSERT(calls->update_channel_meth != NULL); calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()J"); - assert(calls->release_pending_monitor_events_meth != NULL); + DO_ASSERT(calls->release_pending_monitor_events_meth != NULL); LDKWatch ret = { .this_arg = (void*) calls, @@ -666,27 +1194,71 @@ JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new (JNIEnv * env, j *res_ptr = LDKWatch_init(env, _a, o); return (long)res_ptr; } +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKWatch_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) { + return ((LDKWatch_JCalls*)val)->o; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKWatch_1call_1watch_1channel(JNIEnv * _env, jclass _b, jlong arg, jlong funding_txo, jlong monitor) { + LDKWatch* arg_conv = (LDKWatch*)arg; + LDKOutPoint funding_txo_conv = *(LDKOutPoint*)funding_txo; + FREE((void*)funding_txo); + funding_txo_conv.is_owned = true; + LDKChannelMonitor monitor_conv = *(LDKChannelMonitor*)monitor; + FREE((void*)monitor); + monitor_conv.is_owned = true; + LDKCResult_NoneChannelMonitorUpdateErrZ* ret = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ"); + *ret = (arg_conv->watch_channel)(arg_conv->this_arg, funding_txo_conv, monitor_conv); + return (long)ret; +} + +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKWatch_1call_1update_1channel(JNIEnv * _env, jclass _b, jlong arg, jlong funding_txo, jlong update) { + LDKWatch* arg_conv = (LDKWatch*)arg; + LDKOutPoint funding_txo_conv = *(LDKOutPoint*)funding_txo; + FREE((void*)funding_txo); + funding_txo_conv.is_owned = true; + LDKChannelMonitorUpdate update_conv = *(LDKChannelMonitorUpdate*)update; + FREE((void*)update); + update_conv.is_owned = true; + LDKCResult_NoneChannelMonitorUpdateErrZ* ret = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ"); + *ret = (arg_conv->update_channel)(arg_conv->this_arg, funding_txo_conv, update_conv); + return (long)ret; +} + +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKWatch_1call_1release_1pending_1monitor_1events(JNIEnv * _env, jclass _b, jlong arg) { + LDKWatch* arg_conv = (LDKWatch*)arg; + LDKCVec_MonitorEventZ* ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ"); + *ret = (arg_conv->release_pending_monitor_events)(arg_conv->this_arg); + return (long)ret; +} + typedef struct LDKFilter_JCalls { atomic_size_t refcnt; - JNIEnv *env; + JavaVM *vm; jobject o; jmethodID register_tx_meth; jmethodID register_output_meth; } LDKFilter_JCalls; void register_tx_jcall(const void* this_arg, const uint8_t (*txid)[32], LDKu8slice script_pubkey) { LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg; - jbyteArray txid_arr = (*j_calls->env)->NewByteArray(j_calls->env, 32); - (*j_calls->env)->SetByteArrayRegion(j_calls->env, txid_arr, 0, 32, *txid); - return (*j_calls->env)->CallVoidMethod(j_calls->env, j_calls->o, j_calls->register_tx_meth, txid_arr, script_pubkey); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + jbyteArray txid_arr = (*env)->NewByteArray(env, 32); + (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid); + long script_pubkey_ref = (long)&script_pubkey; + return (*env)->CallVoidMethod(env, j_calls->o, j_calls->register_tx_meth, txid_arr, script_pubkey_ref); } void register_output_jcall(const void* this_arg, const LDKOutPoint *outpoint, LDKu8slice script_pubkey) { LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg; - return (*j_calls->env)->CallVoidMethod(j_calls->env, j_calls->o, j_calls->register_output_meth, outpoint, script_pubkey); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + long script_pubkey_ref = (long)&script_pubkey; + return (*env)->CallVoidMethod(env, j_calls->o, j_calls->register_output_meth, outpoint, script_pubkey_ref); } static void LDKFilter_JCalls_free(void* this_arg) { LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg; if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { - (*j_calls->env)->DeleteGlobalRef(j_calls->env, j_calls->o); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + (*env)->DeleteGlobalRef(env, j_calls->o); FREE(j_calls); } } @@ -697,15 +1269,15 @@ static void* LDKFilter_JCalls_clone(const void* this_arg) { } static inline LDKFilter LDKFilter_init (JNIEnv * env, jclass _a, jobject o) { jclass c = (*env)->GetObjectClass(env, o); - assert(c != NULL); + DO_ASSERT(c != NULL); LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls"); atomic_init(&calls->refcnt, 1); - calls->env = env; + DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); calls->o = (*env)->NewGlobalRef(env, o); calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([BJ)V"); - assert(calls->register_tx_meth != NULL); + DO_ASSERT(calls->register_tx_meth != NULL); calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(JJ)V"); - assert(calls->register_output_meth != NULL); + DO_ASSERT(calls->register_output_meth != NULL); LDKFilter ret = { .this_arg = (void*) calls, @@ -720,20 +1292,44 @@ JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new (JNIEnv * env, *res_ptr = LDKFilter_init(env, _a, o); return (long)res_ptr; } +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFilter_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) { + return ((LDKFilter_JCalls*)val)->o; +} +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKFilter_1call_1register_1tx(JNIEnv * _env, jclass _b, jlong arg, jbyteArray txid, jlong script_pubkey) { + LDKFilter* arg_conv = (LDKFilter*)arg; + unsigned char txid_arr[32]; + (*_env)->GetByteArrayRegion (_env, txid, 0, 32, txid_arr); + unsigned char (*txid_ref)[32] = &txid_arr; + LDKu8slice script_pubkey_conv = *(LDKu8slice*)script_pubkey; + return (arg_conv->register_tx)(arg_conv->this_arg, txid_ref, script_pubkey_conv); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKFilter_1call_1register_1output(JNIEnv * _env, jclass _b, jlong arg, jlong outpoint, jlong script_pubkey) { + LDKFilter* arg_conv = (LDKFilter*)arg; + LDKOutPoint* outpoint_conv = (LDKOutPoint*)outpoint; + LDKu8slice script_pubkey_conv = *(LDKu8slice*)script_pubkey; + return (arg_conv->register_output)(arg_conv->this_arg, outpoint_conv, script_pubkey_conv); +} + typedef struct LDKBroadcasterInterface_JCalls { atomic_size_t refcnt; - JNIEnv *env; + JavaVM *vm; jobject o; jmethodID broadcast_transaction_meth; } LDKBroadcasterInterface_JCalls; void broadcast_transaction_jcall(const void* this_arg, LDKTransaction tx) { LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg; - return (*j_calls->env)->CallVoidMethod(j_calls->env, j_calls->o, j_calls->broadcast_transaction_meth, tx); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + long tx_ref = (long)&tx; + return (*env)->CallVoidMethod(env, j_calls->o, j_calls->broadcast_transaction_meth, tx_ref); } static void LDKBroadcasterInterface_JCalls_free(void* this_arg) { LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg; if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { - (*j_calls->env)->DeleteGlobalRef(j_calls->env, j_calls->o); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + (*env)->DeleteGlobalRef(env, j_calls->o); FREE(j_calls); } } @@ -744,13 +1340,13 @@ static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) { } static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv * env, jclass _a, jobject o) { jclass c = (*env)->GetObjectClass(env, o); - assert(c != NULL); + DO_ASSERT(c != NULL); LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls"); atomic_init(&calls->refcnt, 1); - calls->env = env; + DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); calls->o = (*env)->NewGlobalRef(env, o); calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "(J)V"); - assert(calls->broadcast_transaction_meth != NULL); + DO_ASSERT(calls->broadcast_transaction_meth != NULL); LDKBroadcasterInterface ret = { .this_arg = (void*) calls, @@ -764,21 +1360,35 @@ JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new ( *res_ptr = LDKBroadcasterInterface_init(env, _a, o); return (long)res_ptr; } +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) { + return ((LDKBroadcasterInterface_JCalls*)val)->o; +} +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1call_1broadcast_1transaction(JNIEnv * _env, jclass _b, jlong arg, jlong tx) { + LDKBroadcasterInterface* arg_conv = (LDKBroadcasterInterface*)arg; + LDKTransaction tx_conv = *(LDKTransaction*)tx; + FREE((void*)tx); + return (arg_conv->broadcast_transaction)(arg_conv->this_arg, tx_conv); +} + typedef struct LDKFeeEstimator_JCalls { atomic_size_t refcnt; - JNIEnv *env; + JavaVM *vm; jobject o; jmethodID get_est_sat_per_1000_weight_meth; } LDKFeeEstimator_JCalls; uint32_t get_est_sat_per_1000_weight_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) { LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg; - jclass confirmation_target_conv = LDKConfirmationTarget_to_java(j_calls->env, confirmation_target); - return (*j_calls->env)->CallIntMethod(j_calls->env, j_calls->o, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target); + return (*env)->CallIntMethod(env, j_calls->o, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv); } static void LDKFeeEstimator_JCalls_free(void* this_arg) { LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg; if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { - (*j_calls->env)->DeleteGlobalRef(j_calls->env, j_calls->o); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + (*env)->DeleteGlobalRef(env, j_calls->o); FREE(j_calls); } } @@ -789,13 +1399,13 @@ static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) { } static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv * env, jclass _a, jobject o) { jclass c = (*env)->GetObjectClass(env, o); - assert(c != NULL); + DO_ASSERT(c != NULL); LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls"); atomic_init(&calls->refcnt, 1); - calls->env = env; + DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); calls->o = (*env)->NewGlobalRef(env, o); calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/impl/bindings$LDKConfirmationTarget;)I"); - assert(calls->get_est_sat_per_1000_weight_meth != NULL); + DO_ASSERT(calls->get_est_sat_per_1000_weight_meth != NULL); LDKFeeEstimator ret = { .this_arg = (void*) calls, @@ -809,9 +1419,28 @@ JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new (JNIEnv * *res_ptr = LDKFeeEstimator_init(env, _a, o); return (long)res_ptr; } +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) { + return ((LDKFeeEstimator_JCalls*)val)->o; +} +JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1call_1get_1est_1sat_1per_11000_1weight(JNIEnv * _env, jclass _b, jlong arg, jclass confirmation_target) { + LDKFeeEstimator* arg_conv = (LDKFeeEstimator*)arg; + LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(_env, confirmation_target); + return (arg_conv->get_est_sat_per_1000_weight)(arg_conv->this_arg, confirmation_target_conv); +} + +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChainMonitor_1optional_1none (JNIEnv * env, jclass _a) { + LDKChainMonitor *ret = MALLOC(sizeof(LDKChainMonitor), "LDKChainMonitor"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKHTLCUpdate_1optional_1none (JNIEnv * env, jclass _a) { + LDKHTLCUpdate *ret = MALLOC(sizeof(LDKHTLCUpdate), "LDKHTLCUpdate"); + ret->inner = NULL; + return (long)ret; +} typedef struct LDKKeysInterface_JCalls { atomic_size_t refcnt; - JNIEnv *env; + JavaVM *vm; jobject o; jmethodID get_node_secret_meth; jmethodID get_destination_script_meth; @@ -821,35 +1450,45 @@ typedef struct LDKKeysInterface_JCalls { } LDKKeysInterface_JCalls; LDKSecretKey get_node_secret_jcall(const void* this_arg) { LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg; - LDKSecretKey* ret = (LDKSecretKey*)(*j_calls->env)->CallLongMethod(j_calls->env, j_calls->o, j_calls->get_node_secret_meth); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + LDKSecretKey* ret = (LDKSecretKey*)(*env)->CallLongMethod(env, j_calls->o, j_calls->get_node_secret_meth); LDKSecretKey res = *ret; FREE(ret); return res; } LDKCVec_u8Z get_destination_script_jcall(const void* this_arg) { LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg; - LDKCVec_u8Z* ret = (LDKCVec_u8Z*)(*j_calls->env)->CallLongMethod(j_calls->env, j_calls->o, j_calls->get_destination_script_meth); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + LDKCVec_u8Z* ret = (LDKCVec_u8Z*)(*env)->CallLongMethod(env, j_calls->o, j_calls->get_destination_script_meth); LDKCVec_u8Z res = *ret; FREE(ret); return res; } LDKPublicKey get_shutdown_pubkey_jcall(const void* this_arg) { LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg; - LDKPublicKey* ret = (LDKPublicKey*)(*j_calls->env)->CallLongMethod(j_calls->env, j_calls->o, j_calls->get_shutdown_pubkey_meth); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + LDKPublicKey* ret = (LDKPublicKey*)(*env)->CallLongMethod(env, j_calls->o, j_calls->get_shutdown_pubkey_meth); LDKPublicKey res = *ret; FREE(ret); return res; } LDKChannelKeys get_channel_keys_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) { LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg; - LDKChannelKeys* ret = (LDKChannelKeys*)(*j_calls->env)->CallLongMethod(j_calls->env, j_calls->o, j_calls->get_channel_keys_meth, inbound, channel_value_satoshis); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + LDKChannelKeys* ret = (LDKChannelKeys*)(*env)->CallLongMethod(env, j_calls->o, j_calls->get_channel_keys_meth, inbound, channel_value_satoshis); LDKChannelKeys res = *ret; FREE(ret); return res; } LDKThirtyTwoBytes get_secure_random_bytes_jcall(const void* this_arg) { LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg; - LDKThirtyTwoBytes* ret = (LDKThirtyTwoBytes*)(*j_calls->env)->CallLongMethod(j_calls->env, j_calls->o, j_calls->get_secure_random_bytes_meth); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + LDKThirtyTwoBytes* ret = (LDKThirtyTwoBytes*)(*env)->CallLongMethod(env, j_calls->o, j_calls->get_secure_random_bytes_meth); LDKThirtyTwoBytes res = *ret; FREE(ret); return res; @@ -857,7 +1496,9 @@ LDKThirtyTwoBytes get_secure_random_bytes_jcall(const void* this_arg) { static void LDKKeysInterface_JCalls_free(void* this_arg) { LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg; if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { - (*j_calls->env)->DeleteGlobalRef(j_calls->env, j_calls->o); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + (*env)->DeleteGlobalRef(env, j_calls->o); FREE(j_calls); } } @@ -868,21 +1509,21 @@ static void* LDKKeysInterface_JCalls_clone(const void* this_arg) { } static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv * env, jclass _a, jobject o) { jclass c = (*env)->GetObjectClass(env, o); - assert(c != NULL); + DO_ASSERT(c != NULL); LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls"); atomic_init(&calls->refcnt, 1); - calls->env = env; + DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); calls->o = (*env)->NewGlobalRef(env, o); calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()J"); - assert(calls->get_node_secret_meth != NULL); + DO_ASSERT(calls->get_node_secret_meth != NULL); calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()J"); - assert(calls->get_destination_script_meth != NULL); + DO_ASSERT(calls->get_destination_script_meth != NULL); calls->get_shutdown_pubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_pubkey", "()J"); - assert(calls->get_shutdown_pubkey_meth != NULL); + DO_ASSERT(calls->get_shutdown_pubkey_meth != NULL); calls->get_channel_keys_meth = (*env)->GetMethodID(env, c, "get_channel_keys", "(ZJ)J"); - assert(calls->get_channel_keys_meth != NULL); + DO_ASSERT(calls->get_channel_keys_meth != NULL); calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()J"); - assert(calls->get_secure_random_bytes_meth != NULL); + DO_ASSERT(calls->get_secure_random_bytes_meth != NULL); LDKKeysInterface ret = { .this_arg = (void*) calls, @@ -900,9 +1541,112 @@ JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new (JNIEnv *res_ptr = LDKKeysInterface_init(env, _a, o); return (long)res_ptr; } +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) { + return ((LDKKeysInterface_JCalls*)val)->o; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1call_1get_1node_1secret(JNIEnv * _env, jclass _b, jlong arg) { + LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg; + LDKSecretKey* ret = MALLOC(sizeof(LDKSecretKey), "LDKSecretKey"); + *ret = (arg_conv->get_node_secret)(arg_conv->this_arg); + return (long)ret; +} + +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1call_1get_1destination_1script(JNIEnv * _env, jclass _b, jlong arg) { + LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg; + LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z"); + *ret = (arg_conv->get_destination_script)(arg_conv->this_arg); + return (long)ret; +} + +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1call_1get_1shutdown_1pubkey(JNIEnv * _env, jclass _b, jlong arg) { + LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg; + LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey"); + *ret = (arg_conv->get_shutdown_pubkey)(arg_conv->this_arg); + return (long)ret; +} + +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1call_1get_1channel_1keys(JNIEnv * _env, jclass _b, jlong arg, jboolean inbound, jlong channel_value_satoshis) { + LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg; + LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys"); + *ret = (arg_conv->get_channel_keys)(arg_conv->this_arg, inbound, channel_value_satoshis); + return (long)ret; +} + +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1call_1get_1secure_1random_1bytes(JNIEnv * _env, jclass _b, jlong arg) { + LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg; + LDKThirtyTwoBytes* ret = MALLOC(sizeof(LDKThirtyTwoBytes), "LDKThirtyTwoBytes"); + *ret = (arg_conv->get_secure_random_bytes)(arg_conv->this_arg); + return (long)ret; +} + +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKInMemoryChannelKeys_1optional_1none (JNIEnv * env, jclass _a) { + LDKInMemoryChannelKeys *ret = MALLOC(sizeof(LDKInMemoryChannelKeys), "LDKInMemoryChannelKeys"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKKeysManager_1optional_1none (JNIEnv * env, jclass _a) { + LDKKeysManager *ret = MALLOC(sizeof(LDKKeysManager), "LDKKeysManager"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelManager_1optional_1none (JNIEnv * env, jclass _a) { + LDKChannelManager *ret = MALLOC(sizeof(LDKChannelManager), "LDKChannelManager"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelDetails_1optional_1none (JNIEnv * env, jclass _a) { + LDKChannelDetails *ret = MALLOC(sizeof(LDKChannelDetails), "LDKChannelDetails"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKInitFeatures_1optional_1none (JNIEnv * env, jclass _a) { + LDKInitFeatures *ret = MALLOC(sizeof(LDKInitFeatures), "LDKInitFeatures"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKRoute_1optional_1none (JNIEnv * env, jclass _a) { + LDKRoute *ret = MALLOC(sizeof(LDKRoute), "LDKRoute"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKUpdateAddHTLC_1optional_1none (JNIEnv * env, jclass _a) { + LDKUpdateAddHTLC *ret = MALLOC(sizeof(LDKUpdateAddHTLC), "LDKUpdateAddHTLC"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKUpdateFulfillHTLC_1optional_1none (JNIEnv * env, jclass _a) { + LDKUpdateFulfillHTLC *ret = MALLOC(sizeof(LDKUpdateFulfillHTLC), "LDKUpdateFulfillHTLC"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKUpdateFailHTLC_1optional_1none (JNIEnv * env, jclass _a) { + LDKUpdateFailHTLC *ret = MALLOC(sizeof(LDKUpdateFailHTLC), "LDKUpdateFailHTLC"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKUpdateFailMalformedHTLC_1optional_1none (JNIEnv * env, jclass _a) { + LDKUpdateFailMalformedHTLC *ret = MALLOC(sizeof(LDKUpdateFailMalformedHTLC), "LDKUpdateFailMalformedHTLC"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCommitmentSigned_1optional_1none (JNIEnv * env, jclass _a) { + LDKCommitmentSigned *ret = MALLOC(sizeof(LDKCommitmentSigned), "LDKCommitmentSigned"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKUpdateFee_1optional_1none (JNIEnv * env, jclass _a) { + LDKUpdateFee *ret = MALLOC(sizeof(LDKUpdateFee), "LDKUpdateFee"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKInit_1optional_1none (JNIEnv * env, jclass _a) { + LDKInit *ret = MALLOC(sizeof(LDKInit), "LDKInit"); + ret->inner = NULL; + return (long)ret; +} typedef struct LDKChannelMessageHandler_JCalls { atomic_size_t refcnt; - JNIEnv *env; + JavaVM *vm; jobject o; LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider; jmethodID handle_open_channel_meth; @@ -927,84 +1671,145 @@ typedef struct LDKChannelMessageHandler_JCalls { } LDKChannelMessageHandler_JCalls; void handle_open_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; - return (*j_calls->env)->CallVoidMethod(j_calls->env, j_calls->o, j_calls->handle_open_channel_meth, their_node_id, their_features, msg); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + long their_node_id_ref = (long)&their_node_id; + long their_features_ref = (long)&their_features; + return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_open_channel_meth, their_node_id_ref, their_features_ref, msg); } void handle_accept_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; - return (*j_calls->env)->CallVoidMethod(j_calls->env, j_calls->o, j_calls->handle_accept_channel_meth, their_node_id, their_features, msg); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + long their_node_id_ref = (long)&their_node_id; + long their_features_ref = (long)&their_features; + return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_accept_channel_meth, their_node_id_ref, their_features_ref, msg); } void handle_funding_created_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; - return (*j_calls->env)->CallVoidMethod(j_calls->env, j_calls->o, j_calls->handle_funding_created_meth, their_node_id, msg); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + long their_node_id_ref = (long)&their_node_id; + return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_funding_created_meth, their_node_id_ref, msg); } void handle_funding_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; - return (*j_calls->env)->CallVoidMethod(j_calls->env, j_calls->o, j_calls->handle_funding_signed_meth, their_node_id, msg); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + long their_node_id_ref = (long)&their_node_id; + return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_funding_signed_meth, their_node_id_ref, msg); } void handle_funding_locked_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; - return (*j_calls->env)->CallVoidMethod(j_calls->env, j_calls->o, j_calls->handle_funding_locked_meth, their_node_id, msg); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + long their_node_id_ref = (long)&their_node_id; + return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_funding_locked_meth, their_node_id_ref, msg); } void handle_shutdown_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKShutdown *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; - return (*j_calls->env)->CallVoidMethod(j_calls->env, j_calls->o, j_calls->handle_shutdown_meth, their_node_id, msg); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + long their_node_id_ref = (long)&their_node_id; + return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_shutdown_meth, their_node_id_ref, msg); } void handle_closing_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; - return (*j_calls->env)->CallVoidMethod(j_calls->env, j_calls->o, j_calls->handle_closing_signed_meth, their_node_id, msg); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + long their_node_id_ref = (long)&their_node_id; + return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_closing_signed_meth, their_node_id_ref, msg); } void handle_update_add_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; - return (*j_calls->env)->CallVoidMethod(j_calls->env, j_calls->o, j_calls->handle_update_add_htlc_meth, their_node_id, msg); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + long their_node_id_ref = (long)&their_node_id; + return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_update_add_htlc_meth, their_node_id_ref, msg); } void handle_update_fulfill_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; - return (*j_calls->env)->CallVoidMethod(j_calls->env, j_calls->o, j_calls->handle_update_fulfill_htlc_meth, their_node_id, msg); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + long their_node_id_ref = (long)&their_node_id; + return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_update_fulfill_htlc_meth, their_node_id_ref, msg); } void handle_update_fail_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; - return (*j_calls->env)->CallVoidMethod(j_calls->env, j_calls->o, j_calls->handle_update_fail_htlc_meth, their_node_id, msg); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + long their_node_id_ref = (long)&their_node_id; + return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_update_fail_htlc_meth, their_node_id_ref, msg); } void handle_update_fail_malformed_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; - return (*j_calls->env)->CallVoidMethod(j_calls->env, j_calls->o, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id, msg); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + long their_node_id_ref = (long)&their_node_id; + return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_ref, msg); } void handle_commitment_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; - return (*j_calls->env)->CallVoidMethod(j_calls->env, j_calls->o, j_calls->handle_commitment_signed_meth, their_node_id, msg); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + long their_node_id_ref = (long)&their_node_id; + return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_commitment_signed_meth, their_node_id_ref, msg); } void handle_revoke_and_ack_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; - return (*j_calls->env)->CallVoidMethod(j_calls->env, j_calls->o, j_calls->handle_revoke_and_ack_meth, their_node_id, msg); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + long their_node_id_ref = (long)&their_node_id; + return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_revoke_and_ack_meth, their_node_id_ref, msg); } void handle_update_fee_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; - return (*j_calls->env)->CallVoidMethod(j_calls->env, j_calls->o, j_calls->handle_update_fee_meth, their_node_id, msg); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + long their_node_id_ref = (long)&their_node_id; + return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_update_fee_meth, their_node_id_ref, msg); } void handle_announcement_signatures_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; - return (*j_calls->env)->CallVoidMethod(j_calls->env, j_calls->o, j_calls->handle_announcement_signatures_meth, their_node_id, msg); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + long their_node_id_ref = (long)&their_node_id; + return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_announcement_signatures_meth, their_node_id_ref, msg); } void peer_disconnected_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; - return (*j_calls->env)->CallVoidMethod(j_calls->env, j_calls->o, j_calls->peer_disconnected_meth, their_node_id, no_connection_possible); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + long their_node_id_ref = (long)&their_node_id; + return (*env)->CallVoidMethod(env, j_calls->o, j_calls->peer_disconnected_meth, their_node_id_ref, no_connection_possible); } void peer_connected_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; - return (*j_calls->env)->CallVoidMethod(j_calls->env, j_calls->o, j_calls->peer_connected_meth, their_node_id, msg); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + long their_node_id_ref = (long)&their_node_id; + return (*env)->CallVoidMethod(env, j_calls->o, j_calls->peer_connected_meth, their_node_id_ref, msg); } void handle_channel_reestablish_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; - return (*j_calls->env)->CallVoidMethod(j_calls->env, j_calls->o, j_calls->handle_channel_reestablish_meth, their_node_id, msg); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + long their_node_id_ref = (long)&their_node_id; + return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_channel_reestablish_meth, their_node_id_ref, msg); } void handle_error_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; - return (*j_calls->env)->CallVoidMethod(j_calls->env, j_calls->o, j_calls->handle_error_meth, their_node_id, msg); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + long their_node_id_ref = (long)&their_node_id; + return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_error_meth, their_node_id_ref, msg); } static void LDKChannelMessageHandler_JCalls_free(void* this_arg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { - (*j_calls->env)->DeleteGlobalRef(j_calls->env, j_calls->o); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + (*env)->DeleteGlobalRef(env, j_calls->o); FREE(j_calls); } } @@ -1016,49 +1821,49 @@ static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) { } static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv * env, jclass _a, jobject o, jobject MessageSendEventsProvider) { jclass c = (*env)->GetObjectClass(env, o); - assert(c != NULL); + DO_ASSERT(c != NULL); LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls"); atomic_init(&calls->refcnt, 1); - calls->env = env; + DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); calls->o = (*env)->NewGlobalRef(env, o); calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "(JJJ)V"); - assert(calls->handle_open_channel_meth != NULL); + DO_ASSERT(calls->handle_open_channel_meth != NULL); calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "(JJJ)V"); - assert(calls->handle_accept_channel_meth != NULL); + DO_ASSERT(calls->handle_accept_channel_meth != NULL); calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "(JJ)V"); - assert(calls->handle_funding_created_meth != NULL); + DO_ASSERT(calls->handle_funding_created_meth != NULL); calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "(JJ)V"); - assert(calls->handle_funding_signed_meth != NULL); + DO_ASSERT(calls->handle_funding_signed_meth != NULL); calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "(JJ)V"); - assert(calls->handle_funding_locked_meth != NULL); + DO_ASSERT(calls->handle_funding_locked_meth != NULL); calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "(JJ)V"); - assert(calls->handle_shutdown_meth != NULL); + DO_ASSERT(calls->handle_shutdown_meth != NULL); calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "(JJ)V"); - assert(calls->handle_closing_signed_meth != NULL); + DO_ASSERT(calls->handle_closing_signed_meth != NULL); calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "(JJ)V"); - assert(calls->handle_update_add_htlc_meth != NULL); + DO_ASSERT(calls->handle_update_add_htlc_meth != NULL); calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "(JJ)V"); - assert(calls->handle_update_fulfill_htlc_meth != NULL); + DO_ASSERT(calls->handle_update_fulfill_htlc_meth != NULL); calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "(JJ)V"); - assert(calls->handle_update_fail_htlc_meth != NULL); + DO_ASSERT(calls->handle_update_fail_htlc_meth != NULL); calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "(JJ)V"); - assert(calls->handle_update_fail_malformed_htlc_meth != NULL); + DO_ASSERT(calls->handle_update_fail_malformed_htlc_meth != NULL); calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "(JJ)V"); - assert(calls->handle_commitment_signed_meth != NULL); + DO_ASSERT(calls->handle_commitment_signed_meth != NULL); calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "(JJ)V"); - assert(calls->handle_revoke_and_ack_meth != NULL); + DO_ASSERT(calls->handle_revoke_and_ack_meth != NULL); calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "(JJ)V"); - assert(calls->handle_update_fee_meth != NULL); + DO_ASSERT(calls->handle_update_fee_meth != NULL); calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "(JJ)V"); - assert(calls->handle_announcement_signatures_meth != NULL); + DO_ASSERT(calls->handle_announcement_signatures_meth != NULL); calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "(JZ)V"); - assert(calls->peer_disconnected_meth != NULL); + DO_ASSERT(calls->peer_disconnected_meth != NULL); calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "(JJ)V"); - assert(calls->peer_connected_meth != NULL); + DO_ASSERT(calls->peer_connected_meth != NULL); calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "(JJ)V"); - assert(calls->handle_channel_reestablish_meth != NULL); + DO_ASSERT(calls->handle_channel_reestablish_meth != NULL); calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "(JJ)V"); - assert(calls->handle_error_meth != NULL); + DO_ASSERT(calls->handle_error_meth != NULL); LDKChannelMessageHandler ret = { .this_arg = (void*) calls, @@ -1092,9 +1897,254 @@ JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new *res_ptr = LDKChannelMessageHandler_init(env, _a, o, MessageSendEventsProvider); return (long)res_ptr; } +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) { + return ((LDKChannelMessageHandler_JCalls*)val)->o; +} +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1open_1channel(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong their_features, jlong msg) { + LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg; + LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id; + FREE((void*)their_node_id); + LDKInitFeatures their_features_conv = *(LDKInitFeatures*)their_features; + FREE((void*)their_features); + their_features_conv.is_owned = true; + LDKOpenChannel* msg_conv = (LDKOpenChannel*)msg; + return (arg_conv->handle_open_channel)(arg_conv->this_arg, their_node_id_conv, their_features_conv, msg_conv); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1accept_1channel(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong their_features, jlong msg) { + LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg; + LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id; + FREE((void*)their_node_id); + LDKInitFeatures their_features_conv = *(LDKInitFeatures*)their_features; + FREE((void*)their_features); + their_features_conv.is_owned = true; + LDKAcceptChannel* msg_conv = (LDKAcceptChannel*)msg; + return (arg_conv->handle_accept_channel)(arg_conv->this_arg, their_node_id_conv, their_features_conv, msg_conv); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1funding_1created(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) { + LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg; + LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id; + FREE((void*)their_node_id); + LDKFundingCreated* msg_conv = (LDKFundingCreated*)msg; + return (arg_conv->handle_funding_created)(arg_conv->this_arg, their_node_id_conv, msg_conv); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1funding_1signed(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) { + LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg; + LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id; + FREE((void*)their_node_id); + LDKFundingSigned* msg_conv = (LDKFundingSigned*)msg; + return (arg_conv->handle_funding_signed)(arg_conv->this_arg, their_node_id_conv, msg_conv); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1funding_1locked(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) { + LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg; + LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id; + FREE((void*)their_node_id); + LDKFundingLocked* msg_conv = (LDKFundingLocked*)msg; + return (arg_conv->handle_funding_locked)(arg_conv->this_arg, their_node_id_conv, msg_conv); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1shutdown(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) { + LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg; + LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id; + FREE((void*)their_node_id); + LDKShutdown* msg_conv = (LDKShutdown*)msg; + return (arg_conv->handle_shutdown)(arg_conv->this_arg, their_node_id_conv, msg_conv); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1closing_1signed(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) { + LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg; + LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id; + FREE((void*)their_node_id); + LDKClosingSigned* msg_conv = (LDKClosingSigned*)msg; + return (arg_conv->handle_closing_signed)(arg_conv->this_arg, their_node_id_conv, msg_conv); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1update_1add_1htlc(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) { + LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg; + LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id; + FREE((void*)their_node_id); + LDKUpdateAddHTLC* msg_conv = (LDKUpdateAddHTLC*)msg; + return (arg_conv->handle_update_add_htlc)(arg_conv->this_arg, their_node_id_conv, msg_conv); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1update_1fulfill_1htlc(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) { + LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg; + LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id; + FREE((void*)their_node_id); + LDKUpdateFulfillHTLC* msg_conv = (LDKUpdateFulfillHTLC*)msg; + return (arg_conv->handle_update_fulfill_htlc)(arg_conv->this_arg, their_node_id_conv, msg_conv); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1update_1fail_1htlc(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) { + LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg; + LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id; + FREE((void*)their_node_id); + LDKUpdateFailHTLC* msg_conv = (LDKUpdateFailHTLC*)msg; + return (arg_conv->handle_update_fail_htlc)(arg_conv->this_arg, their_node_id_conv, msg_conv); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1update_1fail_1malformed_1htlc(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) { + LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg; + LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id; + FREE((void*)their_node_id); + LDKUpdateFailMalformedHTLC* msg_conv = (LDKUpdateFailMalformedHTLC*)msg; + return (arg_conv->handle_update_fail_malformed_htlc)(arg_conv->this_arg, their_node_id_conv, msg_conv); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1commitment_1signed(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) { + LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg; + LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id; + FREE((void*)their_node_id); + LDKCommitmentSigned* msg_conv = (LDKCommitmentSigned*)msg; + return (arg_conv->handle_commitment_signed)(arg_conv->this_arg, their_node_id_conv, msg_conv); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1revoke_1and_1ack(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) { + LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg; + LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id; + FREE((void*)their_node_id); + LDKRevokeAndACK* msg_conv = (LDKRevokeAndACK*)msg; + return (arg_conv->handle_revoke_and_ack)(arg_conv->this_arg, their_node_id_conv, msg_conv); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1update_1fee(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) { + LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg; + LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id; + FREE((void*)their_node_id); + LDKUpdateFee* msg_conv = (LDKUpdateFee*)msg; + return (arg_conv->handle_update_fee)(arg_conv->this_arg, their_node_id_conv, msg_conv); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1announcement_1signatures(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) { + LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg; + LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id; + FREE((void*)their_node_id); + LDKAnnouncementSignatures* msg_conv = (LDKAnnouncementSignatures*)msg; + return (arg_conv->handle_announcement_signatures)(arg_conv->this_arg, their_node_id_conv, msg_conv); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1peer_1disconnected(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jboolean no_connection_possible) { + LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg; + LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id; + FREE((void*)their_node_id); + return (arg_conv->peer_disconnected)(arg_conv->this_arg, their_node_id_conv, no_connection_possible); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1peer_1connected(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) { + LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg; + LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id; + FREE((void*)their_node_id); + LDKInit* msg_conv = (LDKInit*)msg; + return (arg_conv->peer_connected)(arg_conv->this_arg, their_node_id_conv, msg_conv); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1channel_1reestablish(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) { + LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg; + LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id; + FREE((void*)their_node_id); + LDKChannelReestablish* msg_conv = (LDKChannelReestablish*)msg; + return (arg_conv->handle_channel_reestablish)(arg_conv->this_arg, their_node_id_conv, msg_conv); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1error(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) { + LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg; + LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id; + FREE((void*)their_node_id); + LDKErrorMessage* msg_conv = (LDKErrorMessage*)msg; + return (arg_conv->handle_error)(arg_conv->this_arg, their_node_id_conv, msg_conv); +} + +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelManagerReadArgs_1optional_1none (JNIEnv * env, jclass _a) { + LDKChannelManagerReadArgs *ret = MALLOC(sizeof(LDKChannelManagerReadArgs), "LDKChannelManagerReadArgs"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKDecodeError_1optional_1none (JNIEnv * env, jclass _a) { + LDKDecodeError *ret = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKPing_1optional_1none (JNIEnv * env, jclass _a) { + LDKPing *ret = MALLOC(sizeof(LDKPing), "LDKPing"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKPong_1optional_1none (JNIEnv * env, jclass _a) { + LDKPong *ret = MALLOC(sizeof(LDKPong), "LDKPong"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKDataLossProtect_1optional_1none (JNIEnv * env, jclass _a) { + LDKDataLossProtect *ret = MALLOC(sizeof(LDKDataLossProtect), "LDKDataLossProtect"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKUnsignedNodeAnnouncement_1optional_1none (JNIEnv * env, jclass _a) { + LDKUnsignedNodeAnnouncement *ret = MALLOC(sizeof(LDKUnsignedNodeAnnouncement), "LDKUnsignedNodeAnnouncement"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKNodeFeatures_1optional_1none (JNIEnv * env, jclass _a) { + LDKNodeFeatures *ret = MALLOC(sizeof(LDKNodeFeatures), "LDKNodeFeatures"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelFeatures_1optional_1none (JNIEnv * env, jclass _a) { + LDKChannelFeatures *ret = MALLOC(sizeof(LDKChannelFeatures), "LDKChannelFeatures"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKUnsignedChannelUpdate_1optional_1none (JNIEnv * env, jclass _a) { + LDKUnsignedChannelUpdate *ret = MALLOC(sizeof(LDKUnsignedChannelUpdate), "LDKUnsignedChannelUpdate"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKQueryChannelRange_1optional_1none (JNIEnv * env, jclass _a) { + LDKQueryChannelRange *ret = MALLOC(sizeof(LDKQueryChannelRange), "LDKQueryChannelRange"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKReplyChannelRange_1optional_1none (JNIEnv * env, jclass _a) { + LDKReplyChannelRange *ret = MALLOC(sizeof(LDKReplyChannelRange), "LDKReplyChannelRange"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKQueryShortChannelIds_1optional_1none (JNIEnv * env, jclass _a) { + LDKQueryShortChannelIds *ret = MALLOC(sizeof(LDKQueryShortChannelIds), "LDKQueryShortChannelIds"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKReplyShortChannelIdsEnd_1optional_1none (JNIEnv * env, jclass _a) { + LDKReplyShortChannelIdsEnd *ret = MALLOC(sizeof(LDKReplyShortChannelIdsEnd), "LDKReplyShortChannelIdsEnd"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKGossipTimestampFilter_1optional_1none (JNIEnv * env, jclass _a) { + LDKGossipTimestampFilter *ret = MALLOC(sizeof(LDKGossipTimestampFilter), "LDKGossipTimestampFilter"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKLightningError_1optional_1none (JNIEnv * env, jclass _a) { + LDKLightningError *ret = MALLOC(sizeof(LDKLightningError), "LDKLightningError"); + ret->inner = NULL; + return (long)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; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) { + if (((LDKCResult_boolLightningErrorZ*)arg)->result_ok) { + return (long)((LDKCResult_boolLightningErrorZ*)arg)->contents.result; + } else { + return (long)((LDKCResult_boolLightningErrorZ*)arg)->contents.err; + } +} typedef struct LDKRoutingMessageHandler_JCalls { atomic_size_t refcnt; - JNIEnv *env; + JavaVM *vm; jobject o; jmethodID handle_node_announcement_meth; jmethodID handle_channel_announcement_meth; @@ -1106,51 +2156,69 @@ typedef struct LDKRoutingMessageHandler_JCalls { } LDKRoutingMessageHandler_JCalls; LDKCResult_boolLightningErrorZ handle_node_announcement_jcall(const void* this_arg, const LDKNodeAnnouncement *msg) { LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg; - LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*j_calls->env)->CallLongMethod(j_calls->env, j_calls->o, j_calls->handle_node_announcement_meth, msg); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->handle_node_announcement_meth, msg); LDKCResult_boolLightningErrorZ res = *ret; FREE(ret); return res; } LDKCResult_boolLightningErrorZ handle_channel_announcement_jcall(const void* this_arg, const LDKChannelAnnouncement *msg) { LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg; - LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*j_calls->env)->CallLongMethod(j_calls->env, j_calls->o, j_calls->handle_channel_announcement_meth, msg); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->handle_channel_announcement_meth, msg); LDKCResult_boolLightningErrorZ res = *ret; FREE(ret); return res; } LDKCResult_boolLightningErrorZ handle_channel_update_jcall(const void* this_arg, const LDKChannelUpdate *msg) { LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg; - LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*j_calls->env)->CallLongMethod(j_calls->env, j_calls->o, j_calls->handle_channel_update_meth, msg); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->handle_channel_update_meth, msg); LDKCResult_boolLightningErrorZ res = *ret; FREE(ret); return res; } void handle_htlc_fail_channel_update_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate *update) { LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg; - return (*j_calls->env)->CallVoidMethod(j_calls->env, j_calls->o, j_calls->handle_htlc_fail_channel_update_meth, update); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_htlc_fail_channel_update_meth, update); } LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) { LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg; - LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* ret = (LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)(*j_calls->env)->CallLongMethod(j_calls->env, j_calls->o, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* ret = (LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount); LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ res = *ret; FREE(ret); return res; } LDKCVec_NodeAnnouncementZ get_next_node_announcements_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) { LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg; - LDKCVec_NodeAnnouncementZ* ret = (LDKCVec_NodeAnnouncementZ*)(*j_calls->env)->CallLongMethod(j_calls->env, j_calls->o, j_calls->get_next_node_announcements_meth, starting_point, batch_amount); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + long starting_point_ref = (long)&starting_point; + LDKCVec_NodeAnnouncementZ* ret = (LDKCVec_NodeAnnouncementZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->get_next_node_announcements_meth, starting_point_ref, batch_amount); LDKCVec_NodeAnnouncementZ res = *ret; FREE(ret); return res; } bool should_request_full_sync_jcall(const void* this_arg, LDKPublicKey node_id) { LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg; - return (*j_calls->env)->CallBooleanMethod(j_calls->env, j_calls->o, j_calls->should_request_full_sync_meth, node_id); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + long node_id_ref = (long)&node_id; + return (*env)->CallBooleanMethod(env, j_calls->o, j_calls->should_request_full_sync_meth, node_id_ref); } static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) { LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg; if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { - (*j_calls->env)->DeleteGlobalRef(j_calls->env, j_calls->o); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + (*env)->DeleteGlobalRef(env, j_calls->o); FREE(j_calls); } } @@ -1161,25 +2229,25 @@ static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) { } static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv * env, jclass _a, jobject o) { jclass c = (*env)->GetObjectClass(env, o); - assert(c != NULL); + DO_ASSERT(c != NULL); LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls"); atomic_init(&calls->refcnt, 1); - calls->env = env; + DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); calls->o = (*env)->NewGlobalRef(env, o); calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J"); - assert(calls->handle_node_announcement_meth != NULL); + DO_ASSERT(calls->handle_node_announcement_meth != NULL); calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J"); - assert(calls->handle_channel_announcement_meth != NULL); + DO_ASSERT(calls->handle_channel_announcement_meth != NULL); calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J"); - assert(calls->handle_channel_update_meth != NULL); + DO_ASSERT(calls->handle_channel_update_meth != NULL); calls->handle_htlc_fail_channel_update_meth = (*env)->GetMethodID(env, c, "handle_htlc_fail_channel_update", "(J)V"); - assert(calls->handle_htlc_fail_channel_update_meth != NULL); + DO_ASSERT(calls->handle_htlc_fail_channel_update_meth != NULL); calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)J"); - assert(calls->get_next_channel_announcements_meth != NULL); + DO_ASSERT(calls->get_next_channel_announcements_meth != NULL); calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "(JB)J"); - assert(calls->get_next_node_announcements_meth != NULL); + DO_ASSERT(calls->get_next_node_announcements_meth != NULL); calls->should_request_full_sync_meth = (*env)->GetMethodID(env, c, "should_request_full_sync", "(J)Z"); - assert(calls->should_request_full_sync_meth != NULL); + DO_ASSERT(calls->should_request_full_sync_meth != NULL); LDKRoutingMessageHandler ret = { .this_arg = (void*) calls, @@ -1199,9 +2267,70 @@ JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new *res_ptr = LDKRoutingMessageHandler_init(env, _a, o); return (long)res_ptr; } +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) { + return ((LDKRoutingMessageHandler_JCalls*)val)->o; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1call_1handle_1node_1announcement(JNIEnv * _env, jclass _b, jlong arg, jlong msg) { + LDKRoutingMessageHandler* arg_conv = (LDKRoutingMessageHandler*)arg; + LDKNodeAnnouncement* msg_conv = (LDKNodeAnnouncement*)msg; + LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ"); + *ret = (arg_conv->handle_node_announcement)(arg_conv->this_arg, msg_conv); + return (long)ret; +} + +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1call_1handle_1channel_1announcement(JNIEnv * _env, jclass _b, jlong arg, jlong msg) { + LDKRoutingMessageHandler* arg_conv = (LDKRoutingMessageHandler*)arg; + LDKChannelAnnouncement* msg_conv = (LDKChannelAnnouncement*)msg; + LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ"); + *ret = (arg_conv->handle_channel_announcement)(arg_conv->this_arg, msg_conv); + return (long)ret; +} + +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1call_1handle_1channel_1update(JNIEnv * _env, jclass _b, jlong arg, jlong msg) { + LDKRoutingMessageHandler* arg_conv = (LDKRoutingMessageHandler*)arg; + LDKChannelUpdate* msg_conv = (LDKChannelUpdate*)msg; + LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ"); + *ret = (arg_conv->handle_channel_update)(arg_conv->this_arg, msg_conv); + return (long)ret; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1call_1handle_1htlc_1fail_1channel_1update(JNIEnv * _env, jclass _b, jlong arg, jlong update) { + LDKRoutingMessageHandler* arg_conv = (LDKRoutingMessageHandler*)arg; + LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update; + return (arg_conv->handle_htlc_fail_channel_update)(arg_conv->this_arg, update_conv); +} + +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1call_1get_1next_1channel_1announcements(JNIEnv * _env, jclass _b, jlong arg, jlong starting_point, jbyte batch_amount) { + LDKRoutingMessageHandler* arg_conv = (LDKRoutingMessageHandler*)arg; + LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ"); + *ret = (arg_conv->get_next_channel_announcements)(arg_conv->this_arg, starting_point, batch_amount); + return (long)ret; +} + +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1call_1get_1next_1node_1announcements(JNIEnv * _env, jclass _b, jlong arg, jlong starting_point, jbyte batch_amount) { + LDKRoutingMessageHandler* arg_conv = (LDKRoutingMessageHandler*)arg; + LDKPublicKey starting_point_conv = *(LDKPublicKey*)starting_point; + FREE((void*)starting_point); + LDKCVec_NodeAnnouncementZ* ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ"); + *ret = (arg_conv->get_next_node_announcements)(arg_conv->this_arg, starting_point_conv, batch_amount); + return (long)ret; +} + +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1call_1should_1request_1full_1sync(JNIEnv * _env, jclass _b, jlong arg, jlong node_id) { + LDKRoutingMessageHandler* arg_conv = (LDKRoutingMessageHandler*)arg; + LDKPublicKey node_id_conv = *(LDKPublicKey*)node_id; + FREE((void*)node_id); + return (arg_conv->should_request_full_sync)(arg_conv->this_arg, node_id_conv); +} + +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKMessageHandler_1optional_1none (JNIEnv * env, jclass _a) { + LDKMessageHandler *ret = MALLOC(sizeof(LDKMessageHandler), "LDKMessageHandler"); + ret->inner = NULL; + return (long)ret; +} typedef struct LDKSocketDescriptor_JCalls { atomic_size_t refcnt; - JNIEnv *env; + JavaVM *vm; jobject o; jmethodID send_data_meth; jmethodID disconnect_socket_meth; @@ -1210,24 +2339,35 @@ typedef struct LDKSocketDescriptor_JCalls { } LDKSocketDescriptor_JCalls; uintptr_t send_data_jcall(void* this_arg, LDKu8slice data, bool resume_read) { LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg; - return (*j_calls->env)->CallLongMethod(j_calls->env, j_calls->o, j_calls->send_data_meth, data, resume_read); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + long data_ref = (long)&data; + return (*env)->CallLongMethod(env, j_calls->o, j_calls->send_data_meth, data_ref, resume_read); } void disconnect_socket_jcall(void* this_arg) { LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg; - return (*j_calls->env)->CallVoidMethod(j_calls->env, j_calls->o, j_calls->disconnect_socket_meth); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + return (*env)->CallVoidMethod(env, j_calls->o, j_calls->disconnect_socket_meth); } bool eq_jcall(const void* this_arg, const void *other_arg) { LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg; - return (*j_calls->env)->CallBooleanMethod(j_calls->env, j_calls->o, j_calls->eq_meth, other_arg); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + return (*env)->CallBooleanMethod(env, j_calls->o, j_calls->eq_meth, other_arg); } uint64_t hash_jcall(const void* this_arg) { LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg; - return (*j_calls->env)->CallLongMethod(j_calls->env, j_calls->o, j_calls->hash_meth); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + return (*env)->CallLongMethod(env, j_calls->o, j_calls->hash_meth); } static void LDKSocketDescriptor_JCalls_free(void* this_arg) { LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg; if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { - (*j_calls->env)->DeleteGlobalRef(j_calls->env, j_calls->o); + JNIEnv *env; + DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK); + (*env)->DeleteGlobalRef(env, j_calls->o); FREE(j_calls); } } @@ -1238,19 +2378,19 @@ static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) { } static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv * env, jclass _a, jobject o) { jclass c = (*env)->GetObjectClass(env, o); - assert(c != NULL); + DO_ASSERT(c != NULL); LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls"); atomic_init(&calls->refcnt, 1); - calls->env = env; + DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); calls->o = (*env)->NewGlobalRef(env, o); calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "(JZ)J"); - assert(calls->send_data_meth != NULL); + DO_ASSERT(calls->send_data_meth != NULL); calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V"); - assert(calls->disconnect_socket_meth != NULL); - calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(V)Z"); - assert(calls->eq_meth != NULL); + DO_ASSERT(calls->disconnect_socket_meth != NULL); + calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z"); + DO_ASSERT(calls->eq_meth != NULL); calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J"); - assert(calls->hash_meth != NULL); + DO_ASSERT(calls->hash_meth != NULL); LDKSocketDescriptor ret = { .this_arg = (void*) calls, @@ -1268,6 +2408,145 @@ JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new (JNIE *res_ptr = LDKSocketDescriptor_init(env, _a, o); return (long)res_ptr; } +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) { + return ((LDKSocketDescriptor_JCalls*)val)->o; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1call_1send_1data(JNIEnv * _env, jclass _b, jlong arg, jlong data, jboolean resume_read) { + LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg; + LDKu8slice data_conv = *(LDKu8slice*)data; + return (arg_conv->send_data)(arg_conv->this_arg, data_conv, resume_read); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1call_1disconnect_1socket(JNIEnv * _env, jclass _b, jlong arg) { + LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg; + return (arg_conv->disconnect_socket)(arg_conv->this_arg); +} + +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1call_1hash(JNIEnv * _env, jclass _b, jlong arg) { + LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg; + return (arg_conv->hash)(arg_conv->this_arg); +} + +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKPeerManager_1optional_1none (JNIEnv * env, jclass _a) { + LDKPeerManager *ret = MALLOC(sizeof(LDKPeerManager), "LDKPeerManager"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { + return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) { + if (((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok) { + return (long)((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->contents.result; + } else { + return (long)((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->contents.err; + } +} +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { + return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) { + if (((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok) { + return (long)((LDKCResult_boolPeerHandleErrorZ*)arg)->contents.result; + } else { + return (long)((LDKCResult_boolPeerHandleErrorZ*)arg)->contents.err; + } +} +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { + return ((LDKCResult_SecretKeySecpErrorZ*)arg)->result_ok; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) { + if (((LDKCResult_SecretKeySecpErrorZ*)arg)->result_ok) { + return (long)((LDKCResult_SecretKeySecpErrorZ*)arg)->contents.result; + } else { + return (long)((LDKCResult_SecretKeySecpErrorZ*)arg)->contents.err; + } +} +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeySecpErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { + return ((LDKCResult_PublicKeySecpErrorZ*)arg)->result_ok; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeySecpErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) { + if (((LDKCResult_PublicKeySecpErrorZ*)arg)->result_ok) { + return (long)((LDKCResult_PublicKeySecpErrorZ*)arg)->contents.result; + } else { + return (long)((LDKCResult_PublicKeySecpErrorZ*)arg)->contents.err; + } +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKTxCreationKeys_1optional_1none (JNIEnv * env, jclass _a) { + LDKTxCreationKeys *ret = MALLOC(sizeof(LDKTxCreationKeys), "LDKTxCreationKeys"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysSecpErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { + return ((LDKCResult_TxCreationKeysSecpErrorZ*)arg)->result_ok; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysSecpErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) { + if (((LDKCResult_TxCreationKeysSecpErrorZ*)arg)->result_ok) { + return (long)((LDKCResult_TxCreationKeysSecpErrorZ*)arg)->contents.result; + } else { + return (long)((LDKCResult_TxCreationKeysSecpErrorZ*)arg)->contents.err; + } +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKRouteHop_1optional_1none (JNIEnv * env, jclass _a) { + LDKRouteHop *ret = MALLOC(sizeof(LDKRouteHop), "LDKRouteHop"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKRouteHint_1optional_1none (JNIEnv * env, jclass _a) { + LDKRouteHint *ret = MALLOC(sizeof(LDKRouteHint), "LDKRouteHint"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKRoutingFees_1optional_1none (JNIEnv * env, jclass _a) { + LDKRoutingFees *ret = MALLOC(sizeof(LDKRoutingFees), "LDKRoutingFees"); + ret->inner = NULL; + return (long)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; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) { + if (((LDKCResult_RouteLightningErrorZ*)arg)->result_ok) { + return (long)((LDKCResult_RouteLightningErrorZ*)arg)->contents.result; + } else { + return (long)((LDKCResult_RouteLightningErrorZ*)arg)->contents.err; + } +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKNetworkGraph_1optional_1none (JNIEnv * env, jclass _a) { + LDKNetworkGraph *ret = MALLOC(sizeof(LDKNetworkGraph), "LDKNetworkGraph"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKLockedNetworkGraph_1optional_1none (JNIEnv * env, jclass _a) { + LDKLockedNetworkGraph *ret = MALLOC(sizeof(LDKLockedNetworkGraph), "LDKLockedNetworkGraph"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKNetGraphMsgHandler_1optional_1none (JNIEnv * env, jclass _a) { + LDKNetGraphMsgHandler *ret = MALLOC(sizeof(LDKNetGraphMsgHandler), "LDKNetGraphMsgHandler"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKDirectionalChannelInfo_1optional_1none (JNIEnv * env, jclass _a) { + LDKDirectionalChannelInfo *ret = MALLOC(sizeof(LDKDirectionalChannelInfo), "LDKDirectionalChannelInfo"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelInfo_1optional_1none (JNIEnv * env, jclass _a) { + LDKChannelInfo *ret = MALLOC(sizeof(LDKChannelInfo), "LDKChannelInfo"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKNodeAnnouncementInfo_1optional_1none (JNIEnv * env, jclass _a) { + LDKNodeAnnouncementInfo *ret = MALLOC(sizeof(LDKNodeAnnouncementInfo), "LDKNodeAnnouncementInfo"); + ret->inner = NULL; + return (long)ret; +} +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKNodeInfo_1optional_1none (JNIEnv * env, jclass _a) { + LDKNodeInfo *ret = MALLOC(sizeof(LDKNodeInfo), "LDKNodeInfo"); + ret->inner = NULL; + return (long)ret; +} JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1HTLCOutputInCommitmentSignatureZ_1free(JNIEnv * _env, jclass _b, jlong arg) { LDKC2Tuple_HTLCOutputInCommitmentSignatureZ arg_conv = *(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ*)arg; FREE((void*)arg); @@ -1962,7 +3241,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1o JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1new(JNIEnv * _env, jclass _b, jint minimum_depth_arg, jshort our_to_self_delay_arg, jlong our_htlc_minimum_msat_arg) { LDKChannelHandshakeConfig* ret = MALLOC(sizeof(LDKChannelHandshakeConfig), "LDKChannelHandshakeConfig"); *ret = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -1970,7 +3249,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1new(J JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv * _env, jclass _b) { LDKChannelHandshakeConfig* ret = MALLOC(sizeof(LDKChannelHandshakeConfig), "LDKChannelHandshakeConfig"); *ret = ChannelHandshakeConfig_default(); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -2085,7 +3364,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1t JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1new(JNIEnv * _env, jclass _b, jlong min_funding_satoshis_arg, jlong max_htlc_minimum_msat_arg, jlong min_max_htlc_value_in_flight_msat_arg, jlong max_channel_reserve_satoshis_arg, jshort min_max_accepted_htlcs_arg, jlong min_dust_limit_satoshis_arg, jlong max_dust_limit_satoshis_arg, jint max_minimum_depth_arg, jboolean force_announced_channel_preference_arg, jshort their_to_self_delay_arg) { LDKChannelHandshakeLimits* ret = MALLOC(sizeof(LDKChannelHandshakeLimits), "LDKChannelHandshakeLimits"); *ret = ChannelHandshakeLimits_new(min_funding_satoshis_arg, max_htlc_minimum_msat_arg, min_max_htlc_value_in_flight_msat_arg, max_channel_reserve_satoshis_arg, min_max_accepted_htlcs_arg, min_dust_limit_satoshis_arg, max_dust_limit_satoshis_arg, max_minimum_depth_arg, force_announced_channel_preference_arg, their_to_self_delay_arg); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -2093,7 +3372,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1new(J JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv * _env, jclass _b) { LDKChannelHandshakeLimits* ret = MALLOC(sizeof(LDKChannelHandshakeLimits), "LDKChannelHandshakeLimits"); *ret = ChannelHandshakeLimits_default(); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -2138,7 +3417,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1up JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1new(JNIEnv * _env, jclass _b, jint fee_proportional_millionths_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg) { LDKChannelConfig* ret = MALLOC(sizeof(LDKChannelConfig), "LDKChannelConfig"); *ret = ChannelConfig_new(fee_proportional_millionths_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -2146,7 +3425,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1new(JNIEnv * _ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv * _env, jclass _b) { LDKChannelConfig* ret = MALLOC(sizeof(LDKChannelConfig), "LDKChannelConfig"); *ret = ChannelConfig_default(); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -2160,10 +3439,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv * JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKChannelConfig* ret = MALLOC(sizeof(LDKChannelConfig), "LDKChannelConfig"); *ret = ChannelConfig_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -2179,7 +3457,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel LDKUserConfig* this_ptr_conv = (LDKUserConfig*)this_ptr; LDKChannelHandshakeConfig* ret = MALLOC(sizeof(LDKChannelHandshakeConfig), "LDKChannelHandshakeConfig"); *ret = UserConfig_get_own_channel_config(this_ptr_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -2196,7 +3474,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channe LDKUserConfig* this_ptr_conv = (LDKUserConfig*)this_ptr; LDKChannelHandshakeLimits* ret = MALLOC(sizeof(LDKChannelHandshakeLimits), "LDKChannelHandshakeLimits"); *ret = UserConfig_get_peer_channel_config_limits(this_ptr_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -2213,7 +3491,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1opt LDKUserConfig* this_ptr_conv = (LDKUserConfig*)this_ptr; LDKChannelConfig* ret = MALLOC(sizeof(LDKChannelConfig), "LDKChannelConfig"); *ret = UserConfig_get_channel_options(this_ptr_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -2238,7 +3516,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1new(JNIEnv * _env channel_options_arg_conv.is_owned = true; LDKUserConfig* ret = MALLOC(sizeof(LDKUserConfig), "LDKUserConfig"); *ret = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -2246,7 +3524,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1new(JNIEnv * _env JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv * _env, jclass _b) { LDKUserConfig* ret = MALLOC(sizeof(LDKUserConfig), "LDKUserConfig"); *ret = UserConfig_default(); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -2325,7 +3603,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1new(JNIEnv * _e } LDKChainMonitor* ret = MALLOC(sizeof(LDKChainMonitor), "LDKChainMonitor"); *ret = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -2370,10 +3648,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(J JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKChannelMonitorUpdate* ret = MALLOC(sizeof(LDKChannelMonitorUpdate), "LDKChannelMonitorUpdate"); *ret = ChannelMonitorUpdate_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -2408,10 +3685,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv * _e JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKHTLCUpdate* ret = MALLOC(sizeof(LDKHTLCUpdate), "LDKHTLCUpdate"); *ret = HTLCUpdate_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -2555,7 +3831,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv * _env, FREE((void*)txid_arg); LDKOutPoint* ret = MALLOC(sizeof(LDKOutPoint), "LDKOutPoint"); *ret = OutPoint_new(txid_arg_conv, index_arg); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -2576,10 +3852,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv * _env JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKOutPoint* ret = MALLOC(sizeof(LDKOutPoint), "LDKOutPoint"); *ret = OutPoint_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -2710,7 +3985,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1new(JNIE FREE((void*)key_derivation_params); LDKInMemoryChannelKeys* ret = MALLOC(sizeof(LDKInMemoryChannelKeys), "LDKInMemoryChannelKeys"); *ret = InMemoryChannelKeys_new(funding_key_conv, revocation_base_key_conv, payment_key_conv, delayed_payment_base_key_conv, htlc_base_key_conv, commitment_seed_conv, channel_value_satoshis, key_derivation_params_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -2719,7 +3994,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1counterp LDKInMemoryChannelKeys* this_arg_conv = (LDKInMemoryChannelKeys*)this_arg; LDKChannelPublicKeys* ret = MALLOC(sizeof(LDKChannelPublicKeys), "LDKChannelPublicKeys"); *ret = InMemoryChannelKeys_counterparty_pubkeys(this_arg_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -2750,10 +4025,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1write(JN JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKInMemoryChannelKeys* ret = MALLOC(sizeof(LDKInMemoryChannelKeys), "LDKInMemoryChannelKeys"); *ret = InMemoryChannelKeys_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -2772,7 +4046,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_KeysManager_1new(JNIEnv * _en LDKNetwork network_conv = LDKNetwork_from_java(_env, network); LDKKeysManager* ret = MALLOC(sizeof(LDKKeysManager), "LDKKeysManager"); *ret = KeysManager_new(seed_ref, network_conv, starting_time_secs, starting_time_nanos); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -2781,7 +4055,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_KeysManager_1derive_1channel_ LDKKeysManager* this_arg_conv = (LDKKeysManager*)this_arg; LDKInMemoryChannelKeys* ret = MALLOC(sizeof(LDKInMemoryChannelKeys), "LDKInMemoryChannelKeys"); *ret = KeysManager_derive_channel_keys(this_arg_conv, channel_value_satoshis, params_1, params_2); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -2839,7 +4113,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterp LDKChannelDetails* this_ptr_conv = (LDKChannelDetails*)this_ptr; LDKInitFeatures* ret = MALLOC(sizeof(LDKInitFeatures), "LDKInitFeatures"); *ret = ChannelDetails_get_counterparty_features(this_ptr_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -2941,7 +4215,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1new(JNIEnv * config_conv.is_owned = true; LDKChannelManager* ret = MALLOC(sizeof(LDKChannelManager), "LDKChannelManager"); *ret = ChannelManager_new(network_conv, fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, current_blockchain_height); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -3201,7 +4475,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1 LDKChannelManagerReadArgs* this_ptr_conv = (LDKChannelManagerReadArgs*)this_ptr; LDKUserConfig* ret = MALLOC(sizeof(LDKUserConfig), "LDKUserConfig"); *ret = ChannelManagerReadArgs_get_default_config(this_ptr_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -3247,7 +4521,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1new(J FREE((void*)channel_monitors); LDKChannelManagerReadArgs* ret = MALLOC(sizeof(LDKChannelManagerReadArgs), "LDKChannelManagerReadArgs"); *ret = ChannelManagerReadArgs_new(keys_manager_conv, fee_estimator_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, default_config_conv, channel_monitors_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -3308,7 +4582,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv * _e FREE((void*)data_arg); LDKErrorMessage* ret = MALLOC(sizeof(LDKErrorMessage), "LDKErrorMessage"); *ret = ErrorMessage_new(channel_id_arg_conv, data_arg_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -3343,7 +4617,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv * _ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv * _env, jclass _b, jshort ponglen_arg, jshort byteslen_arg) { LDKPing* ret = MALLOC(sizeof(LDKPing), "LDKPing"); *ret = Ping_new(ponglen_arg, byteslen_arg); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -3368,7 +4642,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv * _ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv * _env, jclass _b, jshort byteslen_arg) { LDKPong* ret = MALLOC(sizeof(LDKPong), "LDKPong"); *ret = Pong_new(byteslen_arg); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -3835,7 +5109,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingCreated_1new(JNIEnv * FREE((void*)signature_arg); LDKFundingCreated* ret = MALLOC(sizeof(LDKFundingCreated), "LDKFundingCreated"); *ret = FundingCreated_new(temporary_channel_id_arg_conv, funding_txid_arg_conv, funding_output_index_arg, signature_arg_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -3882,7 +5156,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv * _ FREE((void*)signature_arg); LDKFundingSigned* ret = MALLOC(sizeof(LDKFundingSigned), "LDKFundingSigned"); *ret = FundingSigned_new(channel_id_arg_conv, signature_arg_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -3929,7 +5203,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingLocked_1new(JNIEnv * _ FREE((void*)next_per_commitment_point_arg); LDKFundingLocked* ret = MALLOC(sizeof(LDKFundingLocked), "LDKFundingLocked"); *ret = FundingLocked_new(channel_id_arg_conv, next_per_commitment_point_arg_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -3976,7 +5250,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv * _env, FREE((void*)scriptpubkey_arg); LDKShutdown* ret = MALLOC(sizeof(LDKShutdown), "LDKShutdown"); *ret = Shutdown_new(channel_id_arg_conv, scriptpubkey_arg_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -4033,7 +5307,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1new(JNIEnv * _ FREE((void*)signature_arg); LDKClosingSigned* ret = MALLOC(sizeof(LDKClosingSigned), "LDKClosingSigned"); *ret = ClosingSigned_new(channel_id_arg_conv, fee_satoshis_arg, signature_arg_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -4155,7 +5429,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1new(JNIEnv FREE((void*)payment_preimage_arg); LDKUpdateFulfillHTLC* ret = MALLOC(sizeof(LDKUpdateFulfillHTLC), "LDKUpdateFulfillHTLC"); *ret = UpdateFulfillHTLC_new(channel_id_arg_conv, htlc_id_arg, payment_preimage_arg_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -4283,7 +5557,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1new(JNIEnv FREE((void*)htlc_signatures_arg); LDKCommitmentSigned* ret = MALLOC(sizeof(LDKCommitmentSigned), "LDKCommitmentSigned"); *ret = CommitmentSigned_new(channel_id_arg_conv, signature_arg_conv, htlc_signatures_arg_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -4346,7 +5620,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1new(JNIEnv * _e FREE((void*)next_per_commitment_point_arg); LDKRevokeAndACK* ret = MALLOC(sizeof(LDKRevokeAndACK), "LDKRevokeAndACK"); *ret = RevokeAndACK_new(channel_id_arg_conv, per_commitment_secret_arg_conv, next_per_commitment_point_arg_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -4387,7 +5661,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFee_1new(JNIEnv * _env, FREE((void*)channel_id_arg); LDKUpdateFee* ret = MALLOC(sizeof(LDKUpdateFee), "LDKUpdateFee"); *ret = UpdateFee_new(channel_id_arg_conv, feerate_per_kw_arg); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -4434,7 +5708,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1new(JNIEnv * FREE((void*)my_current_per_commitment_point_arg); LDKDataLossProtect* ret = MALLOC(sizeof(LDKDataLossProtect), "LDKDataLossProtect"); *ret = DataLossProtect_new(your_last_per_commitment_secret_arg_conv, my_current_per_commitment_point_arg_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -4548,7 +5822,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1new(J FREE((void*)bitcoin_signature_arg); LDKAnnouncementSignatures* ret = MALLOC(sizeof(LDKAnnouncementSignatures), "LDKAnnouncementSignatures"); *ret = AnnouncementSignatures_new(channel_id_arg_conv, short_channel_id_arg, node_signature_arg_conv, bitcoin_signature_arg_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -4570,7 +5844,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get LDKUnsignedNodeAnnouncement* this_ptr_conv = (LDKUnsignedNodeAnnouncement*)this_ptr; LDKNodeFeatures* ret = MALLOC(sizeof(LDKNodeFeatures), "LDKNodeFeatures"); *ret = UnsignedNodeAnnouncement_get_features(this_ptr_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -4667,7 +5941,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1conten LDKNodeAnnouncement* this_ptr_conv = (LDKNodeAnnouncement*)this_ptr; LDKUnsignedNodeAnnouncement* ret = MALLOC(sizeof(LDKUnsignedNodeAnnouncement), "LDKUnsignedNodeAnnouncement"); *ret = NodeAnnouncement_get_contents(this_ptr_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -4688,7 +5962,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv contents_arg_conv.is_owned = true; LDKNodeAnnouncement* ret = MALLOC(sizeof(LDKNodeAnnouncement), "LDKNodeAnnouncement"); *ret = NodeAnnouncement_new(signature_arg_conv, contents_arg_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -4704,7 +5978,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1 LDKUnsignedChannelAnnouncement* this_ptr_conv = (LDKUnsignedChannelAnnouncement*)this_ptr; LDKChannelFeatures* ret = MALLOC(sizeof(LDKChannelFeatures), "LDKChannelFeatures"); *ret = UnsignedChannelAnnouncement_get_features(this_ptr_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -4864,7 +6138,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1con LDKChannelAnnouncement* this_ptr_conv = (LDKChannelAnnouncement*)this_ptr; LDKUnsignedChannelAnnouncement* ret = MALLOC(sizeof(LDKUnsignedChannelAnnouncement), "LDKUnsignedChannelAnnouncement"); *ret = ChannelAnnouncement_get_contents(this_ptr_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -4891,7 +6165,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1new(JNIE contents_arg_conv.is_owned = true; LDKChannelAnnouncement* ret = MALLOC(sizeof(LDKChannelAnnouncement), "LDKChannelAnnouncement"); *ret = ChannelAnnouncement_new(node_signature_1_arg_conv, node_signature_2_arg_conv, bitcoin_signature_1_arg_conv, bitcoin_signature_2_arg_conv, contents_arg_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5012,7 +6286,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents( LDKChannelUpdate* this_ptr_conv = (LDKChannelUpdate*)this_ptr; LDKUnsignedChannelUpdate* ret = MALLOC(sizeof(LDKUnsignedChannelUpdate), "LDKUnsignedChannelUpdate"); *ret = ChannelUpdate_get_contents(this_ptr_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5033,7 +6307,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv * _ contents_arg_conv.is_owned = true; LDKChannelUpdate* ret = MALLOC(sizeof(LDKChannelUpdate), "LDKChannelUpdate"); *ret = ChannelUpdate_new(signature_arg_conv, contents_arg_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5084,7 +6358,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1new(JNIEnv FREE((void*)chain_hash_arg); LDKQueryChannelRange* ret = MALLOC(sizeof(LDKQueryChannelRange), "LDKQueryChannelRange"); *ret = QueryChannelRange_new(chain_hash_arg_conv, first_blocknum_arg, number_of_blocks_arg); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5154,7 +6428,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1new(JNIEnv FREE((void*)short_channel_ids_arg); LDKReplyChannelRange* ret = MALLOC(sizeof(LDKReplyChannelRange), "LDKReplyChannelRange"); *ret = ReplyChannelRange_new(chain_hash_arg_conv, first_blocknum_arg, number_of_blocks_arg, full_information_arg, short_channel_ids_arg_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5194,7 +6468,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1new(JNI FREE((void*)short_channel_ids_arg); LDKQueryShortChannelIds* ret = MALLOC(sizeof(LDKQueryShortChannelIds), "LDKQueryShortChannelIds"); *ret = QueryShortChannelIds_new(chain_hash_arg_conv, short_channel_ids_arg_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5235,7 +6509,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new( FREE((void*)chain_hash_arg); LDKReplyShortChannelIdsEnd* ret = MALLOC(sizeof(LDKReplyShortChannelIdsEnd), "LDKReplyShortChannelIdsEnd"); *ret = ReplyShortChannelIdsEnd_new(chain_hash_arg_conv, full_information_arg); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5286,7 +6560,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1new(JN FREE((void*)chain_hash_arg); LDKGossipTimestampFilter* ret = MALLOC(sizeof(LDKGossipTimestampFilter), "LDKGossipTimestampFilter"); *ret = GossipTimestampFilter_new(chain_hash_arg_conv, first_timestamp_arg, timestamp_range_arg); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5339,7 +6613,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv * FREE((void*)action_arg); LDKLightningError* ret = MALLOC(sizeof(LDKLightningError), "LDKLightningError"); *ret = LightningError_new(err_arg_conv, action_arg_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5383,7 +6657,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update LDKCommitmentUpdate* this_ptr_conv = (LDKCommitmentUpdate*)this_ptr; LDKUpdateFee* ret = MALLOC(sizeof(LDKUpdateFee), "LDKUpdateFee"); *ret = CommitmentUpdate_get_update_fee(this_ptr_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5400,7 +6674,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commit LDKCommitmentUpdate* this_ptr_conv = (LDKCommitmentUpdate*)this_ptr; LDKCommitmentSigned* ret = MALLOC(sizeof(LDKCommitmentSigned), "LDKCommitmentSigned"); *ret = CommitmentUpdate_get_commitment_signed(this_ptr_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5430,7 +6704,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1new(JNIEnv commitment_signed_arg_conv.is_owned = true; LDKCommitmentUpdate* ret = MALLOC(sizeof(LDKCommitmentUpdate), "LDKCommitmentUpdate"); *ret = CommitmentUpdate_new(update_add_htlcs_arg_conv, update_fulfill_htlcs_arg_conv, update_fail_htlcs_arg_conv, update_fail_malformed_htlcs_arg_conv, update_fee_arg_conv, commitment_signed_arg_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5462,10 +6736,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv * JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKAcceptChannel* ret = MALLOC(sizeof(LDKAcceptChannel), "LDKAcceptChannel"); *ret = AcceptChannel_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5479,10 +6752,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKAnnouncementSignatures* ret = MALLOC(sizeof(LDKAnnouncementSignatures), "LDKAnnouncementSignatures"); *ret = AnnouncementSignatures_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5496,10 +6768,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNI JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKChannelReestablish* ret = MALLOC(sizeof(LDKChannelReestablish), "LDKChannelReestablish"); *ret = ChannelReestablish_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5513,10 +6784,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv * JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKClosingSigned* ret = MALLOC(sizeof(LDKClosingSigned), "LDKClosingSigned"); *ret = ClosingSigned_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5530,10 +6800,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEn JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKCommitmentSigned* ret = MALLOC(sizeof(LDKCommitmentSigned), "LDKCommitmentSigned"); *ret = CommitmentSigned_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5547,10 +6816,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKFundingCreated* ret = MALLOC(sizeof(LDKFundingCreated), "LDKFundingCreated"); *ret = FundingCreated_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5564,10 +6832,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv * JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKFundingSigned* ret = MALLOC(sizeof(LDKFundingSigned), "LDKFundingSigned"); *ret = FundingSigned_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5581,10 +6848,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv * JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKFundingLocked* ret = MALLOC(sizeof(LDKFundingLocked), "LDKFundingLocked"); *ret = FundingLocked_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5598,10 +6864,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv * _env, jc JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKInit* ret = MALLOC(sizeof(LDKInit), "LDKInit"); *ret = Init_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5615,10 +6880,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv * _ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKOpenChannel* ret = MALLOC(sizeof(LDKOpenChannel), "LDKOpenChannel"); *ret = OpenChannel_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5632,10 +6896,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv * JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKRevokeAndACK* ret = MALLOC(sizeof(LDKRevokeAndACK), "LDKRevokeAndACK"); *ret = RevokeAndACK_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5649,10 +6912,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv * _env JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKShutdown* ret = MALLOC(sizeof(LDKShutdown), "LDKShutdown"); *ret = Shutdown_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5666,10 +6928,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKUpdateFailHTLC* ret = MALLOC(sizeof(LDKUpdateFailHTLC), "LDKUpdateFailHTLC"); *ret = UpdateFailHTLC_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5683,10 +6944,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1writ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKUpdateFailMalformedHTLC* ret = MALLOC(sizeof(LDKUpdateFailMalformedHTLC), "LDKUpdateFailMalformedHTLC"); *ret = UpdateFailMalformedHTLC_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5700,10 +6960,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv * _en JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKUpdateFee* ret = MALLOC(sizeof(LDKUpdateFee), "LDKUpdateFee"); *ret = UpdateFee_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5717,10 +6976,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIE JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKUpdateFulfillHTLC* ret = MALLOC(sizeof(LDKUpdateFulfillHTLC), "LDKUpdateFulfillHTLC"); *ret = UpdateFulfillHTLC_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5734,10 +6992,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv * JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKUpdateAddHTLC* ret = MALLOC(sizeof(LDKUpdateAddHTLC), "LDKUpdateAddHTLC"); *ret = UpdateAddHTLC_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5751,10 +7008,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv * _env, jc JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKPing* ret = MALLOC(sizeof(LDKPing), "LDKPing"); *ret = Ping_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5768,10 +7024,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv * _env, jc JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKPong* ret = MALLOC(sizeof(LDKPong), "LDKPong"); *ret = Pong_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5785,10 +7040,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKUnsignedChannelAnnouncement* ret = MALLOC(sizeof(LDKUnsignedChannelAnnouncement), "LDKUnsignedChannelAnnouncement"); *ret = UnsignedChannelAnnouncement_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5802,10 +7056,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JN JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKChannelAnnouncement* ret = MALLOC(sizeof(LDKChannelAnnouncement), "LDKChannelAnnouncement"); *ret = ChannelAnnouncement_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5819,10 +7072,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write( JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKUnsignedChannelUpdate* ret = MALLOC(sizeof(LDKUnsignedChannelUpdate), "LDKUnsignedChannelUpdate"); *ret = UnsignedChannelUpdate_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5836,10 +7088,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv * JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKChannelUpdate* ret = MALLOC(sizeof(LDKChannelUpdate), "LDKChannelUpdate"); *ret = ChannelUpdate_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5853,10 +7104,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv * JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKErrorMessage* ret = MALLOC(sizeof(LDKErrorMessage), "LDKErrorMessage"); *ret = ErrorMessage_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5870,10 +7120,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1wri JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKUnsignedNodeAnnouncement* ret = MALLOC(sizeof(LDKUnsignedNodeAnnouncement), "LDKUnsignedNodeAnnouncement"); *ret = UnsignedNodeAnnouncement_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5887,20 +7136,18 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEn JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKNodeAnnouncement* ret = MALLOC(sizeof(LDKNodeAnnouncement), "LDKNodeAnnouncement"); *ret = NodeAnnouncement_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKQueryShortChannelIds* ret = MALLOC(sizeof(LDKQueryShortChannelIds), "LDKQueryShortChannelIds"); *ret = QueryShortChannelIds_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5914,10 +7161,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(J JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKReplyShortChannelIdsEnd* ret = MALLOC(sizeof(LDKReplyShortChannelIdsEnd), "LDKReplyShortChannelIdsEnd"); *ret = ReplyShortChannelIdsEnd_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5931,10 +7177,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1writ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKQueryChannelRange* ret = MALLOC(sizeof(LDKQueryChannelRange), "LDKQueryChannelRange"); *ret = QueryChannelRange_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5948,10 +7193,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIE JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKReplyChannelRange* ret = MALLOC(sizeof(LDKReplyChannelRange), "LDKReplyChannelRange"); *ret = ReplyChannelRange_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -5965,10 +7209,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIE JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKGossipTimestampFilter* ret = MALLOC(sizeof(LDKGossipTimestampFilter), "LDKGossipTimestampFilter"); *ret = GossipTimestampFilter_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -6032,7 +7275,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageHandler_1new(JNIEnv * } LDKMessageHandler* ret = MALLOC(sizeof(LDKMessageHandler), "LDKMessageHandler"); *ret = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -6063,7 +7306,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1conn JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv * _env, jclass _b, jboolean no_connection_possible_arg) { LDKPeerHandleError* ret = MALLOC(sizeof(LDKPeerHandleError), "LDKPeerHandleError"); *ret = PeerHandleError_new(no_connection_possible_arg); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -6091,7 +7334,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1new(JNIEnv * _en } LDKPeerManager* ret = MALLOC(sizeof(LDKPeerManager), "LDKPeerManager"); *ret = PeerManager_new(message_handler_conv, our_node_secret_conv, ephemeral_random_data_ref, logger_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -6141,7 +7384,6 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1read_1event(JNIE LDKPeerManager* this_arg_conv = (LDKPeerManager*)this_arg; LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor; LDKu8slice data_conv = *(LDKu8slice*)data; - FREE((void*)data); LDKCResult_boolPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ"); *ret = PeerManager_read_event(this_arg_conv, peer_descriptor_conv, data_conv); return (long)ret; @@ -6305,7 +7547,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1new(JNIEnv * FREE((void*)broadcaster_delayed_payment_key_arg); LDKTxCreationKeys* ret = MALLOC(sizeof(LDKTxCreationKeys), "LDKTxCreationKeys"); *ret = TxCreationKeys_new(per_commitment_point_arg_conv, revocation_key_arg_conv, broadcaster_htlc_key_arg_conv, countersignatory_htlc_key_arg_conv, broadcaster_delayed_payment_key_arg_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -6319,10 +7561,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKTxCreationKeys* ret = MALLOC(sizeof(LDKTxCreationKeys), "LDKTxCreationKeys"); *ret = TxCreationKeys_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -6340,7 +7581,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PreCalculatedTxCreationKeys_1 keys_conv.is_owned = true; LDKPreCalculatedTxCreationKeys* ret = MALLOC(sizeof(LDKPreCalculatedTxCreationKeys), "LDKPreCalculatedTxCreationKeys"); *ret = PreCalculatedTxCreationKeys_new(keys_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -6349,7 +7590,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PreCalculatedTxCreationKeys_1 LDKPreCalculatedTxCreationKeys* this_arg_conv = (LDKPreCalculatedTxCreationKeys*)this_arg; LDKTxCreationKeys* ret = MALLOC(sizeof(LDKTxCreationKeys), "LDKTxCreationKeys"); *ret = PreCalculatedTxCreationKeys_trust_key_derivation(this_arg_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -6451,7 +7692,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1new(JNIEnv FREE((void*)htlc_basepoint_arg); LDKChannelPublicKeys* ret = MALLOC(sizeof(LDKChannelPublicKeys), "LDKChannelPublicKeys"); *ret = ChannelPublicKeys_new(funding_pubkey_arg_conv, revocation_basepoint_arg_conv, payment_point_arg_conv, delayed_payment_basepoint_arg_conv, htlc_basepoint_arg_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -6465,10 +7706,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIE JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKChannelPublicKeys* ret = MALLOC(sizeof(LDKChannelPublicKeys), "LDKChannelPublicKeys"); *ret = ChannelPublicKeys_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -6559,10 +7799,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKHTLCOutputInCommitment* ret = MALLOC(sizeof(LDKHTLCOutputInCommitment), "LDKHTLCOutputInCommitment"); *ret = HTLCOutputInCommitment_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -6667,7 +7906,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1 FREE((void*)htlc_data); LDKHolderCommitmentTransaction* ret = MALLOC(sizeof(LDKHolderCommitmentTransaction), "LDKHolderCommitmentTransaction"); *ret = HolderCommitmentTransaction_new_missing_holder_sig(unsigned_tx_conv, counterparty_sig_conv, holder_funding_key_conv, counterparty_funding_key_conv, keys_conv, feerate_per_kw, htlc_data_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -6676,7 +7915,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1 LDKHolderCommitmentTransaction* this_arg_conv = (LDKHolderCommitmentTransaction*)this_arg; LDKTxCreationKeys* ret = MALLOC(sizeof(LDKTxCreationKeys), "LDKTxCreationKeys"); *ret = HolderCommitmentTransaction_trust_key_derivation(this_arg_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -6694,7 +7933,6 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1 (*_env)->GetByteArrayRegion (_env, funding_key, 0, 32, funding_key_arr); unsigned char (*funding_key_ref)[32] = &funding_key_arr; LDKu8slice funding_redeemscript_conv = *(LDKu8slice*)funding_redeemscript; - FREE((void*)funding_redeemscript); LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature"); *ret = HolderCommitmentTransaction_get_holder_sig(this_arg_conv, funding_key_ref, funding_redeemscript_conv, channel_value_satoshis); return (long)ret; @@ -6719,10 +7957,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKHolderCommitmentTransaction* ret = MALLOC(sizeof(LDKHolderCommitmentTransaction), "LDKHolderCommitmentTransaction"); *ret = HolderCommitmentTransaction_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -6773,7 +8010,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features LDKRouteHop* this_ptr_conv = (LDKRouteHop*)this_ptr; LDKNodeFeatures* ret = MALLOC(sizeof(LDKNodeFeatures), "LDKNodeFeatures"); *ret = RouteHop_get_node_features(this_ptr_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -6800,7 +8037,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1featu LDKRouteHop* this_ptr_conv = (LDKRouteHop*)this_ptr; LDKChannelFeatures* ret = MALLOC(sizeof(LDKChannelFeatures), "LDKChannelFeatures"); *ret = RouteHop_get_channel_features(this_ptr_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -6844,7 +8081,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1new(JNIEnv * _env, channel_features_arg_conv.is_owned = true; LDKRouteHop* ret = MALLOC(sizeof(LDKRouteHop), "LDKRouteHop"); *ret = RouteHop_new(pubkey_arg_conv, node_features_arg_conv, short_channel_id_arg, channel_features_arg_conv, fee_msat_arg, cltv_expiry_delta_arg); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -6868,7 +8105,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv * _env, jcl FREE((void*)paths_arg); LDKRoute* ret = MALLOC(sizeof(LDKRoute), "LDKRoute"); *ret = Route_new(paths_arg_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -6882,10 +8119,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv * _env, j JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKRoute* ret = MALLOC(sizeof(LDKRoute), "LDKRoute"); *ret = Route_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -6925,7 +8161,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1fees(JNIEnv * LDKRouteHint* this_ptr_conv = (LDKRouteHint*)this_ptr; LDKRoutingFees* ret = MALLOC(sizeof(LDKRoutingFees), "LDKRoutingFees"); *ret = RouteHint_get_fees(this_ptr_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -6966,7 +8202,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv * _env, fees_arg_conv.is_owned = true; LDKRouteHint* ret = MALLOC(sizeof(LDKRouteHint), "LDKRouteHint"); *ret = RouteHint_new(src_node_id_arg_conv, short_channel_id_arg, fees_arg_conv, cltv_expiry_delta_arg, htlc_minimum_msat_arg); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -7020,7 +8256,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1new(JNIEn } LDKNetGraphMsgHandler* ret = MALLOC(sizeof(LDKNetGraphMsgHandler), "LDKNetGraphMsgHandler"); *ret = NetGraphMsgHandler_new(chain_access_conv, logger_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -7037,7 +8273,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1from_1net network_graph_conv.is_owned = true; LDKNetGraphMsgHandler* ret = MALLOC(sizeof(LDKNetGraphMsgHandler), "LDKNetGraphMsgHandler"); *ret = NetGraphMsgHandler_from_net_graph(chain_access_conv, logger_conv, network_graph_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -7046,7 +8282,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1read_1loc LDKNetGraphMsgHandler* this_arg_conv = (LDKNetGraphMsgHandler*)this_arg; LDKLockedNetworkGraph* ret = MALLOC(sizeof(LDKLockedNetworkGraph), "LDKLockedNetworkGraph"); *ret = NetGraphMsgHandler_read_locked_graph(this_arg_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -7055,7 +8291,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1graph(JNI LDKLockedNetworkGraph* this_arg_conv = (LDKLockedNetworkGraph*)this_arg; LDKNetworkGraph* ret = MALLOC(sizeof(LDKNetworkGraph), "LDKNetworkGraph"); *ret = LockedNetworkGraph_graph(this_arg_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -7118,7 +8354,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1 LDKDirectionalChannelInfo* this_ptr_conv = (LDKDirectionalChannelInfo*)this_ptr; LDKChannelUpdate* ret = MALLOC(sizeof(LDKChannelUpdate), "LDKChannelUpdate"); *ret = DirectionalChannelInfo_get_last_update_message(this_ptr_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -7140,10 +8376,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKDirectionalChannelInfo* ret = MALLOC(sizeof(LDKDirectionalChannelInfo), "LDKDirectionalChannelInfo"); *ret = DirectionalChannelInfo_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -7159,7 +8394,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JN LDKChannelInfo* this_ptr_conv = (LDKChannelInfo*)this_ptr; LDKChannelFeatures* ret = MALLOC(sizeof(LDKChannelFeatures), "LDKChannelFeatures"); *ret = ChannelInfo_get_features(this_ptr_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -7190,7 +8425,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1tw LDKChannelInfo* this_ptr_conv = (LDKChannelInfo*)this_ptr; LDKDirectionalChannelInfo* ret = MALLOC(sizeof(LDKDirectionalChannelInfo), "LDKDirectionalChannelInfo"); *ret = ChannelInfo_get_one_to_two(this_ptr_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -7221,7 +8456,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1on LDKChannelInfo* this_ptr_conv = (LDKChannelInfo*)this_ptr; LDKDirectionalChannelInfo* ret = MALLOC(sizeof(LDKDirectionalChannelInfo), "LDKDirectionalChannelInfo"); *ret = ChannelInfo_get_two_to_one(this_ptr_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -7238,7 +8473,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcemen LDKChannelInfo* this_ptr_conv = (LDKChannelInfo*)this_ptr; LDKChannelAnnouncement* ret = MALLOC(sizeof(LDKChannelAnnouncement), "LDKChannelAnnouncement"); *ret = ChannelInfo_get_announcement_message(this_ptr_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -7260,10 +8495,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv * _ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKChannelInfo* ret = MALLOC(sizeof(LDKChannelInfo), "LDKChannelInfo"); *ret = ChannelInfo_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -7298,17 +8532,16 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingFees_1new(JNIEnv * _env, jclass _b, jint base_msat_arg, jint proportional_millionths_arg) { LDKRoutingFees* ret = MALLOC(sizeof(LDKRoutingFees), "LDKRoutingFees"); *ret = RoutingFees_new(base_msat_arg, proportional_millionths_arg); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKRoutingFees* ret = MALLOC(sizeof(LDKRoutingFees), "LDKRoutingFees"); *ret = RoutingFees_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -7331,7 +8564,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1fe LDKNodeAnnouncementInfo* this_ptr_conv = (LDKNodeAnnouncementInfo*)this_ptr; LDKNodeFeatures* ret = MALLOC(sizeof(LDKNodeFeatures), "LDKNodeFeatures"); *ret = NodeAnnouncementInfo_get_features(this_ptr_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -7393,7 +8626,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1an LDKNodeAnnouncementInfo* this_ptr_conv = (LDKNodeAnnouncementInfo*)this_ptr; LDKNodeAnnouncement* ret = MALLOC(sizeof(LDKNodeAnnouncement), "LDKNodeAnnouncement"); *ret = NodeAnnouncementInfo_get_announcement_message(this_ptr_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -7421,7 +8654,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1new(JNI announcement_message_arg_conv.is_owned = true; LDKNodeAnnouncementInfo* ret = MALLOC(sizeof(LDKNodeAnnouncementInfo), "LDKNodeAnnouncementInfo"); *ret = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_conv, alias_arg_conv, addresses_arg_conv, announcement_message_arg_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -7435,10 +8668,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(J JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKNodeAnnouncementInfo* ret = MALLOC(sizeof(LDKNodeAnnouncementInfo), "LDKNodeAnnouncementInfo"); *ret = NodeAnnouncementInfo_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -7461,7 +8693,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inboun LDKNodeInfo* this_ptr_conv = (LDKNodeInfo*)this_ptr; LDKRoutingFees* ret = MALLOC(sizeof(LDKRoutingFees), "LDKRoutingFees"); *ret = NodeInfo_get_lowest_inbound_channel_fees(this_ptr_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -7478,7 +8710,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1 LDKNodeInfo* this_ptr_conv = (LDKNodeInfo*)this_ptr; LDKNodeAnnouncementInfo* ret = MALLOC(sizeof(LDKNodeAnnouncementInfo), "LDKNodeAnnouncementInfo"); *ret = NodeInfo_get_announcement_info(this_ptr_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -7502,7 +8734,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1new(JNIEnv * _env, announcement_info_arg_conv.is_owned = true; LDKNodeInfo* ret = MALLOC(sizeof(LDKNodeInfo), "LDKNodeInfo"); *ret = NodeInfo_new(channels_arg_conv, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -7516,10 +8748,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv * _env JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKNodeInfo* ret = MALLOC(sizeof(LDKNodeInfo), "LDKNodeInfo"); *ret = NodeInfo_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -7533,10 +8764,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv * JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv * _env, jclass _b, jlong ser) { LDKu8slice ser_conv = *(LDKu8slice*)ser; - FREE((void*)ser); LDKNetworkGraph* ret = MALLOC(sizeof(LDKNetworkGraph), "LDKNetworkGraph"); *ret = NetworkGraph_read(ser_conv); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; } @@ -7544,7 +8774,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv * _ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv * _env, jclass _b) { LDKNetworkGraph* ret = MALLOC(sizeof(LDKNetworkGraph), "LDKNetworkGraph"); *ret = NetworkGraph_new(); - assert(ret->is_owned); + DO_ASSERT(ret->is_owned); ret->is_owned = false; return (long)ret; }