From 0eacc1508c07dd5f6bdc337ea13f8637999fd278 Mon Sep 17 00:00:00 2001 From: xyzmaker123 Date: Thu, 10 Jun 2021 18:24:04 +0200 Subject: [PATCH 1/4] Fix incorrect tx link to tx explorer - fixes #5548 --- .../src/main/java/bisq/desktop/components/TxIdTextField.java | 5 ++++- .../bisq/desktop/main/overlays/windows/ContractWindow.java | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/desktop/src/main/java/bisq/desktop/components/TxIdTextField.java b/desktop/src/main/java/bisq/desktop/components/TxIdTextField.java index 84cea87e541..41417503071 100644 --- a/desktop/src/main/java/bisq/desktop/components/TxIdTextField.java +++ b/desktop/src/main/java/bisq/desktop/components/TxIdTextField.java @@ -66,6 +66,8 @@ public static void setWalletService(BtcWalletService walletService) { private TxConfidenceListener txConfidenceListener; @Setter private boolean isBsq; + @Setter + private boolean isAddress = false; /////////////////////////////////////////////////////////////////////////////////////////// @@ -173,7 +175,8 @@ private void openBlockExplorer(String txId) { BlockChainExplorer blockChainExplorer = isBsq ? preferences.getBsqBlockChainExplorer() : preferences.getBlockChainExplorer(); - GUIUtil.openWebPage(blockChainExplorer.txUrl + txId, false); + String url = this.isAddress ? blockChainExplorer.addressUrl : blockChainExplorer.txUrl; + GUIUtil.openWebPage(url + txId, false); } } diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/windows/ContractWindow.java b/desktop/src/main/java/bisq/desktop/main/overlays/windows/ContractWindow.java index 4f025afec0b..90ba24dbe05 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/windows/ContractWindow.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/windows/ContractWindow.java @@ -18,6 +18,7 @@ package bisq.desktop.main.overlays.windows; import bisq.desktop.components.BisqTextArea; +import bisq.desktop.components.TxIdTextField; import bisq.desktop.main.MainView; import bisq.desktop.main.overlays.Overlay; import bisq.desktop.util.DisplayUtils; @@ -45,6 +46,7 @@ import bisq.common.UserThread; import bisq.common.crypto.PubKeyRing; +import bisq.common.util.Tuple2; import org.bitcoinj.core.Utils; @@ -256,8 +258,9 @@ private void addContent() { addLabelTxIdTextField(gridPane, ++rowIndex, Res.get("shared.delayedPayoutTxId"), dispute.getDelayedPayoutTxId()); if (dispute.getDonationAddressOfDelayedPayoutTx() != null) { - addLabelTxIdTextField(gridPane, ++rowIndex, Res.get("shared.delayedPayoutTxReceiverAddress"), + Tuple2 field = addLabelTxIdTextField(gridPane, ++rowIndex, Res.get("shared.delayedPayoutTxReceiverAddress"), dispute.getDonationAddressOfDelayedPayoutTx()); + field.second.setAddress(true); } if (dispute.getPayoutTxSerialized() != null) From 88a58ff462305eaed444ac0c4c2e558a8c3c4cbe Mon Sep 17 00:00:00 2001 From: xyzmaker123 Date: Fri, 11 Jun 2021 16:37:35 +0200 Subject: [PATCH 2/4] Fix incorrect tx link to tx explorer - another approach --- .../components/ExplorerAddressTextField.java | 137 ++++++++++++++++++ .../desktop/components/TxIdTextField.java | 5 +- .../java/bisq/desktop/main/MainViewModel.java | 2 + .../main/overlays/windows/ContractWindow.java | 4 +- .../presentation/MarketPricePresentation.java | 2 + .../java/bisq/desktop/util/FormBuilder.java | 19 +++ 6 files changed, 163 insertions(+), 6 deletions(-) create mode 100644 desktop/src/main/java/bisq/desktop/components/ExplorerAddressTextField.java diff --git a/desktop/src/main/java/bisq/desktop/components/ExplorerAddressTextField.java b/desktop/src/main/java/bisq/desktop/components/ExplorerAddressTextField.java new file mode 100644 index 00000000000..f0e72841090 --- /dev/null +++ b/desktop/src/main/java/bisq/desktop/components/ExplorerAddressTextField.java @@ -0,0 +1,137 @@ +/* + * This file is part of Bisq. + * + * Bisq 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. + * + * Bisq 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 Bisq. If not, see . + */ + +package bisq.desktop.components; + +import bisq.desktop.util.GUIUtil; + +import bisq.core.locale.Res; +import bisq.core.user.BlockChainExplorer; +import bisq.core.user.Preferences; + +import bisq.common.util.Utilities; + +import de.jensd.fx.fontawesome.AwesomeDude; +import de.jensd.fx.fontawesome.AwesomeIcon; + +import com.jfoenix.controls.JFXTextField; + +import javafx.scene.control.Label; +import javafx.scene.control.TextField; +import javafx.scene.control.Tooltip; +import javafx.scene.layout.AnchorPane; + +import lombok.Getter; +import lombok.Setter; + +import javax.annotation.Nullable; + +public class ExplorerAddressTextField extends AnchorPane { + private static Preferences preferences; + + public static void setPreferences(Preferences preferences) { + ExplorerAddressTextField.preferences = preferences; + } + + @Getter + private final TextField textField; + private final Label copyIcon, blockExplorerIcon, missingAddressWarningIcon; + @Setter + private boolean isBsq; + + + /////////////////////////////////////////////////////////////////////////////////////////// + // Constructor + /////////////////////////////////////////////////////////////////////////////////////////// + + public ExplorerAddressTextField() { + copyIcon = new Label(); + copyIcon.setLayoutY(3); + copyIcon.getStyleClass().addAll("icon", "highlight"); + copyIcon.setTooltip(new Tooltip(Res.get("txIdTextField.copyIcon.tooltip"))); + AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY); + AnchorPane.setRightAnchor(copyIcon, 30.0); + + Tooltip tooltip = new Tooltip(Res.get("txIdTextField.blockExplorerIcon.tooltip")); + + blockExplorerIcon = new Label(); + blockExplorerIcon.getStyleClass().addAll("icon", "highlight"); + blockExplorerIcon.setTooltip(tooltip); + AwesomeDude.setIcon(blockExplorerIcon, AwesomeIcon.EXTERNAL_LINK); + blockExplorerIcon.setMinWidth(20); + AnchorPane.setRightAnchor(blockExplorerIcon, 52.0); + AnchorPane.setTopAnchor(blockExplorerIcon, 4.0); + + missingAddressWarningIcon = new Label(); + missingAddressWarningIcon.getStyleClass().addAll("icon", "error-icon"); + AwesomeDude.setIcon(missingAddressWarningIcon, AwesomeIcon.WARNING_SIGN); + missingAddressWarningIcon.setTooltip(new Tooltip(Res.get("txIdTextField.missingTx.warning.tooltip"))); + missingAddressWarningIcon.setMinWidth(20); + AnchorPane.setRightAnchor(missingAddressWarningIcon, 52.0); + AnchorPane.setTopAnchor(missingAddressWarningIcon, 4.0); + missingAddressWarningIcon.setVisible(false); + missingAddressWarningIcon.setManaged(false); + + textField = new JFXTextField(); + textField.setId("address-text-field"); + textField.setEditable(false); + textField.setTooltip(tooltip); + AnchorPane.setRightAnchor(textField, 80.0); + AnchorPane.setLeftAnchor(textField, 0.0); + textField.focusTraversableProperty().set(focusTraversableProperty().get()); + getChildren().addAll(textField, missingAddressWarningIcon, blockExplorerIcon, copyIcon); + } + + public void setup(@Nullable String addressId) { + if (addressId == null) { + textField.setText(Res.get("shared.na")); + textField.setId("address-text-field-error"); + blockExplorerIcon.setVisible(false); + blockExplorerIcon.setManaged(false); + copyIcon.setVisible(false); + copyIcon.setManaged(false); + missingAddressWarningIcon.setVisible(true); + missingAddressWarningIcon.setManaged(true); + return; + } + + textField.setText(addressId); + textField.setOnMouseClicked(mouseEvent -> openBlockExplorer(addressId)); + blockExplorerIcon.setOnMouseClicked(mouseEvent -> openBlockExplorer(addressId)); + copyIcon.setOnMouseClicked(e -> Utilities.copyToClipboard(addressId)); + } + + public void cleanup() { + textField.setOnMouseClicked(null); + blockExplorerIcon.setOnMouseClicked(null); + copyIcon.setOnMouseClicked(null); + textField.setText(""); + } + + /////////////////////////////////////////////////////////////////////////////////////////// + // Private + /////////////////////////////////////////////////////////////////////////////////////////// + + private void openBlockExplorer(String addressId) { + if (preferences != null) { + BlockChainExplorer blockChainExplorer = isBsq ? + preferences.getBsqBlockChainExplorer() : + preferences.getBlockChainExplorer(); + GUIUtil.openWebPage(blockChainExplorer.addressUrl + addressId, false); + } + } +} diff --git a/desktop/src/main/java/bisq/desktop/components/TxIdTextField.java b/desktop/src/main/java/bisq/desktop/components/TxIdTextField.java index 41417503071..84cea87e541 100644 --- a/desktop/src/main/java/bisq/desktop/components/TxIdTextField.java +++ b/desktop/src/main/java/bisq/desktop/components/TxIdTextField.java @@ -66,8 +66,6 @@ public static void setWalletService(BtcWalletService walletService) { private TxConfidenceListener txConfidenceListener; @Setter private boolean isBsq; - @Setter - private boolean isAddress = false; /////////////////////////////////////////////////////////////////////////////////////////// @@ -175,8 +173,7 @@ private void openBlockExplorer(String txId) { BlockChainExplorer blockChainExplorer = isBsq ? preferences.getBsqBlockChainExplorer() : preferences.getBlockChainExplorer(); - String url = this.isAddress ? blockChainExplorer.addressUrl : blockChainExplorer.txUrl; - GUIUtil.openWebPage(url + txId, false); + GUIUtil.openWebPage(blockChainExplorer.txUrl + txId, false); } } diff --git a/desktop/src/main/java/bisq/desktop/main/MainViewModel.java b/desktop/src/main/java/bisq/desktop/main/MainViewModel.java index abba0a66b96..4a50a3bcc1f 100644 --- a/desktop/src/main/java/bisq/desktop/main/MainViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/MainViewModel.java @@ -19,6 +19,7 @@ import bisq.desktop.app.BisqApp; import bisq.desktop.common.model.ViewModel; +import bisq.desktop.components.ExplorerAddressTextField; import bisq.desktop.components.TxIdTextField; import bisq.desktop.main.overlays.Overlay; import bisq.desktop.main.overlays.notifications.NotificationCenter; @@ -205,6 +206,7 @@ public MainViewModel(BisqSetup bisqSetup, this.corruptedStorageFileHandler = corruptedStorageFileHandler; TxIdTextField.setPreferences(preferences); + ExplorerAddressTextField.setPreferences(preferences); TxIdTextField.setWalletService(btcWalletService); diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/windows/ContractWindow.java b/desktop/src/main/java/bisq/desktop/main/overlays/windows/ContractWindow.java index 90ba24dbe05..0a618144176 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/windows/ContractWindow.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/windows/ContractWindow.java @@ -18,6 +18,7 @@ package bisq.desktop.main.overlays.windows; import bisq.desktop.components.BisqTextArea; +import bisq.desktop.components.ExplorerAddressTextField; import bisq.desktop.components.TxIdTextField; import bisq.desktop.main.MainView; import bisq.desktop.main.overlays.Overlay; @@ -258,9 +259,8 @@ private void addContent() { addLabelTxIdTextField(gridPane, ++rowIndex, Res.get("shared.delayedPayoutTxId"), dispute.getDelayedPayoutTxId()); if (dispute.getDonationAddressOfDelayedPayoutTx() != null) { - Tuple2 field = addLabelTxIdTextField(gridPane, ++rowIndex, Res.get("shared.delayedPayoutTxReceiverAddress"), + addLabelExplorerAddressTextField(gridPane, ++rowIndex, Res.get("shared.delayedPayoutTxReceiverAddress"), dispute.getDonationAddressOfDelayedPayoutTx()); - field.second.setAddress(true); } if (dispute.getPayoutTxSerialized() != null) diff --git a/desktop/src/main/java/bisq/desktop/main/presentation/MarketPricePresentation.java b/desktop/src/main/java/bisq/desktop/main/presentation/MarketPricePresentation.java index 02c6aac52a0..795203175d6 100644 --- a/desktop/src/main/java/bisq/desktop/main/presentation/MarketPricePresentation.java +++ b/desktop/src/main/java/bisq/desktop/main/presentation/MarketPricePresentation.java @@ -17,6 +17,7 @@ package bisq.desktop.main.presentation; +import bisq.desktop.components.ExplorerAddressTextField; import bisq.desktop.components.TxIdTextField; import bisq.desktop.main.shared.PriceFeedComboBoxItem; import bisq.desktop.util.GUIUtil; @@ -94,6 +95,7 @@ public MarketPricePresentation(BtcWalletService btcWalletService, this.preferences = preferences; TxIdTextField.setPreferences(preferences); + ExplorerAddressTextField.setPreferences(preferences); // TODO TxIdTextField.setWalletService(btcWalletService); diff --git a/desktop/src/main/java/bisq/desktop/util/FormBuilder.java b/desktop/src/main/java/bisq/desktop/util/FormBuilder.java index 51faf17f93d..472ee4d8620 100644 --- a/desktop/src/main/java/bisq/desktop/util/FormBuilder.java +++ b/desktop/src/main/java/bisq/desktop/util/FormBuilder.java @@ -29,6 +29,7 @@ import bisq.desktop.components.BisqTextField; import bisq.desktop.components.BsqAddressTextField; import bisq.desktop.components.BusyAnimation; +import bisq.desktop.components.ExplorerAddressTextField; import bisq.desktop.components.ExternalHyperlink; import bisq.desktop.components.FundsTextField; import bisq.desktop.components.HyperlinkWithIcon; @@ -699,6 +700,24 @@ public static Tuple2 addLabelTxIdTextField(GridPane gridPa return new Tuple2<>(label, txTextField); } + /////////////////////////////////////////////////////////////////////////////////////////// + // Label + ExplorerAddressTextField + /////////////////////////////////////////////////////////////////////////////////////////// + public static void addLabelExplorerAddressTextField(GridPane gridPane, + int rowIndex, + String title, + String address) { + Label label = addLabel(gridPane, rowIndex, title, 0); + label.getStyleClass().add("confirmation-label"); + GridPane.setHalignment(label, HPos.LEFT); + + ExplorerAddressTextField addressTextField = new ExplorerAddressTextField(); + addressTextField.setup(address); + GridPane.setRowIndex(addressTextField, rowIndex); + GridPane.setColumnIndex(addressTextField, 1); + gridPane.getChildren().add(addressTextField); + } + /////////////////////////////////////////////////////////////////////////////////////////// // Label + InputTextField From cfdd4b475706c53e20f384f5426ce5d06f1c6c6d Mon Sep 17 00:00:00 2001 From: xyzmaker123 Date: Tue, 15 Jun 2021 12:27:06 +0200 Subject: [PATCH 3/4] Fix incorrect tx link to tx explorer - update translations --- .../resources/i18n/displayStrings.properties | 4 ++++ .../components/ExplorerAddressTextField.java | 22 +++++++++---------- .../main/overlays/windows/ContractWindow.java | 3 --- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index bdf67008e7b..d68529e3636 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -3095,6 +3095,10 @@ addressTextField.copyToClipboard=Copy address to clipboard addressTextField.addressCopiedToClipboard=Address has been copied to clipboard addressTextField.openWallet.failed=Opening a default Bitcoin wallet application has failed. Perhaps you don't have one installed? +explorerAddressTextField.copyToClipboard=Copy address to clipboard +explorerAddressTextField.blockExplorerIcon.tooltip=Open a blockchain explorer with this address +explorerAddressTextField.missingTx.warning.tooltip=Missing required address + peerInfoIcon.tooltip={0}\nTag: {1} txIdTextField.copyIcon.tooltip=Copy transaction ID to clipboard diff --git a/desktop/src/main/java/bisq/desktop/components/ExplorerAddressTextField.java b/desktop/src/main/java/bisq/desktop/components/ExplorerAddressTextField.java index f0e72841090..66de9fa2593 100644 --- a/desktop/src/main/java/bisq/desktop/components/ExplorerAddressTextField.java +++ b/desktop/src/main/java/bisq/desktop/components/ExplorerAddressTextField.java @@ -62,11 +62,11 @@ public ExplorerAddressTextField() { copyIcon = new Label(); copyIcon.setLayoutY(3); copyIcon.getStyleClass().addAll("icon", "highlight"); - copyIcon.setTooltip(new Tooltip(Res.get("txIdTextField.copyIcon.tooltip"))); + copyIcon.setTooltip(new Tooltip(Res.get("explorerAddressTextField.copyToClipboard"))); AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY); AnchorPane.setRightAnchor(copyIcon, 30.0); - Tooltip tooltip = new Tooltip(Res.get("txIdTextField.blockExplorerIcon.tooltip")); + Tooltip tooltip = new Tooltip(Res.get("explorerAddressTextField.blockExplorerIcon.tooltip")); blockExplorerIcon = new Label(); blockExplorerIcon.getStyleClass().addAll("icon", "highlight"); @@ -79,7 +79,7 @@ public ExplorerAddressTextField() { missingAddressWarningIcon = new Label(); missingAddressWarningIcon.getStyleClass().addAll("icon", "error-icon"); AwesomeDude.setIcon(missingAddressWarningIcon, AwesomeIcon.WARNING_SIGN); - missingAddressWarningIcon.setTooltip(new Tooltip(Res.get("txIdTextField.missingTx.warning.tooltip"))); + missingAddressWarningIcon.setTooltip(new Tooltip(Res.get("explorerAddressTextField.missingTx.warning.tooltip"))); missingAddressWarningIcon.setMinWidth(20); AnchorPane.setRightAnchor(missingAddressWarningIcon, 52.0); AnchorPane.setTopAnchor(missingAddressWarningIcon, 4.0); @@ -96,8 +96,8 @@ public ExplorerAddressTextField() { getChildren().addAll(textField, missingAddressWarningIcon, blockExplorerIcon, copyIcon); } - public void setup(@Nullable String addressId) { - if (addressId == null) { + public void setup(@Nullable String address) { + if (address == null) { textField.setText(Res.get("shared.na")); textField.setId("address-text-field-error"); blockExplorerIcon.setVisible(false); @@ -109,10 +109,10 @@ public void setup(@Nullable String addressId) { return; } - textField.setText(addressId); - textField.setOnMouseClicked(mouseEvent -> openBlockExplorer(addressId)); - blockExplorerIcon.setOnMouseClicked(mouseEvent -> openBlockExplorer(addressId)); - copyIcon.setOnMouseClicked(e -> Utilities.copyToClipboard(addressId)); + textField.setText(address); + textField.setOnMouseClicked(mouseEvent -> openBlockExplorer(address)); + blockExplorerIcon.setOnMouseClicked(mouseEvent -> openBlockExplorer(address)); + copyIcon.setOnMouseClicked(e -> Utilities.copyToClipboard(address)); } public void cleanup() { @@ -126,12 +126,12 @@ public void cleanup() { // Private /////////////////////////////////////////////////////////////////////////////////////////// - private void openBlockExplorer(String addressId) { + private void openBlockExplorer(String address) { if (preferences != null) { BlockChainExplorer blockChainExplorer = isBsq ? preferences.getBsqBlockChainExplorer() : preferences.getBlockChainExplorer(); - GUIUtil.openWebPage(blockChainExplorer.addressUrl + addressId, false); + GUIUtil.openWebPage(blockChainExplorer.addressUrl + address, false); } } } diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/windows/ContractWindow.java b/desktop/src/main/java/bisq/desktop/main/overlays/windows/ContractWindow.java index 0a618144176..49bc879aa4c 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/windows/ContractWindow.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/windows/ContractWindow.java @@ -18,8 +18,6 @@ package bisq.desktop.main.overlays.windows; import bisq.desktop.components.BisqTextArea; -import bisq.desktop.components.ExplorerAddressTextField; -import bisq.desktop.components.TxIdTextField; import bisq.desktop.main.MainView; import bisq.desktop.main.overlays.Overlay; import bisq.desktop.util.DisplayUtils; @@ -47,7 +45,6 @@ import bisq.common.UserThread; import bisq.common.crypto.PubKeyRing; -import bisq.common.util.Tuple2; import org.bitcoinj.core.Utils; From 12a7fd60b26ece3d18552f346f73d28a19523b1e Mon Sep 17 00:00:00 2001 From: xyzmaker123 Date: Thu, 17 Jun 2021 20:57:52 +0200 Subject: [PATCH 4/4] Fix incorrect tx link to tx explorer - use @Setter --- .../desktop/components/ExplorerAddressTextField.java | 5 +---- .../java/bisq/desktop/components/TxIdTextField.java | 11 ++--------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/desktop/src/main/java/bisq/desktop/components/ExplorerAddressTextField.java b/desktop/src/main/java/bisq/desktop/components/ExplorerAddressTextField.java index 66de9fa2593..1f2efb58bb1 100644 --- a/desktop/src/main/java/bisq/desktop/components/ExplorerAddressTextField.java +++ b/desktop/src/main/java/bisq/desktop/components/ExplorerAddressTextField.java @@ -41,12 +41,9 @@ import javax.annotation.Nullable; public class ExplorerAddressTextField extends AnchorPane { + @Setter private static Preferences preferences; - public static void setPreferences(Preferences preferences) { - ExplorerAddressTextField.preferences = preferences; - } - @Getter private final TextField textField; private final Label copyIcon, blockExplorerIcon, missingAddressWarningIcon; diff --git a/desktop/src/main/java/bisq/desktop/components/TxIdTextField.java b/desktop/src/main/java/bisq/desktop/components/TxIdTextField.java index 84cea87e541..084fd5fba45 100644 --- a/desktop/src/main/java/bisq/desktop/components/TxIdTextField.java +++ b/desktop/src/main/java/bisq/desktop/components/TxIdTextField.java @@ -46,18 +46,11 @@ import javax.annotation.Nullable; public class TxIdTextField extends AnchorPane { + @Setter private static Preferences preferences; - - public static void setPreferences(Preferences preferences) { - TxIdTextField.preferences = preferences; - } - + @Setter private static BtcWalletService walletService; - public static void setWalletService(BtcWalletService walletService) { - TxIdTextField.walletService = walletService; - } - @Getter private final TextField textField; private final Tooltip progressIndicatorTooltip;