mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 13:16:44 +00:00
show a warning dialog before refreshing a passphrase wallet where all the history has changed
This commit is contained in:
parent
fb1e1cefda
commit
d894343457
2 changed files with 18 additions and 0 deletions
|
@ -3051,6 +3051,8 @@ public class AppController implements Initializable {
|
||||||
public void requestWalletOpen(RequestWalletOpenEvent event) {
|
public void requestWalletOpen(RequestWalletOpenEvent event) {
|
||||||
if(tabs.getScene().getWindow().equals(event.getWindow())) {
|
if(tabs.getScene().getWindow().equals(event.getWindow())) {
|
||||||
if(event.getFile() != null) {
|
if(event.getFile() != null) {
|
||||||
|
Optional<Tab> optExisting = tabs.getTabs().stream().filter(tab -> tab.getUserData() instanceof WalletTabData walletTabData && walletTabData.getStorage().getWalletFile().equals(event.getFile())).findFirst();
|
||||||
|
optExisting.ifPresent(tab -> tabs.getTabs().remove(tab));
|
||||||
openWalletFile(event.getFile(), true);
|
openWalletFile(event.getFile(), true);
|
||||||
} else {
|
} else {
|
||||||
openWallet(true);
|
openWallet(true);
|
||||||
|
|
|
@ -20,6 +20,8 @@ import javafx.beans.property.BooleanProperty;
|
||||||
import javafx.beans.property.ObjectProperty;
|
import javafx.beans.property.ObjectProperty;
|
||||||
import javafx.beans.property.SimpleBooleanProperty;
|
import javafx.beans.property.SimpleBooleanProperty;
|
||||||
import javafx.beans.property.SimpleObjectProperty;
|
import javafx.beans.property.SimpleObjectProperty;
|
||||||
|
import javafx.scene.control.ButtonBar;
|
||||||
|
import javafx.scene.control.ButtonType;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -164,6 +166,20 @@ public class WalletForm {
|
||||||
});
|
});
|
||||||
historyService.setOnFailed(workerStateEvent -> {
|
historyService.setOnFailed(workerStateEvent -> {
|
||||||
if(workerStateEvent.getSource().getException() instanceof AllHistoryChangedException) {
|
if(workerStateEvent.getSource().getException() instanceof AllHistoryChangedException) {
|
||||||
|
if(getWallet().isMasterWallet() && getWallet().getKeystores().stream().anyMatch(Keystore::needsPassphrase)) {
|
||||||
|
Optional<ButtonType> optType = AppServices.showWarningDialog("Reopen " + getWallet().getMasterName() + "?",
|
||||||
|
"It appears that the history of this wallet has changed, which may be caused by an incorrect passphrase. " +
|
||||||
|
"Note that any typos when entering the passphrase will create an entirely different wallet, with a correspondingly different history.\n\n" +
|
||||||
|
"You can proceed with a full refresh of this wallet, or you can reopen it to enter the passphrase again.",
|
||||||
|
new ButtonType("Refresh Wallet", ButtonBar.ButtonData.CANCEL_CLOSE),
|
||||||
|
new ButtonType("Reopen Wallet", ButtonBar.ButtonData.OK_DONE));
|
||||||
|
|
||||||
|
if(optType.isPresent() && optType.get().getButtonData() == ButtonBar.ButtonData.OK_DONE) {
|
||||||
|
EventManager.get().post(new RequestWalletOpenEvent(AppServices.get().getWindowForWallet(getWalletId()), getStorage().getWalletFile()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
storage.backupWallet();
|
storage.backupWallet();
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
|
|
Loading…
Reference in a new issue