Display error string on wallet creation fail

This commit is contained in:
pokkst 2022-10-01 22:09:37 -05:00
parent b1f8552628
commit c4d012be69
No known key found for this signature in database
GPG Key ID: 90C2ED85E67A50FF
2 changed files with 6 additions and 2 deletions

View File

@ -109,7 +109,7 @@ public class OnboardingFragment extends Fragment {
wallet = WalletManager.getInstance().createWallet(walletFile, walletPassword, Constants.MNEMONIC_LANGUAGE, restoreHeight); wallet = WalletManager.getInstance().createWallet(walletFile, walletPassword, Constants.MNEMONIC_LANGUAGE, restoreHeight);
} else { } else {
if (!checkMnemonic(walletSeed)) { if (!checkMnemonic(walletSeed)) {
Toast.makeText(getContext(), getString(R.string.invalid_mnemonic_code), Toast.LENGTH_SHORT).show(); Toast.makeText(mainActivity, getString(R.string.invalid_mnemonic_code), Toast.LENGTH_SHORT).show();
return; return;
} }
if (!restoreHeightText.isEmpty()) { if (!restoreHeightText.isEmpty()) {
@ -117,12 +117,15 @@ public class OnboardingFragment extends Fragment {
} }
wallet = WalletManager.getInstance().recoveryWallet(walletFile, walletPassword, walletSeed, "", restoreHeight); wallet = WalletManager.getInstance().recoveryWallet(walletFile, walletPassword, walletSeed, "", restoreHeight);
} }
boolean ok = wallet.getStatus().isOk(); Wallet.Status walletStatus = wallet.getStatus();
boolean ok = walletStatus.isOk();
walletFile.delete(); // cache is broken for some reason when recovering wallets. delete the file here. this happens in monerujo too. walletFile.delete(); // cache is broken for some reason when recovering wallets. delete the file here. this happens in monerujo too.
if (ok) { if (ok) {
mainActivity.init(walletFile, walletPassword); mainActivity.init(walletFile, walletPassword);
mainActivity.runOnUiThread(mainActivity::onBackPressed); mainActivity.runOnUiThread(mainActivity::onBackPressed);
} else {
Toast.makeText(mainActivity, getString(R.string.create_wallet_failed, walletStatus.getErrorString()), Toast.LENGTH_SHORT).show();
} }
} }
} }

View File

@ -96,4 +96,5 @@
<string name="selected_utxos_value">Selected value: %1$s XMR</string> <string name="selected_utxos_value">Selected value: %1$s XMR</string>
<string name="global_index_text">Global Idx: %1$d</string> <string name="global_index_text">Global Idx: %1$d</string>
<string name="outpoint_text">Outpoint: %1$s</string> <string name="outpoint_text">Outpoint: %1$s</string>
<string name="create_wallet_failed">Create wallet failed: %1$s</string>
</resources> </resources>