Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions JNI/cpp/RippleSigner.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright © 2017-2019 Trust.
//
// This file is part of Trust. The full Trust copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.
//
// This is a GENERATED FILE, changes made here WILL BE LOST.
//

#include <jni.h>
#include <stdio.h>
#include <string.h>

#include <TrustWalletCore/TWRippleSigner.h>

#include "TWJNI.h"
#include "RippleSigner.h"

jobject JNICALL Java_wallet_core_jni_RippleSigner_sign(JNIEnv *env, jclass thisClass, jobject input) {
jclass inputClass = (*env)->GetObjectClass(env, input);
jmethodID inputToByteArrayMethodID = (*env)->GetMethodID(env, inputClass, "toByteArray", "()[B");
jbyteArray inputByteArray = (*env)->CallObjectMethod(env, input, inputToByteArrayMethodID);
TWData *inputData = TWDataCreateWithJByteArray(env, inputByteArray);
jbyteArray resultData = TWDataJByteArray(TWRippleSignerSign(inputData), env);
jclass resultClass = (*env)->FindClass(env, "wallet/core/jni/proto/Proto$SigningOutput");
jmethodID parseFromMethodID = (*env)->GetStaticMethodID(env, resultClass, "parseFrom", "([B)Lwallet/core/jni/proto/Proto$SigningOutput;");
jobject result = (*env)->CallStaticObjectMethod(env, resultClass, parseFromMethodID, resultData);

(*env)->DeleteLocalRef(env, resultClass);
(*env)->DeleteLocalRef(env, inputByteArray);
(*env)->DeleteLocalRef(env, inputClass);

return result;
}

24 changes: 24 additions & 0 deletions JNI/cpp/RippleSigner.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright © 2017-2019 Trust.
//
// This file is part of Trust. The full Trust copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.
//
// This is a GENERATED FILE, changes made here WILL BE LOST.
//

#ifndef JNI_TW_RIPPLESIGNER_H
#define JNI_TW_RIPPLESIGNER_H

#include <jni.h>
#include <TrustWalletCore/TWBase.h>

TW_EXTERN_C_BEGIN

JNIEXPORT
jobject JNICALL Java_wallet_core_jni_RippleSigner_sign(JNIEnv *env, jclass thisClass, jobject input);


TW_EXTERN_C_END

#endif // JNI_TW_RIPPLESIGNER_H
Loading