diff --git a/desktop/src/main/java/bisq/desktop/main/account/content/seedwords/SeedWordsView.java b/desktop/src/main/java/bisq/desktop/main/account/content/seedwords/SeedWordsView.java index a193f687982..491d7b489f7 100644 --- a/desktop/src/main/java/bisq/desktop/main/account/content/seedwords/SeedWordsView.java +++ b/desktop/src/main/java/bisq/desktop/main/account/content/seedwords/SeedWordsView.java @@ -61,6 +61,7 @@ import java.io.IOException; import java.util.List; +import java.util.TimeZone; import static bisq.desktop.util.FormBuilder.*; import static javafx.beans.binding.Bindings.createBooleanBinding; @@ -249,16 +250,26 @@ private void checkIfEncrypted() { } private void doRestore() { - LocalDate value = restoreDatePicker.getValue(); - if (value == null) { - // If no date was specified, use Bisq 0.5 release date (no current Bisq wallet could have been created before that date). - value = LocalDate.of(2017, Month.JUNE, 28); + 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. + // So use when the BIP39 standard was finalised (2013.10.09) as the oldest possible wallet date. + LocalDate oldestWalletDate = LocalDate.ofInstant( + Instant.ofEpochMilli(MnemonicCode.BIP39_STANDARDISATION_TIME_SECS * 1000), + TimeZone.getDefault().toZoneId()); + if (walletDate == null) { + // No date was specified, perhaps the user doesn't know the wallet date + walletDate = oldestWalletDate; + } else if (walletDate.isBefore(oldestWalletDate)) { + walletDate = oldestWalletDate; + } else if (walletDate.isAfter(LocalDate.now())) { + walletDate = LocalDate.now(); } // 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. - LocalDateTime localDateTime = value.atStartOfDay().minusDays(1); + LocalDateTime localDateTime = walletDate.atStartOfDay().minusDays(1); long date = localDateTime.toEpochSecond(ZoneOffset.UTC); DeterministicSeed seed = new DeterministicSeed(Splitter.on(" ").splitToList(seedWordsTextArea.getText()), null, "", date);