mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-02 20:36: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) {
|
||||
if(tabs.getScene().getWindow().equals(event.getWindow())) {
|
||||
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);
|
||||
} else {
|
||||
openWallet(true);
|
||||
|
|
|
@ -20,6 +20,8 @@ import javafx.beans.property.BooleanProperty;
|
|||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.scene.control.ButtonBar;
|
||||
import javafx.scene.control.ButtonType;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -164,6 +166,20 @@ public class WalletForm {
|
|||
});
|
||||
historyService.setOnFailed(workerStateEvent -> {
|
||||
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 {
|
||||
storage.backupWallet();
|
||||
} catch(IOException e) {
|
||||
|
|
Loading…
Reference in a new issue