mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 15:00:30 +01:00
Add export tool for wallet data
This commit is contained in:
parent
c970201833
commit
6ca66c6b8f
4 changed files with 117 additions and 4 deletions
|
@ -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(() -> {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel
|
|||
UserThread.runAfter(() -> {
|
||||
amount.set("1");
|
||||
minAmount.set(amount.get());
|
||||
price.set("600");
|
||||
price.set("700");
|
||||
|
||||
setAmountToModel();
|
||||
setMinAmountToModel();
|
||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<ShowWalletDataWindow> {
|
||||
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<Label, TextArea> 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()));
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue