Skip to content

Commit

Permalink
remove bip39 when creating a new wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
erasmospunk committed Apr 22, 2016
1 parent 6b1301b commit ebe040e
Showing 4 changed files with 15 additions and 84 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/com/coinomi/core/wallet/Wallet.java
Original file line number Diff line number Diff line change
@@ -117,8 +117,8 @@ public static String generateMnemonicString(int entropyBitsSize) {
public static String mnemonicToString(List<String> mnemonicWords) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < mnemonicWords.size(); i++) {
if (i != 0) sb.append(' ');
sb.append(mnemonicWords.get(i));
sb.append(' ');
}
return sb.toString();
}
43 changes: 12 additions & 31 deletions wallet/src/main/java/com/coinomi/wallet/ui/RestoreFragment.java
Original file line number Diff line number Diff line change
@@ -85,7 +85,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
View view = inflater.inflate(R.layout.fragment_restore, container, false);

Fonts.setTypeface(view.findViewById(R.id.coins_icon), Fonts.Font.COINOMI_FONT_ICONS);
Fonts.setTypeface(view.findViewById(R.id.warning_icon), Fonts.Font.COINOMI_FONT_ICONS);

ImageButton scanQrButton = (ImageButton) view.findViewById(R.id.scan_qr_code);
scanQrButton.setOnClickListener(new View.OnClickListener() {
@@ -117,43 +116,24 @@ public void onToken() {
bip39Passphrase.setVisibility(View.GONE);
bip39PassphraseTitle.setVisibility(View.GONE);

// Checkbox to enable/disable password protected seed (BIP39)
// For new seed
final View seedProtectInfoNew = view.findViewById(R.id.seed_protect_info);
seedProtectInfoNew.setVisibility(View.GONE);
CheckBox seedProtectNew = (CheckBox) view.findViewById(R.id.seed_protect);
if (!isNewSeed) seedProtectNew.setVisibility(View.GONE);

// For existing seed
final View seedProtectInfoExisting = view.findViewById(R.id.restore_seed_protected_info);
seedProtectInfoExisting.setVisibility(View.GONE);
final CheckBox seedProtectExisting = (CheckBox) view.findViewById(R.id.restore_seed_protected);
if (isNewSeed) seedProtectExisting.setVisibility(View.GONE);

// Generic checkbox and info text
final View seedProtectInfo;
final CheckBox seedProtect;

if (isNewSeed) {
seedProtectInfo = seedProtectInfoNew;
seedProtect = seedProtectNew;
} else {
seedProtectInfo = seedProtectInfoExisting;
seedProtect = seedProtectExisting;
}
final View bip39Info = view.findViewById(R.id.bip39_info);
bip39Info.setVisibility(View.GONE);
final CheckBox useBip39Checkbox = (CheckBox) view.findViewById(R.id.use_bip39);
if (isNewSeed) useBip39Checkbox.setVisibility(View.GONE);

seedProtect.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
useBip39Checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
isSeedProtected = isChecked;
if (isChecked) {
skipButton.setVisibility(View.GONE);
seedProtectInfo.setVisibility(View.VISIBLE);
if (isNewSeed) skipButton.setVisibility(View.GONE);
bip39Info.setVisibility(View.VISIBLE);
bip39PassphraseTitle.setVisibility(View.VISIBLE);
bip39Passphrase.setVisibility(View.VISIBLE);
} else {
skipButton.setVisibility(View.VISIBLE);
seedProtectInfo.setVisibility(View.GONE);
if (isNewSeed) skipButton.setVisibility(View.VISIBLE);
bip39Info.setVisibility(View.GONE);
bip39PassphraseTitle.setVisibility(View.GONE);
bip39Passphrase.setVisibility(View.GONE);
bip39Passphrase.setText(null);
@@ -163,7 +143,7 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

// Skip link
skipButton = (Button) view.findViewById(R.id.seed_entry_skip);
if (seed != null) {
if (isNewSeed) {
skipButton.setOnClickListener(getOnSkipListener());
skipButton.setVisibility(View.VISIBLE);
} else {
@@ -220,7 +200,8 @@ private void verifyMnemonicAndProceed() {
Bundle args = getArguments();
if (args == null) args = new Bundle();

if (isSeedProtected) {
// Do not set a BIP39 passphrase on new recovery phrases
if (!isNewSeed && isSeedProtected) {
args.putString(Constants.ARG_SEED_PASSWORD, bip39Passphrase.getText().toString());
}
args.putString(Constants.ARG_SEED, mnemonicTextView.getText().toString().trim());
51 changes: 2 additions & 49 deletions wallet/src/main/res/layout/fragment_restore.xml
Original file line number Diff line number Diff line change
@@ -74,66 +74,19 @@
android:text="@string/restore_error_checksum" />

<CheckBox
android:id="@+id/restore_seed_protected"
android:id="@+id/use_bip39"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/half_standard_margin"
android:text="@string/restore_seed_protected" />

<TextView
android:id="@+id/restore_seed_protected_info"
android:id="@+id/bip39_info"
style="@style/NormalText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/password_wallet_recovery" />

<CheckBox
android:id="@+id/seed_protect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/half_standard_margin"
android:text="@string/set_password_seed_protect" />

<LinearLayout
android:id="@+id/seed_protect_info"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<TextView
style="@style/NormalText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/set_password_seed_protect_explanation" />

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/half_standard_margin"
android:orientation="horizontal">

<TextView
android:id="@+id/warning_icon"
style="@style/WarningText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/standard_margin"
android:layout_marginRight="@dimen/standard_margin"
android:gravity="center"
android:text="@string/font_icon_warning"
android:textSize="@dimen/font_icon_text_size"
tools:text="Δ" />

<TextView
style="@style/WarningText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/set_password_seed_protect_info" />

</LinearLayout>
</LinearLayout>

<TextView
android:id="@+id/bip39_passphrase_title"
android:layout_width="wrap_content"
3 changes: 0 additions & 3 deletions wallet/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -149,9 +149,6 @@
<string name="amount_warn_fees_apply">Slightly less will be sent because of fees</string>
<!-- Set Password fragment -->
<string name="set_password_info">Set a password to protect your wallet in everyday use.</string>
<string name="set_password_seed_protect">Setup a BIP39 passphrase</string>
<string name="set_password_seed_protect_explanation">The BIP39 passphrase locks your recovery phrase and is unchangeable. It is required when restoring your wallet.</string>
<string name="set_password_seed_protect_info"><b>WARNING: If you lose your passphrase it will be impossible to restore your wallet!</b>\nPlease proceed only if you know what you are doing.</string>
<string name="set_bip39_passphrase">Type your BIP39 passphrase</string>
<string name="set_password1">Type your password</string>
<string name="set_password2">Re-type your password</string>

0 comments on commit ebe040e

Please sign in to comment.