package org.ldk.impl;
import org.ldk.enums.*;
+import java.io.File;
+import java.io.InputStream;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
public class bindings {
public static class VecOrSliceDef {
}
}
static {
- System.loadLibrary("lightningjni");
+ try {
+ // Try to load natively first, this works on Android and in testing.
+ System.loadLibrary("lightningjni");
+ } catch (UnsatisfiedLinkError _ignored) {
+ // Otherwise try to load from the library jar.
+ File tmpdir = new File(System.getProperty("java.io.tmpdir"), "ldk-java-nativelib");
+ tmpdir.mkdir(); // If it fails to create, assume it was there already
+ tmpdir.deleteOnExit();
+ String libname = "liblightningjni_" + System.getProperty("os.name").replaceAll(" ", "") +
+ "-" + System.getProperty("os.arch").replaceAll(" ", "") + ".nativelib";
+ try (InputStream is = bindings.class.getResourceAsStream("/" + libname)) {
+ Path libpath = new File(tmpdir.toPath().toString(), "liblightningjni.so").toPath();
+ Files.copy(is, libpath, StandardCopyOption.REPLACE_EXISTING);
+ Runtime.getRuntime().load(libpath.toString());
+ } catch (IOException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
init(java.lang.Enum.class, VecOrSliceDef.class);
init_class_cache();
if (!get_lib_version_string().equals(get_ldk_java_bindings_version()))
static native String get_lib_version_string();
public static String get_ldk_java_bindings_version() {
- return "v0.0.98.1";
+ return "v0.0.98.2";
}
public static native String get_ldk_c_bindings_version();
public static native String get_ldk_version();
#define LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ LDKCVec_TransactionOutputsZ
#define CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free CVec_TransactionOutputsZ_free
+#include <jni.h>
+// On OSX jlong (ie long long) is not equivalent to int64_t, so we override here
+#define int64_t jlong
#include "org_ldk_impl_bindings.h"
#include <lightning.h>
#include <string.h>
}
JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1lib_1version_1string(JNIEnv *env, jclass _c) {
- return str_ref_to_java(env, "v0.0.98.1", strlen("v0.0.98.1"));
+ return str_ref_to_java(env, "v0.0.98.2", strlen("v0.0.98.2"));
}
JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) {
return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version()));
+#include <jni.h>
+// On OSX jlong (ie long long) is not equivalent to int64_t, so we override here
+#define int64_t jlong
#include "org_ldk_impl_bindings.h"
#include <lightning.h>
#include <string.h>
}
JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1lib_1version_1string(JNIEnv *env, jclass _c) {
- return str_ref_to_java(env, "v0.0.98.1", strlen("v0.0.98.1"));
+ return str_ref_to_java(env, "v0.0.98.2", strlen("v0.0.98.2"));
}
JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) {
return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version()));