mirror of
https://github.com/wownero/wownerujo.git
synced 2026-11-15 04:34:08 +01:00
CrAzYpass implementation (#234)
This commit is contained in:
@@ -695,6 +695,23 @@ Java_com_m2049r_xmrwallet_model_Wallet_isSynchronized(JNIEnv *env, jobject insta
|
||||
return static_cast<jboolean>(wallet->synchronized());
|
||||
}
|
||||
|
||||
//void cn_slow_hash(const void *data, size_t length, char *hash); // from crypto/hash-ops.h
|
||||
JNIEXPORT jbyteArray JNICALL
|
||||
Java_com_m2049r_xmrwallet_util_KeyStoreHelper_cnSlowHash(JNIEnv *env, jobject clazz,
|
||||
jbyteArray data) {
|
||||
|
||||
jbyte *buffer = env->GetByteArrayElements(data, NULL);
|
||||
jsize size = env->GetArrayLength(data);
|
||||
char hash[HASH_SIZE];
|
||||
cn_slow_hash(buffer, (size_t) size, hash);
|
||||
|
||||
env->ReleaseByteArrayElements(data, buffer, JNI_ABORT); // do not update java byte[]
|
||||
|
||||
jbyteArray result = env->NewByteArray(HASH_SIZE);
|
||||
env->SetByteArrayRegion(result, 0, HASH_SIZE, (jbyte *) hash);
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_m2049r_xmrwallet_model_Wallet_getDisplayAmount(JNIEnv *env, jobject clazz,
|
||||
jlong amount) {
|
||||
@@ -1083,7 +1100,8 @@ Java_com_m2049r_xmrwallet_model_PendingTransaction_getTxCount(JNIEnv *env, jobje
|
||||
//static void error(const std::string &category, const std::string &str);
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_m2049r_xmrwallet_model_WalletManager_initLogger(JNIEnv *env, jobject instance,
|
||||
jstring argv0, jstring default_log_base_name) {
|
||||
jstring argv0,
|
||||
jstring default_log_base_name) {
|
||||
|
||||
const char *_argv0 = env->GetStringUTFChars(argv0, NULL);
|
||||
const char *_default_log_base_name = env->GetStringUTFChars(default_log_base_name, NULL);
|
||||
@@ -1109,7 +1127,7 @@ Java_com_m2049r_xmrwallet_model_WalletManager_logDebug(JNIEnv *env, jobject inst
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_m2049r_xmrwallet_model_WalletManager_logInfo(JNIEnv *env, jobject instance,
|
||||
jstring category, jstring message) {
|
||||
jstring category, jstring message) {
|
||||
|
||||
const char *_category = env->GetStringUTFChars(category, NULL);
|
||||
const char *_message = env->GetStringUTFChars(message, NULL);
|
||||
@@ -1122,7 +1140,7 @@ Java_com_m2049r_xmrwallet_model_WalletManager_logInfo(JNIEnv *env, jobject insta
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_m2049r_xmrwallet_model_WalletManager_logWarning(JNIEnv *env, jobject instance,
|
||||
jstring category, jstring message) {
|
||||
jstring category, jstring message) {
|
||||
|
||||
const char *_category = env->GetStringUTFChars(category, NULL);
|
||||
const char *_message = env->GetStringUTFChars(message, NULL);
|
||||
@@ -1149,11 +1167,10 @@ Java_com_m2049r_xmrwallet_model_WalletManager_logError(JNIEnv *env, jobject inst
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_m2049r_xmrwallet_model_WalletManager_setLogLevel(JNIEnv *env, jobject instance,
|
||||
jint level) {
|
||||
Bitmonero::WalletManagerFactory::setLogLevel(level);
|
||||
Bitmonero::WalletManagerFactory::setLogLevel(level);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#define XMRWALLET_WALLET_LIB_H
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
/*
|
||||
#include <android/log.h>
|
||||
|
||||
@@ -27,13 +28,13 @@
|
||||
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
|
||||
*/
|
||||
|
||||
jfieldID getHandleField(JNIEnv *env, jobject obj, const char* fieldName = "handle") {
|
||||
jfieldID getHandleField(JNIEnv *env, jobject obj, const char *fieldName = "handle") {
|
||||
jclass c = env->GetObjectClass(obj);
|
||||
return env->GetFieldID(c, fieldName, "J"); // of type long
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T *getHandle(JNIEnv *env, jobject obj, const char* fieldName = "handle") {
|
||||
template<typename T>
|
||||
T *getHandle(JNIEnv *env, jobject obj, const char *fieldName = "handle") {
|
||||
jlong handle = env->GetLongField(obj, getHandleField(env, obj, fieldName));
|
||||
return reinterpret_cast<T *>(handle);
|
||||
}
|
||||
@@ -42,10 +43,27 @@ void setHandleFromLong(JNIEnv *env, jobject obj, jlong handle) {
|
||||
env->SetLongField(obj, getHandleField(env, obj), handle);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
template<typename T>
|
||||
void setHandle(JNIEnv *env, jobject obj, T *t) {
|
||||
jlong handle = reinterpret_cast<jlong>(t);
|
||||
setHandleFromLong(env, obj, handle);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
// from monero-core crypto/hash-ops.h - avoid #including monero code here
|
||||
enum {
|
||||
HASH_SIZE = 32,
|
||||
HASH_DATA_AREA = 136
|
||||
};
|
||||
|
||||
void cn_slow_hash(const void *data, size_t length, char *hash);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //XMRWALLET_WALLET_LIB_H
|
||||
|
||||
Reference in New Issue
Block a user