Modify HDAccountCold Support For Importing Chinese
MODIFY
bither-android/src/net/bither/activity/cold/ColdActivity.java
bither-android/src/net/bither/activity/cold/ColdActivity.java
@@ -41,6 +41,7 @@ import net.bither.bitherj.crypto.ECKey;
import net.bither.bitherj.crypto.EncryptedData;
import net.bither.bitherj.crypto.PasswordSeed;
import net.bither.bitherj.crypto.SecureCharSequence;
+import net.bither.bitherj.crypto.mnemonic.MnemonicCode;
import net.bither.bitherj.qrcode.QRCodeUtil;
import net.bither.bitherj.utils.PrivateKeyUtil;
import net.bither.bitherj.utils.Utils;
@@ -382,10 +383,10 @@ public class ColdActivity extends BaseFragmentActivity {
String[] strings = BackupUtil.getBackupKeyStrList(file);
HDMKeychain hdmKeychain = null;
boolean check = false;
+ int hdQrCodeFlagLength = hdQrCodeFlagLength(strings);
if (strings != null && strings.length > 0) {
- if (strings[0].indexOf(QRCodeUtil.HDM_QR_CODE_FLAG) == 0 || strings[0]
- .indexOf(QRCodeUtil.HD_QR_CODE_FLAG) == 0) {
- String keychainString = strings[0].substring(1);
+ if (strings[0].indexOf(QRCodeUtil.HDM_QR_CODE_FLAG) == 0 || hdQrCodeFlagLength != 0) {
+ String keychainString = strings[0].substring(hdQrCodeFlagLength);
try {
check = HDMKeychain.checkPassword(keychainString, password);
} catch (Exception e) {
@@ -417,7 +418,7 @@ public class ColdActivity extends BaseFragmentActivity {
}
continue;
}
- if (keyString.indexOf(QRCodeUtil.HD_QR_CODE_FLAG) == 0) {
+ if (keyString.indexOf(MnemonicCode.instance().getMnemonicWordList().getHdQrCodeFlag()) == 0) {
String[] passwordSeeds = QRCodeUtil.splitOfPasswordSeed(keyString);
String encreyptString = Utils.joinString(new String[]{passwordSeeds[1], passwordSeeds[2], passwordSeeds[3]}, QRCodeUtil.QR_CODE_SPLIT);
try {
@@ -453,6 +454,13 @@ public class ColdActivity extends BaseFragmentActivity {
}
+ private int hdQrCodeFlagLength(String[] strings) {
+ String hdQrCodeFlag = MnemonicCode.instance().getMnemonicWordList().getHdQrCodeFlag();
+ if (strings.length < hdQrCodeFlag.length()) { return 0; }
+ String prefixStr = strings[0].substring(0, hdQrCodeFlag.length());
+ return hdQrCodeFlag.equals(prefixStr) ? hdQrCodeFlag.length() : 0;
+ }
+
private void checkPasswordWrong() {
ThreadUtil.runOnMainThread(new Runnable() {
@Override

MODIFY
bither-android/src/net/bither/activity/cold/ColdAdvanceActivity.java
bither-android/src/net/bither/activity/cold/ColdAdvanceActivity.java
@@ -42,6 +42,7 @@ import net.bither.bitherj.crypto.ECKey;
import net.bither.bitherj.crypto.EncryptedData;
import net.bither.bitherj.crypto.SecureCharSequence;
import net.bither.bitherj.crypto.bip38.Bip38;
+import net.bither.bitherj.crypto.mnemonic.MnemonicCode;
import net.bither.bitherj.factory.ImportHDSeed;
import net.bither.bitherj.factory.ImportPrivateKey;
import net.bither.bitherj.qrcode.QRCodeUtil;
@@ -742,7 +743,7 @@ public class ColdAdvanceActivity extends SwipeRightFragmentActivity {
break;
case BitherSetting.INTENT_REF.IMPORT_HD_ACCOUNT_SEED_REQUEST_CODE:
final String hdAccountSeed = data.getStringExtra(ScanActivity.INTENT_EXTRA_RESULT);
- if (hdAccountSeed.indexOf(QRCodeUtil.HD_QR_CODE_FLAG) == 0) {
+ if (hdAccountSeed.indexOf(MnemonicCode.instance().getMnemonicWordList().getHdQrCodeFlag()) == 0) {
dialogPassword = new DialogPassword(this,
new ImportHDAccountPasswordListener(hdAccountSeed));
dialogPassword.setCheckPre(false);

MODIFY
bither-android/src/net/bither/activity/hot/HotAdvanceActivity.java
bither-android/src/net/bither/activity/hot/HotAdvanceActivity.java
@@ -47,6 +47,7 @@ import net.bither.bitherj.crypto.EncryptedData;
import net.bither.bitherj.crypto.PasswordSeed;
import net.bither.bitherj.crypto.SecureCharSequence;
import net.bither.bitherj.crypto.bip38.Bip38;
+import net.bither.bitherj.crypto.mnemonic.MnemonicCode;
import net.bither.bitherj.db.AbstractDb;
import net.bither.bitherj.factory.ImportHDSeed;
import net.bither.bitherj.factory.ImportPrivateKey;
@@ -1267,7 +1268,7 @@ public class HotAdvanceActivity extends SwipeRightFragmentActivity {
break;
case BitherSetting.INTENT_REF.IMPORT_HD_ACCOUNT_SEED_REQUEST_CODE:
final String hdAccountSeed = data.getStringExtra(ScanActivity.INTENT_EXTRA_RESULT);
- if (hdAccountSeed.indexOf(QRCodeUtil.HD_QR_CODE_FLAG) == 0) {
+ if (hdAccountSeed.indexOf(MnemonicCode.instance().getMnemonicWordList().getHdQrCodeFlag()) == 0) {
dialogPassword = new DialogPassword(this,
new ImportHDAccountPasswordListener(hdAccountSeed));
dialogPassword.setCheckPre(false);

MODIFY
bither-android/src/net/bither/factory/ImportHDSeedAndroid.java
bither-android/src/net/bither/factory/ImportHDSeedAndroid.java
@@ -43,7 +43,6 @@ import java.util.List;
public class ImportHDSeedAndroid extends ImportHDSeed {
private DialogProgress dp;
private Activity activity;
- private MnemonicCode mnemonicCode = MnemonicCode.instance();
public ImportHDSeedAndroid(Activity activity, DialogProgress dp, String content, SecureCharSequence password) {
super(ImportHDSeedType.HDMColdSeedQRCode, content, null, password);
@@ -63,7 +62,6 @@ public class ImportHDSeedAndroid extends ImportHDSeed {
super(importHDSeedType, content, worlds, password, mnemonicCode);
this.activity = activity;
this.dp = dp;
- this.mnemonicCode = mnemonicCode;
}

MODIFY
bitherj
bitherj
-Subproject commit 627342641855db0a3a2fa0861a34a185529bf415
+Subproject commit 7daddc49fde02cc75c1f0d60645d0fe75603b509

Modify HDAccountCold Support For Importing Chinese