Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn when restoring wallet seedwords without date #4283

Merged
merged 1 commit into from Jun 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2935,6 +2935,10 @@ seed.warn.walletNotEmpty.emptyWallet=I will empty my wallets first
seed.warn.notEncryptedAnymore=Your wallets are encrypted.\n\n\
After restore, the wallets will no longer be encrypted and you must set a new password.\n\n\
Do you want to proceed?
seed.warn.walletDateEmpty=As you have not specified a wallet date, bisq will have to scan the blockchain from 2013.10.09 (the BIP39 epoch date).\n\n\
BIP39 wallets were first introduced in bisq on 2017.06.28 (release v0.5). So you could save time by using that date.\n\n\
Ideally you should specify the date your wallet seed was created.\n\n\n\
Are you sure you want to go ahead without specifying a wallet date?
seed.restore.success=Wallets restored successfully with the new seed words.\n\nYou need to shut down and restart the application.
seed.restore.error=An error occurred when restoring the wallets with seed words.{0}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,19 @@ private void onRestore() {
private void checkIfEncrypted() {
if (walletsManager.areWalletsEncrypted()) {
new Popup().information(Res.get("seed.warn.notEncryptedAnymore"))
.closeButtonText(Res.get("shared.no"))
.actionButtonText(Res.get("shared.yes"))
.onAction(this::doRestoreDateCheck)
.show();
} else {
doRestoreDateCheck();
}
}

private void doRestoreDateCheck() {
if (restoreDatePicker.getValue() == null) {
// Provide feedback when attempting to restore a wallet from seed words without specifying a date
new Popup().information(Res.get("seed.warn.walletDateEmpty"))
.closeButtonText(Res.get("shared.no"))
.actionButtonText(Res.get("shared.yes"))
.onAction(this::doRestore)
Expand All @@ -248,7 +261,7 @@ private void checkIfEncrypted() {
}
}

private void doRestore() {
private LocalDate getWalletDate() {
LocalDate walletDate = restoreDatePicker.getValue();
// Even though no current Bisq wallet could have been created before the v0.5 release date (2017.06.28),
// the user may want to import from a seed generated by another wallet.
Expand All @@ -264,7 +277,11 @@ private void doRestore() {
} else if (walletDate.isAfter(LocalDate.now())) {
walletDate = LocalDate.now();
}
return walletDate;
}

private void doRestore() {
LocalDate walletDate = getWalletDate();
// We subtract 1 day to be sure to not have any issues with timezones. Even if we can be sure that the timezone
// is handled correctly it could be that the user created the wallet in one timezone and make a restore at
// a different timezone which could lead in the worst case that he miss the first day of the wallet transactions.
Expand Down