Allow restore from seednode if wallet is not empty

This commit is contained in:
Manfred Karrer 2016-04-17 20:39:20 +02:00
parent 6726504bd0
commit b889e9dc14
5 changed files with 33 additions and 13 deletions

View file

@ -76,7 +76,7 @@ import static io.bitsquare.app.BitsquareEnvironment.APP_NAME_KEY;
public class BitsquareApp extends Application { public class BitsquareApp extends Application {
private static final Logger log = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(BitsquareApp.class); 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; public static final boolean IS_RELEASE_VERSION = !DEV_MODE && true;
private static Environment env; private static Environment env;

View file

@ -237,13 +237,25 @@ public class SeedWordsView extends ActivatableView<GridPane, Void> {
"Please finalize your trades, close all your open offers and go to the Funds section to withdraw your bitcoin.\n" + "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" + "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\".") "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(); .show();
} else if (wallet.isEncrypted()) { } else {
checkIfEncrypted();
}
}
private void checkIfEncrypted() {
if (walletService.getWallet().isEncrypted()) {
new Popup() 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.") "After restore, the wallet will no longer be encrypted and you must set a new password.\n\n" +
.closeButtonText("I understand") "Do you want to proceed?")
.onClose(() -> doRestore()).show(); .closeButtonText("No")
.actionButtonText("Yes")
.onAction(this::doRestore)
.show();
} else { } else {
doRestore(); doRestore();
} }
@ -253,7 +265,7 @@ public class SeedWordsView extends ActivatableView<GridPane, Void> {
log.info("Attempting wallet restore using seed '{}' from date {}", restoreSeedWordsTextArea.getText(), restoreDatePicker.getValue()); log.info("Attempting wallet restore using seed '{}' from date {}", restoreSeedWordsTextArea.getText(), restoreDatePicker.getValue());
long date = restoreDatePicker.getValue().atStartOfDay().toEpochSecond(ZoneOffset.UTC); long date = restoreDatePicker.getValue().atStartOfDay().toEpochSecond(ZoneOffset.UTC);
DeterministicSeed seed = new DeterministicSeed(Splitter.on(" ").splitToList(restoreSeedWordsTextArea.getText()), null, "", date); DeterministicSeed seed = new DeterministicSeed(Splitter.on(" ").splitToList(restoreSeedWordsTextArea.getText()), null, "", date);
walletService.restoreSeedWords(seed, walletService.restoreSeedWords(seed,
() -> UserThread.execute(() -> { () -> UserThread.execute(() -> {
log.debug("Wallet restored with seed words"); log.debug("Wallet restored with seed words");
@ -261,7 +273,7 @@ public class SeedWordsView extends ActivatableView<GridPane, Void> {
.feedback("Wallet restored successfully with the new seed words.\n\n" + .feedback("Wallet restored successfully with the new seed words.\n\n" +
"You need to shut down and restart the application.") "You need to shut down and restart the application.")
.closeButtonText("Shut down") .closeButtonText("Shut down")
.onClose(() -> BitsquareApp.shutDownHandler.run()).show(); .onClose(BitsquareApp.shutDownHandler::run).show();
}), }),
throwable -> UserThread.execute(() -> { throwable -> UserThread.execute(() -> {
log.error(throwable.getMessage()); log.error(throwable.getMessage());

View file

@ -159,7 +159,7 @@ public class DepositView extends ActivatableView<VBox, Void> {
amountLabel = amountTuple.first; amountLabel = amountTuple.first;
amountTextField = amountTuple.second; amountTextField = amountTuple.second;
if (BitsquareApp.DEV_MODE) if (BitsquareApp.DEV_MODE)
amountTextField.setText("1"); amountTextField.setText("10");
titledGroupBg.setVisible(false); titledGroupBg.setVisible(false);
titledGroupBg.setManaged(false); titledGroupBg.setManaged(false);

View file

@ -148,8 +148,7 @@ public class TransactionsListItem {
} else if (trade.getPayoutTx() != null && } else if (trade.getPayoutTx() != null &&
trade.getPayoutTx().getHashAsString().equals(txId)) { trade.getPayoutTx().getHashAsString().equals(txId)) {
details = "MultiSig payout: " + tradable.getShortId(); details = "MultiSig payout: " + tradable.getShortId();
} else if (trade.getDisputeState() == Trade.DisputeState.DISPUTE_CLOSED || } else if (trade.getDisputeState() != Trade.DisputeState.NONE) {
trade.getDisputeState() == Trade.DisputeState.DISPUTE_STARTED_BY_PEER) {
if (valueSentToMe.isPositive()) { if (valueSentToMe.isPositive()) {
details = "Dispute payout: " + tradable.getShortId(); details = "Dispute payout: " + tradable.getShortId();
} else { } else {

View file

@ -334,10 +334,19 @@ public class WalletPasswordWindow extends Overlay<WalletPasswordWindow> {
"Please finalize your trades, close all your open offers and go to the Funds section to withdraw your bitcoin.\n" + "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" + "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\".") "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(); .show();
} else if (wallet.isEncrypted()) { } else {
checkIfEncrypted();
}
}
private void checkIfEncrypted() {
if (walletService.getWallet().isEncrypted()) {
new Popup() 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" + "After restore, the wallet will no longer be encrypted and you must set a new password.\n\n" +
"Do you want to proceed?") "Do you want to proceed?")
.closeButtonText("No") .closeButtonText("No")