From b889e9dc1460d5fec6902c21b644dbe28d0240ea Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Sun, 17 Apr 2016 20:39:20 +0200 Subject: [PATCH] Allow restore from seednode if wallet is not empty --- .../java/io/bitsquare/app/BitsquareApp.java | 2 +- .../content/seedwords/SeedWordsView.java | 26 ++++++++++++++----- .../gui/main/funds/deposit/DepositView.java | 2 +- .../transactions/TransactionsListItem.java | 3 +-- .../windows/WalletPasswordWindow.java | 13 ++++++++-- 5 files changed, 33 insertions(+), 13 deletions(-) diff --git a/gui/src/main/java/io/bitsquare/app/BitsquareApp.java b/gui/src/main/java/io/bitsquare/app/BitsquareApp.java index 2a4348d9a5..cf61f7da3f 100644 --- a/gui/src/main/java/io/bitsquare/app/BitsquareApp.java +++ b/gui/src/main/java/io/bitsquare/app/BitsquareApp.java @@ -76,7 +76,7 @@ import static io.bitsquare.app.BitsquareEnvironment.APP_NAME_KEY; public class BitsquareApp extends Application { private static final Logger log = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(BitsquareApp.class); - public static final boolean DEV_MODE = false; + public static final boolean DEV_MODE = true; public static final boolean IS_RELEASE_VERSION = !DEV_MODE && true; private static Environment env; diff --git a/gui/src/main/java/io/bitsquare/gui/main/account/content/seedwords/SeedWordsView.java b/gui/src/main/java/io/bitsquare/gui/main/account/content/seedwords/SeedWordsView.java index 8b5301a25c..8e341b863a 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/account/content/seedwords/SeedWordsView.java +++ b/gui/src/main/java/io/bitsquare/gui/main/account/content/seedwords/SeedWordsView.java @@ -237,13 +237,25 @@ public class SeedWordsView extends ActivatableView { "Please finalize your trades, close all your open offers and go to the Funds section to withdraw your bitcoin.\n" + "In case you cannot access your bitcoin you can use the emergency tool to empty the wallet.\n" + "To open that emergency tool press \"cmd + e\".") + .actionButtonText("I want to restore anyway") + .onAction(this::checkIfEncrypted) + .closeButtonText("I will empty my wallet first") .show(); - } else if (wallet.isEncrypted()) { + } else { + checkIfEncrypted(); + } + } + + private void checkIfEncrypted() { + if (walletService.getWallet().isEncrypted()) { new Popup() - .warning("Your bitcoin wallet is encrypted.\n\n" + - "After restore, the wallet will no longer be encrypted and you must set a new password.") - .closeButtonText("I understand") - .onClose(() -> doRestore()).show(); + .information("Your bitcoin wallet is encrypted.\n\n" + + "After restore, the wallet will no longer be encrypted and you must set a new password.\n\n" + + "Do you want to proceed?") + .closeButtonText("No") + .actionButtonText("Yes") + .onAction(this::doRestore) + .show(); } else { doRestore(); } @@ -253,7 +265,7 @@ public class SeedWordsView extends ActivatableView { log.info("Attempting wallet restore using seed '{}' from date {}", restoreSeedWordsTextArea.getText(), restoreDatePicker.getValue()); long date = restoreDatePicker.getValue().atStartOfDay().toEpochSecond(ZoneOffset.UTC); DeterministicSeed seed = new DeterministicSeed(Splitter.on(" ").splitToList(restoreSeedWordsTextArea.getText()), null, "", date); - walletService.restoreSeedWords(seed, + walletService.restoreSeedWords(seed, () -> UserThread.execute(() -> { log.debug("Wallet restored with seed words"); @@ -261,7 +273,7 @@ public class SeedWordsView extends ActivatableView { .feedback("Wallet restored successfully with the new seed words.\n\n" + "You need to shut down and restart the application.") .closeButtonText("Shut down") - .onClose(() -> BitsquareApp.shutDownHandler.run()).show(); + .onClose(BitsquareApp.shutDownHandler::run).show(); }), throwable -> UserThread.execute(() -> { log.error(throwable.getMessage()); diff --git a/gui/src/main/java/io/bitsquare/gui/main/funds/deposit/DepositView.java b/gui/src/main/java/io/bitsquare/gui/main/funds/deposit/DepositView.java index 6f24ed87bd..ec818f1df1 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/funds/deposit/DepositView.java +++ b/gui/src/main/java/io/bitsquare/gui/main/funds/deposit/DepositView.java @@ -159,7 +159,7 @@ public class DepositView extends ActivatableView { amountLabel = amountTuple.first; amountTextField = amountTuple.second; if (BitsquareApp.DEV_MODE) - amountTextField.setText("1"); + amountTextField.setText("10"); titledGroupBg.setVisible(false); titledGroupBg.setManaged(false); diff --git a/gui/src/main/java/io/bitsquare/gui/main/funds/transactions/TransactionsListItem.java b/gui/src/main/java/io/bitsquare/gui/main/funds/transactions/TransactionsListItem.java index 352d4605d0..3729b05c76 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/funds/transactions/TransactionsListItem.java +++ b/gui/src/main/java/io/bitsquare/gui/main/funds/transactions/TransactionsListItem.java @@ -148,8 +148,7 @@ public class TransactionsListItem { } else if (trade.getPayoutTx() != null && trade.getPayoutTx().getHashAsString().equals(txId)) { details = "MultiSig payout: " + tradable.getShortId(); - } else if (trade.getDisputeState() == Trade.DisputeState.DISPUTE_CLOSED || - trade.getDisputeState() == Trade.DisputeState.DISPUTE_STARTED_BY_PEER) { + } else if (trade.getDisputeState() != Trade.DisputeState.NONE) { if (valueSentToMe.isPositive()) { details = "Dispute payout: " + tradable.getShortId(); } else { diff --git a/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/WalletPasswordWindow.java b/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/WalletPasswordWindow.java index 55231a321a..1f69c5226f 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/WalletPasswordWindow.java +++ b/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/WalletPasswordWindow.java @@ -334,10 +334,19 @@ public class WalletPasswordWindow extends Overlay { "Please finalize your trades, close all your open offers and go to the Funds section to withdraw your bitcoin.\n" + "In case you cannot access your bitcoin you can use the emergency tool to empty the wallet.\n" + "To open that emergency tool press \"cmd + e\".") + .actionButtonText("I want to restore anyway") + .onAction(this::checkIfEncrypted) + .closeButtonText("I will empty my wallet first") .show(); - } else if (wallet.isEncrypted()) { + } else { + checkIfEncrypted(); + } + } + + private void checkIfEncrypted() { + if (walletService.getWallet().isEncrypted()) { new Popup() - .warning("Your bitcoin wallet is encrypted.\n\n" + + .information("Your bitcoin wallet is encrypted.\n\n" + "After restore, the wallet will no longer be encrypted and you must set a new password.\n\n" + "Do you want to proceed?") .closeButtonText("No")