mirror of https://github.com/m2049r/xmrwallet.git
testnet => stagenet (#288)
This commit is contained in:
parent
f50629ff81
commit
5a7aa6cc77
|
@ -757,8 +757,6 @@ Java_com_m2049r_xmrwallet_model_Wallet_isAddressValid(JNIEnv *env, jobject clazz
|
||||||
return static_cast<jboolean>(isValid);
|
return static_cast<jboolean>(isValid);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO static static bool keyValid(const std::string &secret_key_string, const std::string &address_string, bool isViewKey, bool testnet, std::string &error);
|
|
||||||
|
|
||||||
JNIEXPORT jstring JNICALL
|
JNIEXPORT jstring JNICALL
|
||||||
Java_com_m2049r_xmrwallet_model_Wallet_getPaymentIdFromAddress(JNIEnv *env, jobject clazz,
|
Java_com_m2049r_xmrwallet_model_Wallet_getPaymentIdFromAddress(JNIEnv *env, jobject clazz,
|
||||||
jstring address,
|
jstring address,
|
||||||
|
|
|
@ -102,10 +102,10 @@ public class GenerateReviewFragment extends Fragment {
|
||||||
|
|
||||||
bAccept = (Button) view.findViewById(R.id.bAccept);
|
bAccept = (Button) view.findViewById(R.id.bAccept);
|
||||||
|
|
||||||
boolean testnet = WalletManager.getInstance().getNetworkType() != NetworkType.NetworkType_Mainnet;
|
boolean allowCopy = WalletManager.getInstance().getNetworkType() != NetworkType.NetworkType_Mainnet;
|
||||||
tvWalletMnemonic.setTextIsSelectable(testnet);
|
tvWalletMnemonic.setTextIsSelectable(allowCopy);
|
||||||
tvWalletSpendKey.setTextIsSelectable(testnet);
|
tvWalletSpendKey.setTextIsSelectable(allowCopy);
|
||||||
tvWalletPassword.setTextIsSelectable(testnet);
|
tvWalletPassword.setTextIsSelectable(allowCopy);
|
||||||
|
|
||||||
bAccept.setOnClickListener(new View.OnClickListener() {
|
bAccept.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1007,11 +1007,11 @@ public class LoginActivity extends SecureActivity
|
||||||
case R.id.action_privacy_policy:
|
case R.id.action_privacy_policy:
|
||||||
PrivacyFragment.display(getSupportFragmentManager());
|
PrivacyFragment.display(getSupportFragmentManager());
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_testnet:
|
case R.id.action_stagenet:
|
||||||
try {
|
try {
|
||||||
LoginFragment loginFragment = (LoginFragment)
|
LoginFragment loginFragment = (LoginFragment)
|
||||||
getSupportFragmentManager().findFragmentById(R.id.fragment_container);
|
getSupportFragmentManager().findFragmentById(R.id.fragment_container);
|
||||||
item.setChecked(loginFragment.onTestnetMenuItem());
|
item.setChecked(loginFragment.onStagenetMenuItem());
|
||||||
} catch (ClassCastException ex) {
|
} catch (ClassCastException ex) {
|
||||||
// never mind then
|
// never mind then
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,15 +18,12 @@ package com.m2049r.xmrwallet;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.ColorStateList;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.design.widget.FloatingActionButton;
|
import android.support.design.widget.FloatingActionButton;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.content.ContextCompat;
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.Gravity;
|
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
|
@ -41,14 +38,11 @@ import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.m2049r.xmrwallet.dialog.HelpFragment;
|
|
||||||
import com.m2049r.xmrwallet.layout.WalletInfoAdapter;
|
import com.m2049r.xmrwallet.layout.WalletInfoAdapter;
|
||||||
import com.m2049r.xmrwallet.model.NetworkType;
|
import com.m2049r.xmrwallet.model.NetworkType;
|
||||||
import com.m2049r.xmrwallet.model.WalletManager;
|
import com.m2049r.xmrwallet.model.WalletManager;
|
||||||
|
@ -343,69 +337,65 @@ public class LoginFragment extends Fragment implements WalletInfoAdapter.OnInter
|
||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
inflater.inflate(R.menu.list_menu, menu);
|
inflater.inflate(R.menu.list_menu, menu);
|
||||||
menu.findItem(R.id.action_testnet).setChecked(testnetCheckMenu);
|
menu.findItem(R.id.action_stagenet).setChecked(stagenetCheckMenu);
|
||||||
super.onCreateOptionsMenu(menu, inflater);
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean testnetCheckMenu = BuildConfig.DEBUG;
|
private boolean stagenetCheckMenu = BuildConfig.DEBUG;
|
||||||
|
|
||||||
//boolean isTestnet() {
|
public boolean onStagenetMenuItem() {
|
||||||
// return testnet;
|
boolean lastState = stagenetCheckMenu;
|
||||||
//}
|
|
||||||
|
|
||||||
public boolean onTestnetMenuItem() {
|
|
||||||
boolean lastState = testnetCheckMenu;
|
|
||||||
setNet(!lastState, true); // set and save
|
setNet(!lastState, true); // set and save
|
||||||
return !lastState;
|
return !lastState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNet(boolean testnetChecked, boolean save) {
|
public void setNet(boolean stagenetChecked, boolean save) {
|
||||||
this.testnetCheckMenu = testnetChecked;
|
this.stagenetCheckMenu = stagenetChecked;
|
||||||
NetworkType net = testnetChecked ? NetworkType.NetworkType_Testnet : NetworkType.NetworkType_Mainnet;
|
NetworkType net = stagenetChecked ? NetworkType.NetworkType_Stagenet : NetworkType.NetworkType_Mainnet;
|
||||||
activityCallback.setNetworkType(net);
|
activityCallback.setNetworkType(net);
|
||||||
activityCallback.showNet();
|
activityCallback.showNet();
|
||||||
if (save) {
|
if (save) {
|
||||||
savePrefs(true); // use previous state as we just clicked it
|
savePrefs(true); // use previous state as we just clicked it
|
||||||
}
|
}
|
||||||
if (testnetChecked) {
|
if (stagenetChecked) {
|
||||||
setDaemon(daemonTestNet);
|
setDaemon(daemonStageNet);
|
||||||
} else {
|
} else {
|
||||||
setDaemon(daemonMainNet);
|
setDaemon(daemonMainNet);
|
||||||
}
|
}
|
||||||
loadList();
|
loadList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String PREF_DAEMON_TESTNET = "daemon_testnet";
|
private static final String PREF_DAEMON_STAGENET = "daemon_stagenet";
|
||||||
private static final String PREF_DAEMON_MAINNET = "daemon_mainnet";
|
private static final String PREF_DAEMON_MAINNET = "daemon_mainnet";
|
||||||
|
|
||||||
private static final String PREF_DAEMONLIST_MAINNET =
|
private static final String PREF_DAEMONLIST_MAINNET =
|
||||||
"node.moneroworld.com:18089;node.xmrbackb.one;node.xmr.be";
|
"node.moneroworld.com:18089;node.xmrbackb.one;node.xmr.be";
|
||||||
|
|
||||||
private static final String PREF_DAEMONLIST_TESTNET =
|
private static final String PREF_DAEMONLIST_STAGENET =
|
||||||
"testnet.xmrchain.net";
|
"stagenet.xmr-tw.org";
|
||||||
|
|
||||||
private NodeList daemonTestNet;
|
private NodeList daemonStageNet;
|
||||||
private NodeList daemonMainNet;
|
private NodeList daemonMainNet;
|
||||||
|
|
||||||
void loadPrefs() {
|
void loadPrefs() {
|
||||||
SharedPreferences sharedPref = activityCallback.getPrefs();
|
SharedPreferences sharedPref = activityCallback.getPrefs();
|
||||||
|
|
||||||
daemonMainNet = new NodeList(sharedPref.getString(PREF_DAEMON_MAINNET, PREF_DAEMONLIST_MAINNET));
|
daemonMainNet = new NodeList(sharedPref.getString(PREF_DAEMON_MAINNET, PREF_DAEMONLIST_MAINNET));
|
||||||
daemonTestNet = new NodeList(sharedPref.getString(PREF_DAEMON_TESTNET, PREF_DAEMONLIST_TESTNET));
|
daemonStageNet = new NodeList(sharedPref.getString(PREF_DAEMON_STAGENET, PREF_DAEMONLIST_STAGENET));
|
||||||
setNet(testnetCheckMenu, false);
|
setNet(stagenetCheckMenu, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void savePrefs() {
|
void savePrefs() {
|
||||||
savePrefs(false);
|
savePrefs(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void savePrefs(boolean usePreviousTestnetState) {
|
void savePrefs(boolean usePreviousNetState) {
|
||||||
Timber.d("SAVE / %s", usePreviousTestnetState);
|
Timber.d("SAVE / %s", usePreviousNetState);
|
||||||
// save the daemon address for the net
|
// save the daemon address for the net
|
||||||
boolean testnet = testnetCheckMenu ^ usePreviousTestnetState;
|
boolean stagenet = stagenetCheckMenu ^ usePreviousNetState;
|
||||||
String daemon = getDaemon();
|
String daemon = getDaemon();
|
||||||
if (testnet) {
|
if (stagenet) {
|
||||||
daemonTestNet.setRecent(daemon);
|
daemonStageNet.setRecent(daemon);
|
||||||
} else {
|
} else {
|
||||||
daemonMainNet.setRecent(daemon);
|
daemonMainNet.setRecent(daemon);
|
||||||
}
|
}
|
||||||
|
@ -413,7 +403,7 @@ public class LoginFragment extends Fragment implements WalletInfoAdapter.OnInter
|
||||||
SharedPreferences sharedPref = activityCallback.getPrefs();
|
SharedPreferences sharedPref = activityCallback.getPrefs();
|
||||||
SharedPreferences.Editor editor = sharedPref.edit();
|
SharedPreferences.Editor editor = sharedPref.edit();
|
||||||
editor.putString(PREF_DAEMON_MAINNET, daemonMainNet.toString());
|
editor.putString(PREF_DAEMON_MAINNET, daemonMainNet.toString());
|
||||||
editor.putString(PREF_DAEMON_TESTNET, daemonTestNet.toString());
|
editor.putString(PREF_DAEMON_STAGENET, daemonStageNet.toString());
|
||||||
editor.apply();
|
editor.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -233,7 +233,7 @@ public class SendAddressWizardFragment extends SendWizardFragment {
|
||||||
|
|
||||||
private boolean isBitcoinAddress() {
|
private boolean isBitcoinAddress() {
|
||||||
String address = etAddress.getEditText().getText().toString();
|
String address = etAddress.getEditText().getText().toString();
|
||||||
if ((address.length() >= 27) && (address.length() <= 34))
|
if ((address.length() >= 27) && (address.length() <= 35))
|
||||||
return BitcoinAddressValidator.validate(address);
|
return BitcoinAddressValidator.validate(address);
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -247,7 +247,7 @@ public class SendBtcAmountWizardFragment extends SendWizardFragment {
|
||||||
|
|
||||||
private XmrToApi xmrToApi = null;
|
private XmrToApi xmrToApi = null;
|
||||||
|
|
||||||
private final XmrToApi getXmrToApi() {
|
private XmrToApi getXmrToApi() {
|
||||||
if (xmrToApi == null) {
|
if (xmrToApi == null) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (xmrToApi == null) {
|
if (xmrToApi == null) {
|
||||||
|
|
|
@ -164,8 +164,6 @@ public class Wallet {
|
||||||
|
|
||||||
public static native boolean isAddressValid(String address, int networkType);
|
public static native boolean isAddressValid(String address, int networkType);
|
||||||
|
|
||||||
//TODO static static bool keyValid(const std::string &secret_key_string, const std::string &address_string, bool isViewKey, bool testnet, std::string &error);
|
|
||||||
|
|
||||||
public static native String getPaymentIdFromAddress(String address, int networkType);
|
public static native String getPaymentIdFromAddress(String address, int networkType);
|
||||||
|
|
||||||
public static native long getMaximumAllowedAmount();
|
public static native long getMaximumAllowedAmount();
|
||||||
|
|
|
@ -228,7 +228,6 @@ public class WalletManager {
|
||||||
|
|
||||||
public String getDaemonAddress() {
|
public String getDaemonAddress() {
|
||||||
if (daemonAddress == null) {
|
if (daemonAddress == null) {
|
||||||
// assume testnet not explicitly initialised
|
|
||||||
throw new IllegalStateException("use setDaemon() to initialise daemon and net first!");
|
throw new IllegalStateException("use setDaemon() to initialise daemon and net first!");
|
||||||
}
|
}
|
||||||
return this.daemonAddress;
|
return this.daemonAddress;
|
||||||
|
@ -236,13 +235,13 @@ public class WalletManager {
|
||||||
|
|
||||||
private native void setDaemonAddressJ(String address);
|
private native void setDaemonAddressJ(String address);
|
||||||
|
|
||||||
String daemonUsername = "";
|
private String daemonUsername = "";
|
||||||
|
|
||||||
public String getDaemonUsername() {
|
public String getDaemonUsername() {
|
||||||
return daemonUsername;
|
return daemonUsername;
|
||||||
}
|
}
|
||||||
|
|
||||||
String daemonPassword = "";
|
private String daemonPassword = "";
|
||||||
|
|
||||||
public String getDaemonPassword() {
|
public String getDaemonPassword() {
|
||||||
return daemonPassword;
|
return daemonPassword;
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_testnet"
|
android:id="@+id/action_stagenet"
|
||||||
android:checkable="true"
|
android:checkable="true"
|
||||||
android:orderInCategory="100"
|
android:orderInCategory="100"
|
||||||
android:title="@string/menu_testnet"
|
android:title="@string/menu_stagenet"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<resources>
|
<resources>
|
||||||
<string name="wallet_activity_name">Wallet</string>
|
<string name="wallet_activity_name">Wallet</string>
|
||||||
|
|
||||||
<string name="menu_testnet">Testnet</string>
|
|
||||||
<string name="menu_about">Über</string>
|
<string name="menu_about">Über</string>
|
||||||
<string name="menu_privacy">Datenschutzerklärung</string>
|
<string name="menu_privacy">Datenschutzerklärung</string>
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<resources>
|
<resources>
|
||||||
<string name="wallet_activity_name">Monedero</string>
|
<string name="wallet_activity_name">Monedero</string>
|
||||||
|
|
||||||
<string name="menu_testnet">Testnet</string>
|
|
||||||
<string name="menu_about">Acerca De</string>
|
<string name="menu_about">Acerca De</string>
|
||||||
<string name="menu_privacy">Política de Privacidad</string>
|
<string name="menu_privacy">Política de Privacidad</string>
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<resources>
|
<resources>
|
||||||
<string name="wallet_activity_name">Portefeuille</string>
|
<string name="wallet_activity_name">Portefeuille</string>
|
||||||
|
|
||||||
<string name="menu_testnet">Testnet</string>
|
|
||||||
<string name="menu_about">À Propos</string>
|
<string name="menu_about">À Propos</string>
|
||||||
<string name="menu_privacy">Politique de Confidentialité</string>
|
<string name="menu_privacy">Politique de Confidentialité</string>
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<resources>
|
<resources>
|
||||||
<string name="wallet_activity_name">Portafoglio</string>
|
<string name="wallet_activity_name">Portafoglio</string>
|
||||||
|
|
||||||
<string name="menu_testnet">Testnet</string>
|
|
||||||
<string name="menu_about">Informazioni</string>
|
<string name="menu_about">Informazioni</string>
|
||||||
<string name="menu_privacy">Politiche Privacy</string>
|
<string name="menu_privacy">Politiche Privacy</string>
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<resources>
|
<resources>
|
||||||
<string name="wallet_activity_name">Lommebok</string>
|
<string name="wallet_activity_name">Lommebok</string>
|
||||||
|
|
||||||
<string name="menu_testnet">Testnett</string>
|
|
||||||
<string name="menu_about">Om</string>
|
<string name="menu_about">Om</string>
|
||||||
<string name="menu_privacy">Personvernserklæring</string>
|
<string name="menu_privacy">Personvernserklæring</string>
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<resources>
|
<resources>
|
||||||
<string name="wallet_activity_name">钱包</string>
|
<string name="wallet_activity_name">钱包</string>
|
||||||
|
|
||||||
<string name="menu_testnet">Testnet</string>
|
|
||||||
<string name="menu_about">关于</string>
|
<string name="menu_about">关于</string>
|
||||||
<string name="menu_privacy">隐私权政策</string>
|
<string name="menu_privacy">隐私权政策</string>
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<resources>
|
<resources>
|
||||||
<string name="wallet_activity_name">錢包</string>
|
<string name="wallet_activity_name">錢包</string>
|
||||||
|
|
||||||
<string name="menu_testnet">Testnet</string>
|
|
||||||
<string name="menu_about">關於</string>
|
<string name="menu_about">關於</string>
|
||||||
<string name="menu_privacy">隱私權政策</string>
|
<string name="menu_privacy">隱私權政策</string>
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<string name="app_name" translatable="false">monerujo</string>
|
<string name="app_name" translatable="false">monerujo</string>
|
||||||
<string name="wallet_activity_name">Wallet</string>
|
<string name="wallet_activity_name">Wallet</string>
|
||||||
|
|
||||||
<string name="menu_testnet">Testnet</string>
|
<string name="menu_stagenet" translatable="false">Stagenet</string>
|
||||||
<string name="menu_about">About</string>
|
<string name="menu_about">About</string>
|
||||||
<string name="menu_privacy">Privacy Policy</string>
|
<string name="menu_privacy">Privacy Policy</string>
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ public class BitcoinAddressValidatorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void validateBTC_shouldValidate() {
|
public void validateBTC_shouldValidate() {
|
||||||
|
assertTrue(BitcoinAddressValidator.validate("2NBMEXXS4v8ubajzfQUjYvh2ptLkxzH8uTC", true));
|
||||||
assertTrue(BitcoinAddressValidator.validate("2N9fzq66uZYQXp7uqrPBH6jKBhjrgTzpGCy", true));
|
assertTrue(BitcoinAddressValidator.validate("2N9fzq66uZYQXp7uqrPBH6jKBhjrgTzpGCy", true));
|
||||||
assertTrue(BitcoinAddressValidator.validate("1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i", false));
|
assertTrue(BitcoinAddressValidator.validate("1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i", false));
|
||||||
assertTrue(BitcoinAddressValidator.validate("1Q1pE5vPGEEMqRcVRMbtBK842Y6Pzo6nK9", false));
|
assertTrue(BitcoinAddressValidator.validate("1Q1pE5vPGEEMqRcVRMbtBK842Y6Pzo6nK9", false));
|
||||||
|
|
Loading…
Reference in New Issue