diff --git a/src/main/java/com/sparrowwallet/sparrow/control/KeystorePassphraseDialog.java b/src/main/java/com/sparrowwallet/sparrow/control/KeystorePassphraseDialog.java index 5a90143b..30e93c65 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/KeystorePassphraseDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/KeystorePassphraseDialog.java @@ -21,11 +21,15 @@ public class KeystorePassphraseDialog extends Dialog { } public KeystorePassphraseDialog(String walletName, Keystore keystore) { + this(walletName, keystore, false); + } + + public KeystorePassphraseDialog(String walletName, Keystore keystore, boolean confirm) { this.passphrase = (CustomPasswordField) TextFields.createClearablePasswordField(); final DialogPane dialogPane = getDialogPane(); setTitle("Keystore Passphrase" + (walletName != null ? " - " + walletName : "")); - dialogPane.setHeaderText("Enter the BIP39 passphrase\nfor keystore: " + keystore.getLabel()); + dialogPane.setHeaderText((confirm ? "Re-enter" : "Enter") + " the BIP39 passphrase\n" + (confirm ? "to confirm:" : "for keystore: " + keystore.getLabel())); dialogPane.getStylesheets().add(AppServices.class.getResource("general.css").toExternalForm()); AppServices.setStageIcon(dialogPane.getScene().getWindow()); dialogPane.getButtonTypes().addAll(ButtonType.CANCEL, ButtonType.OK); diff --git a/src/main/java/com/sparrowwallet/sparrow/control/MnemonicKeystoreImportPane.java b/src/main/java/com/sparrowwallet/sparrow/control/MnemonicKeystoreImportPane.java index 924c2373..c2710b8e 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/MnemonicKeystoreImportPane.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/MnemonicKeystoreImportPane.java @@ -38,6 +38,7 @@ import java.security.SecureRandom; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Optional; public class MnemonicKeystoreImportPane extends TitledDescriptionPane { protected final Wallet wallet; @@ -384,6 +385,14 @@ public class MnemonicKeystoreImportPane extends TitledDescriptionPane { try { Keystore keystore = importer.getKeystore(derivation, wordEntriesProperty.get(), passphraseProperty.get()); if(!dryrun) { + if(passphraseProperty.get() != null && !passphraseProperty.get().isEmpty()) { + KeystorePassphraseDialog keystorePassphraseDialog = new KeystorePassphraseDialog(null, keystore, true); + Optional optPassphrase = keystorePassphraseDialog.showAndWait(); + if(optPassphrase.isEmpty() || !optPassphrase.get().equals(passphraseProperty.get())) { + throw new ImportException("Re-entered passphrase did not match"); + } + } + EventManager.get().post(new KeystoreImportEvent(keystore)); } return true; @@ -394,7 +403,7 @@ public class MnemonicKeystoreImportPane extends TitledDescriptionPane { } else if(e.getCause() != null && e.getCause().getMessage() != null && !e.getCause().getMessage().isEmpty()) { errorMessage = e.getCause().getMessage(); } - setError("Import Error", errorMessage); + setError("Import Error", errorMessage + "."); importButton.setDisable(false); return false; }