From 750f6483cb9fd4798aff2043f4553d1a2cbfb538 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 24 Aug 2020 10:12:16 +0200 Subject: [PATCH] show alternative xpub values as tooltips --- drongo | 2 +- .../sparrow/wallet/KeystoreController.java | 20 ++++++++++++++++++- .../sparrow/transaction/input.fxml | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/drongo b/drongo index 0fbce035..ea5101df 160000 --- a/drongo +++ b/drongo @@ -1 +1 @@ -Subproject commit 0fbce035a3083f1cd5dc9f168b0cd4365a75ce40 +Subproject commit ea5101dff725a9973ac3056b5b59d26d3b4674f3 diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/KeystoreController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/KeystoreController.java index 896e2bee..29b049ed 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/KeystoreController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/KeystoreController.java @@ -98,6 +98,7 @@ public class KeystoreController extends WalletFormController implements Initiali if(keystore.getExtendedPublicKey() != null) { xpub.setText(keystore.getExtendedPublicKey().toString()); + setXpubTooltip(keystore.getExtendedPublicKey()); } if(keystore.getKeyDerivation() != null) { @@ -123,12 +124,26 @@ public class KeystoreController extends WalletFormController implements Initiali }); xpub.textProperty().addListener((observable, oldValue, newValue) -> { if(ExtendedKey.isValid(newValue)) { - keystore.setExtendedPublicKey(ExtendedKey.fromDescriptor(newValue)); + ExtendedKey extendedKey = ExtendedKey.fromDescriptor(newValue); + setXpubTooltip(extendedKey); + keystore.setExtendedPublicKey(extendedKey); EventManager.get().post(new SettingsChangedEvent(walletForm.getWallet(), SettingsChangedEvent.Type.KEYSTORE_XPUB)); + } else { + xpub.setTooltip(null); } }); } + private void setXpubTooltip(ExtendedKey extendedKey) { + ExtendedKey.Header header = ExtendedKey.Header.fromScriptType(walletForm.getWallet().getScriptType(), false); + if(header != ExtendedKey.Header.xpub) { + Tooltip tooltip = new Tooltip(extendedKey.getExtendedKey(header)); + xpub.setTooltip(tooltip); + } else { + xpub.setTooltip(null); + } + } + public void selectSource(ActionEvent event) { keystoreSourceToggleGroup.selectToggle(null); ToggleButton sourceButton = (ToggleButton)event.getSource(); @@ -288,6 +303,9 @@ public class KeystoreController extends WalletFormController implements Initiali derivation.setText(derivationPath + " "); derivation.setText(derivationPath); } + if(keystore.getExtendedPublicKey() != null) { + setXpubTooltip(keystore.getExtendedPublicKey()); + } } } } diff --git a/src/main/resources/com/sparrowwallet/sparrow/transaction/input.fxml b/src/main/resources/com/sparrowwallet/sparrow/transaction/input.fxml index 2d3db353..807ada6c 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/transaction/input.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/transaction/input.fxml @@ -98,7 +98,7 @@
-
+