#!/usr/bin/env python3
import sys, re
-if len(sys.argv) != 5:
- print("USAGE: /path/to/lightning.h /path/to/bindings/output.java /path/to/bindings/output.c debug")
+if len(sys.argv) != 6:
+ print("USAGE: /path/to/lightning.h /path/to/bindings/output.java /path/to/bindings/enums/ /path/to/bindings/output.c debug")
print("debug should be true or false and indicates whether to track allocations and ensure we don't leak")
sys.exit(1)
out_java.write(" arg")
out_c.write(" arg")
-with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java, open(sys.argv[3], "w") as out_c:
+with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java, open(sys.argv[4], "w") as out_c:
opaque_structs = set()
trait_structs = set()
unitary_enums = set()
if ma.group(1).strip() in unitary_enums:
java_ty = ma.group(1).strip()
c_ty = "jclass"
- fn_ty_arg = "Lorg/ldk/impl/bindings$" + ma.group(1).strip() + ";"
+ fn_ty_arg = "Lorg/ldk/enums/" + ma.group(1).strip() + ";"
fn_arg = ma.group(2).strip()
rust_obj = ma.group(1).strip()
take_by_ptr = True
}
""")
out_java.write("""package org.ldk.impl;
+import org.ldk.enums.*;
public class bindings {
public static class VecOrSliceDef {
field_lines.append(struct_line)
assert(struct_name is not None)
- assert(len(trait_fn_lines) == 0 or not (is_opaque or is_unitary_enum or is_union_enum or is_union))
- assert(not is_opaque or not (len(trait_fn_lines) != 0 or is_unitary_enum or is_union_enum or is_union))
- assert(not is_unitary_enum or not (len(trait_fn_lines) != 0 or is_opaque or is_union_enum or is_union))
- assert(not is_union_enum or not (len(trait_fn_lines) != 0 or is_unitary_enum or is_opaque or is_union))
- assert(not is_union or not (len(trait_fn_lines) != 0 or is_unitary_enum or is_union_enum or is_opaque))
+ assert(len(trait_fn_lines) == 0 or not (is_opaque or is_unitary_enum or is_union_enum or is_union or is_result or vec_ty is not None))
+ assert(not is_opaque or not (len(trait_fn_lines) != 0 or is_unitary_enum or is_union_enum or is_union or is_result or vec_ty is not None))
+ assert(not is_unitary_enum or not (len(trait_fn_lines) != 0 or is_opaque or is_union_enum or is_union or is_result or vec_ty is not None))
+ assert(not is_union_enum or not (len(trait_fn_lines) != 0 or is_unitary_enum or is_opaque or is_union or is_result or vec_ty is not None))
+ assert(not is_union or not (len(trait_fn_lines) != 0 or is_unitary_enum or is_union_enum or is_opaque or is_result or vec_ty is not None))
+ assert(not is_result or not (len(trait_fn_lines) != 0 or is_unitary_enum or is_union_enum or is_opaque or is_union or vec_ty is not None))
+ assert(vec_ty is None or not (len(trait_fn_lines) != 0 or is_unitary_enum or is_union_enum or is_opaque or is_union or is_result))
if is_opaque:
opaque_structs.add(struct_name)
out_java.write("\tpublic static native long " + struct_name + "_optional_none();\n")
out_c.write("\treturn (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(" + vec_ty + "));\n")
out_c.write("}\n")
elif is_unitary_enum:
- unitary_enums.add(struct_name)
- out_c.write("static inline " + struct_name + " " + struct_name + "_from_java(JNIEnv *env, jclass val) {\n")
- out_c.write("\tswitch ((*env)->CallIntMethod(env, val, ordinal_meth)) {\n")
- ord_v = 0
- for idx, struct_line in enumerate(field_lines):
- if idx == 0:
- out_java.write("\tpublic enum " + struct_name + " {\n")
- elif idx == len(field_lines) - 3:
- assert(struct_line.endswith("_Sentinel,"))
- elif idx == len(field_lines) - 2:
- out_java.write("\t}\n")
- elif idx == len(field_lines) - 1:
- assert(struct_line == "")
- else:
- out_java.write("\t" + struct_line + "\n")
- out_c.write("\t\tcase %d: return %s;\n" % (ord_v, struct_line.strip().strip(",")))
- ord_v = ord_v + 1
- out_c.write("\t}\n")
- out_c.write("\tabort();\n")
- out_c.write("}\n")
-
- ord_v = 0
- out_c.write("static inline jclass " + struct_name + "_to_java(JNIEnv *env, " + struct_name + " val) {\n")
- out_c.write("\t// TODO: This is pretty inefficient, we really need to cache the field IDs and class\n")
- out_c.write("\tjclass enum_class = (*env)->FindClass(env, \"Lorg/ldk/impl/bindings$" + struct_name + ";\");\n")
- out_c.write("\tDO_ASSERT(enum_class != NULL);\n")
- out_c.write("\tswitch (val) {\n")
- for idx, struct_line in enumerate(field_lines):
- if idx > 0 and idx < len(field_lines) - 3:
- variant = struct_line.strip().strip(",")
- out_c.write("\t\tcase " + variant + ": {\n")
- out_c.write("\t\t\tjfieldID field = (*env)->GetStaticFieldID(env, enum_class, \"" + variant + "\", \"Lorg/ldk/impl/bindings$" + struct_name + ";\");\n")
- out_c.write("\t\t\tDO_ASSERT(field != NULL);\n")
- out_c.write("\t\t\treturn (*env)->GetStaticObjectField(env, enum_class, field);\n")
- out_c.write("\t\t}\n")
- ord_v = ord_v + 1
- out_c.write("\t\tdefault: abort();\n")
- out_c.write("\t}\n")
- out_c.write("}\n\n")
+ with open(sys.argv[3] + "/" + struct_name + ".java", "w") as out_java_enum:
+ out_java_enum.write("package org.ldk.enums;\n\n")
+ unitary_enums.add(struct_name)
+ out_c.write("static inline " + struct_name + " " + struct_name + "_from_java(JNIEnv *env, jclass val) {\n")
+ out_c.write("\tswitch ((*env)->CallIntMethod(env, val, ordinal_meth)) {\n")
+ ord_v = 0
+ for idx, struct_line in enumerate(field_lines):
+ if idx == 0:
+ out_java_enum.write("public enum " + struct_name + " {\n")
+ elif idx == len(field_lines) - 3:
+ assert(struct_line.endswith("_Sentinel,"))
+ elif idx == len(field_lines) - 2:
+ out_java_enum.write("}")
+ elif idx == len(field_lines) - 1:
+ assert(struct_line == "")
+ else:
+ out_java_enum.write(struct_line + "\n")
+ out_c.write("\t\tcase %d: return %s;\n" % (ord_v, struct_line.strip().strip(",")))
+ ord_v = ord_v + 1
+ out_c.write("\t}\n")
+ out_c.write("\tabort();\n")
+ out_c.write("}\n")
+
+ ord_v = 0
+ out_c.write("static inline jclass " + struct_name + "_to_java(JNIEnv *env, " + struct_name + " val) {\n")
+ out_c.write("\t// TODO: This is pretty inefficient, we really need to cache the field IDs and class\n")
+ out_c.write("\tjclass enum_class = (*env)->FindClass(env, \"Lorg/ldk/enums/" + struct_name + ";\");\n")
+ out_c.write("\tDO_ASSERT(enum_class != NULL);\n")
+ out_c.write("\tswitch (val) {\n")
+ for idx, struct_line in enumerate(field_lines):
+ if idx > 0 and idx < len(field_lines) - 3:
+ variant = struct_line.strip().strip(",")
+ out_c.write("\t\tcase " + variant + ": {\n")
+ out_c.write("\t\t\tjfieldID field = (*env)->GetStaticFieldID(env, enum_class, \"" + variant + "\", \"Lorg/ldk/enums/" + struct_name + ";\");\n")
+ out_c.write("\t\t\tDO_ASSERT(field != NULL);\n")
+ out_c.write("\t\t\treturn (*env)->GetStaticObjectField(env, enum_class, field);\n")
+ out_c.write("\t\t}\n")
+ ord_v = ord_v + 1
+ out_c.write("\t\tdefault: abort();\n")
+ out_c.write("\t}\n")
+ out_c.write("}\n\n")
elif len(trait_fn_lines) > 0:
trait_structs.add(struct_name)
map_trait(struct_name, field_var_lines, trait_fn_lines)
[ "$3" != "true" -a "$3" != "false" ] && usage
set -e
-./genbindings.py "$1/lightning-c-bindings/include/lightning.h" src/main/java/org/ldk/impl/bindings.java src/main/jni/bindings.c $3
-javac -h src/main/jni src/main/java/org/ldk/impl/bindings.java
-rm src/main/java/org/ldk/impl/bindings*.class
+mkdir -p src/main/java/org/ldk/enums
+rm -f src/main/java/org/ldk/enums/*.java
+./genbindings.py "$1/lightning-c-bindings/include/lightning.h" src/main/java/org/ldk/impl/bindings.java src/main/java/org/ldk/enums src/main/jni/bindings.c $3
+javac -h src/main/jni src/main/java/org/ldk/enums/*.java src/main/java/org/ldk/impl/bindings.java
+rm src/main/java/org/ldk/enums/*.class src/main/java/org/ldk/impl/bindings*.class
COMPILE="clang -std=c11 -Wall -Wno-unused-function -Wl,--no-undefined -pthread -ldl -o liblightningjni.so -shared -fPIC -Wno-pointer-sign -Isrc/main/jni"
if [ "$3" = "true" ]; then
$COMPILE -g -fsanitize=address -shared-libasan -I"$1"/lightning-c-bindings/include/ $2 src/main/jni/bindings.c "$1"/lightning-c-bindings/target/debug/libldk.a
--- /dev/null
+package org.ldk.enums;
+
+public enum LDKAccessError {
+ LDKAccessError_UnknownChain,
+ LDKAccessError_UnknownTx,
+}
\ No newline at end of file
--- /dev/null
+package org.ldk.enums;
+
+public enum LDKChannelMonitorUpdateErr {
+ LDKChannelMonitorUpdateErr_TemporaryFailure,
+ LDKChannelMonitorUpdateErr_PermanentFailure,
+}
\ No newline at end of file
--- /dev/null
+package org.ldk.enums;
+
+public enum LDKConfirmationTarget {
+ LDKConfirmationTarget_Background,
+ LDKConfirmationTarget_Normal,
+ LDKConfirmationTarget_HighPriority,
+}
\ No newline at end of file
--- /dev/null
+package org.ldk.enums;
+
+public enum LDKLevel {
+ LDKLevel_Off,
+ LDKLevel_Error,
+ LDKLevel_Warn,
+ LDKLevel_Info,
+ LDKLevel_Debug,
+ LDKLevel_Trace,
+}
\ No newline at end of file
--- /dev/null
+package org.ldk.enums;
+
+public enum LDKNetwork {
+ LDKNetwork_Bitcoin,
+ LDKNetwork_Testnet,
+ LDKNetwork_Regtest,
+}
\ No newline at end of file
--- /dev/null
+package org.ldk.enums;
+
+public enum LDKSecp256k1Error {
+ LDKSecp256k1Error_IncorrectSignature,
+ LDKSecp256k1Error_InvalidMessage,
+ LDKSecp256k1Error_InvalidPublicKey,
+ LDKSecp256k1Error_InvalidSignature,
+ LDKSecp256k1Error_InvalidSecretKey,
+ LDKSecp256k1Error_InvalidRecoveryId,
+ LDKSecp256k1Error_InvalidTweak,
+ LDKSecp256k1Error_NotEnoughMemory,
+ LDKSecp256k1Error_CallbackPanicked,
+}
\ No newline at end of file
package org.ldk.impl;
+import org.ldk.enums.*;
public class bindings {
public static class VecOrSliceDef {
public static native long LDKSecretKey_new();
- public enum LDKAccessError {
- LDKAccessError_UnknownChain,
- LDKAccessError_UnknownTx,
- }
- public enum LDKChannelMonitorUpdateErr {
- LDKChannelMonitorUpdateErr_TemporaryFailure,
- LDKChannelMonitorUpdateErr_PermanentFailure,
- }
- public enum LDKConfirmationTarget {
- LDKConfirmationTarget_Background,
- LDKConfirmationTarget_Normal,
- LDKConfirmationTarget_HighPriority,
- }
- public enum LDKLevel {
- LDKLevel_Off,
- LDKLevel_Error,
- LDKLevel_Warn,
- LDKLevel_Info,
- LDKLevel_Debug,
- LDKLevel_Trace,
- }
- public enum LDKNetwork {
- LDKNetwork_Bitcoin,
- LDKNetwork_Testnet,
- LDKNetwork_Regtest,
- }
- public enum LDKSecp256k1Error {
- LDKSecp256k1Error_IncorrectSignature,
- LDKSecp256k1Error_InvalidMessage,
- LDKSecp256k1Error_InvalidPublicKey,
- LDKSecp256k1Error_InvalidSignature,
- LDKSecp256k1Error_InvalidSecretKey,
- LDKSecp256k1Error_InvalidRecoveryId,
- LDKSecp256k1Error_InvalidTweak,
- LDKSecp256k1Error_NotEnoughMemory,
- LDKSecp256k1Error_CallbackPanicked,
- }
public static native VecOrSliceDef LDKCVecTempl_u8_arr_info(long vec_ptr);
public static native boolean LDKCResult_NoneChannelMonitorUpdateErrZ_result_ok(long arg);
public static native long LDKCResult_NoneChannelMonitorUpdateErrZ_get_inner(long arg);
}
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;");
+ jclass enum_class = (*env)->FindClass(env, "Lorg/ldk/enums/LDKAccessError;");
DO_ASSERT(enum_class != NULL);
switch (val) {
case LDKAccessError_UnknownChain: {
- jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKAccessError_UnknownChain", "Lorg/ldk/impl/bindings$LDKAccessError;");
+ jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/LDKAccessError;");
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;");
+ jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/LDKAccessError;");
DO_ASSERT(field != NULL);
return (*env)->GetStaticObjectField(env, enum_class, field);
}
}
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;");
+ jclass enum_class = (*env)->FindClass(env, "Lorg/ldk/enums/LDKChannelMonitorUpdateErr;");
DO_ASSERT(enum_class != NULL);
switch (val) {
case LDKChannelMonitorUpdateErr_TemporaryFailure: {
- jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKChannelMonitorUpdateErr_TemporaryFailure", "Lorg/ldk/impl/bindings$LDKChannelMonitorUpdateErr;");
+ jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKChannelMonitorUpdateErr_TemporaryFailure", "Lorg/ldk/enums/LDKChannelMonitorUpdateErr;");
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;");
+ jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKChannelMonitorUpdateErr_PermanentFailure", "Lorg/ldk/enums/LDKChannelMonitorUpdateErr;");
DO_ASSERT(field != NULL);
return (*env)->GetStaticObjectField(env, enum_class, field);
}
}
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;");
+ jclass enum_class = (*env)->FindClass(env, "Lorg/ldk/enums/LDKConfirmationTarget;");
DO_ASSERT(enum_class != NULL);
switch (val) {
case LDKConfirmationTarget_Background: {
- jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKConfirmationTarget_Background", "Lorg/ldk/impl/bindings$LDKConfirmationTarget;");
+ jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/LDKConfirmationTarget;");
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;");
+ jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/LDKConfirmationTarget;");
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;");
+ jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/LDKConfirmationTarget;");
DO_ASSERT(field != NULL);
return (*env)->GetStaticObjectField(env, enum_class, field);
}
}
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;");
+ jclass enum_class = (*env)->FindClass(env, "Lorg/ldk/enums/LDKLevel;");
DO_ASSERT(enum_class != NULL);
switch (val) {
case LDKLevel_Off: {
- jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKLevel_Off", "Lorg/ldk/impl/bindings$LDKLevel;");
+ jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKLevel_Off", "Lorg/ldk/enums/LDKLevel;");
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;");
+ jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKLevel_Error", "Lorg/ldk/enums/LDKLevel;");
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;");
+ jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKLevel_Warn", "Lorg/ldk/enums/LDKLevel;");
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;");
+ jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKLevel_Info", "Lorg/ldk/enums/LDKLevel;");
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;");
+ jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKLevel_Debug", "Lorg/ldk/enums/LDKLevel;");
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;");
+ jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKLevel_Trace", "Lorg/ldk/enums/LDKLevel;");
DO_ASSERT(field != NULL);
return (*env)->GetStaticObjectField(env, enum_class, field);
}
}
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;");
+ jclass enum_class = (*env)->FindClass(env, "Lorg/ldk/enums/LDKNetwork;");
DO_ASSERT(enum_class != NULL);
switch (val) {
case LDKNetwork_Bitcoin: {
- jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKNetwork_Bitcoin", "Lorg/ldk/impl/bindings$LDKNetwork;");
+ jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/LDKNetwork;");
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;");
+ jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/LDKNetwork;");
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;");
+ jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/LDKNetwork;");
DO_ASSERT(field != NULL);
return (*env)->GetStaticObjectField(env, enum_class, field);
}
}
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;");
+ jclass enum_class = (*env)->FindClass(env, "Lorg/ldk/enums/LDKSecp256k1Error;");
DO_ASSERT(enum_class != NULL);
switch (val) {
case LDKSecp256k1Error_IncorrectSignature: {
- jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/impl/bindings$LDKSecp256k1Error;");
+ jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/LDKSecp256k1Error;");
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;");
+ jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/LDKSecp256k1Error;");
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;");
+ jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/LDKSecp256k1Error;");
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;");
+ jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/LDKSecp256k1Error;");
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;");
+ jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/LDKSecp256k1Error;");
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;");
+ jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/LDKSecp256k1Error;");
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;");
+ jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/LDKSecp256k1Error;");
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;");
+ jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/LDKSecp256k1Error;");
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;");
+ jfieldID field = (*env)->GetStaticFieldID(env, enum_class, "LDKSecp256k1Error_CallbackPanicked", "Lorg/ldk/enums/LDKSecp256k1Error;");
DO_ASSERT(field != NULL);
return (*env)->GetStaticObjectField(env, enum_class, field);
}
atomic_init(&calls->refcnt, 1);
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");
+ calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/LDKConfirmationTarget;)I");
DO_ASSERT(calls->get_est_sat_per_1000_weight_meth != NULL);
LDKFeeEstimator ret = {
/*
* Class: org_ldk_impl_bindings
* Method: LDKFeeEstimator_call_get_est_sat_per_1000_weight
- * Signature: (JLorg/ldk/impl/bindings/LDKConfirmationTarget;)I
+ * Signature: (JLorg/ldk/enums/LDKConfirmationTarget;)I
*/
JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1call_1get_1est_1sat_1per_11000_1weight
(JNIEnv *, jclass, jlong, jobject);
/*
* Class: org_ldk_impl_bindings
* Method: CResult_NoneChannelMonitorUpdateErrZ_err
- * Signature: (Lorg/ldk/impl/bindings/LDKChannelMonitorUpdateErr;)J
+ * Signature: (Lorg/ldk/enums/LDKChannelMonitorUpdateErr;)J
*/
JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err
(JNIEnv *, jclass, jobject);
/*
* Class: org_ldk_impl_bindings
* Method: CResult_PublicKeySecpErrorZ_err
- * Signature: (Lorg/ldk/impl/bindings/LDKSecp256k1Error;)J
+ * Signature: (Lorg/ldk/enums/LDKSecp256k1Error;)J
*/
JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeySecpErrorZ_1err
(JNIEnv *, jclass, jobject);
/*
* Class: org_ldk_impl_bindings
* Method: CResult_SecretKeySecpErrorZ_err
- * Signature: (Lorg/ldk/impl/bindings/LDKSecp256k1Error;)J
+ * Signature: (Lorg/ldk/enums/LDKSecp256k1Error;)J
*/
JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeySecpErrorZ_1err
(JNIEnv *, jclass, jobject);
/*
* Class: org_ldk_impl_bindings
* Method: CResult_TxCreationKeysSecpErrorZ_err
- * Signature: (Lorg/ldk/impl/bindings/LDKSecp256k1Error;)J
+ * Signature: (Lorg/ldk/enums/LDKSecp256k1Error;)J
*/
JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysSecpErrorZ_1err
(JNIEnv *, jclass, jobject);
/*
* Class: org_ldk_impl_bindings
* Method: CResult_TxOutAccessErrorZ_err
- * Signature: (Lorg/ldk/impl/bindings/LDKAccessError;)J
+ * Signature: (Lorg/ldk/enums/LDKAccessError;)J
*/
JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err
(JNIEnv *, jclass, jobject);
/*
* Class: org_ldk_impl_bindings
* Method: Level_max
- * Signature: ()Lorg/ldk/impl/bindings/LDKLevel;
+ * Signature: ()Lorg/ldk/enums/LDKLevel;
*/
JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_Level_1max
(JNIEnv *, jclass);
/*
* Class: org_ldk_impl_bindings
* Method: KeysManager_new
- * Signature: ([BLorg/ldk/impl/bindings/LDKNetwork;JI)J
+ * Signature: ([BLorg/ldk/enums/LDKNetwork;JI)J
*/
JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_KeysManager_1new
(JNIEnv *, jclass, jbyteArray, jobject, jlong, jint);
/*
* Class: org_ldk_impl_bindings
* Method: ChannelManager_new
- * Signature: (Lorg/ldk/impl/bindings/LDKNetwork;JJJJJJJ)J
+ * Signature: (Lorg/ldk/enums/LDKNetwork;JJJJJJJ)J
*/
JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1new
(JNIEnv *, jclass, jobject, jlong, jlong, jlong, jlong, jlong, jlong, jlong);
import org.junit.jupiter.api.Test;
import org.ldk.impl.bindings;
+import org.ldk.enums.*;
public class ManualMsgHandlingPeerTest {
@Test
long peer_manager = bindings.PeerManager_new(message_handler, our_node_secret, random_data, logger);
// Test Level_max() since its the only place we create a java object from a Rust-returned enum.
- assert bindings.Level_max() == bindings.LDKLevel.LDKLevel_Trace;
+ assert bindings.Level_max() == LDKLevel.LDKLevel_Trace;
// Note that we can't rely on finalizer order, so don't bother trying to rely on it here
bindings.Logger_free(logger);
import org.junit.jupiter.api.Test;
import org.ldk.impl.bindings;
+import org.ldk.enums.*;
import java.util.concurrent.ConcurrentLinkedQueue;
byte[] key_seed = new byte[32];
for (byte i = 0; i < 32; i++) { key_seed[i] = (byte) (i ^ seed); }
- this.keys = bindings.KeysManager_new(key_seed, bindings.LDKNetwork.LDKNetwork_Bitcoin, System.currentTimeMillis() / 1000, (int)(System.currentTimeMillis() * 1000) & 0xffffffff);
+ this.keys = bindings.KeysManager_new(key_seed, LDKNetwork.LDKNetwork_Bitcoin, System.currentTimeMillis() / 1000, (int)(System.currentTimeMillis() * 1000) & 0xffffffff);
this.keys_interface = bindings.KeysManager_as_KeysInterface(keys);
this.config = bindings.UserConfig_default();
- this.chan_manager = bindings.ChannelManager_new(bindings.LDKNetwork.LDKNetwork_Bitcoin, fee_estimator, chain_monitor, tx_broadcaster, logger, keys_interface, config, 1);
+ this.chan_manager = bindings.ChannelManager_new(LDKNetwork.LDKNetwork_Bitcoin, fee_estimator, chain_monitor, tx_broadcaster, logger, keys_interface, config, 1);
this.chan_manager_events = bindings.ChannelManager_as_EventsProvider(chan_manager);
this.chan_handler = bindings.ChannelManager_as_ChannelMessageHandler(chan_manager);