diff --git a/core/src/main/java/io/bitsquare/btc/WalletService.java b/core/src/main/java/io/bitsquare/btc/WalletService.java index 4ec02324e5..e7503331ef 100644 --- a/core/src/main/java/io/bitsquare/btc/WalletService.java +++ b/core/src/main/java/io/bitsquare/btc/WalletService.java @@ -379,6 +379,15 @@ public class WalletService { } } + public String exportWalletData(boolean includePrivKeys) { + StringBuilder addressEntryListData = new StringBuilder(); + getAddressEntryListAsImmutableList().stream().forEach(e -> addressEntryListData.append(e.toString()).append("\n")); + return "BitcoinJ wallet:\n" + + wallet.toString(includePrivKeys, true, true, walletAppKit.chain()) + "\n\n" + + "Bitsquare address entry list:\n" + + addressEntryListData.toString(); + } + public void restoreSeedWords(DeterministicSeed seed, ResultHandler resultHandler, ExceptionHandler exceptionHandler) { Context ctx = Context.get(); new Thread(() -> { diff --git a/gui/src/main/java/io/bitsquare/app/BitsquareApp.java b/gui/src/main/java/io/bitsquare/app/BitsquareApp.java index 59375f3572..0327ef347a 100644 --- a/gui/src/main/java/io/bitsquare/app/BitsquareApp.java +++ b/gui/src/main/java/io/bitsquare/app/BitsquareApp.java @@ -44,6 +44,7 @@ import io.bitsquare.gui.main.overlays.popups.Popup; import io.bitsquare.gui.main.overlays.windows.EmptyWalletWindow; import io.bitsquare.gui.main.overlays.windows.FilterWindow; import io.bitsquare.gui.main.overlays.windows.SendAlertMessageWindow; +import io.bitsquare.gui.main.overlays.windows.ShowWalletDataWindow; import io.bitsquare.gui.util.ImageUtil; import io.bitsquare.p2p.P2PService; import io.bitsquare.storage.Storage; @@ -146,7 +147,7 @@ public class BitsquareApp extends Application { e.printStackTrace(); UserThread.execute(() -> showErrorPopup(e, true)); } - + Security.addProvider(new BouncyCastleProvider()); try { @@ -206,9 +207,15 @@ public class BitsquareApp extends Application { showSendAlertMessagePopup(); } else if (new KeyCodeCombination(KeyCode.F, KeyCombination.SHORTCUT_DOWN).match(keyEvent)) { showFilterPopup(); - } else if (new KeyCodeCombination(KeyCode.F, KeyCombination.SHORTCUT_DOWN).match(keyEvent)) + } else if (new KeyCodeCombination(KeyCode.F, KeyCombination.SHORTCUT_DOWN).match(keyEvent)) { showFPSWindow(); - else if (DevFlags.DEV_MODE) { + } else if (new KeyCodeCombination(KeyCode.J, KeyCombination.SHORTCUT_DOWN).match(keyEvent)) { + WalletService walletService = injector.getInstance(WalletService.class); + if (walletService.getWallet() != null) + new ShowWalletDataWindow(walletService).information("Wallet raw data").show(); + else + new Popup<>().warning("The wallet is not initialized yet").show(); + } else if (DevFlags.DEV_MODE) { if (new KeyCodeCombination(KeyCode.D, KeyCombination.SHORTCUT_DOWN).match(keyEvent)) showDebugWindow(); } diff --git a/gui/src/main/java/io/bitsquare/gui/main/offer/createoffer/CreateOfferViewModel.java b/gui/src/main/java/io/bitsquare/gui/main/offer/createoffer/CreateOfferViewModel.java index 10589cc194..92fa962ca5 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/offer/createoffer/CreateOfferViewModel.java +++ b/gui/src/main/java/io/bitsquare/gui/main/offer/createoffer/CreateOfferViewModel.java @@ -160,7 +160,7 @@ class CreateOfferViewModel extends ActivatableWithDataModel { amount.set("1"); minAmount.set(amount.get()); - price.set("600"); + price.set("700"); setAmountToModel(); setMinAmountToModel(); diff --git a/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/ShowWalletDataWindow.java b/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/ShowWalletDataWindow.java new file mode 100644 index 0000000000..ddace7f48a --- /dev/null +++ b/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/ShowWalletDataWindow.java @@ -0,0 +1,97 @@ +/* + * This file is part of Bitsquare. + * + * Bitsquare is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bitsquare is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bitsquare. If not, see . + */ + +package io.bitsquare.gui.main.overlays.windows; + +import io.bitsquare.btc.WalletService; +import io.bitsquare.common.util.Tuple2; +import io.bitsquare.common.util.Utilities; +import io.bitsquare.gui.main.overlays.Overlay; +import javafx.scene.Scene; +import javafx.scene.control.CheckBox; +import javafx.scene.control.Label; +import javafx.scene.control.TextArea; +import javafx.scene.input.KeyCode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static io.bitsquare.gui.util.FormBuilder.addLabelCheckBox; +import static io.bitsquare.gui.util.FormBuilder.addLabelTextArea; + +public class ShowWalletDataWindow extends Overlay { + private static final Logger log = LoggerFactory.getLogger(ShowWalletDataWindow.class); + private WalletService walletService; + + + /////////////////////////////////////////////////////////////////////////////////////////// + // Public API + /////////////////////////////////////////////////////////////////////////////////////////// + + public ShowWalletDataWindow(WalletService walletService) { + this.walletService = walletService; + type = Type.Attention; + } + + public void show() { + if (headLine == null) + headLine = "Wallet data"; + + width = 1000; + createGridPane(); + addHeadLine(); + addSeparator(); + addContent(); + addCloseButton(); + applyStyles(); + display(); + } + + /////////////////////////////////////////////////////////////////////////////////////////// + // Protected + /////////////////////////////////////////////////////////////////////////////////////////// + + @Override + protected void setupKeyHandler(Scene scene) { + if (!hideCloseButton) { + scene.setOnKeyPressed(e -> { + if (e.getCode() == KeyCode.ESCAPE) { + e.consume(); + doClose(); + } + }); + } + } + + private void addContent() { + Tuple2 labelTextAreaTuple2 = addLabelTextArea(gridPane, ++rowIndex, "Wallet data:", ""); + TextArea textArea = labelTextAreaTuple2.second; + Label label = labelTextAreaTuple2.first; + label.setMinWidth(150); + textArea.setPrefHeight(500); + CheckBox isUpdateCheckBox = addLabelCheckBox(gridPane, ++rowIndex, "Include private keys:", "").second; + isUpdateCheckBox.setSelected(false); + + isUpdateCheckBox.selectedProperty().addListener((observable, oldValue, newValue) -> { + textArea.setText(walletService.exportWalletData(isUpdateCheckBox.isSelected())); + }); + + textArea.setText(walletService.exportWalletData(isUpdateCheckBox.isSelected())); + + actionButtonText("Copy to clipboard"); + onAction(() -> Utilities.copyToClipboard(textArea.getText())); + } +}