Basic check for 25 word mnemonic

This commit is contained in:
pokkst 2022-09-07 23:24:59 -05:00
parent 5c69fb7dba
commit 772a5004b3
No known key found for this signature in database
GPG key ID: 90C2ED85E67A50FF

View file

@ -52,6 +52,10 @@ public class OnboardingFragment extends Fragment {
if(walletSeed.isEmpty()) {
wallet = WalletManager.getInstance().createWallet(walletFile, walletPassword, Constants.MNEMONIC_LANGUAGE, 0);
} else {
if(!checkMnemonic(walletSeed)) {
Toast.makeText(getContext(), getString(R.string.invalid_mnemonic_code), Toast.LENGTH_SHORT).show();
return;
}
wallet = WalletManager.getInstance().recoveryWallet(walletFile, walletPassword, walletSeed, "", 0);
}
wallet.close();
@ -75,4 +79,8 @@ public class OnboardingFragment extends Fragment {
}
});
}
private boolean checkMnemonic(String seed) {
return (seed.split("\\s").length == 25);
}
}