testnet => stagenet (#288)

This commit is contained in:
m2049r 2018-05-25 18:19:29 +02:00 committed by GitHub
parent f50629ff81
commit 5a7aa6cc77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 35 additions and 56 deletions

View File

@ -757,8 +757,6 @@ Java_com_m2049r_xmrwallet_model_Wallet_isAddressValid(JNIEnv *env, jobject clazz
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
Java_com_m2049r_xmrwallet_model_Wallet_getPaymentIdFromAddress(JNIEnv *env, jobject clazz,
jstring address,

View File

@ -102,10 +102,10 @@ public class GenerateReviewFragment extends Fragment {
bAccept = (Button) view.findViewById(R.id.bAccept);
boolean testnet = WalletManager.getInstance().getNetworkType() != NetworkType.NetworkType_Mainnet;
tvWalletMnemonic.setTextIsSelectable(testnet);
tvWalletSpendKey.setTextIsSelectable(testnet);
tvWalletPassword.setTextIsSelectable(testnet);
boolean allowCopy = WalletManager.getInstance().getNetworkType() != NetworkType.NetworkType_Mainnet;
tvWalletMnemonic.setTextIsSelectable(allowCopy);
tvWalletSpendKey.setTextIsSelectable(allowCopy);
tvWalletPassword.setTextIsSelectable(allowCopy);
bAccept.setOnClickListener(new View.OnClickListener() {
@Override

View File

@ -1007,11 +1007,11 @@ public class LoginActivity extends SecureActivity
case R.id.action_privacy_policy:
PrivacyFragment.display(getSupportFragmentManager());
return true;
case R.id.action_testnet:
case R.id.action_stagenet:
try {
LoginFragment loginFragment = (LoginFragment)
getSupportFragmentManager().findFragmentById(R.id.fragment_container);
item.setChecked(loginFragment.onTestnetMenuItem());
item.setChecked(loginFragment.onStagenetMenuItem());
} catch (ClassCastException ex) {
// never mind then
}

View File

@ -18,15 +18,12 @@ package com.m2049r.xmrwallet;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.ColorStateList;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
@ -41,14 +38,11 @@ import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.m2049r.xmrwallet.dialog.HelpFragment;
import com.m2049r.xmrwallet.layout.WalletInfoAdapter;
import com.m2049r.xmrwallet.model.NetworkType;
import com.m2049r.xmrwallet.model.WalletManager;
@ -343,69 +337,65 @@ public class LoginFragment extends Fragment implements WalletInfoAdapter.OnInter
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
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);
}
private boolean testnetCheckMenu = BuildConfig.DEBUG;
private boolean stagenetCheckMenu = BuildConfig.DEBUG;
//boolean isTestnet() {
// return testnet;
//}
public boolean onTestnetMenuItem() {
boolean lastState = testnetCheckMenu;
public boolean onStagenetMenuItem() {
boolean lastState = stagenetCheckMenu;
setNet(!lastState, true); // set and save
return !lastState;
}
public void setNet(boolean testnetChecked, boolean save) {
this.testnetCheckMenu = testnetChecked;
NetworkType net = testnetChecked ? NetworkType.NetworkType_Testnet : NetworkType.NetworkType_Mainnet;
public void setNet(boolean stagenetChecked, boolean save) {
this.stagenetCheckMenu = stagenetChecked;
NetworkType net = stagenetChecked ? NetworkType.NetworkType_Stagenet : NetworkType.NetworkType_Mainnet;
activityCallback.setNetworkType(net);
activityCallback.showNet();
if (save) {
savePrefs(true); // use previous state as we just clicked it
}
if (testnetChecked) {
setDaemon(daemonTestNet);
if (stagenetChecked) {
setDaemon(daemonStageNet);
} else {
setDaemon(daemonMainNet);
}
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_DAEMONLIST_MAINNET =
"node.moneroworld.com:18089;node.xmrbackb.one;node.xmr.be";
private static final String PREF_DAEMONLIST_TESTNET =
"testnet.xmrchain.net";
private static final String PREF_DAEMONLIST_STAGENET =
"stagenet.xmr-tw.org";
private NodeList daemonTestNet;
private NodeList daemonStageNet;
private NodeList daemonMainNet;
void loadPrefs() {
SharedPreferences sharedPref = activityCallback.getPrefs();
daemonMainNet = new NodeList(sharedPref.getString(PREF_DAEMON_MAINNET, PREF_DAEMONLIST_MAINNET));
daemonTestNet = new NodeList(sharedPref.getString(PREF_DAEMON_TESTNET, PREF_DAEMONLIST_TESTNET));
setNet(testnetCheckMenu, false);
daemonStageNet = new NodeList(sharedPref.getString(PREF_DAEMON_STAGENET, PREF_DAEMONLIST_STAGENET));
setNet(stagenetCheckMenu, false);
}
void savePrefs() {
savePrefs(false);
}
void savePrefs(boolean usePreviousTestnetState) {
Timber.d("SAVE / %s", usePreviousTestnetState);
void savePrefs(boolean usePreviousNetState) {
Timber.d("SAVE / %s", usePreviousNetState);
// save the daemon address for the net
boolean testnet = testnetCheckMenu ^ usePreviousTestnetState;
boolean stagenet = stagenetCheckMenu ^ usePreviousNetState;
String daemon = getDaemon();
if (testnet) {
daemonTestNet.setRecent(daemon);
if (stagenet) {
daemonStageNet.setRecent(daemon);
} else {
daemonMainNet.setRecent(daemon);
}
@ -413,7 +403,7 @@ public class LoginFragment extends Fragment implements WalletInfoAdapter.OnInter
SharedPreferences sharedPref = activityCallback.getPrefs();
SharedPreferences.Editor editor = sharedPref.edit();
editor.putString(PREF_DAEMON_MAINNET, daemonMainNet.toString());
editor.putString(PREF_DAEMON_TESTNET, daemonTestNet.toString());
editor.putString(PREF_DAEMON_STAGENET, daemonStageNet.toString());
editor.apply();
}

View File

@ -233,7 +233,7 @@ public class SendAddressWizardFragment extends SendWizardFragment {
private boolean isBitcoinAddress() {
String address = etAddress.getEditText().getText().toString();
if ((address.length() >= 27) && (address.length() <= 34))
if ((address.length() >= 27) && (address.length() <= 35))
return BitcoinAddressValidator.validate(address);
else
return false;

View File

@ -247,7 +247,7 @@ public class SendBtcAmountWizardFragment extends SendWizardFragment {
private XmrToApi xmrToApi = null;
private final XmrToApi getXmrToApi() {
private XmrToApi getXmrToApi() {
if (xmrToApi == null) {
synchronized (this) {
if (xmrToApi == null) {

View File

@ -164,8 +164,6 @@ public class Wallet {
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 long getMaximumAllowedAmount();

View File

@ -228,7 +228,6 @@ public class WalletManager {
public String getDaemonAddress() {
if (daemonAddress == null) {
// assume testnet not explicitly initialised
throw new IllegalStateException("use setDaemon() to initialise daemon and net first!");
}
return this.daemonAddress;
@ -236,13 +235,13 @@ public class WalletManager {
private native void setDaemonAddressJ(String address);
String daemonUsername = "";
private String daemonUsername = "";
public String getDaemonUsername() {
return daemonUsername;
}
String daemonPassword = "";
private String daemonPassword = "";
public String getDaemonPassword() {
return daemonPassword;

View File

@ -3,10 +3,10 @@
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_testnet"
android:id="@+id/action_stagenet"
android:checkable="true"
android:orderInCategory="100"
android:title="@string/menu_testnet"
android:title="@string/menu_stagenet"
app:showAsAction="never" />
<item

View File

@ -1,7 +1,6 @@
<resources>
<string name="wallet_activity_name">Wallet</string>
<string name="menu_testnet">Testnet</string>
<string name="menu_about">Über</string>
<string name="menu_privacy">Datenschutzerklärung</string>

View File

@ -1,7 +1,6 @@
<resources>
<string name="wallet_activity_name">Monedero</string>
<string name="menu_testnet">Testnet</string>
<string name="menu_about">Acerca De</string>
<string name="menu_privacy">Política de Privacidad</string>

View File

@ -1,7 +1,6 @@
<resources>
<string name="wallet_activity_name">Portefeuille</string>
<string name="menu_testnet">Testnet</string>
<string name="menu_about">À Propos</string>
<string name="menu_privacy">Politique de Confidentialité</string>

View File

@ -1,7 +1,6 @@
<resources>
<string name="wallet_activity_name">Portafoglio</string>
<string name="menu_testnet">Testnet</string>
<string name="menu_about">Informazioni</string>
<string name="menu_privacy">Politiche Privacy</string>

View File

@ -1,7 +1,6 @@
<resources>
<string name="wallet_activity_name">Lommebok</string>
<string name="menu_testnet">Testnett</string>
<string name="menu_about">Om</string>
<string name="menu_privacy">Personvernserklæring</string>

View File

@ -1,7 +1,6 @@
<resources>
<string name="wallet_activity_name">钱包</string>
<string name="menu_testnet">Testnet</string>
<string name="menu_about">关于</string>
<string name="menu_privacy">隐私权政策</string>

View File

@ -1,7 +1,6 @@
<resources>
<string name="wallet_activity_name">錢包</string>
<string name="menu_testnet">Testnet</string>
<string name="menu_about">關於</string>
<string name="menu_privacy">隱私權政策</string>

View File

@ -2,7 +2,7 @@
<string name="app_name" translatable="false">monerujo</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_privacy">Privacy Policy</string>

View File

@ -25,6 +25,7 @@ public class BitcoinAddressValidatorTest {
@Test
public void validateBTC_shouldValidate() {
assertTrue(BitcoinAddressValidator.validate("2NBMEXXS4v8ubajzfQUjYvh2ptLkxzH8uTC", true));
assertTrue(BitcoinAddressValidator.validate("2N9fzq66uZYQXp7uqrPBH6jKBhjrgTzpGCy", true));
assertTrue(BitcoinAddressValidator.validate("1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i", false));
assertTrue(BitcoinAddressValidator.validate("1Q1pE5vPGEEMqRcVRMbtBK842Y6Pzo6nK9", false));