From 639e1456723df61a651778bf35dfa488cf9da16c Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Tue, 6 Oct 2020 12:39:30 +0200 Subject: [PATCH] use tPubs instead of xPubs on labels in testnet --- .../keystoreimport/KeystoreImportDialog.java | 3 ++- .../sparrow/wallet/KeystoreController.java | 15 ++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/keystoreimport/KeystoreImportDialog.java b/src/main/java/com/sparrowwallet/sparrow/keystoreimport/KeystoreImportDialog.java index cb18b39e..ec5c070a 100644 --- a/src/main/java/com/sparrowwallet/sparrow/keystoreimport/KeystoreImportDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/keystoreimport/KeystoreImportDialog.java @@ -2,6 +2,7 @@ package com.sparrowwallet.sparrow.keystoreimport; import com.google.common.eventbus.Subscribe; import com.sparrowwallet.drongo.KeyDerivation; +import com.sparrowwallet.drongo.Network; import com.sparrowwallet.drongo.wallet.Keystore; import com.sparrowwallet.drongo.wallet.KeystoreSource; import com.sparrowwallet.drongo.wallet.Wallet; @@ -40,7 +41,7 @@ public class KeystoreImportDialog extends Dialog { keystoreImportController.initializeView(wallet); keystoreImportController.selectSource(initialSource); - final ButtonType watchOnlyButtonType = new javafx.scene.control.ButtonType("xPub / Watch Only Wallet", ButtonBar.ButtonData.LEFT); + final ButtonType watchOnlyButtonType = new javafx.scene.control.ButtonType(Network.get().getXpubHeader().getDisplayName() + " / Watch Only Wallet", ButtonBar.ButtonData.LEFT); final ButtonType cancelButtonType = new javafx.scene.control.ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE); dialogPane.getButtonTypes().addAll(watchOnlyButtonType, cancelButtonType); dialogPane.setPrefWidth(650); diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/KeystoreController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/KeystoreController.java index 8be7e4a5..6ff07449 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/KeystoreController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/KeystoreController.java @@ -121,6 +121,7 @@ public class KeystoreController extends WalletFormController implements Initiali setXpubContext(keystore.getExtendedPublicKey()); } else { switchXpubHeader.setDisable(true); + xpubField.setText(Network.get().getXpubHeader().getDisplayName() + ":"); } if(keystore.getKeyDerivation() != null) { @@ -163,7 +164,7 @@ public class KeystoreController extends WalletFormController implements Initiali private void setXpubContext(ExtendedKey extendedKey) { ContextMenu contextMenu = new ContextMenu(); - MenuItem copyXPub = new MenuItem("Copy xPub"); + MenuItem copyXPub = new MenuItem("Copy " + Network.get().getXpubHeader().getDisplayName()); copyXPub.setOnAction(AE -> { contextMenu.hide(); ClipboardContent content = new ClipboardContent(); @@ -185,11 +186,11 @@ public class KeystoreController extends WalletFormController implements Initiali }); contextMenu.getItems().add(copyOtherPub); - xpubField.setText("xPub / " + header.getDisplayName() + ":"); + xpubField.setText(Network.get().getXpubHeader().getDisplayName() + " / " + header.getDisplayName() + ":"); switchXpubHeader.setDisable(false); switchXpubHeader.setTooltip(new Tooltip("Show as " + header.getDisplayName())); } else { - xpubField.setText("xPub:"); + xpubField.setText(Network.get().getXpubHeader().getDisplayName() + ":"); switchXpubHeader.setDisable(true); } @@ -224,8 +225,8 @@ public class KeystoreController extends WalletFormController implements Initiali )); validationSupport.registerValidator(xpub, Validator.combine( - Validator.createEmptyValidator("xPub is required"), - (Control c, String newValue) -> ValidationResult.fromErrorIf( c, "xPub is invalid", !ExtendedKey.isValid(newValue)) + Validator.createEmptyValidator(Network.get().getXpubHeader().getDisplayName() + " is required"), + (Control c, String newValue) -> ValidationResult.fromErrorIf( c, Network.get().getXpubHeader().getDisplayName() + " is invalid", !ExtendedKey.isValid(newValue)) )); validationSupport.registerValidator(derivation, Validator.combine( @@ -367,7 +368,7 @@ public class KeystoreController extends WalletFormController implements Initiali log.error("Error opening webcam", result.exception); AppController.showErrorDialog("Error opening webcam", result.exception.getMessage()); } else { - AppController.showErrorDialog("Invalid QR Code", "QR Code did not contain a valid xPub"); + AppController.showErrorDialog("Invalid QR Code", "QR Code did not contain a valid " + Network.get().getXpubHeader().getDisplayName()); } } } @@ -383,7 +384,7 @@ public class KeystoreController extends WalletFormController implements Initiali if(!xpub.getText().startsWith(header.getName())) { String otherPub = keystore.getExtendedPublicKey().getExtendedKey(header); xpub.setText(otherPub); - switchXpubHeader.setTooltip(new Tooltip("Show as xPub")); + switchXpubHeader.setTooltip(new Tooltip("Show as " + Network.get().getXpubHeader().getDisplayName())); } else { String xPub = keystore.getExtendedPublicKey().getExtendedKey(); xpub.setText(xPub);