mirror of
https://github.com/m2049r/xmrwallet
synced 2025-09-06 02:27:11 +02:00
Compare commits
56 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
110057c294 | ||
![]() |
7553d3c5f4 | ||
![]() |
317976b34a | ||
![]() |
6ad423567f | ||
![]() |
d497158856 | ||
![]() |
f4cada5fa1 | ||
![]() |
352f0ad09c | ||
![]() |
ff1a9c1570 | ||
![]() |
fa811a39a2 | ||
![]() |
cf5018be33 | ||
![]() |
8ec027f9d4 | ||
![]() |
f28428e677 | ||
![]() |
294084bec5 | ||
![]() |
4349907627 | ||
![]() |
f7cef24a83 | ||
![]() |
2774f99b15 | ||
![]() |
bc630fc445 | ||
![]() |
895cf16d33 | ||
![]() |
7f1796b12e | ||
![]() |
abe5c8afab | ||
![]() |
47f79b5269 | ||
![]() |
c9c07eaa15 | ||
![]() |
a490e3af0c | ||
![]() |
64d5b3bdea | ||
![]() |
bf91eaf22f | ||
![]() |
2c3e73b540 | ||
![]() |
830d9dadb9 | ||
![]() |
331d88ebba | ||
![]() |
7cc2f6fafb | ||
![]() |
9a3ee0eda8 | ||
![]() |
6e898939a3 | ||
![]() |
40ae39d647 | ||
![]() |
ca81e652e5 | ||
![]() |
796048be4e | ||
![]() |
441bf995c8 | ||
![]() |
e8860ab8eb | ||
![]() |
525b38ff53 | ||
![]() |
ba79bf87aa | ||
![]() |
3fe6571e7d | ||
![]() |
364e6a8137 | ||
![]() |
cb69ce99d6 | ||
![]() |
1f976872fc | ||
![]() |
27f266b6f7 | ||
![]() |
168928d54a | ||
![]() |
b3f61072aa | ||
![]() |
ccb64aded0 | ||
![]() |
e98fa089f2 | ||
![]() |
884878b7a7 | ||
![]() |
4e23f0ef3a | ||
![]() |
6ea4e3d998 | ||
![]() |
971c90f35b | ||
![]() |
f0523c403c | ||
![]() |
966ed23b87 | ||
![]() |
95f2ca74a6 | ||
![]() |
81d94478f2 | ||
![]() |
16ff779ebc |
@@ -137,7 +137,11 @@ set_target_properties(checkpoints PROPERTIES IMPORTED_LOCATION
|
|||||||
|
|
||||||
add_library(device STATIC IMPORTED)
|
add_library(device STATIC IMPORTED)
|
||||||
set_target_properties(device PROPERTIES IMPORTED_LOCATION
|
set_target_properties(device PROPERTIES IMPORTED_LOCATION
|
||||||
${EXTERNAL_LIBS_DIR}/monero/lib/${ANDROID_ABI}/libdevice.a)
|
${EXTERNAL_LIBS_DIR}/monero/lib/${ANDROID_ABI}/libdevice.a)
|
||||||
|
|
||||||
|
add_library(device_trezor STATIC IMPORTED)
|
||||||
|
set_target_properties(device_trezor PROPERTIES IMPORTED_LOCATION
|
||||||
|
${EXTERNAL_LIBS_DIR}/monero/lib/${ANDROID_ABI}/libdevice_trezor.a)
|
||||||
|
|
||||||
add_library(multisig STATIC IMPORTED)
|
add_library(multisig STATIC IMPORTED)
|
||||||
set_target_properties(multisig PROPERTIES IMPORTED_LOCATION
|
set_target_properties(multisig PROPERTIES IMPORTED_LOCATION
|
||||||
@@ -147,6 +151,10 @@ add_library(version STATIC IMPORTED)
|
|||||||
set_target_properties(version PROPERTIES IMPORTED_LOCATION
|
set_target_properties(version PROPERTIES IMPORTED_LOCATION
|
||||||
${EXTERNAL_LIBS_DIR}/monero/lib/${ANDROID_ABI}/libversion.a)
|
${EXTERNAL_LIBS_DIR}/monero/lib/${ANDROID_ABI}/libversion.a)
|
||||||
|
|
||||||
|
add_library(net STATIC IMPORTED)
|
||||||
|
set_target_properties(net PROPERTIES IMPORTED_LOCATION
|
||||||
|
${EXTERNAL_LIBS_DIR}/monero/lib/${ANDROID_ABI}/libnet.a)
|
||||||
|
|
||||||
#############
|
#############
|
||||||
# System
|
# System
|
||||||
#############
|
#############
|
||||||
@@ -166,6 +174,7 @@ target_link_libraries( monerujo
|
|||||||
mnemonics
|
mnemonics
|
||||||
ringct
|
ringct
|
||||||
ringct_basic
|
ringct_basic
|
||||||
|
net
|
||||||
common
|
common
|
||||||
cncrypto
|
cncrypto
|
||||||
blockchain_db
|
blockchain_db
|
||||||
@@ -176,6 +185,7 @@ target_link_libraries( monerujo
|
|||||||
blocks
|
blocks
|
||||||
checkpoints
|
checkpoints
|
||||||
device
|
device
|
||||||
|
device_trezor
|
||||||
multisig
|
multisig
|
||||||
version
|
version
|
||||||
|
|
||||||
|
@@ -7,8 +7,8 @@ android {
|
|||||||
applicationId "com.m2049r.xmrwallet"
|
applicationId "com.m2049r.xmrwallet"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
versionCode 173
|
versionCode 183
|
||||||
versionName "1.11.3 'Chernushka'"
|
versionName "1.11.13 'Chernushka'"
|
||||||
|
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
externalNativeBuild {
|
externalNativeBuild {
|
||||||
|
@@ -1,88 +0,0 @@
|
|||||||
// Copyright (c) 2017-2018, The Monero Project
|
|
||||||
//
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
|
||||||
// permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
||||||
// conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
||||||
// of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
// materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
|
||||||
// used to endorse or promote products derived from this software without specific
|
|
||||||
// prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
|
||||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
|
||||||
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
|
||||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
//
|
|
||||||
|
|
||||||
#if defined(HAVE_MONERUJO)
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief LedgerFind - find Ledger Device and return it's name
|
|
||||||
* @param buffer - buffer for name of found device
|
|
||||||
* @param len - length of buffer
|
|
||||||
* @return 0 - success
|
|
||||||
* -1 - no device connected / found
|
|
||||||
* -2 - JVM not found
|
|
||||||
*/
|
|
||||||
int LedgerFind(char *buffer, size_t len);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief LedgerExchange - exchange data with Ledger Device
|
|
||||||
* @param command - buffer for data to send
|
|
||||||
* @param cmd_len - length of send to send
|
|
||||||
* @param response - buffer for received data
|
|
||||||
* @param max_resp_len - size of receive buffer
|
|
||||||
*
|
|
||||||
* @return length of received data in response or -1 if error
|
|
||||||
*/
|
|
||||||
int LedgerExchange(unsigned char *command, unsigned int cmd_len, unsigned char *response, unsigned int max_resp_len);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "device_io.hpp"
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
namespace hw {
|
|
||||||
namespace io {
|
|
||||||
class device_io_monerujo: device_io {
|
|
||||||
public:
|
|
||||||
device_io_monerujo() {};
|
|
||||||
~device_io_monerujo() {};
|
|
||||||
|
|
||||||
void init() {};
|
|
||||||
void release() {};
|
|
||||||
|
|
||||||
void connect(void *params) {};
|
|
||||||
void disconnect() {};
|
|
||||||
bool connected() const {return true;}; // monerujo is always connected before it gets here
|
|
||||||
|
|
||||||
// returns number of bytes read or -1 on error
|
|
||||||
int exchange(unsigned char *command, unsigned int cmd_len, unsigned char *response, unsigned int max_resp_len) {
|
|
||||||
return LedgerExchange(command, cmd_len, response, max_resp_len);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //#if defined(HAVE_MONERUJO)
|
|
@@ -39,6 +39,7 @@ static jclass class_WalletListener;
|
|||||||
static jclass class_TransactionInfo;
|
static jclass class_TransactionInfo;
|
||||||
static jclass class_Transfer;
|
static jclass class_Transfer;
|
||||||
static jclass class_Ledger;
|
static jclass class_Ledger;
|
||||||
|
static jclass class_WalletStatus;
|
||||||
|
|
||||||
std::mutex _listenerMutex;
|
std::mutex _listenerMutex;
|
||||||
|
|
||||||
@@ -61,6 +62,8 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) {
|
|||||||
jenv->FindClass("com/m2049r/xmrwallet/model/WalletListener")));
|
jenv->FindClass("com/m2049r/xmrwallet/model/WalletListener")));
|
||||||
class_Ledger = static_cast<jclass>(jenv->NewGlobalRef(
|
class_Ledger = static_cast<jclass>(jenv->NewGlobalRef(
|
||||||
jenv->FindClass("com/m2049r/xmrwallet/ledger/Ledger")));
|
jenv->FindClass("com/m2049r/xmrwallet/ledger/Ledger")));
|
||||||
|
class_WalletStatus = static_cast<jclass>(jenv->NewGlobalRef(
|
||||||
|
jenv->FindClass("com/m2049r/xmrwallet/model/Wallet$Status")));
|
||||||
return JNI_VERSION_1_6;
|
return JNI_VERSION_1_6;
|
||||||
}
|
}
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@@ -581,10 +584,25 @@ Java_com_m2049r_xmrwallet_model_Wallet_getStatusJ(JNIEnv *env, jobject instance)
|
|||||||
return wallet->status();
|
return wallet->status();
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jstring JNICALL
|
jobject newWalletStatusInstance(JNIEnv *env, int status, const std::string &errorString) {
|
||||||
Java_com_m2049r_xmrwallet_model_Wallet_getErrorString(JNIEnv *env, jobject instance) {
|
jmethodID init = env->GetMethodID(class_WalletStatus, "<init>",
|
||||||
|
"(ILjava/lang/String;)V");
|
||||||
|
jstring _errorString = env->NewStringUTF(errorString.c_str());
|
||||||
|
jobject instance = env->NewObject(class_WalletStatus, init, status, _errorString);
|
||||||
|
env->DeleteLocalRef(_errorString);
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
JNIEXPORT jobject JNICALL
|
||||||
|
Java_com_m2049r_xmrwallet_model_Wallet_statusWithErrorString(JNIEnv *env, jobject instance) {
|
||||||
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
|
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
|
||||||
return env->NewStringUTF(wallet->errorString().c_str());
|
|
||||||
|
int status;
|
||||||
|
std::string errorString;
|
||||||
|
wallet->statusWithErrorString(status, errorString);
|
||||||
|
|
||||||
|
return newWalletStatusInstance(env, status, errorString);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL
|
JNIEXPORT jboolean JNICALL
|
||||||
@@ -1292,7 +1310,6 @@ Java_com_m2049r_xmrwallet_model_PendingTransaction_getFirstTxIdJ(JNIEnv *env, jo
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
JNIEXPORT jlong JNICALL
|
JNIEXPORT jlong JNICALL
|
||||||
Java_com_m2049r_xmrwallet_model_PendingTransaction_getTxCount(JNIEnv *env, jobject instance) {
|
Java_com_m2049r_xmrwallet_model_PendingTransaction_getTxCount(JNIEnv *env, jobject instance) {
|
||||||
Bitmonero::PendingTransaction *tx = getHandle<Bitmonero::PendingTransaction>(env, instance);
|
Bitmonero::PendingTransaction *tx = getHandle<Bitmonero::PendingTransaction>(env, instance);
|
||||||
@@ -1378,12 +1395,15 @@ Java_com_m2049r_xmrwallet_model_WalletManager_setLogLevel(JNIEnv *env, jclass cl
|
|||||||
Bitmonero::WalletManagerFactory::setLogLevel(level);
|
Bitmonero::WalletManagerFactory::setLogLevel(level);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jstring JNICALL
|
||||||
|
Java_com_m2049r_xmrwallet_model_WalletManager_moneroVersion(JNIEnv *env, jclass clazz) {
|
||||||
|
return env->NewStringUTF(MONERO_VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Ledger Stuff
|
// Ledger Stuff
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "device_io_monerujo.hpp"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief LedgerExchange - exchange data with Ledger Device
|
* @brief LedgerExchange - exchange data with Ledger Device
|
||||||
* @param command - buffer for data to send
|
* @param command - buffer for data to send
|
||||||
@@ -1417,7 +1437,7 @@ int LedgerExchange(
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
jsize len = jenv->GetArrayLength(dataRecv);
|
jsize len = jenv->GetArrayLength(dataRecv);
|
||||||
LOGD("LedgerExchange SCARD_S_SUCCESS %ld/%d", cmd_len, len);
|
LOGD("LedgerExchange SCARD_S_SUCCESS %u/%d", cmd_len, len);
|
||||||
if (len <= max_resp_len) {
|
if (len <= max_resp_len) {
|
||||||
jenv->GetByteArrayRegion(dataRecv, 0, len, (jbyte *) response);
|
jenv->GetByteArrayRegion(dataRecv, 0, len, (jbyte *) response);
|
||||||
jenv->DeleteLocalRef(dataRecv);
|
jenv->DeleteLocalRef(dataRecv);
|
||||||
|
@@ -54,6 +54,8 @@ extern "C"
|
|||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern const char* const MONERO_VERSION; // the actual monero core version
|
||||||
|
|
||||||
// from monero-core crypto/hash-ops.h - avoid #including monero code here
|
// from monero-core crypto/hash-ops.h - avoid #including monero code here
|
||||||
enum {
|
enum {
|
||||||
HASH_SIZE = 32,
|
HASH_SIZE = 32,
|
||||||
|
@@ -46,8 +46,12 @@ public class BTChipTransportAndroidHID implements BTChipTransport {
|
|||||||
HashMap<String, UsbDevice> deviceList = manager.getDeviceList();
|
HashMap<String, UsbDevice> deviceList = manager.getDeviceList();
|
||||||
for (UsbDevice device : deviceList.values()) {
|
for (UsbDevice device : deviceList.values()) {
|
||||||
Timber.d("%04X:%04X %s, %s", device.getVendorId(), device.getProductId(), device.getManufacturerName(), device.getProductName());
|
Timber.d("%04X:%04X %s, %s", device.getVendorId(), device.getProductId(), device.getManufacturerName(), device.getProductName());
|
||||||
if ((device.getVendorId() == VID) && (device.getProductId() == PID_HID)) {
|
if (device.getVendorId() == VID) {
|
||||||
return device;
|
final int deviceProductId = device.getProductId();
|
||||||
|
for (int pid : PID_HIDS) {
|
||||||
|
if (deviceProductId == pid)
|
||||||
|
return device;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -74,7 +78,7 @@ public class BTChipTransportAndroidHID implements BTChipTransport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final int VID = 0x2C97;
|
private static final int VID = 0x2C97;
|
||||||
private static final int PID_HID = 0x0001;
|
private static final int[] PID_HIDS = {0x0001, 0x0004};
|
||||||
|
|
||||||
private UsbDeviceConnection connection;
|
private UsbDeviceConnection connection;
|
||||||
private UsbInterface dongleInterface;
|
private UsbInterface dongleInterface;
|
||||||
|
@@ -682,8 +682,7 @@ public class GenerateFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// set FLAG_SECURE to prevent screenshots in Release Mode
|
if (Helper.preventScreenshot()) {
|
||||||
if (!(BuildConfig.DEBUG && BuildConfig.FLAVOR_type.equals("alpha"))) {
|
|
||||||
ledgerDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
|
ledgerDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -55,6 +55,8 @@ import com.m2049r.xmrwallet.util.KeyStoreHelper;
|
|||||||
import com.m2049r.xmrwallet.util.MoneroThreadPoolExecutor;
|
import com.m2049r.xmrwallet.util.MoneroThreadPoolExecutor;
|
||||||
import com.m2049r.xmrwallet.widget.Toolbar;
|
import com.m2049r.xmrwallet.widget.Toolbar;
|
||||||
|
|
||||||
|
import java.text.NumberFormat;
|
||||||
|
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
public class GenerateReviewFragment extends Fragment {
|
public class GenerateReviewFragment extends Fragment {
|
||||||
@@ -72,6 +74,7 @@ public class GenerateReviewFragment extends Fragment {
|
|||||||
private TextView tvWalletPassword;
|
private TextView tvWalletPassword;
|
||||||
private TextView tvWalletAddress;
|
private TextView tvWalletAddress;
|
||||||
private TextView tvWalletMnemonic;
|
private TextView tvWalletMnemonic;
|
||||||
|
private TextView tvWalletHeight;
|
||||||
private TextView tvWalletViewKey;
|
private TextView tvWalletViewKey;
|
||||||
private TextView tvWalletSpendKey;
|
private TextView tvWalletSpendKey;
|
||||||
private ImageButton bCopyAddress;
|
private ImageButton bCopyAddress;
|
||||||
@@ -99,6 +102,7 @@ public class GenerateReviewFragment extends Fragment {
|
|||||||
tvWalletViewKey = view.findViewById(R.id.tvWalletViewKey);
|
tvWalletViewKey = view.findViewById(R.id.tvWalletViewKey);
|
||||||
tvWalletSpendKey = view.findViewById(R.id.tvWalletSpendKey);
|
tvWalletSpendKey = view.findViewById(R.id.tvWalletSpendKey);
|
||||||
tvWalletMnemonic = view.findViewById(R.id.tvWalletMnemonic);
|
tvWalletMnemonic = view.findViewById(R.id.tvWalletMnemonic);
|
||||||
|
tvWalletHeight = view.findViewById(R.id.tvWalletHeight);
|
||||||
bCopyAddress = view.findViewById(R.id.bCopyAddress);
|
bCopyAddress = view.findViewById(R.id.bCopyAddress);
|
||||||
bAdvancedInfo = view.findViewById(R.id.bAdvancedInfo);
|
bAdvancedInfo = view.findViewById(R.id.bAdvancedInfo);
|
||||||
llAdvancedInfo = view.findViewById(R.id.llAdvancedInfo);
|
llAdvancedInfo = view.findViewById(R.id.llAdvancedInfo);
|
||||||
@@ -188,11 +192,12 @@ public class GenerateReviewFragment extends Fragment {
|
|||||||
private class AsyncShow extends AsyncTask<String, Void, Boolean> {
|
private class AsyncShow extends AsyncTask<String, Void, Boolean> {
|
||||||
String name;
|
String name;
|
||||||
String address;
|
String address;
|
||||||
|
long height;
|
||||||
String seed;
|
String seed;
|
||||||
String viewKey;
|
String viewKey;
|
||||||
String spendKey;
|
String spendKey;
|
||||||
boolean isWatchOnly;
|
boolean isWatchOnly;
|
||||||
Wallet.Status status;
|
Wallet.Status walletStatus;
|
||||||
|
|
||||||
boolean dialogOpened = false;
|
boolean dialogOpened = false;
|
||||||
|
|
||||||
@@ -224,14 +229,15 @@ public class GenerateReviewFragment extends Fragment {
|
|||||||
closeWallet = true;
|
closeWallet = true;
|
||||||
}
|
}
|
||||||
name = wallet.getName();
|
name = wallet.getName();
|
||||||
status = wallet.getStatus();
|
walletStatus = wallet.getStatus();
|
||||||
if (status != Wallet.Status.Status_Ok) {
|
if (!walletStatus.isOk()) {
|
||||||
Timber.e(wallet.getErrorString());
|
Timber.e(walletStatus.getErrorString());
|
||||||
if (closeWallet) wallet.close();
|
if (closeWallet) wallet.close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
address = wallet.getAddress();
|
address = wallet.getAddress();
|
||||||
|
height = wallet.getRestoreHeight();
|
||||||
seed = wallet.getSeed();
|
seed = wallet.getSeed();
|
||||||
switch (wallet.getDeviceType()) {
|
switch (wallet.getDeviceType()) {
|
||||||
case Device_Ledger:
|
case Device_Ledger:
|
||||||
@@ -264,6 +270,7 @@ public class GenerateReviewFragment extends Fragment {
|
|||||||
llPassword.setVisibility(View.VISIBLE);
|
llPassword.setVisibility(View.VISIBLE);
|
||||||
tvWalletPassword.setText(getPassword());
|
tvWalletPassword.setText(getPassword());
|
||||||
tvWalletAddress.setText(address);
|
tvWalletAddress.setText(address);
|
||||||
|
tvWalletHeight.setText(NumberFormat.getInstance().format(height));
|
||||||
if (!seed.isEmpty()) {
|
if (!seed.isEmpty()) {
|
||||||
llMnemonic.setVisibility(View.VISIBLE);
|
llMnemonic.setVisibility(View.VISIBLE);
|
||||||
tvWalletMnemonic.setText(seed);
|
tvWalletMnemonic.setText(seed);
|
||||||
@@ -287,10 +294,11 @@ public class GenerateReviewFragment extends Fragment {
|
|||||||
GenerateReviewFragment.VIEW_TYPE_ACCEPT.equals(type) ? Toolbar.BUTTON_NONE : Toolbar.BUTTON_BACK);
|
GenerateReviewFragment.VIEW_TYPE_ACCEPT.equals(type) ? Toolbar.BUTTON_NONE : Toolbar.BUTTON_BACK);
|
||||||
} else {
|
} else {
|
||||||
// TODO show proper error message and/or end the fragment?
|
// TODO show proper error message and/or end the fragment?
|
||||||
tvWalletAddress.setText(status.toString());
|
tvWalletAddress.setText(walletStatus.toString());
|
||||||
tvWalletMnemonic.setText(status.toString());
|
tvWalletHeight.setText(walletStatus.toString());
|
||||||
tvWalletViewKey.setText(status.toString());
|
tvWalletMnemonic.setText(walletStatus.toString());
|
||||||
tvWalletSpendKey.setText(status.toString());
|
tvWalletViewKey.setText(walletStatus.toString());
|
||||||
|
tvWalletSpendKey.setText(walletStatus.toString());
|
||||||
}
|
}
|
||||||
hideProgress();
|
hideProgress();
|
||||||
}
|
}
|
||||||
@@ -414,12 +422,13 @@ public class GenerateReviewFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean ok = false;
|
boolean ok = false;
|
||||||
if (wallet.getStatus() == Wallet.Status.Status_Ok) {
|
Wallet.Status walletStatus = wallet.getStatus();
|
||||||
|
if (walletStatus.isOk()) {
|
||||||
wallet.setPassword(newPassword);
|
wallet.setPassword(newPassword);
|
||||||
wallet.store();
|
wallet.store();
|
||||||
ok = true;
|
ok = true;
|
||||||
} else {
|
} else {
|
||||||
Timber.e(wallet.getErrorString());
|
Timber.e(walletStatus.getErrorString());
|
||||||
}
|
}
|
||||||
if (closeWallet) wallet.close();
|
if (closeWallet) wallet.close();
|
||||||
return ok;
|
return ok;
|
||||||
@@ -621,8 +630,8 @@ public class GenerateReviewFragment extends Fragment {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// set FLAG_SECURE to prevent screenshots in Release Mode
|
|
||||||
if (!(BuildConfig.DEBUG && BuildConfig.FLAVOR_type.equals("alpha"))) {
|
if (Helper.preventScreenshot()) {
|
||||||
openDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
|
openDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -918,6 +918,16 @@ public class LoginActivity extends BaseActivity
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean checkAndCloseWallet(Wallet aWallet) {
|
||||||
|
Wallet.Status walletStatus = aWallet.getStatus();
|
||||||
|
if (!walletStatus.isOk()) {
|
||||||
|
Timber.e(walletStatus.getErrorString());
|
||||||
|
toast(walletStatus.getErrorString());
|
||||||
|
}
|
||||||
|
aWallet.close();
|
||||||
|
return walletStatus.isOk();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGenerate(final String name, final String password) {
|
public void onGenerate(final String name, final String password) {
|
||||||
createWallet(name, password,
|
createWallet(name, password,
|
||||||
@@ -929,15 +939,13 @@ public class LoginActivity extends BaseActivity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean createWallet(File aFile, String password) {
|
public boolean createWallet(File aFile, String password) {
|
||||||
|
NodeInfo currentNode = getNode();
|
||||||
|
// get it from the connected node if we have one, and go back ca. 4 days
|
||||||
|
final long restoreHeight =
|
||||||
|
(currentNode != null) ? currentNode.getHeight() - 2000 : -1;
|
||||||
Wallet newWallet = WalletManager.getInstance()
|
Wallet newWallet = WalletManager.getInstance()
|
||||||
.createWallet(aFile, password, MNEMONIC_LANGUAGE);
|
.createWallet(aFile, password, MNEMONIC_LANGUAGE, restoreHeight);
|
||||||
boolean success = (newWallet.getStatus() == Wallet.Status.Status_Ok);
|
return checkAndCloseWallet(newWallet);
|
||||||
if (!success) {
|
|
||||||
Timber.e(newWallet.getErrorString());
|
|
||||||
toast(newWallet.getErrorString());
|
|
||||||
}
|
|
||||||
newWallet.close();
|
|
||||||
return success;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -956,13 +964,7 @@ public class LoginActivity extends BaseActivity
|
|||||||
public boolean createWallet(File aFile, String password) {
|
public boolean createWallet(File aFile, String password) {
|
||||||
Wallet newWallet = WalletManager.getInstance()
|
Wallet newWallet = WalletManager.getInstance()
|
||||||
.recoveryWallet(aFile, password, seed, restoreHeight);
|
.recoveryWallet(aFile, password, seed, restoreHeight);
|
||||||
boolean success = (newWallet.getStatus() == Wallet.Status.Status_Ok);
|
return checkAndCloseWallet(newWallet);
|
||||||
if (!success) {
|
|
||||||
Timber.e(newWallet.getErrorString());
|
|
||||||
toast(newWallet.getErrorString());
|
|
||||||
}
|
|
||||||
newWallet.close();
|
|
||||||
return success;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -982,13 +984,7 @@ public class LoginActivity extends BaseActivity
|
|||||||
Wallet newWallet = WalletManager.getInstance()
|
Wallet newWallet = WalletManager.getInstance()
|
||||||
.createWalletFromDevice(aFile, password,
|
.createWalletFromDevice(aFile, password,
|
||||||
restoreHeight, "Ledger");
|
restoreHeight, "Ledger");
|
||||||
boolean success = (newWallet.getStatus() == Wallet.Status.Status_Ok);
|
return checkAndCloseWallet(newWallet);
|
||||||
if (!success) {
|
|
||||||
Timber.e(newWallet.getErrorString());
|
|
||||||
toast(newWallet.getErrorString());
|
|
||||||
}
|
|
||||||
newWallet.close();
|
|
||||||
return success;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1009,13 +1005,7 @@ public class LoginActivity extends BaseActivity
|
|||||||
Wallet newWallet = WalletManager.getInstance()
|
Wallet newWallet = WalletManager.getInstance()
|
||||||
.createWalletWithKeys(aFile, password, MNEMONIC_LANGUAGE, restoreHeight,
|
.createWalletWithKeys(aFile, password, MNEMONIC_LANGUAGE, restoreHeight,
|
||||||
address, viewKey, spendKey);
|
address, viewKey, spendKey);
|
||||||
boolean success = (newWallet.getStatus() == Wallet.Status.Status_Ok);
|
return checkAndCloseWallet(newWallet);
|
||||||
if (!success) {
|
|
||||||
Timber.e(newWallet.getErrorString());
|
|
||||||
toast(newWallet.getErrorString());
|
|
||||||
}
|
|
||||||
newWallet.close();
|
|
||||||
return success;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1370,17 +1360,30 @@ public class LoginActivity extends BaseActivity
|
|||||||
if (Ledger.ENABLED)
|
if (Ledger.ENABLED)
|
||||||
try {
|
try {
|
||||||
Ledger.connect(usbManager, usbDevice);
|
Ledger.connect(usbManager, usbDevice);
|
||||||
registerDetachReceiver();
|
if (!Ledger.check()) {
|
||||||
onLedgerAction();
|
Ledger.disconnect();
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Toast.makeText(LoginActivity.this,
|
Toast.makeText(LoginActivity.this,
|
||||||
getString(R.string.toast_ledger_attached, usbDevice.getProductName()),
|
getString(R.string.toast_ledger_start_app, usbDevice.getProductName()),
|
||||||
Toast.LENGTH_SHORT)
|
Toast.LENGTH_SHORT)
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
registerDetachReceiver();
|
||||||
|
onLedgerAction();
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Toast.makeText(LoginActivity.this,
|
||||||
|
getString(R.string.toast_ledger_attached, usbDevice.getProductName()),
|
||||||
|
Toast.LENGTH_SHORT)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
@@ -439,10 +439,13 @@ public class LoginFragment extends Fragment implements WalletInfoAdapter.OnInter
|
|||||||
}
|
}
|
||||||
Collections.sort(nodesToTest, NodeInfo.BestNodeComparator);
|
Collections.sort(nodesToTest, NodeInfo.BestNodeComparator);
|
||||||
NodeInfo bestNode = nodesToTest.get(0);
|
NodeInfo bestNode = nodesToTest.get(0);
|
||||||
if (bestNode.isValid())
|
if (bestNode.isValid()) {
|
||||||
return nodesToTest.get(0);
|
activityCallback.setNode(bestNode);
|
||||||
else
|
return bestNode;
|
||||||
|
} else {
|
||||||
|
activityCallback.setNode(null);
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -450,7 +453,6 @@ public class LoginFragment extends Fragment implements WalletInfoAdapter.OnInter
|
|||||||
if (!isAdded()) return;
|
if (!isAdded()) return;
|
||||||
pbNode.setVisibility(View.INVISIBLE);
|
pbNode.setVisibility(View.INVISIBLE);
|
||||||
llNode.setVisibility(View.VISIBLE);
|
llNode.setVisibility(View.VISIBLE);
|
||||||
activityCallback.setNode(result);
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
Timber.d("found a good node %s", result.toString());
|
Timber.d("found a good node %s", result.toString());
|
||||||
showNode(result);
|
showNode(result);
|
||||||
|
@@ -506,8 +506,8 @@ public class NodeFragment extends Fragment
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// set FLAG_SECURE to prevent screenshots in Release Mode
|
|
||||||
if (!(BuildConfig.DEBUG && BuildConfig.FLAVOR_type.equals("alpha"))) {
|
if (Helper.preventScreenshot()) {
|
||||||
editDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
|
editDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -302,7 +302,7 @@ public class ReceiveFragment extends Fragment {
|
|||||||
File imagePath = new File(getActivity().getCacheDir(), "images");
|
File imagePath = new File(getActivity().getCacheDir(), "images");
|
||||||
File png = new File(imagePath, "QR.png");
|
File png = new File(imagePath, "QR.png");
|
||||||
Uri contentUri = FileProvider.getUriForFile(getActivity(),
|
Uri contentUri = FileProvider.getUriForFile(getActivity(),
|
||||||
"com.m2049r.xmrwallet.fileprovider", png);
|
BuildConfig.APPLICATION_ID + ".fileprovider", png);
|
||||||
if (contentUri != null) {
|
if (contentUri != null) {
|
||||||
Intent shareIntent = new Intent();
|
Intent shareIntent = new Intent();
|
||||||
shareIntent.setAction(Intent.ACTION_SEND);
|
shareIntent.setAction(Intent.ACTION_SEND);
|
||||||
@@ -574,6 +574,7 @@ public class ReceiveFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
Timber.d("onPause()");
|
Timber.d("onPause()");
|
||||||
|
Helper.hideKeyboard(getActivity());
|
||||||
super.onPause();
|
super.onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,6 +21,7 @@ import android.os.Bundle;
|
|||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import com.m2049r.xmrwallet.util.Helper;
|
||||||
import com.m2049r.xmrwallet.util.LocaleHelper;
|
import com.m2049r.xmrwallet.util.LocaleHelper;
|
||||||
|
|
||||||
import static android.view.WindowManager.LayoutParams;
|
import static android.view.WindowManager.LayoutParams;
|
||||||
@@ -30,8 +31,7 @@ public abstract class SecureActivity extends AppCompatActivity {
|
|||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
// set FLAG_SECURE to prevent screenshots in Release Mode
|
if (Helper.preventScreenshot()) {
|
||||||
if (!(BuildConfig.DEBUG && BuildConfig.FLAVOR_type.equals("alpha"))) {
|
|
||||||
getWindow().setFlags(LayoutParams.FLAG_SECURE, LayoutParams.FLAG_SECURE);
|
getWindow().setFlags(LayoutParams.FLAG_SECURE, LayoutParams.FLAG_SECURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -71,7 +71,6 @@ public class TxFragment extends Fragment {
|
|||||||
private TextView tvTxFee;
|
private TextView tvTxFee;
|
||||||
private TextView tvTxTransfers;
|
private TextView tvTxTransfers;
|
||||||
private TextView etTxNotes;
|
private TextView etTxNotes;
|
||||||
private Button bTxNotes;
|
|
||||||
|
|
||||||
// XMRTO stuff
|
// XMRTO stuff
|
||||||
private View cvXmrTo;
|
private View cvXmrTo;
|
||||||
@@ -102,21 +101,9 @@ public class TxFragment extends Fragment {
|
|||||||
tvTxFee = view.findViewById(R.id.tvTxFee);
|
tvTxFee = view.findViewById(R.id.tvTxFee);
|
||||||
tvTxTransfers = view.findViewById(R.id.tvTxTransfers);
|
tvTxTransfers = view.findViewById(R.id.tvTxTransfers);
|
||||||
etTxNotes = view.findViewById(R.id.etTxNotes);
|
etTxNotes = view.findViewById(R.id.etTxNotes);
|
||||||
bTxNotes = view.findViewById(R.id.bTxNotes);
|
|
||||||
|
|
||||||
etTxNotes.setRawInputType(InputType.TYPE_CLASS_TEXT);
|
etTxNotes.setRawInputType(InputType.TYPE_CLASS_TEXT);
|
||||||
|
|
||||||
bTxNotes.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
info.notes = null; // force reload on next view
|
|
||||||
bTxNotes.setEnabled(false);
|
|
||||||
etTxNotes.setEnabled(false);
|
|
||||||
userNotes.setNote(etTxNotes.getText().toString());
|
|
||||||
activityCallback.onSetNote(info.hash, userNotes.txNotes);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
tvTxXmrToKey.setOnClickListener(new View.OnClickListener() {
|
tvTxXmrToKey.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@@ -131,14 +118,6 @@ public class TxFragment extends Fragment {
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onNotesSet(boolean reload) {
|
|
||||||
bTxNotes.setEnabled(true);
|
|
||||||
etTxNotes.setEnabled(true);
|
|
||||||
if (reload) {
|
|
||||||
loadNotes(this.info);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void shareTxInfo() {
|
void shareTxInfo() {
|
||||||
if (this.info == null) return;
|
if (this.info == null) return;
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
@@ -315,7 +294,6 @@ public class TxFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -337,9 +315,9 @@ public class TxFragment extends Fragment {
|
|||||||
|
|
||||||
String getTxNotes(String hash);
|
String getTxNotes(String hash);
|
||||||
|
|
||||||
String getTxAddress(int major, int minor);
|
boolean setTxNotes(String txId, String txNotes);
|
||||||
|
|
||||||
void onSetNote(String txId, String notes);
|
String getTxAddress(int major, int minor);
|
||||||
|
|
||||||
void setToolbarButton(int type);
|
void setToolbarButton(int type);
|
||||||
|
|
||||||
@@ -357,4 +335,16 @@ public class TxFragment extends Fragment {
|
|||||||
+ " must implement Listener");
|
+ " must implement Listener");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
if (!etTxNotes.getText().toString().equals(userNotes.note)) { // notes have changed
|
||||||
|
// save them
|
||||||
|
userNotes.setNote(etTxNotes.getText().toString());
|
||||||
|
info.notes = userNotes.txNotes;
|
||||||
|
activityCallback.setTxNotes(info.hash, info.notes);
|
||||||
|
}
|
||||||
|
Helper.hideKeyboard(getActivity());
|
||||||
|
super.onPause();
|
||||||
|
}
|
||||||
|
}
|
@@ -150,8 +150,13 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||||||
final WalletFragment walletFragment = (WalletFragment)
|
final WalletFragment walletFragment = (WalletFragment)
|
||||||
getSupportFragmentManager().findFragmentByTag(WalletFragment.class.getName());
|
getSupportFragmentManager().findFragmentByTag(WalletFragment.class.getName());
|
||||||
if (walletFragment != null) walletFragment.resetDismissedTransactions();
|
if (walletFragment != null) walletFragment.resetDismissedTransactions();
|
||||||
updateAccountsBalance();
|
|
||||||
forceUpdate();
|
forceUpdate();
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
updateAccountsBalance();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -174,6 +179,11 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||||||
return getWallet().getUserNote(txId);
|
return getWallet().getUserNote(txId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setTxNotes(String txId, String txNotes) {
|
||||||
|
return getWallet().setUserNote(txId, txNotes);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTxAddress(int major, int minor) {
|
public String getTxAddress(int major, int minor) {
|
||||||
return getWallet().getSubaddress(major, minor);
|
return getWallet().getSubaddress(major, minor);
|
||||||
@@ -618,23 +628,22 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWalletStarted(final Wallet.ConnectionStatus connStatus) {
|
public void onWalletStarted(final Wallet.Status walletStatus) {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
dismissProgressDialog();
|
dismissProgressDialog();
|
||||||
switch (connStatus) {
|
if (walletStatus == null) {
|
||||||
case ConnectionStatus_Disconnected:
|
// guess what went wrong
|
||||||
Toast.makeText(WalletActivity.this, getString(R.string.status_wallet_connect_failed), Toast.LENGTH_LONG).show();
|
Toast.makeText(WalletActivity.this, getString(R.string.status_wallet_connect_failed), Toast.LENGTH_LONG).show();
|
||||||
break;
|
} else {
|
||||||
case ConnectionStatus_WrongVersion:
|
if (Wallet.ConnectionStatus.ConnectionStatus_WrongVersion == walletStatus.getConnectionStatus())
|
||||||
Toast.makeText(WalletActivity.this, getString(R.string.status_wallet_connect_wrongversion), Toast.LENGTH_LONG).show();
|
Toast.makeText(WalletActivity.this, getString(R.string.status_wallet_connect_wrongversion), Toast.LENGTH_LONG).show();
|
||||||
break;
|
else if (!walletStatus.isOk())
|
||||||
case ConnectionStatus_Connected:
|
Toast.makeText(WalletActivity.this, walletStatus.getErrorString(), Toast.LENGTH_LONG).show();
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (connStatus != Wallet.ConnectionStatus.ConnectionStatus_Connected) {
|
if ((walletStatus == null) || (Wallet.ConnectionStatus.ConnectionStatus_Connected != walletStatus.getConnectionStatus())) {
|
||||||
finish();
|
finish();
|
||||||
} else {
|
} else {
|
||||||
haveWallet = true;
|
haveWallet = true;
|
||||||
@@ -713,26 +722,6 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSetNotes(final boolean success) {
|
|
||||||
try {
|
|
||||||
final TxFragment txFragment = (TxFragment)
|
|
||||||
getSupportFragmentManager().findFragmentById(R.id.fragment_container);
|
|
||||||
runOnUiThread(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
if (!success) {
|
|
||||||
Toast.makeText(WalletActivity.this, getString(R.string.tx_notes_set_failed), Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
txFragment.onNotesSet(success);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (ClassCastException ex) {
|
|
||||||
// not in tx fragment
|
|
||||||
Timber.d(ex.getLocalizedMessage());
|
|
||||||
// never mind
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProgress(final String text) {
|
public void onProgress(final String text) {
|
||||||
try {
|
try {
|
||||||
@@ -794,21 +783,6 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSetNote(String txId, String notes) {
|
|
||||||
if (mIsBound) { // no point in talking to unbound service
|
|
||||||
Intent intent = new Intent(getApplicationContext(), WalletService.class);
|
|
||||||
intent.putExtra(WalletService.REQUEST, WalletService.REQUEST_CMD_SETNOTE);
|
|
||||||
intent.putExtra(WalletService.REQUEST_CMD_SETNOTE_TX, txId);
|
|
||||||
intent.putExtra(WalletService.REQUEST_CMD_SETNOTE_NOTES, notes);
|
|
||||||
startService(intent);
|
|
||||||
Timber.d("SET NOTE request sent");
|
|
||||||
} else {
|
|
||||||
Timber.e("Service not bound");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPrepareSend(final String tag, final TxData txData) {
|
public void onPrepareSend(final String tag, final TxData txData) {
|
||||||
if (mIsBound) { // no point in talking to unbound service
|
if (mIsBound) { // no point in talking to unbound service
|
||||||
@@ -1062,6 +1036,7 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||||||
} else {
|
} else {
|
||||||
tvBalance.setText(null);
|
tvBalance.setText(null);
|
||||||
}
|
}
|
||||||
|
updateAccountsList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateAccountsHeader() {
|
void updateAccountsHeader() {
|
||||||
@@ -1075,8 +1050,11 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||||||
Menu menu = accountsView.getMenu();
|
Menu menu = accountsView.getMenu();
|
||||||
menu.removeGroup(R.id.accounts_list);
|
menu.removeGroup(R.id.accounts_list);
|
||||||
final int n = wallet.getNumAccounts();
|
final int n = wallet.getNumAccounts();
|
||||||
|
final boolean showBalances = (n > 1) && !isStreetMode();
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
final String label = wallet.getAccountLabel(i);
|
final String label = (showBalances ?
|
||||||
|
getString(R.string.label_account, wallet.getAccountLabel(i), Helper.getDisplayAmount(wallet.getBalance(i), 2))
|
||||||
|
: wallet.getAccountLabel(i));
|
||||||
final MenuItem item = menu.add(R.id.accounts_list, getAccountId(i), 2 * i, label);
|
final MenuItem item = menu.add(R.id.accounts_list, getAccountId(i), 2 * i, label);
|
||||||
item.setIcon(R.drawable.ic_account_balance_wallet_black_24dp);
|
item.setIcon(R.drawable.ic_account_balance_wallet_black_24dp);
|
||||||
if (i == wallet.getAccountIndex())
|
if (i == wallet.getAccountIndex())
|
||||||
|
@@ -219,7 +219,7 @@ public class WalletFragment extends Fragment
|
|||||||
if (isExchanging) return; // wait for exchange to finish - it will fire this itself then.
|
if (isExchanging) return; // wait for exchange to finish - it will fire this itself then.
|
||||||
// at this point selection is XMR in case of error
|
// at this point selection is XMR in case of error
|
||||||
String displayB;
|
String displayB;
|
||||||
double amountA = Double.parseDouble(Wallet.getDisplayAmount(unlockedBalance)); // crash if this fails!
|
double amountA = Helper.getDecimalAmount(unlockedBalance).doubleValue();
|
||||||
if (!Helper.CRYPTO.equals(balanceCurrency)) { // not XMR
|
if (!Helper.CRYPTO.equals(balanceCurrency)) { // not XMR
|
||||||
double amountB = amountA * balanceRate;
|
double amountB = amountA * balanceRate;
|
||||||
displayB = Helper.getFormattedAmount(amountB, false);
|
displayB = Helper.getFormattedAmount(amountB, false);
|
||||||
@@ -235,10 +235,10 @@ public class WalletFragment extends Fragment
|
|||||||
private final ExchangeApi exchangeApi = Helper.getExchangeApi();
|
private final ExchangeApi exchangeApi = Helper.getExchangeApi();
|
||||||
|
|
||||||
void refreshBalance() {
|
void refreshBalance() {
|
||||||
double unconfirmedXmr = Double.parseDouble(Helper.getDisplayAmount(balance - unlockedBalance));
|
double unconfirmedXmr = Helper.getDecimalAmount(balance - unlockedBalance).doubleValue();
|
||||||
showUnconfirmed(unconfirmedXmr);
|
showUnconfirmed(unconfirmedXmr);
|
||||||
if (sCurrency.getSelectedItemPosition() == 0) { // XMR
|
if (sCurrency.getSelectedItemPosition() == 0) { // XMR
|
||||||
double amountXmr = Double.parseDouble(Wallet.getDisplayAmount(unlockedBalance)); // assume this cannot fail!
|
double amountXmr = Helper.getDecimalAmount(unlockedBalance).doubleValue();
|
||||||
showBalance(Helper.getFormattedAmount(amountXmr, true));
|
showBalance(Helper.getFormattedAmount(amountXmr, true));
|
||||||
} else { // not XMR
|
} else { // not XMR
|
||||||
String currency = (String) sCurrency.getSelectedItem();
|
String currency = (String) sCurrency.getSelectedItem();
|
||||||
@@ -294,7 +294,7 @@ public class WalletFragment extends Fragment
|
|||||||
|
|
||||||
public void exchangeFailed() {
|
public void exchangeFailed() {
|
||||||
sCurrency.setSelection(0, true); // default to XMR
|
sCurrency.setSelection(0, true); // default to XMR
|
||||||
double amountXmr = Double.parseDouble(Wallet.getDisplayAmount(unlockedBalance)); // assume this cannot fail!
|
double amountXmr = Helper.getDecimalAmount(unlockedBalance).doubleValue();
|
||||||
showBalance(Helper.getFormattedAmount(amountXmr, true));
|
showBalance(Helper.getFormattedAmount(amountXmr, true));
|
||||||
hideExchanging();
|
hideExchanging();
|
||||||
}
|
}
|
||||||
|
@@ -46,7 +46,8 @@ import okhttp3.ResponseBody;
|
|||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
public class NodeInfo extends Node {
|
public class NodeInfo extends Node {
|
||||||
final static public int MIN_MAJOR_VERSION = 9;
|
final static public int MIN_MAJOR_VERSION = 11;
|
||||||
|
final static public String RPC_VERSION = "2.0";
|
||||||
|
|
||||||
private long height = 0;
|
private long height = 0;
|
||||||
private long timestamp = 0;
|
private long timestamp = 0;
|
||||||
@@ -228,9 +229,12 @@ public class NodeInfo extends Node {
|
|||||||
responseCode = response.code();
|
responseCode = response.code();
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
ResponseBody respBody = response.body(); // closed through Response object
|
ResponseBody respBody = response.body(); // closed through Response object
|
||||||
if ((respBody != null) && (respBody.contentLength() < 1000)) { // sanity check
|
if ((respBody != null) && (respBody.contentLength() < 2000)) { // sanity check
|
||||||
final JSONObject json = new JSONObject(
|
final JSONObject json = new JSONObject(
|
||||||
respBody.string());
|
respBody.string());
|
||||||
|
String rpcVersion = json.getString("jsonrpc");
|
||||||
|
if (!RPC_VERSION.equals(rpcVersion))
|
||||||
|
return false;
|
||||||
final JSONObject header = json.getJSONObject(
|
final JSONObject header = json.getJSONObject(
|
||||||
"result").getJSONObject("block_header");
|
"result").getJSONObject("block_header");
|
||||||
height = header.getLong("height");
|
height = header.getLong("height");
|
||||||
|
@@ -28,6 +28,7 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import com.m2049r.xmrwallet.BuildConfig;
|
import com.m2049r.xmrwallet.BuildConfig;
|
||||||
import com.m2049r.xmrwallet.R;
|
import com.m2049r.xmrwallet.R;
|
||||||
|
import com.m2049r.xmrwallet.util.Helper;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@@ -76,8 +77,7 @@ public class ProgressDialog extends AlertDialog {
|
|||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
// set FLAG_SECURE to prevent screenshots in Release Mode
|
if (Helper.preventScreenshot()) {
|
||||||
if (!(BuildConfig.DEBUG && BuildConfig.FLAVOR_type.equals("alpha"))) {
|
|
||||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
|
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -33,7 +33,9 @@ import android.view.ViewGroup;
|
|||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.ImageButton;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.m2049r.xmrwallet.R;
|
import com.m2049r.xmrwallet.R;
|
||||||
import com.m2049r.xmrwallet.data.BarcodeData;
|
import com.m2049r.xmrwallet.data.BarcodeData;
|
||||||
@@ -92,6 +94,7 @@ public class SendAddressWizardFragment extends SendWizardFragment {
|
|||||||
private View llPaymentId;
|
private View llPaymentId;
|
||||||
private TextView tvXmrTo;
|
private TextView tvXmrTo;
|
||||||
private View llXmrTo;
|
private View llXmrTo;
|
||||||
|
private ImageButton bPasteAddress;
|
||||||
|
|
||||||
private boolean resolvingOA = false;
|
private boolean resolvingOA = false;
|
||||||
private boolean resolvingPP = false;
|
private boolean resolvingPP = false;
|
||||||
@@ -197,6 +200,21 @@ public class SendAddressWizardFragment extends SendWizardFragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
bPasteAddress = view.findViewById(R.id.bPasteAddress);
|
||||||
|
bPasteAddress.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
final String clip = Helper.getClipBoardText(getActivity());
|
||||||
|
if (clip == null) return;
|
||||||
|
// clean it up
|
||||||
|
final String address = clip.replaceAll("[^0-9A-Z-a-z]", "");
|
||||||
|
if (Wallet.isAddressValid(address) || BitcoinAddressValidator.validate(address))
|
||||||
|
etAddress.getEditText().setText(address);
|
||||||
|
else
|
||||||
|
Toast.makeText(getActivity(), getString(R.string.send_address_invalid), Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
etPaymentId = view.findViewById(R.id.etPaymentId);
|
etPaymentId = view.findViewById(R.id.etPaymentId);
|
||||||
etPaymentId.getEditText().setRawInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
|
etPaymentId.getEditText().setRawInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
|
||||||
etPaymentId.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
etPaymentId.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
|
@@ -437,8 +437,8 @@ public class SendBtcConfirmWizardFragment extends SendWizardFragment implements
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// set FLAG_SECURE to prevent screenshots in Release Mode
|
|
||||||
if (!(BuildConfig.DEBUG && BuildConfig.FLAVOR_type.equals("alpha"))) {
|
if (Helper.preventScreenshot()) {
|
||||||
passwordDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
|
passwordDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -324,8 +324,8 @@ public class SendConfirmWizardFragment extends SendWizardFragment implements Sen
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// set FLAG_SECURE to prevent screenshots in Release Mode
|
|
||||||
if (!(BuildConfig.DEBUG && BuildConfig.FLAVOR_type.equals("alpha"))) {
|
if (Helper.preventScreenshot()) {
|
||||||
passwordDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
|
passwordDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -30,6 +30,7 @@ import com.m2049r.xmrwallet.model.TransactionInfo;
|
|||||||
import com.m2049r.xmrwallet.util.Helper;
|
import com.m2049r.xmrwallet.util.Helper;
|
||||||
import com.m2049r.xmrwallet.data.UserNotes;
|
import com.m2049r.xmrwallet.data.UserNotes;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
@@ -154,7 +155,7 @@ public class TransactionInfoAdapter extends RecyclerView.Adapter<TransactionInfo
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((infoItem.fee > 0)) {
|
if ((infoItem.fee > 0)) {
|
||||||
String fee = Helper.getDisplayAmount(infoItem.fee, 5);
|
String fee = Helper.getDisplayAmount(infoItem.fee, Helper.DISPLAY_DIGITS_INFO);
|
||||||
tvFee.setText(context.getString(R.string.tx_list_fee, fee));
|
tvFee.setText(context.getString(R.string.tx_list_fee, fee));
|
||||||
tvFee.setVisibility(View.VISIBLE);
|
tvFee.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -134,6 +134,10 @@ public enum Instruction {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public byte getByteValue() {
|
||||||
|
return (byte) (value & 0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
private int value;
|
private int value;
|
||||||
|
|
||||||
Instruction(int value) {
|
Instruction(int value) {
|
||||||
|
@@ -27,22 +27,26 @@ import com.btchip.BTChipException;
|
|||||||
import com.btchip.comm.BTChipTransport;
|
import com.btchip.comm.BTChipTransport;
|
||||||
import com.btchip.comm.android.BTChipTransportAndroidHID;
|
import com.btchip.comm.android.BTChipTransportAndroidHID;
|
||||||
import com.m2049r.xmrwallet.BuildConfig;
|
import com.m2049r.xmrwallet.BuildConfig;
|
||||||
|
import com.m2049r.xmrwallet.model.WalletManager;
|
||||||
import com.m2049r.xmrwallet.util.Helper;
|
import com.m2049r.xmrwallet.util.Helper;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
public class Ledger {
|
public class Ledger {
|
||||||
static final public boolean ENABLED = false;
|
static final public boolean ENABLED = true;
|
||||||
// 5:20 is same as wallet2.cpp::restore()
|
// 5:20 is same as wallet2.cpp::restore()
|
||||||
static public final int LOOKAHEAD_ACCOUNTS = 5;
|
static public final int LOOKAHEAD_ACCOUNTS = 5;
|
||||||
static public final int LOOKAHEAD_SUBADDRESSES = 20;
|
static public final int LOOKAHEAD_SUBADDRESSES = 20;
|
||||||
static public final String SUBADDRESS_LOOKAHEAD = LOOKAHEAD_ACCOUNTS + ":" + LOOKAHEAD_SUBADDRESSES;
|
static public final String SUBADDRESS_LOOKAHEAD = LOOKAHEAD_ACCOUNTS + ":" + LOOKAHEAD_SUBADDRESSES;
|
||||||
|
|
||||||
|
private static final byte PROTOCOL_VERSION = 0x02;
|
||||||
public static final int SW_OK = 0x9000;
|
public static final int SW_OK = 0x9000;
|
||||||
public static final int SW_INS_NOT_SUPPORTED = 0x6D00;
|
public static final int SW_INS_NOT_SUPPORTED = 0x6D00;
|
||||||
public static final int OK[] = {SW_OK};
|
public static final int OK[] = {SW_OK};
|
||||||
|
public static final int MINIMUM_LEDGER_VERSION = (1 << 16) + (3 << 8) + (1); // 1.3.1
|
||||||
|
|
||||||
public static UsbDevice findDevice(UsbManager usbManager) {
|
public static UsbDevice findDevice(UsbManager usbManager) {
|
||||||
if (!ENABLED) return null;
|
if (!ENABLED) return null;
|
||||||
@@ -89,6 +93,21 @@ public class Ledger {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public boolean check() {
|
||||||
|
if (Instance == null) return false;
|
||||||
|
byte[] moneroVersion = WalletManager.moneroVersion().getBytes(StandardCharsets.US_ASCII);
|
||||||
|
|
||||||
|
try {
|
||||||
|
byte[] resp = Instance.exchangeApduNoOpt(Instruction.INS_RESET, moneroVersion, OK);
|
||||||
|
int deviceVersion = (resp[0] << 16) + (resp[1] << 8) + (resp[2]);
|
||||||
|
if (deviceVersion < MINIMUM_LEDGER_VERSION)
|
||||||
|
return false;
|
||||||
|
} catch (BTChipException ex) { // comm error - probably wrong app started on device
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
final private BTChipTransport transport;
|
final private BTChipTransport transport;
|
||||||
final private String name;
|
final private String name;
|
||||||
private int lastSW = 0;
|
private int lastSW = 0;
|
||||||
@@ -112,7 +131,7 @@ public class Ledger {
|
|||||||
synchronized private byte[] exchangeRaw(byte[] apdu) {
|
synchronized private byte[] exchangeRaw(byte[] apdu) {
|
||||||
if (transport == null)
|
if (transport == null)
|
||||||
throw new IllegalStateException("No transport (probably closed previously)");
|
throw new IllegalStateException("No transport (probably closed previously)");
|
||||||
Timber.i("exchangeRaw %02x", apdu[1]);
|
Timber.d("exchangeRaw %02x", apdu[1]);
|
||||||
Instruction ins = Instruction.fromByte(apdu[1]);
|
Instruction ins = Instruction.fromByte(apdu[1]);
|
||||||
if (listener != null) listener.onInstructionSend(ins, apdu);
|
if (listener != null) listener.onInstructionSend(ins, apdu);
|
||||||
sniffOut(ins, apdu);
|
sniffOut(ins, apdu);
|
||||||
@@ -120,7 +139,6 @@ public class Ledger {
|
|||||||
if (listener != null) listener.onInstructionReceive(ins, data);
|
if (listener != null) listener.onInstructionReceive(ins, data);
|
||||||
sniffIn(data);
|
sniffIn(data);
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] exchange(byte[] apdu) throws BTChipException {
|
private byte[] exchange(byte[] apdu) throws BTChipException {
|
||||||
@@ -148,68 +166,19 @@ public class Ledger {
|
|||||||
throw new BTChipException("Invalid status", lastSW);
|
throw new BTChipException("Invalid status", lastSW);
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] exchangeApdu(byte cla, byte ins, byte p1, byte p2, byte[] data, int acceptedSW[]) throws BTChipException {
|
private byte[] exchangeApduNoOpt(Instruction instruction, byte[] data, int acceptedSW[])
|
||||||
byte[] apdu = new byte[data.length + 5];
|
throws BTChipException {
|
||||||
apdu[0] = cla;
|
byte[] apdu = new byte[data.length + 6];
|
||||||
apdu[1] = ins;
|
apdu[0] = PROTOCOL_VERSION;
|
||||||
apdu[2] = p1;
|
apdu[1] = instruction.getByteValue();
|
||||||
apdu[3] = p2;
|
apdu[2] = 0; // p1
|
||||||
apdu[4] = (byte) (data.length);
|
apdu[3] = 0; // p2
|
||||||
System.arraycopy(data, 0, apdu, 5, data.length);
|
apdu[4] = (byte) (data.length + 1); // +1 because the opt byte is part of the data
|
||||||
|
apdu[5] = 0; // opt
|
||||||
|
System.arraycopy(data, 0, apdu, 6, data.length);
|
||||||
return exchangeCheck(apdu, acceptedSW);
|
return exchangeCheck(apdu, acceptedSW);
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] exchangeApdu(byte cla, byte ins, byte p1, byte p2, int length, int acceptedSW[]) throws BTChipException {
|
|
||||||
byte[] apdu = new byte[5];
|
|
||||||
apdu[0] = cla;
|
|
||||||
apdu[1] = ins;
|
|
||||||
apdu[2] = p1;
|
|
||||||
apdu[3] = p2;
|
|
||||||
apdu[4] = (byte) (length);
|
|
||||||
return exchangeCheck(apdu, acceptedSW);
|
|
||||||
}
|
|
||||||
|
|
||||||
private byte[] exchangeApduSplit(byte cla, byte ins, byte p1, byte p2, byte[] data, int acceptedSW[]) throws BTChipException {
|
|
||||||
int offset = 0;
|
|
||||||
byte[] result = null;
|
|
||||||
while (offset < data.length) {
|
|
||||||
int blockLength = ((data.length - offset) > 255 ? 255 : data.length - offset);
|
|
||||||
byte[] apdu = new byte[blockLength + 5];
|
|
||||||
apdu[0] = cla;
|
|
||||||
apdu[1] = ins;
|
|
||||||
apdu[2] = p1;
|
|
||||||
apdu[3] = p2;
|
|
||||||
apdu[4] = (byte) (blockLength);
|
|
||||||
System.arraycopy(data, offset, apdu, 5, blockLength);
|
|
||||||
result = exchangeCheck(apdu, acceptedSW);
|
|
||||||
offset += blockLength;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private byte[] exchangeApduSplit2(byte cla, byte ins, byte p1, byte p2, byte[] data, byte[] data2, int acceptedSW[]) throws BTChipException {
|
|
||||||
int offset = 0;
|
|
||||||
byte[] result = null;
|
|
||||||
int maxBlockSize = 255 - data2.length;
|
|
||||||
while (offset < data.length) {
|
|
||||||
int blockLength = ((data.length - offset) > maxBlockSize ? maxBlockSize : data.length - offset);
|
|
||||||
boolean lastBlock = ((offset + blockLength) == data.length);
|
|
||||||
byte[] apdu = new byte[blockLength + 5 + (lastBlock ? data2.length : 0)];
|
|
||||||
apdu[0] = cla;
|
|
||||||
apdu[1] = ins;
|
|
||||||
apdu[2] = p1;
|
|
||||||
apdu[3] = p2;
|
|
||||||
apdu[4] = (byte) (blockLength + (lastBlock ? data2.length : 0));
|
|
||||||
System.arraycopy(data, offset, apdu, 5, blockLength);
|
|
||||||
if (lastBlock) {
|
|
||||||
System.arraycopy(data2, 0, apdu, 5 + blockLength, data2.length);
|
|
||||||
}
|
|
||||||
result = exchangeCheck(apdu, acceptedSW);
|
|
||||||
offset += blockLength;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface Listener {
|
public interface Listener {
|
||||||
void onInstructionSend(Instruction ins, byte[] apdu);
|
void onInstructionSend(Instruction ins, byte[] apdu);
|
||||||
|
|
||||||
@@ -251,7 +220,6 @@ public class Ledger {
|
|||||||
if (ins == Instruction.INS_GET_KEY) {
|
if (ins == Instruction.INS_GET_KEY) {
|
||||||
snoopKey = (apdu[2] == 2);
|
snoopKey = (apdu[2] == 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sniffIn(byte[] data) {
|
private void sniffIn(byte[] data) {
|
||||||
|
@@ -173,5 +173,4 @@ public class TransactionInfo implements Parcelable, Comparable<TransactionInfo>
|
|||||||
return this.hash.compareTo(another.hash);
|
return this.hash.compareTo(another.hash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package com.m2049r.xmrwallet.model;
|
package com.m2049r.xmrwallet.model;
|
||||||
|
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
import com.m2049r.xmrwallet.data.TxData;
|
import com.m2049r.xmrwallet.data.TxData;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -32,6 +35,47 @@ public class Wallet {
|
|||||||
System.loadLibrary("monerujo");
|
System.loadLibrary("monerujo");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public class Status {
|
||||||
|
Status(int status, String errorString) {
|
||||||
|
this.status = StatusEnum.values()[status];
|
||||||
|
this.errorString = errorString;
|
||||||
|
}
|
||||||
|
|
||||||
|
final private StatusEnum status;
|
||||||
|
final private String errorString;
|
||||||
|
@Nullable
|
||||||
|
private ConnectionStatus connectionStatus; // optional
|
||||||
|
|
||||||
|
public StatusEnum getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getErrorString() {
|
||||||
|
return errorString;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConnectionStatus(@Nullable ConnectionStatus connectionStatus) {
|
||||||
|
this.connectionStatus = connectionStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public ConnectionStatus getConnectionStatus() {
|
||||||
|
return connectionStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isOk() {
|
||||||
|
return (getStatus() == StatusEnum.Status_Ok)
|
||||||
|
&& ((getConnectionStatus() == null) ||
|
||||||
|
(getConnectionStatus() == ConnectionStatus.ConnectionStatus_Connected));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonNull
|
||||||
|
public String toString() {
|
||||||
|
return "Wallet.Status: (" + status + "/" + errorString + ", " + connectionStatus;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private int accountIndex = 0;
|
private int accountIndex = 0;
|
||||||
|
|
||||||
public int getAccountIndex() {
|
public int getAccountIndex() {
|
||||||
@@ -66,7 +110,7 @@ public class Wallet {
|
|||||||
Device_Ledger
|
Device_Ledger
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Status {
|
public enum StatusEnum {
|
||||||
Status_Ok,
|
Status_Ok,
|
||||||
Status_Error,
|
Status_Error,
|
||||||
Status_Critical
|
Status_Critical
|
||||||
@@ -85,12 +129,16 @@ public class Wallet {
|
|||||||
public native void setSeedLanguage(String language);
|
public native void setSeedLanguage(String language);
|
||||||
|
|
||||||
public Status getStatus() {
|
public Status getStatus() {
|
||||||
return Wallet.Status.values()[getStatusJ()];
|
return statusWithErrorString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private native int getStatusJ();
|
public Status getFullStatus() {
|
||||||
|
Wallet.Status walletStatus = statusWithErrorString();
|
||||||
|
walletStatus.setConnectionStatus(getConnectionStatus());
|
||||||
|
return walletStatus;
|
||||||
|
}
|
||||||
|
|
||||||
public native String getErrorString();
|
private native Status statusWithErrorString();
|
||||||
|
|
||||||
public native boolean setPassword(String password);
|
public native boolean setPassword(String password);
|
||||||
|
|
||||||
@@ -353,9 +401,10 @@ public class Wallet {
|
|||||||
if (label.equals(NEW_ACCOUNT_NAME)) {
|
if (label.equals(NEW_ACCOUNT_NAME)) {
|
||||||
String address = getAddress(accountIndex);
|
String address = getAddress(accountIndex);
|
||||||
int len = address.length();
|
int len = address.length();
|
||||||
return address.substring(0, 6) +
|
label = address.substring(0, 6) +
|
||||||
"\u2026" + address.substring(len - 6, len);
|
"\u2026" + address.substring(len - 6, len);
|
||||||
} else return label;
|
}
|
||||||
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSubaddressLabel(int addressIndex) {
|
public String getSubaddressLabel(int addressIndex) {
|
||||||
|
@@ -91,14 +91,16 @@ public class WalletManager {
|
|||||||
managedWallet = null;
|
managedWallet = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Wallet createWallet(File aFile, String password, String language) {
|
public Wallet createWallet(File aFile, String password, String language, long height) {
|
||||||
long walletHandle = createWalletJ(aFile.getAbsolutePath(), password, language, getNetworkType().getValue());
|
long walletHandle = createWalletJ(aFile.getAbsolutePath(), password, language, getNetworkType().getValue());
|
||||||
Wallet wallet = new Wallet(walletHandle);
|
Wallet wallet = new Wallet(walletHandle);
|
||||||
manageWallet(wallet);
|
manageWallet(wallet);
|
||||||
if (wallet.getStatus() == Wallet.Status.Status_Ok) {
|
if (wallet.getStatus().isOk()) {
|
||||||
// (Re-)Estimate restore height based on what we know
|
// (Re-)Estimate restore height based on what we know
|
||||||
long oldHeight = wallet.getRestoreHeight();
|
final long oldHeight = wallet.getRestoreHeight();
|
||||||
wallet.setRestoreHeight(RestoreHeight.getInstance().getHeight(new Date()));
|
final long restoreHeight =
|
||||||
|
(height > -1) ? height : RestoreHeight.getInstance().getHeight(new Date());
|
||||||
|
wallet.setRestoreHeight(restoreHeight);
|
||||||
Timber.d("Changed Restore Height from %d to %d", oldHeight, wallet.getRestoreHeight());
|
Timber.d("Changed Restore Height from %d to %d", oldHeight, wallet.getRestoreHeight());
|
||||||
wallet.setPassword(password); // this rewrites the keys file (which contains the restore height)
|
wallet.setPassword(password); // this rewrites the keys file (which contains the restore height)
|
||||||
}
|
}
|
||||||
@@ -285,7 +287,8 @@ public class WalletManager {
|
|||||||
this.daemonAddress = null;
|
this.daemonAddress = null;
|
||||||
this.daemonUsername = "";
|
this.daemonUsername = "";
|
||||||
this.daemonPassword = "";
|
this.daemonPassword = "";
|
||||||
setDaemonAddressJ("");
|
//setDaemonAddressJ(""); // don't disconnect as monero code blocks for many seconds!
|
||||||
|
//TODO: need to do something about that later
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -351,4 +354,6 @@ public class WalletManager {
|
|||||||
static public native void logWarning(String category, String message);
|
static public native void logWarning(String category, String message);
|
||||||
|
|
||||||
static public native void logError(String category, String message);
|
static public native void logError(String category, String message);
|
||||||
|
|
||||||
|
static public native String moneroVersion();
|
||||||
}
|
}
|
@@ -31,6 +31,7 @@ import android.os.IBinder;
|
|||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.support.annotation.RequiresApi;
|
import android.support.annotation.RequiresApi;
|
||||||
import android.support.v4.app.NotificationCompat;
|
import android.support.v4.app.NotificationCompat;
|
||||||
|
|
||||||
@@ -69,10 +70,6 @@ public class WalletService extends Service {
|
|||||||
public static final String REQUEST_CMD_SEND = "send";
|
public static final String REQUEST_CMD_SEND = "send";
|
||||||
public static final String REQUEST_CMD_SEND_NOTES = "notes";
|
public static final String REQUEST_CMD_SEND_NOTES = "notes";
|
||||||
|
|
||||||
public static final String REQUEST_CMD_SETNOTE = "setnote";
|
|
||||||
public static final String REQUEST_CMD_SETNOTE_TX = "tx";
|
|
||||||
public static final String REQUEST_CMD_SETNOTE_NOTES = "notes";
|
|
||||||
|
|
||||||
public static final int START_SERVICE = 1;
|
public static final int START_SERVICE = 1;
|
||||||
public static final int STOP_SERVICE = 2;
|
public static final int STOP_SERVICE = 2;
|
||||||
|
|
||||||
@@ -224,9 +221,7 @@ public class WalletService extends Service {
|
|||||||
|
|
||||||
void onSendTransactionFailed(String error);
|
void onSendTransactionFailed(String error);
|
||||||
|
|
||||||
void onSetNotes(boolean success);
|
void onWalletStarted(Wallet.Status walletStatus);
|
||||||
|
|
||||||
void onWalletStarted(Wallet.ConnectionStatus walletStatus);
|
|
||||||
|
|
||||||
void onWalletOpen(Wallet.Device device);
|
void onWalletOpen(Wallet.Device device);
|
||||||
}
|
}
|
||||||
@@ -293,9 +288,9 @@ public class WalletService extends Service {
|
|||||||
if (walletId != null) {
|
if (walletId != null) {
|
||||||
showProgress(getString(R.string.status_wallet_loading));
|
showProgress(getString(R.string.status_wallet_loading));
|
||||||
showProgress(10);
|
showProgress(10);
|
||||||
Wallet.ConnectionStatus connStatus = start(walletId, walletPw);
|
Wallet.Status walletStatus = start(walletId, walletPw);
|
||||||
if (observer != null) observer.onWalletStarted(connStatus);
|
if (observer != null) observer.onWalletStarted(walletStatus);
|
||||||
if (connStatus != Wallet.ConnectionStatus.ConnectionStatus_Connected) {
|
if ((walletStatus == null) || !walletStatus.isOk()) {
|
||||||
errorState = true;
|
errorState = true;
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
@@ -306,7 +301,7 @@ public class WalletService extends Service {
|
|||||||
boolean rc = myWallet.store();
|
boolean rc = myWallet.store();
|
||||||
Timber.d("wallet stored: %s with rc=%b", myWallet.getName(), rc);
|
Timber.d("wallet stored: %s with rc=%b", myWallet.getName(), rc);
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
Timber.w("Wallet store failed: %s", myWallet.getErrorString());
|
Timber.w("Wallet store failed: %s", myWallet.getStatus().getErrorString());
|
||||||
}
|
}
|
||||||
if (observer != null) observer.onWalletStored(rc);
|
if (observer != null) observer.onWalletStored(rc);
|
||||||
} else if (cmd.equals(REQUEST_CMD_TX)) {
|
} else if (cmd.equals(REQUEST_CMD_TX)) {
|
||||||
@@ -368,7 +363,7 @@ public class WalletService extends Service {
|
|||||||
boolean rc = myWallet.store();
|
boolean rc = myWallet.store();
|
||||||
Timber.d("wallet stored: %s with rc=%b", myWallet.getName(), rc);
|
Timber.d("wallet stored: %s with rc=%b", myWallet.getName(), rc);
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
Timber.w("Wallet store failed: %s", myWallet.getErrorString());
|
Timber.w("Wallet store failed: %s", myWallet.getStatus().getErrorString());
|
||||||
}
|
}
|
||||||
if (observer != null) observer.onWalletStored(rc);
|
if (observer != null) observer.onWalletStored(rc);
|
||||||
listener.updated = true;
|
listener.updated = true;
|
||||||
@@ -378,26 +373,6 @@ public class WalletService extends Service {
|
|||||||
if (observer != null) observer.onSendTransactionFailed(error);
|
if (observer != null) observer.onSendTransactionFailed(error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (cmd.equals(REQUEST_CMD_SETNOTE)) {
|
|
||||||
Wallet myWallet = getWallet();
|
|
||||||
Timber.d("SET NOTE for wallet: %s", myWallet.getName());
|
|
||||||
String txId = extras.getString(REQUEST_CMD_SETNOTE_TX);
|
|
||||||
String notes = extras.getString(REQUEST_CMD_SETNOTE_NOTES);
|
|
||||||
if ((txId != null) && (notes != null)) {
|
|
||||||
boolean success = myWallet.setUserNote(txId, notes);
|
|
||||||
if (!success) {
|
|
||||||
Timber.e(myWallet.getErrorString());
|
|
||||||
}
|
|
||||||
if (observer != null) observer.onSetNotes(success);
|
|
||||||
if (success) {
|
|
||||||
boolean rc = myWallet.store();
|
|
||||||
Timber.d("wallet stored: %s with rc=%b", myWallet.getName(), rc);
|
|
||||||
if (!rc) {
|
|
||||||
Timber.w("Wallet store failed: %s", myWallet.getErrorString());
|
|
||||||
}
|
|
||||||
if (observer != null) observer.onWalletStored(rc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -490,7 +465,8 @@ public class WalletService extends Service {
|
|||||||
return true; // true is important so that onUnbind is also called next time
|
return true; // true is important so that onUnbind is also called next time
|
||||||
}
|
}
|
||||||
|
|
||||||
private Wallet.ConnectionStatus start(String walletName, String walletPassword) {
|
@Nullable
|
||||||
|
private Wallet.Status start(String walletName, String walletPassword) {
|
||||||
Timber.d("start()");
|
Timber.d("start()");
|
||||||
startNotfication();
|
startNotfication();
|
||||||
showProgress(getString(R.string.status_wallet_loading));
|
showProgress(getString(R.string.status_wallet_loading));
|
||||||
@@ -498,11 +474,11 @@ public class WalletService extends Service {
|
|||||||
if (listener == null) {
|
if (listener == null) {
|
||||||
Timber.d("start() loadWallet");
|
Timber.d("start() loadWallet");
|
||||||
Wallet aWallet = loadWallet(walletName, walletPassword);
|
Wallet aWallet = loadWallet(walletName, walletPassword);
|
||||||
Wallet.ConnectionStatus connStatus = Wallet.ConnectionStatus.ConnectionStatus_Disconnected;
|
if (aWallet == null) return null;
|
||||||
if (aWallet != null) connStatus = aWallet.getConnectionStatus();
|
Wallet.Status walletStatus = aWallet.getFullStatus();
|
||||||
if (connStatus != Wallet.ConnectionStatus.ConnectionStatus_Connected) {
|
if (!walletStatus.isOk()) {
|
||||||
if (aWallet != null) aWallet.close();
|
aWallet.close();
|
||||||
return connStatus;
|
return walletStatus;
|
||||||
}
|
}
|
||||||
listener = new MyWalletListener();
|
listener = new MyWalletListener();
|
||||||
listener.start();
|
listener.start();
|
||||||
@@ -513,7 +489,7 @@ public class WalletService extends Service {
|
|||||||
// if we try to refresh the history here we get occasional segfaults!
|
// if we try to refresh the history here we get occasional segfaults!
|
||||||
// doesnt matter since we update as soon as we get a new block anyway
|
// doesnt matter since we update as soon as we get a new block anyway
|
||||||
Timber.d("start() done");
|
Timber.d("start() done");
|
||||||
return Wallet.ConnectionStatus.ConnectionStatus_Connected;
|
return getWallet().getFullStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
@@ -558,10 +534,9 @@ public class WalletService extends Service {
|
|||||||
wallet = walletMgr.openWallet(path, walletPassword);
|
wallet = walletMgr.openWallet(path, walletPassword);
|
||||||
showProgress(60);
|
showProgress(60);
|
||||||
Timber.d("wallet opened");
|
Timber.d("wallet opened");
|
||||||
Wallet.Status status = wallet.getStatus();
|
Wallet.Status walletStatus = wallet.getStatus();
|
||||||
Timber.d("wallet status is %s", status);
|
if (!walletStatus.isOk()) {
|
||||||
if (status != Wallet.Status.Status_Ok) {
|
Timber.d("wallet status is %s", walletStatus);
|
||||||
Timber.d("wallet status is %s", status);
|
|
||||||
WalletManager.getInstance().close(wallet); // TODO close() failed?
|
WalletManager.getInstance().close(wallet); // TODO close() failed?
|
||||||
wallet = null;
|
wallet = null;
|
||||||
// TODO what do we do with the progress??
|
// TODO what do we do with the progress??
|
||||||
|
@@ -21,6 +21,7 @@ import android.app.Activity;
|
|||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.ClipData;
|
import android.content.ClipData;
|
||||||
|
import android.content.ClipDescription;
|
||||||
import android.content.ClipboardManager;
|
import android.content.ClipboardManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
@@ -64,6 +65,7 @@ import com.m2049r.xmrwallet.service.exchange.api.ExchangeApi;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.SocketTimeoutException;
|
import java.net.SocketTimeoutException;
|
||||||
@@ -186,28 +188,23 @@ public class Helper {
|
|||||||
act.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
|
act.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public BigDecimal getDecimalAmount(long amount) {
|
||||||
|
return new BigDecimal(amount).scaleByPowerOfTen(-12);
|
||||||
|
}
|
||||||
|
|
||||||
static public String getDisplayAmount(long amount) {
|
static public String getDisplayAmount(long amount) {
|
||||||
return getDisplayAmount(amount, 12);
|
return getDisplayAmount(amount, 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public String getDisplayAmount(long amount, int maxDecimals) {
|
static public String getDisplayAmount(long amount, int maxDecimals) {
|
||||||
return getDisplayAmount(Wallet.getDisplayAmount(amount), maxDecimals);
|
// a Java bug does not strip zeros properly if the value is 0
|
||||||
}
|
if (amount == 0) return "0.00";
|
||||||
|
BigDecimal d = getDecimalAmount(amount)
|
||||||
// amountString must have '.' as decimal point
|
.setScale(maxDecimals, BigDecimal.ROUND_HALF_UP)
|
||||||
private static String getDisplayAmount(String amountString, int maxDecimals) {
|
.stripTrailingZeros();
|
||||||
int lastZero = 0;
|
if (d.scale() < 2)
|
||||||
int decimal = 0;
|
d = d.setScale(2, BigDecimal.ROUND_UNNECESSARY);
|
||||||
for (int i = amountString.length() - 1; i >= 0; i--) {
|
return d.toPlainString();
|
||||||
if ((lastZero == 0) && (amountString.charAt(i) != '0')) lastZero = i + 1;
|
|
||||||
// TODO i18n
|
|
||||||
if (amountString.charAt(i) == '.') {
|
|
||||||
decimal = i + 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int cutoff = Math.min(Math.max(lastZero, decimal + 2), decimal + maxDecimals);
|
|
||||||
return amountString.substring(0, cutoff);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static public String getFormattedAmount(double amount, boolean isXmr) {
|
static public String getFormattedAmount(double amount, boolean isXmr) {
|
||||||
@@ -285,6 +282,21 @@ public class Helper {
|
|||||||
clipboardManager.setPrimaryClip(clip);
|
clipboardManager.setPrimaryClip(clip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public String getClipBoardText(Context context) {
|
||||||
|
final ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
|
try {
|
||||||
|
if (clipboardManager.hasPrimaryClip()
|
||||||
|
&& clipboardManager.getPrimaryClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
|
||||||
|
final ClipData.Item item = clipboardManager.getPrimaryClip().getItemAt(0);
|
||||||
|
return item.getText().toString();
|
||||||
|
}
|
||||||
|
} catch (NullPointerException ex) {
|
||||||
|
// if we have don't find a text in the clipboard
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
static private Animation ShakeAnimation;
|
static private Animation ShakeAnimation;
|
||||||
|
|
||||||
static public Animation getShakeAnimation(Context context) {
|
static public Animation getShakeAnimation(Context context) {
|
||||||
@@ -556,6 +568,8 @@ public class Helper {
|
|||||||
tvOpenPrompt.setText(context.getText(R.string.prompt_fingerprint_auth));
|
tvOpenPrompt.setText(context.getText(R.string.prompt_fingerprint_auth));
|
||||||
tvOpenPrompt.setVisibility(View.VISIBLE);
|
tvOpenPrompt.setVisibility(View.VISIBLE);
|
||||||
FingerprintHelper.authenticate(context, cancelSignal, fingerprintAuthCallback);
|
FingerprintHelper.authenticate(context, cancelSignal, fingerprintAuthCallback);
|
||||||
|
} else {
|
||||||
|
etPassword.requestFocus();
|
||||||
}
|
}
|
||||||
Button button = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);
|
Button button = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);
|
||||||
button.setOnClickListener(new View.OnClickListener() {
|
button.setOnClickListener(new View.OnClickListener() {
|
||||||
@@ -587,8 +601,7 @@ public class Helper {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// set FLAG_SECURE to prevent screenshots in Release Mode
|
if (Helper.preventScreenshot()) {
|
||||||
if (!(BuildConfig.DEBUG && BuildConfig.FLAVOR_type.equals("alpha"))) {
|
|
||||||
openDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
|
openDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -628,4 +641,8 @@ public class Helper {
|
|||||||
StrictMode.setThreadPolicy(currentPolicy);
|
StrictMode.setThreadPolicy(currentPolicy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public boolean preventScreenshot() {
|
||||||
|
return !(BuildConfig.DEBUG || BuildConfig.FLAVOR_type.equals("alpha"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -101,6 +101,10 @@ public class RestoreHeight {
|
|||||||
blockheight.put("2019-01-01", 1738923L);
|
blockheight.put("2019-01-01", 1738923L);
|
||||||
blockheight.put("2019-02-01", 1761435L);
|
blockheight.put("2019-02-01", 1761435L);
|
||||||
blockheight.put("2019-03-01", 1781681L);
|
blockheight.put("2019-03-01", 1781681L);
|
||||||
|
blockheight.put("2019-04-01", 1803081L);
|
||||||
|
blockheight.put("2019-05-01", 1824671L);
|
||||||
|
blockheight.put("2019-06-01", 1847005L);
|
||||||
|
blockheight.put("2019-07-01", 1868590L);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getHeight(String date) {
|
public long getHeight(String date) {
|
||||||
|
@@ -28,6 +28,7 @@ import java.security.spec.ECPoint;
|
|||||||
|
|
||||||
public class ECsecp256k1 {
|
public class ECsecp256k1 {
|
||||||
static private final BigInteger TWO = new BigInteger("2");
|
static private final BigInteger TWO = new BigInteger("2");
|
||||||
|
static private final BigInteger THREE = new BigInteger("3");
|
||||||
static public final BigInteger p = new BigInteger("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F", 16);
|
static public final BigInteger p = new BigInteger("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F", 16);
|
||||||
static public final BigInteger a = new BigInteger("0000000000000000000000000000000000000000000000000000000000000000", 16);
|
static public final BigInteger a = new BigInteger("0000000000000000000000000000000000000000000000000000000000000000", 16);
|
||||||
static public final BigInteger b = new BigInteger("0000000000000000000000000000000000000000000000000000000000000007", 16);
|
static public final BigInteger b = new BigInteger("0000000000000000000000000000000000000000000000000000000000000007", 16);
|
||||||
@@ -61,19 +62,18 @@ public class ECsecp256k1 {
|
|||||||
return s;
|
return s;
|
||||||
else if (s.equals(ECPoint.POINT_INFINITY))
|
else if (s.equals(ECPoint.POINT_INFINITY))
|
||||||
return r;
|
return r;
|
||||||
BigInteger slope = (r.getAffineY().subtract(s.getAffineY())).multiply(r.getAffineX().subtract(s.getAffineX()).modInverse(p)).mod(p);
|
BigInteger slope = (r.getAffineY().subtract(s.getAffineY()))
|
||||||
|
.multiply(r.getAffineX().subtract(s.getAffineX()).modInverse(p));
|
||||||
BigInteger Xout = (slope.modPow(TWO, p).subtract(r.getAffineX())).subtract(s.getAffineX()).mod(p);
|
BigInteger Xout = (slope.modPow(TWO, p).subtract(r.getAffineX())).subtract(s.getAffineX()).mod(p);
|
||||||
BigInteger Yout = s.getAffineY().negate().mod(p);
|
BigInteger Yout = s.getAffineY().negate().add(slope.multiply(s.getAffineX().subtract(Xout))).mod(p);
|
||||||
Yout = Yout.add(slope.multiply(s.getAffineX().subtract(Xout))).mod(p);
|
|
||||||
return new ECPoint(Xout, Yout);
|
return new ECPoint(Xout, Yout);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ECPoint doublePoint(ECPoint r) {
|
public static ECPoint doublePoint(ECPoint r) {
|
||||||
if (r.equals(ECPoint.POINT_INFINITY))
|
if (r.equals(ECPoint.POINT_INFINITY))
|
||||||
return r;
|
return r;
|
||||||
BigInteger slope = (r.getAffineX().pow(2)).multiply(new BigInteger("3"));
|
BigInteger slope = (r.getAffineX().pow(2)).multiply(THREE).add(a)
|
||||||
slope = slope.add(a);
|
.multiply((r.getAffineY().multiply(TWO)).modInverse(p));
|
||||||
slope = slope.multiply((r.getAffineY().multiply(TWO)).modInverse(p));
|
|
||||||
BigInteger Xout = slope.pow(2).subtract(r.getAffineX().multiply(TWO)).mod(p);
|
BigInteger Xout = slope.pow(2).subtract(r.getAffineX().multiply(TWO)).mod(p);
|
||||||
BigInteger Yout = (r.getAffineY().negate()).add(slope.multiply(r.getAffineX().subtract(Xout))).mod(p);
|
BigInteger Yout = (r.getAffineY().negate()).add(slope.multiply(r.getAffineX().subtract(Xout))).mod(p);
|
||||||
return new ECPoint(Xout, Yout);
|
return new ECPoint(Xout, Yout);
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user