Merge pull request #677 from m2049r/fix_various

Various fixes & tweaks
This commit is contained in:
m2049r 2020-09-17 09:34:04 +02:00 committed by GitHub
commit ffdf54c2e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 83 additions and 82 deletions

View File

@ -22,7 +22,7 @@
android:usesCleartextTraffic="true"> android:usesCleartextTraffic="true">
<activity android:name=".MainActivity" <activity android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden" android:configChanges="orientation|keyboardHidden"
android:launchMode="singleTask" android:launchMode="singleTop"
android:screenOrientation="portrait"> android:screenOrientation="portrait">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />

View File

@ -221,7 +221,7 @@ std::vector<std::string> java2cpp(JNIEnv *env, jobject arrayList) {
for (jint i = 0; i < len; i++) { for (jint i = 0; i < len; i++) {
jstring element = static_cast<jstring>(env->CallObjectMethod(arrayList, jstring element = static_cast<jstring>(env->CallObjectMethod(arrayList,
java_util_ArrayList_get, i)); java_util_ArrayList_get, i));
const char *pchars = env->GetStringUTFChars(element, NULL); const char *pchars = env->GetStringUTFChars(element, nullptr);
result.emplace_back(pchars); result.emplace_back(pchars);
env->ReleaseStringUTFChars(element, pchars); env->ReleaseStringUTFChars(element, pchars);
env->DeleteLocalRef(element); env->DeleteLocalRef(element);
@ -229,14 +229,15 @@ std::vector<std::string> java2cpp(JNIEnv *env, jobject arrayList) {
return result; return result;
} }
jobject cpp2java(JNIEnv *env, std::vector<std::string> vector) { jobject cpp2java(JNIEnv *env, const std::vector<std::string>& vector) {
jmethodID java_util_ArrayList_ = env->GetMethodID(class_ArrayList, "<init>", "(I)V"); jmethodID java_util_ArrayList_ = env->GetMethodID(class_ArrayList, "<init>", "(I)V");
jmethodID java_util_ArrayList_add = env->GetMethodID(class_ArrayList, "add", jmethodID java_util_ArrayList_add = env->GetMethodID(class_ArrayList, "add",
"(Ljava/lang/Object;)Z"); "(Ljava/lang/Object;)Z");
jobject result = env->NewObject(class_ArrayList, java_util_ArrayList_, vector.size()); jobject result = env->NewObject(class_ArrayList, java_util_ArrayList_,
for (std::string &s: vector) { static_cast<jint> (vector.size()));
for (const std::string &s: vector) {
jstring element = env->NewStringUTF(s.c_str()); jstring element = env->NewStringUTF(s.c_str());
env->CallBooleanMethod(result, java_util_ArrayList_add, element); env->CallBooleanMethod(result, java_util_ArrayList_add, element);
env->DeleteLocalRef(element); env->DeleteLocalRef(element);
@ -260,9 +261,9 @@ Java_com_m2049r_xmrwallet_model_WalletManager_createWalletJ(JNIEnv *env, jobject
jstring path, jstring password, jstring path, jstring password,
jstring language, jstring language,
jint networkType) { jint networkType) {
const char *_path = env->GetStringUTFChars(path, NULL); const char *_path = env->GetStringUTFChars(path, nullptr);
const char *_password = env->GetStringUTFChars(password, NULL); const char *_password = env->GetStringUTFChars(password, nullptr);
const char *_language = env->GetStringUTFChars(language, NULL); const char *_language = env->GetStringUTFChars(language, nullptr);
Monero::NetworkType _networkType = static_cast<Monero::NetworkType>(networkType); Monero::NetworkType _networkType = static_cast<Monero::NetworkType>(networkType);
Bitmonero::Wallet *wallet = Bitmonero::Wallet *wallet =
@ -282,8 +283,8 @@ JNIEXPORT jlong JNICALL
Java_com_m2049r_xmrwallet_model_WalletManager_openWalletJ(JNIEnv *env, jobject instance, Java_com_m2049r_xmrwallet_model_WalletManager_openWalletJ(JNIEnv *env, jobject instance,
jstring path, jstring password, jstring path, jstring password,
jint networkType) { jint networkType) {
const char *_path = env->GetStringUTFChars(path, NULL); const char *_path = env->GetStringUTFChars(path, nullptr);
const char *_password = env->GetStringUTFChars(password, NULL); const char *_password = env->GetStringUTFChars(password, nullptr);
Monero::NetworkType _networkType = static_cast<Monero::NetworkType>(networkType); Monero::NetworkType _networkType = static_cast<Monero::NetworkType>(networkType);
Bitmonero::Wallet *wallet = Bitmonero::Wallet *wallet =
@ -303,9 +304,9 @@ Java_com_m2049r_xmrwallet_model_WalletManager_recoveryWalletJ(JNIEnv *env, jobje
jstring mnemonic, jstring mnemonic,
jint networkType, jint networkType,
jlong restoreHeight) { jlong restoreHeight) {
const char *_path = env->GetStringUTFChars(path, NULL); const char *_path = env->GetStringUTFChars(path, nullptr);
const char *_password = env->GetStringUTFChars(password, NULL); const char *_password = env->GetStringUTFChars(password, nullptr);
const char *_mnemonic = env->GetStringUTFChars(mnemonic, NULL); const char *_mnemonic = env->GetStringUTFChars(mnemonic, nullptr);
Monero::NetworkType _networkType = static_cast<Monero::NetworkType>(networkType); Monero::NetworkType _networkType = static_cast<Monero::NetworkType>(networkType);
Bitmonero::Wallet *wallet = Bitmonero::Wallet *wallet =
@ -331,13 +332,13 @@ Java_com_m2049r_xmrwallet_model_WalletManager_createWalletFromKeysJ(JNIEnv *env,
jstring addressString, jstring addressString,
jstring viewKeyString, jstring viewKeyString,
jstring spendKeyString) { jstring spendKeyString) {
const char *_path = env->GetStringUTFChars(path, NULL); const char *_path = env->GetStringUTFChars(path, nullptr);
const char *_password = env->GetStringUTFChars(password, NULL); const char *_password = env->GetStringUTFChars(password, nullptr);
const char *_language = env->GetStringUTFChars(language, NULL); const char *_language = env->GetStringUTFChars(language, nullptr);
Monero::NetworkType _networkType = static_cast<Monero::NetworkType>(networkType); Monero::NetworkType _networkType = static_cast<Monero::NetworkType>(networkType);
const char *_addressString = env->GetStringUTFChars(addressString, NULL); const char *_addressString = env->GetStringUTFChars(addressString, nullptr);
const char *_viewKeyString = env->GetStringUTFChars(viewKeyString, NULL); const char *_viewKeyString = env->GetStringUTFChars(viewKeyString, nullptr);
const char *_spendKeyString = env->GetStringUTFChars(spendKeyString, NULL); const char *_spendKeyString = env->GetStringUTFChars(spendKeyString, nullptr);
Bitmonero::Wallet *wallet = Bitmonero::Wallet *wallet =
Bitmonero::WalletManagerFactory::getWalletManager()->createWalletFromKeys( Bitmonero::WalletManagerFactory::getWalletManager()->createWalletFromKeys(
@ -370,11 +371,11 @@ Java_com_m2049r_xmrwallet_model_WalletManager_createWalletFromDeviceJ(JNIEnv *en
jstring deviceName, jstring deviceName,
jlong restoreHeight, jlong restoreHeight,
jstring subaddressLookahead) { jstring subaddressLookahead) {
const char *_path = env->GetStringUTFChars(path, NULL); const char *_path = env->GetStringUTFChars(path, nullptr);
const char *_password = env->GetStringUTFChars(password, NULL); const char *_password = env->GetStringUTFChars(password, nullptr);
Monero::NetworkType _networkType = static_cast<Monero::NetworkType>(networkType); Monero::NetworkType _networkType = static_cast<Monero::NetworkType>(networkType);
const char *_deviceName = env->GetStringUTFChars(deviceName, NULL); const char *_deviceName = env->GetStringUTFChars(deviceName, nullptr);
const char *_subaddressLookahead = env->GetStringUTFChars(subaddressLookahead, NULL); const char *_subaddressLookahead = env->GetStringUTFChars(subaddressLookahead, nullptr);
Bitmonero::Wallet *wallet = Bitmonero::Wallet *wallet =
Bitmonero::WalletManagerFactory::getWalletManager()->createWalletFromDevice( Bitmonero::WalletManagerFactory::getWalletManager()->createWalletFromDevice(
@ -395,7 +396,7 @@ Java_com_m2049r_xmrwallet_model_WalletManager_createWalletFromDeviceJ(JNIEnv *en
JNIEXPORT jboolean JNICALL JNIEXPORT jboolean JNICALL
Java_com_m2049r_xmrwallet_model_WalletManager_walletExists(JNIEnv *env, jobject instance, Java_com_m2049r_xmrwallet_model_WalletManager_walletExists(JNIEnv *env, jobject instance,
jstring path) { jstring path) {
const char *_path = env->GetStringUTFChars(path, NULL); const char *_path = env->GetStringUTFChars(path, nullptr);
bool exists = bool exists =
Bitmonero::WalletManagerFactory::getWalletManager()->walletExists(std::string(_path)); Bitmonero::WalletManagerFactory::getWalletManager()->walletExists(std::string(_path));
env->ReleaseStringUTFChars(path, _path); env->ReleaseStringUTFChars(path, _path);
@ -407,8 +408,8 @@ Java_com_m2049r_xmrwallet_model_WalletManager_verifyWalletPassword(JNIEnv *env,
jstring keys_file_name, jstring keys_file_name,
jstring password, jstring password,
jboolean watch_only) { jboolean watch_only) {
const char *_keys_file_name = env->GetStringUTFChars(keys_file_name, NULL); const char *_keys_file_name = env->GetStringUTFChars(keys_file_name, nullptr);
const char *_password = env->GetStringUTFChars(password, NULL); const char *_password = env->GetStringUTFChars(password, nullptr);
bool passwordOk = bool passwordOk =
Bitmonero::WalletManagerFactory::getWalletManager()->verifyWalletPassword( Bitmonero::WalletManagerFactory::getWalletManager()->verifyWalletPassword(
std::string(_keys_file_name), std::string(_password), watch_only); std::string(_keys_file_name), std::string(_password), watch_only);
@ -422,8 +423,8 @@ JNIEXPORT jint JNICALL
Java_com_m2049r_xmrwallet_model_WalletManager_queryWalletDeviceJ(JNIEnv *env, jobject instance, Java_com_m2049r_xmrwallet_model_WalletManager_queryWalletDeviceJ(JNIEnv *env, jobject instance,
jstring keys_file_name, jstring keys_file_name,
jstring password) { jstring password) {
const char *_keys_file_name = env->GetStringUTFChars(keys_file_name, NULL); const char *_keys_file_name = env->GetStringUTFChars(keys_file_name, nullptr);
const char *_password = env->GetStringUTFChars(password, NULL); const char *_password = env->GetStringUTFChars(password, nullptr);
Bitmonero::Wallet::Device device_type; Bitmonero::Wallet::Device device_type;
bool ok = Bitmonero::WalletManagerFactory::getWalletManager()-> bool ok = Bitmonero::WalletManagerFactory::getWalletManager()->
queryWalletDevice(device_type, std::string(_keys_file_name), std::string(_password)); queryWalletDevice(device_type, std::string(_keys_file_name), std::string(_password));
@ -438,7 +439,7 @@ Java_com_m2049r_xmrwallet_model_WalletManager_queryWalletDeviceJ(JNIEnv *env, jo
JNIEXPORT jobject JNICALL JNIEXPORT jobject JNICALL
Java_com_m2049r_xmrwallet_model_WalletManager_findWallets(JNIEnv *env, jobject instance, Java_com_m2049r_xmrwallet_model_WalletManager_findWallets(JNIEnv *env, jobject instance,
jstring path) { jstring path) {
const char *_path = env->GetStringUTFChars(path, NULL); const char *_path = env->GetStringUTFChars(path, nullptr);
std::vector<std::string> walletPaths = std::vector<std::string> walletPaths =
Bitmonero::WalletManagerFactory::getWalletManager()->findWallets(std::string(_path)); Bitmonero::WalletManagerFactory::getWalletManager()->findWallets(std::string(_path));
env->ReleaseStringUTFChars(path, _path); env->ReleaseStringUTFChars(path, _path);
@ -450,7 +451,7 @@ Java_com_m2049r_xmrwallet_model_WalletManager_findWallets(JNIEnv *env, jobject i
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
Java_com_m2049r_xmrwallet_model_WalletManager_setDaemonAddressJ(JNIEnv *env, jobject instance, Java_com_m2049r_xmrwallet_model_WalletManager_setDaemonAddressJ(JNIEnv *env, jobject instance,
jstring address) { jstring address) {
const char *_address = env->GetStringUTFChars(address, NULL); const char *_address = env->GetStringUTFChars(address, nullptr);
Bitmonero::WalletManagerFactory::getWalletManager()->setDaemonAddress(std::string(_address)); Bitmonero::WalletManagerFactory::getWalletManager()->setDaemonAddress(std::string(_address));
env->ReleaseStringUTFChars(address, _address); env->ReleaseStringUTFChars(address, _address);
} }
@ -502,7 +503,7 @@ Java_com_m2049r_xmrwallet_model_WalletManager_startMining(JNIEnv *env, jobject i
jstring address, jstring address,
jboolean background_mining, jboolean background_mining,
jboolean ignore_battery) { jboolean ignore_battery) {
const char *_address = env->GetStringUTFChars(address, NULL); const char *_address = env->GetStringUTFChars(address, nullptr);
bool success = bool success =
Bitmonero::WalletManagerFactory::getWalletManager()->startMining(std::string(_address), Bitmonero::WalletManagerFactory::getWalletManager()->startMining(std::string(_address),
background_mining, background_mining,
@ -520,7 +521,7 @@ JNIEXPORT jstring JNICALL
Java_com_m2049r_xmrwallet_model_WalletManager_resolveOpenAlias(JNIEnv *env, jobject instance, Java_com_m2049r_xmrwallet_model_WalletManager_resolveOpenAlias(JNIEnv *env, jobject instance,
jstring address, jstring address,
jboolean dnssec_valid) { jboolean dnssec_valid) {
const char *_address = env->GetStringUTFChars(address, NULL); const char *_address = env->GetStringUTFChars(address, nullptr);
bool _dnssec_valid = (bool) dnssec_valid; bool _dnssec_valid = (bool) dnssec_valid;
std::string resolvedAlias = std::string resolvedAlias =
Bitmonero::WalletManagerFactory::getWalletManager()->resolveOpenAlias( Bitmonero::WalletManagerFactory::getWalletManager()->resolveOpenAlias(
@ -572,7 +573,7 @@ Java_com_m2049r_xmrwallet_model_Wallet_getSeedLanguage(JNIEnv *env, jobject inst
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
Java_com_m2049r_xmrwallet_model_Wallet_setSeedLanguage(JNIEnv *env, jobject instance, Java_com_m2049r_xmrwallet_model_Wallet_setSeedLanguage(JNIEnv *env, jobject instance,
jstring language) { jstring language) {
const char *_language = env->GetStringUTFChars(language, NULL); const char *_language = env->GetStringUTFChars(language, nullptr);
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance); Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
wallet->setSeedLanguage(std::string(_language)); wallet->setSeedLanguage(std::string(_language));
env->ReleaseStringUTFChars(language, _language); env->ReleaseStringUTFChars(language, _language);
@ -608,7 +609,7 @@ Java_com_m2049r_xmrwallet_model_Wallet_statusWithErrorString(JNIEnv *env, jobjec
JNIEXPORT jboolean JNICALL JNIEXPORT jboolean JNICALL
Java_com_m2049r_xmrwallet_model_Wallet_setPassword(JNIEnv *env, jobject instance, Java_com_m2049r_xmrwallet_model_Wallet_setPassword(JNIEnv *env, jobject instance,
jstring password) { jstring password) {
const char *_password = env->GetStringUTFChars(password, NULL); const char *_password = env->GetStringUTFChars(password, nullptr);
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance); Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
bool success = wallet->setPassword(std::string(_password)); bool success = wallet->setPassword(std::string(_password));
env->ReleaseStringUTFChars(password, _password); env->ReleaseStringUTFChars(password, _password);
@ -642,7 +643,7 @@ Java_com_m2049r_xmrwallet_model_Wallet_nettype(JNIEnv *env, jobject instance) {
JNIEXPORT jstring JNICALL JNIEXPORT jstring JNICALL
Java_com_m2049r_xmrwallet_model_Wallet_getIntegratedAddress(JNIEnv *env, jobject instance, Java_com_m2049r_xmrwallet_model_Wallet_getIntegratedAddress(JNIEnv *env, jobject instance,
jstring payment_id) { jstring payment_id) {
const char *_payment_id = env->GetStringUTFChars(payment_id, NULL); const char *_payment_id = env->GetStringUTFChars(payment_id, nullptr);
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance); Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
std::string address = wallet->integratedAddress(_payment_id); std::string address = wallet->integratedAddress(_payment_id);
env->ReleaseStringUTFChars(payment_id, _payment_id); env->ReleaseStringUTFChars(payment_id, _payment_id);
@ -664,7 +665,7 @@ Java_com_m2049r_xmrwallet_model_Wallet_getSecretSpendKey(JNIEnv *env, jobject in
JNIEXPORT jboolean JNICALL JNIEXPORT jboolean JNICALL
Java_com_m2049r_xmrwallet_model_Wallet_store(JNIEnv *env, jobject instance, Java_com_m2049r_xmrwallet_model_Wallet_store(JNIEnv *env, jobject instance,
jstring path) { jstring path) {
const char *_path = env->GetStringUTFChars(path, NULL); const char *_path = env->GetStringUTFChars(path, nullptr);
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance); Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
bool success = wallet->store(std::string(_path)); bool success = wallet->store(std::string(_path));
if (!success) { if (!success) {
@ -687,9 +688,9 @@ Java_com_m2049r_xmrwallet_model_Wallet_initJ(JNIEnv *env, jobject instance,
jstring daemon_address, jstring daemon_address,
jlong upper_transaction_size_limit, jlong upper_transaction_size_limit,
jstring daemon_username, jstring daemon_password) { jstring daemon_username, jstring daemon_password) {
const char *_daemon_address = env->GetStringUTFChars(daemon_address, NULL); const char *_daemon_address = env->GetStringUTFChars(daemon_address, nullptr);
const char *_daemon_username = env->GetStringUTFChars(daemon_username, NULL); const char *_daemon_username = env->GetStringUTFChars(daemon_username, nullptr);
const char *_daemon_password = env->GetStringUTFChars(daemon_password, NULL); const char *_daemon_password = env->GetStringUTFChars(daemon_password, nullptr);
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance); Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
bool status = wallet->init(_daemon_address, (uint64_t) upper_transaction_size_limit, bool status = wallet->init(_daemon_address, (uint64_t) upper_transaction_size_limit,
_daemon_username, _daemon_username,
@ -807,7 +808,7 @@ Java_com_m2049r_xmrwallet_util_KeyStoreHelper_slowHash(JNIEnv *env, jclass clazz
return nullptr; return nullptr;
} }
jbyte *buffer = env->GetByteArrayElements(data, NULL); jbyte *buffer = env->GetByteArrayElements(data, nullptr);
switch (brokenVariant) { switch (brokenVariant) {
case 1: case 1:
slow_hash_broken(buffer, hash, 1); slow_hash_broken(buffer, hash, 1);
@ -833,7 +834,7 @@ Java_com_m2049r_xmrwallet_model_Wallet_getDisplayAmount(JNIEnv *env, jclass claz
JNIEXPORT jlong JNICALL JNIEXPORT jlong JNICALL
Java_com_m2049r_xmrwallet_model_Wallet_getAmountFromString(JNIEnv *env, jclass clazz, Java_com_m2049r_xmrwallet_model_Wallet_getAmountFromString(JNIEnv *env, jclass clazz,
jstring amount) { jstring amount) {
const char *_amount = env->GetStringUTFChars(amount, NULL); const char *_amount = env->GetStringUTFChars(amount, nullptr);
uint64_t x = Bitmonero::Wallet::amountFromString(_amount); uint64_t x = Bitmonero::Wallet::amountFromString(_amount);
env->ReleaseStringUTFChars(amount, _amount); env->ReleaseStringUTFChars(amount, _amount);
return x; return x;
@ -853,7 +854,7 @@ Java_com_m2049r_xmrwallet_model_Wallet_generatePaymentId(JNIEnv *env, jclass cla
JNIEXPORT jboolean JNICALL JNIEXPORT jboolean JNICALL
Java_com_m2049r_xmrwallet_model_Wallet_isPaymentIdValid(JNIEnv *env, jclass clazz, Java_com_m2049r_xmrwallet_model_Wallet_isPaymentIdValid(JNIEnv *env, jclass clazz,
jstring payment_id) { jstring payment_id) {
const char *_payment_id = env->GetStringUTFChars(payment_id, NULL); const char *_payment_id = env->GetStringUTFChars(payment_id, nullptr);
bool isValid = Bitmonero::Wallet::paymentIdValid(_payment_id); bool isValid = Bitmonero::Wallet::paymentIdValid(_payment_id);
env->ReleaseStringUTFChars(payment_id, _payment_id); env->ReleaseStringUTFChars(payment_id, _payment_id);
return static_cast<jboolean>(isValid); return static_cast<jboolean>(isValid);
@ -862,7 +863,7 @@ Java_com_m2049r_xmrwallet_model_Wallet_isPaymentIdValid(JNIEnv *env, jclass claz
JNIEXPORT jboolean JNICALL JNIEXPORT jboolean JNICALL
Java_com_m2049r_xmrwallet_model_Wallet_isAddressValid(JNIEnv *env, jclass clazz, Java_com_m2049r_xmrwallet_model_Wallet_isAddressValid(JNIEnv *env, jclass clazz,
jstring address, jint networkType) { jstring address, jint networkType) {
const char *_address = env->GetStringUTFChars(address, NULL); const char *_address = env->GetStringUTFChars(address, nullptr);
Monero::NetworkType _networkType = static_cast<Monero::NetworkType>(networkType); Monero::NetworkType _networkType = static_cast<Monero::NetworkType>(networkType);
bool isValid = Bitmonero::Wallet::addressValid(_address, _networkType); bool isValid = Bitmonero::Wallet::addressValid(_address, _networkType);
env->ReleaseStringUTFChars(address, _address); env->ReleaseStringUTFChars(address, _address);
@ -874,7 +875,7 @@ Java_com_m2049r_xmrwallet_model_Wallet_getPaymentIdFromAddress(JNIEnv *env, jcla
jstring address, jstring address,
jint networkType) { jint networkType) {
Monero::NetworkType _networkType = static_cast<Monero::NetworkType>(networkType); Monero::NetworkType _networkType = static_cast<Monero::NetworkType>(networkType);
const char *_address = env->GetStringUTFChars(address, NULL); const char *_address = env->GetStringUTFChars(address, nullptr);
std::string payment_id = Bitmonero::Wallet::paymentIdFromAddress(_address, _networkType); std::string payment_id = Bitmonero::Wallet::paymentIdFromAddress(_address, _networkType);
env->ReleaseStringUTFChars(address, _address); env->ReleaseStringUTFChars(address, _address);
return env->NewStringUTF(payment_id.c_str()); return env->NewStringUTF(payment_id.c_str());
@ -929,8 +930,8 @@ Java_com_m2049r_xmrwallet_model_Wallet_createTransactionJ(JNIEnv *env, jobject i
jint priority, jint priority,
jint accountIndex) { jint accountIndex) {
const char *_dst_addr = env->GetStringUTFChars(dst_addr, NULL); const char *_dst_addr = env->GetStringUTFChars(dst_addr, nullptr);
const char *_payment_id = env->GetStringUTFChars(payment_id, NULL); const char *_payment_id = env->GetStringUTFChars(payment_id, nullptr);
Bitmonero::PendingTransaction::Priority _priority = Bitmonero::PendingTransaction::Priority _priority =
static_cast<Bitmonero::PendingTransaction::Priority>(priority); static_cast<Bitmonero::PendingTransaction::Priority>(priority);
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance); Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
@ -952,8 +953,8 @@ Java_com_m2049r_xmrwallet_model_Wallet_createSweepTransaction(JNIEnv *env, jobje
jint priority, jint priority,
jint accountIndex) { jint accountIndex) {
const char *_dst_addr = env->GetStringUTFChars(dst_addr, NULL); const char *_dst_addr = env->GetStringUTFChars(dst_addr, nullptr);
const char *_payment_id = env->GetStringUTFChars(payment_id, NULL); const char *_payment_id = env->GetStringUTFChars(payment_id, nullptr);
Bitmonero::PendingTransaction::Priority _priority = Bitmonero::PendingTransaction::Priority _priority =
static_cast<Bitmonero::PendingTransaction::Priority>(priority); static_cast<Bitmonero::PendingTransaction::Priority>(priority);
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance); Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
@ -1041,8 +1042,8 @@ JNIEXPORT jboolean JNICALL
Java_com_m2049r_xmrwallet_model_Wallet_setUserNote(JNIEnv *env, jobject instance, Java_com_m2049r_xmrwallet_model_Wallet_setUserNote(JNIEnv *env, jobject instance,
jstring txid, jstring note) { jstring txid, jstring note) {
const char *_txid = env->GetStringUTFChars(txid, NULL); const char *_txid = env->GetStringUTFChars(txid, nullptr);
const char *_note = env->GetStringUTFChars(note, NULL); const char *_note = env->GetStringUTFChars(note, nullptr);
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance); Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
@ -1058,7 +1059,7 @@ JNIEXPORT jstring JNICALL
Java_com_m2049r_xmrwallet_model_Wallet_getUserNote(JNIEnv *env, jobject instance, Java_com_m2049r_xmrwallet_model_Wallet_getUserNote(JNIEnv *env, jobject instance,
jstring txid) { jstring txid) {
const char *_txid = env->GetStringUTFChars(txid, NULL); const char *_txid = env->GetStringUTFChars(txid, nullptr);
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance); Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
@ -1072,7 +1073,7 @@ JNIEXPORT jstring JNICALL
Java_com_m2049r_xmrwallet_model_Wallet_getTxKey(JNIEnv *env, jobject instance, Java_com_m2049r_xmrwallet_model_Wallet_getTxKey(JNIEnv *env, jobject instance,
jstring txid) { jstring txid) {
const char *_txid = env->GetStringUTFChars(txid, NULL); const char *_txid = env->GetStringUTFChars(txid, nullptr);
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance); Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
@ -1087,7 +1088,7 @@ JNIEXPORT void JNICALL
Java_com_m2049r_xmrwallet_model_Wallet_addAccount(JNIEnv *env, jobject instance, Java_com_m2049r_xmrwallet_model_Wallet_addAccount(JNIEnv *env, jobject instance,
jstring label) { jstring label) {
const char *_label = env->GetStringUTFChars(label, NULL); const char *_label = env->GetStringUTFChars(label, nullptr);
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance); Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
wallet->addSubaddressAccount(_label); wallet->addSubaddressAccount(_label);
@ -1114,7 +1115,7 @@ Java_com_m2049r_xmrwallet_model_Wallet_setSubaddressLabel(JNIEnv *env, jobject i
jint accountIndex, jint addressIndex, jint accountIndex, jint addressIndex,
jstring label) { jstring label) {
const char *_label = env->GetStringUTFChars(label, NULL); const char *_label = env->GetStringUTFChars(label, nullptr);
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance); Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
wallet->setSubaddressLabel(accountIndex, addressIndex, _label); wallet->setSubaddressLabel(accountIndex, addressIndex, _label);
@ -1143,7 +1144,7 @@ Java_com_m2049r_xmrwallet_model_Wallet_addSubaddress(JNIEnv *env, jobject instan
jint accountIndex, jint accountIndex,
jstring label) { jstring label) {
const char *_label = env->GetStringUTFChars(label, NULL); const char *_label = env->GetStringUTFChars(label, nullptr);
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance); Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
wallet->addSubaddress(accountIndex, _label); wallet->addSubaddress(accountIndex, _label);
env->ReleaseStringUTFChars(label, _label); env->ReleaseStringUTFChars(label, _label);
@ -1181,21 +1182,22 @@ jobject newTransferInstance(JNIEnv *env, uint64_t amount, const std::string &add
jmethodID c = env->GetMethodID(class_Transfer, "<init>", jmethodID c = env->GetMethodID(class_Transfer, "<init>",
"(JLjava/lang/String;)V"); "(JLjava/lang/String;)V");
jstring _address = env->NewStringUTF(address.c_str()); jstring _address = env->NewStringUTF(address.c_str());
jobject transfer = env->NewObject(class_Transfer, c, amount, _address); jobject transfer = env->NewObject(class_Transfer, c, static_cast<jlong> (amount), _address);
env->DeleteLocalRef(_address); env->DeleteLocalRef(_address);
return transfer; return transfer;
} }
jobject newTransferList(JNIEnv *env, Bitmonero::TransactionInfo *info) { jobject newTransferList(JNIEnv *env, Bitmonero::TransactionInfo *info) {
const std::vector<Bitmonero::TransactionInfo::Transfer> &transfers = info->transfers(); const std::vector<Bitmonero::TransactionInfo::Transfer> &transfers = info->transfers();
if (transfers.size() == 0) { // don't create empty Lists if (transfers.empty()) { // don't create empty Lists
return nullptr; return nullptr;
} }
// make new ArrayList // make new ArrayList
jmethodID java_util_ArrayList_ = env->GetMethodID(class_ArrayList, "<init>", "(I)V"); jmethodID java_util_ArrayList_ = env->GetMethodID(class_ArrayList, "<init>", "(I)V");
jmethodID java_util_ArrayList_add = env->GetMethodID(class_ArrayList, "add", jmethodID java_util_ArrayList_add = env->GetMethodID(class_ArrayList, "add",
"(Ljava/lang/Object;)Z"); "(Ljava/lang/Object;)Z");
jobject result = env->NewObject(class_ArrayList, java_util_ArrayList_, transfers.size()); jobject result = env->NewObject(class_ArrayList, java_util_ArrayList_,
static_cast<jint> (transfers.size()));
// create Transfer objects and stick them in the List // create Transfer objects and stick them in the List
for (const Bitmonero::TransactionInfo::Transfer &s: transfers) { for (const Bitmonero::TransactionInfo::Transfer &s: transfers) {
jobject element = newTransferInstance(env, s.amount, s.address); jobject element = newTransferInstance(env, s.amount, s.address);
@ -1219,15 +1221,15 @@ jobject newTransactionInfo(JNIEnv *env, Bitmonero::TransactionInfo *info) {
info->direction(), info->direction(),
info->isPending(), info->isPending(),
info->isFailed(), info->isFailed(),
info->amount(), static_cast<jlong> (info->amount()),
info->fee(), static_cast<jlong> (info->fee()),
info->blockHeight(), static_cast<jlong> (info->blockHeight()),
_hash, _hash,
static_cast<jlong> (info->timestamp()), static_cast<jlong> (info->timestamp()),
_paymentId, _paymentId,
info->subaddrAccount(), static_cast<jint> (info->subaddrAccount()),
subaddrIndex, static_cast<jint> (subaddrIndex),
info->confirmations(), static_cast<jlong> (info->confirmations()),
_label, _label,
transfers); transfers);
env->DeleteLocalRef(transfers); env->DeleteLocalRef(transfers);
@ -1239,13 +1241,14 @@ jobject newTransactionInfo(JNIEnv *env, Bitmonero::TransactionInfo *info) {
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
jobject cpp2java(JNIEnv *env, std::vector<Bitmonero::TransactionInfo *> vector) { jobject cpp2java(JNIEnv *env, const std::vector<Bitmonero::TransactionInfo *>& vector) {
jmethodID java_util_ArrayList_ = env->GetMethodID(class_ArrayList, "<init>", "(I)V"); jmethodID java_util_ArrayList_ = env->GetMethodID(class_ArrayList, "<init>", "(I)V");
jmethodID java_util_ArrayList_add = env->GetMethodID(class_ArrayList, "add", jmethodID java_util_ArrayList_add = env->GetMethodID(class_ArrayList, "add",
"(Ljava/lang/Object;)Z"); "(Ljava/lang/Object;)Z");
jobject arrayList = env->NewObject(class_ArrayList, java_util_ArrayList_, vector.size()); jobject arrayList = env->NewObject(class_ArrayList, java_util_ArrayList_,
static_cast<jint> (vector.size()));
for (Bitmonero::TransactionInfo *s: vector) { for (Bitmonero::TransactionInfo *s: vector) {
jobject info = newTransactionInfo(env, s); jobject info = newTransactionInfo(env, s);
env->CallBooleanMethod(arrayList, java_util_ArrayList_add, info); env->CallBooleanMethod(arrayList, java_util_ArrayList_add, info);
@ -1281,7 +1284,7 @@ JNIEXPORT jboolean JNICALL
Java_com_m2049r_xmrwallet_model_PendingTransaction_commit(JNIEnv *env, jobject instance, Java_com_m2049r_xmrwallet_model_PendingTransaction_commit(JNIEnv *env, jobject instance,
jstring filename, jboolean overwrite) { jstring filename, jboolean overwrite) {
const char *_filename = env->GetStringUTFChars(filename, NULL); const char *_filename = env->GetStringUTFChars(filename, nullptr);
Bitmonero::PendingTransaction *tx = getHandle<Bitmonero::PendingTransaction>(env, instance); Bitmonero::PendingTransaction *tx = getHandle<Bitmonero::PendingTransaction>(env, instance);
bool success = tx->commit(_filename, overwrite); bool success = tx->commit(_filename, overwrite);
@ -1338,8 +1341,8 @@ Java_com_m2049r_xmrwallet_model_WalletManager_initLogger(JNIEnv *env, jclass cla
jstring argv0, jstring argv0,
jstring default_log_base_name) { jstring default_log_base_name) {
const char *_argv0 = env->GetStringUTFChars(argv0, NULL); const char *_argv0 = env->GetStringUTFChars(argv0, nullptr);
const char *_default_log_base_name = env->GetStringUTFChars(default_log_base_name, NULL); const char *_default_log_base_name = env->GetStringUTFChars(default_log_base_name, nullptr);
Bitmonero::Wallet::init(_argv0, _default_log_base_name); Bitmonero::Wallet::init(_argv0, _default_log_base_name);
@ -1351,8 +1354,8 @@ JNIEXPORT void JNICALL
Java_com_m2049r_xmrwallet_model_WalletManager_logDebug(JNIEnv *env, jclass clazz, Java_com_m2049r_xmrwallet_model_WalletManager_logDebug(JNIEnv *env, jclass clazz,
jstring category, jstring message) { jstring category, jstring message) {
const char *_category = env->GetStringUTFChars(category, NULL); const char *_category = env->GetStringUTFChars(category, nullptr);
const char *_message = env->GetStringUTFChars(message, NULL); const char *_message = env->GetStringUTFChars(message, nullptr);
Bitmonero::Wallet::debug(_category, _message); Bitmonero::Wallet::debug(_category, _message);
@ -1364,8 +1367,8 @@ JNIEXPORT void JNICALL
Java_com_m2049r_xmrwallet_model_WalletManager_logInfo(JNIEnv *env, jclass clazz, Java_com_m2049r_xmrwallet_model_WalletManager_logInfo(JNIEnv *env, jclass clazz,
jstring category, jstring message) { jstring category, jstring message) {
const char *_category = env->GetStringUTFChars(category, NULL); const char *_category = env->GetStringUTFChars(category, nullptr);
const char *_message = env->GetStringUTFChars(message, NULL); const char *_message = env->GetStringUTFChars(message, nullptr);
Bitmonero::Wallet::info(_category, _message); Bitmonero::Wallet::info(_category, _message);
@ -1377,8 +1380,8 @@ JNIEXPORT void JNICALL
Java_com_m2049r_xmrwallet_model_WalletManager_logWarning(JNIEnv *env, jclass clazz, Java_com_m2049r_xmrwallet_model_WalletManager_logWarning(JNIEnv *env, jclass clazz,
jstring category, jstring message) { jstring category, jstring message) {
const char *_category = env->GetStringUTFChars(category, NULL); const char *_category = env->GetStringUTFChars(category, nullptr);
const char *_message = env->GetStringUTFChars(message, NULL); const char *_message = env->GetStringUTFChars(message, nullptr);
Bitmonero::Wallet::warning(_category, _message); Bitmonero::Wallet::warning(_category, _message);
@ -1390,8 +1393,8 @@ JNIEXPORT void JNICALL
Java_com_m2049r_xmrwallet_model_WalletManager_logError(JNIEnv *env, jclass clazz, Java_com_m2049r_xmrwallet_model_WalletManager_logError(JNIEnv *env, jclass clazz,
jstring category, jstring message) { jstring category, jstring message) {
const char *_category = env->GetStringUTFChars(category, NULL); const char *_category = env->GetStringUTFChars(category, nullptr);
const char *_message = env->GetStringUTFChars(message, NULL); const char *_message = env->GetStringUTFChars(message, nullptr);
Bitmonero::Wallet::error(_category, _message); Bitmonero::Wallet::error(_category, _message);
@ -1480,7 +1483,7 @@ int LedgerFind(char *buffer, size_t len) {
int ret; int ret;
if (name != nullptr) { if (name != nullptr) {
const char *_name = jenv->GetStringUTFChars(name, NULL); const char *_name = jenv->GetStringUTFChars(name, nullptr);
strncpy(buffer, _name, len); strncpy(buffer, _name, len);
jenv->ReleaseStringUTFChars(name, _name); jenv->ReleaseStringUTFChars(name, _name);
buffer[len - 1] = 0; // terminate in case _name is bigger buffer[len - 1] = 0; // terminate in case _name is bigger

View File

@ -24,13 +24,11 @@ import android.support.v7.app.AppCompatActivity;
import com.m2049r.xmrwallet.onboarding.OnBoardingActivity; import com.m2049r.xmrwallet.onboarding.OnBoardingActivity;
import com.m2049r.xmrwallet.onboarding.OnBoardingManager; import com.m2049r.xmrwallet.onboarding.OnBoardingManager;
import timber.log.Timber;
public class MainActivity extends AppCompatActivity { public class MainActivity extends AppCompatActivity {
@Override @Override
protected void onCreate(@Nullable final Bundle savedInstanceState) { protected void onCreate(@Nullable final Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (OnBoardingManager.shouldShowOnBoarding(getApplicationContext()) || BuildConfig.DEBUG) { if (OnBoardingManager.shouldShowOnBoarding(getApplicationContext())) {
startActivity(new Intent(this, OnBoardingActivity.class)); startActivity(new Intent(this, OnBoardingActivity.class));
} else { } else {
startActivity(new Intent(this, LoginActivity.class)); startActivity(new Intent(this, LoginActivity.class));

View File

@ -36,7 +36,7 @@
android:layout_alignParentStart="true" android:layout_alignParentStart="true"
android:layout_toStartOf="@+id/bPasteAddress" android:layout_toStartOf="@+id/bPasteAddress"
app:counterEnabled="true" app:counterEnabled="true"
app:counterMaxLength="16" app:counterMaxLength="95"
app:errorEnabled="true"> app:errorEnabled="true">
<android.support.design.widget.TextInputEditText <android.support.design.widget.TextInputEditText