From 4ae5d550009533ba6bb7b1b3b8ad2249769301d9 Mon Sep 17 00:00:00 2001 From: Android-X13 <76814540+Android-X13@users.noreply.github.com> Date: Wed, 10 Aug 2022 18:53:30 +0300 Subject: [PATCH] Standardize blockchain explorer URL usage --- .../components/ExplorerAddressTextField.java | 22 +---------- .../desktop/components/TxIdTextField.java | 17 +-------- .../java/bisq/desktop/main/MainViewModel.java | 4 -- .../main/dao/bonding/bonds/BondsView.java | 8 +--- .../bonding/reputation/MyReputationView.java | 8 +--- .../main/dao/bonding/roles/RolesView.java | 8 +--- .../burnbsq/proofofburn/ProofOfBurnView.java | 8 +--- .../transactions/BSQTransactionsView.java | 9 ++--- .../main/dao/governance/ProposalDisplay.java | 6 +-- .../dao/governance/make/MakeProposalView.java | 2 +- .../main/dao/wallet/send/BsqSendView.java | 6 --- .../desktop/main/dao/wallet/tx/BsqTxView.java | 19 +--------- .../main/funds/deposit/DepositView.java | 11 +----- .../desktop/main/funds/locked/LockedView.java | 10 +---- .../main/funds/reserved/ReservedView.java | 10 +---- .../funds/transactions/TransactionsView.java | 15 +------- .../main/funds/withdrawal/WithdrawalView.java | 7 +--- .../windows/ManualPayoutTxWindow.java | 19 ++-------- .../windows/ProposalResultsWindow.java | 16 ++------ .../windows/SelectProposalWindow.java | 8 +--- .../windows/TxInputSelectionWindow.java | 6 +-- .../presentation/MarketPricePresentation.java | 4 -- .../main/java/bisq/desktop/util/GUIUtil.java | 38 ++++++++++++++++++- 23 files changed, 71 insertions(+), 190 deletions(-) diff --git a/desktop/src/main/java/bisq/desktop/components/ExplorerAddressTextField.java b/desktop/src/main/java/bisq/desktop/components/ExplorerAddressTextField.java index 1f2efb58bb..c269ea6706 100644 --- a/desktop/src/main/java/bisq/desktop/components/ExplorerAddressTextField.java +++ b/desktop/src/main/java/bisq/desktop/components/ExplorerAddressTextField.java @@ -20,8 +20,6 @@ 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; @@ -41,9 +39,6 @@ import lombok.Setter; import javax.annotation.Nullable; public class ExplorerAddressTextField extends AnchorPane { - @Setter - private static Preferences preferences; - @Getter private final TextField textField; private final Label copyIcon, blockExplorerIcon, missingAddressWarningIcon; @@ -107,8 +102,8 @@ public class ExplorerAddressTextField extends AnchorPane { } textField.setText(address); - textField.setOnMouseClicked(mouseEvent -> openBlockExplorer(address)); - blockExplorerIcon.setOnMouseClicked(mouseEvent -> openBlockExplorer(address)); + textField.setOnMouseClicked(mouseEvent -> GUIUtil.openAddressInBlockExplorer(address, isBsq)); + blockExplorerIcon.setOnMouseClicked(mouseEvent -> GUIUtil.openAddressInBlockExplorer(address, isBsq)); copyIcon.setOnMouseClicked(e -> Utilities.copyToClipboard(address)); } @@ -118,17 +113,4 @@ public class ExplorerAddressTextField extends AnchorPane { copyIcon.setOnMouseClicked(null); textField.setText(""); } - - /////////////////////////////////////////////////////////////////////////////////////////// - // Private - /////////////////////////////////////////////////////////////////////////////////////////// - - private void openBlockExplorer(String address) { - if (preferences != null) { - BlockChainExplorer blockChainExplorer = isBsq ? - preferences.getBsqBlockChainExplorer() : - preferences.getBlockChainExplorer(); - GUIUtil.openWebPage(blockChainExplorer.addressUrl + address, false); - } - } } diff --git a/desktop/src/main/java/bisq/desktop/components/TxIdTextField.java b/desktop/src/main/java/bisq/desktop/components/TxIdTextField.java index 084fd5fba4..b84d32a44d 100644 --- a/desktop/src/main/java/bisq/desktop/components/TxIdTextField.java +++ b/desktop/src/main/java/bisq/desktop/components/TxIdTextField.java @@ -23,8 +23,6 @@ import bisq.desktop.util.GUIUtil; import bisq.core.btc.listeners.TxConfidenceListener; import bisq.core.btc.wallet.BtcWalletService; import bisq.core.locale.Res; -import bisq.core.user.BlockChainExplorer; -import bisq.core.user.Preferences; import bisq.common.util.Utilities; @@ -46,8 +44,6 @@ import lombok.Setter; import javax.annotation.Nullable; public class TxIdTextField extends AnchorPane { - @Setter - private static Preferences preferences; @Setter private static BtcWalletService walletService; @@ -142,8 +138,8 @@ public class TxIdTextField extends AnchorPane { updateConfidence(walletService.getConfidenceForTxId(txId)); textField.setText(txId); - textField.setOnMouseClicked(mouseEvent -> openBlockExplorer(txId)); - blockExplorerIcon.setOnMouseClicked(mouseEvent -> openBlockExplorer(txId)); + textField.setOnMouseClicked(mouseEvent -> GUIUtil.openTxInBlockExplorer(txId, isBsq)); + blockExplorerIcon.setOnMouseClicked(mouseEvent -> GUIUtil.openTxInBlockExplorer(txId, isBsq)); copyIcon.setOnMouseClicked(e -> Utilities.copyToClipboard(txId)); } @@ -161,15 +157,6 @@ public class TxIdTextField extends AnchorPane { // Private /////////////////////////////////////////////////////////////////////////////////////////// - private void openBlockExplorer(String txId) { - if (preferences != null) { - BlockChainExplorer blockChainExplorer = isBsq ? - preferences.getBsqBlockChainExplorer() : - preferences.getBlockChainExplorer(); - GUIUtil.openWebPage(blockChainExplorer.txUrl + txId, false); - } - } - private void updateConfidence(TransactionConfidence confidence) { GUIUtil.updateConfidence(confidence, progressIndicatorTooltip, txConfidenceIndicator); if (confidence != null) { diff --git a/desktop/src/main/java/bisq/desktop/main/MainViewModel.java b/desktop/src/main/java/bisq/desktop/main/MainViewModel.java index 8f7d0fc4f1..345528bc07 100644 --- a/desktop/src/main/java/bisq/desktop/main/MainViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/MainViewModel.java @@ -20,7 +20,6 @@ package bisq.desktop.main; import bisq.desktop.Navigation; 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.account.AccountView; import bisq.desktop.main.account.content.backup.BackupView; @@ -233,9 +232,6 @@ public class MainViewModel implements ViewModel, BisqSetup.BisqSetupListener { this.clockWatcher = clockWatcher; this.navigation = navigation; - TxIdTextField.setPreferences(preferences); - ExplorerAddressTextField.setPreferences(preferences); - TxIdTextField.setWalletService(btcWalletService); GUIUtil.setFeeService(feeService); diff --git a/desktop/src/main/java/bisq/desktop/main/dao/bonding/bonds/BondsView.java b/desktop/src/main/java/bisq/desktop/main/dao/bonding/bonds/BondsView.java index 9a32224107..a518b8bace 100644 --- a/desktop/src/main/java/bisq/desktop/main/dao/bonding/bonds/BondsView.java +++ b/desktop/src/main/java/bisq/desktop/main/dao/bonding/bonds/BondsView.java @@ -32,7 +32,6 @@ import bisq.core.dao.governance.bond.reputation.BondedReputationRepository; import bisq.core.dao.governance.bond.role.BondedRole; import bisq.core.dao.governance.bond.role.BondedRolesRepository; import bisq.core.locale.Res; -import bisq.core.user.Preferences; import bisq.core.util.coin.BsqFormatter; import javax.inject.Inject; @@ -68,7 +67,6 @@ public class BondsView extends ActivatableView { private final BsqFormatter bsqFormatter; private final BondedRolesRepository bondedRolesRepository; private final BondedReputationRepository bondedReputationRepository; - private final Preferences preferences; private int gridRow = 0; @@ -87,12 +85,10 @@ public class BondsView extends ActivatableView { @Inject private BondsView(BsqFormatter bsqFormatter, BondedRolesRepository bondedRolesRepository, - BondedReputationRepository bondedReputationRepository, - Preferences preferences) { + BondedReputationRepository bondedReputationRepository) { this.bsqFormatter = bsqFormatter; this.bondedRolesRepository = bondedRolesRepository; this.bondedReputationRepository = bondedReputationRepository; - this.preferences = preferences; } @Override @@ -330,7 +326,7 @@ public class BondsView extends ActivatableView { if (item != null && !empty) { String lockupTxId = item.getLockupTxId(); hyperlinkWithIcon = new ExternalHyperlink(lockupTxId); - hyperlinkWithIcon.setOnAction(event -> GUIUtil.openTxInBsqBlockExplorer(lockupTxId, preferences)); + hyperlinkWithIcon.setOnAction(event -> GUIUtil.openTxInBlockExplorer(lockupTxId, true)); hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForTx", lockupTxId))); if (item.getLockupDateString().equals("-")) hyperlinkWithIcon.hideIcon(); setGraphic(hyperlinkWithIcon); diff --git a/desktop/src/main/java/bisq/desktop/main/dao/bonding/reputation/MyReputationView.java b/desktop/src/main/java/bisq/desktop/main/dao/bonding/reputation/MyReputationView.java index 787a31cf0e..34e281b909 100644 --- a/desktop/src/main/java/bisq/desktop/main/dao/bonding/reputation/MyReputationView.java +++ b/desktop/src/main/java/bisq/desktop/main/dao/bonding/reputation/MyReputationView.java @@ -37,7 +37,6 @@ import bisq.core.dao.governance.bond.BondConsensus; import bisq.core.dao.governance.bond.BondState; import bisq.core.dao.governance.bond.reputation.MyBondedReputation; import bisq.core.locale.Res; -import bisq.core.user.Preferences; import bisq.core.util.ParsingUtils; import bisq.core.util.coin.BsqFormatter; import bisq.core.util.validation.HexStringValidator; @@ -90,7 +89,6 @@ public class MyReputationView extends ActivatableView implements private final HexStringValidator hexStringValidator; private final BsqValidator bsqValidator; private final DaoFacade daoFacade; - private final Preferences preferences; private final IntegerValidator timeInputTextFieldValidator; @@ -114,15 +112,13 @@ public class MyReputationView extends ActivatableView implements BondingViewUtils bondingViewUtils, HexStringValidator hexStringValidator, BsqValidator bsqValidator, - DaoFacade daoFacade, - Preferences preferences) { + DaoFacade daoFacade) { this.bsqFormatter = bsqFormatter; this.bsqWalletService = bsqWalletService; this.bondingViewUtils = bondingViewUtils; this.hexStringValidator = hexStringValidator; this.bsqValidator = bsqValidator; this.daoFacade = daoFacade; - this.preferences = preferences; timeInputTextFieldValidator = new IntegerValidator(); timeInputTextFieldValidator.setMinValue(BondConsensus.getMinLockTime()); @@ -397,7 +393,7 @@ public class MyReputationView extends ActivatableView implements if (item != null && !empty) { String transactionId = item.getTxId(); hyperlinkWithIcon = new ExternalHyperlink(transactionId); - hyperlinkWithIcon.setOnAction(event -> GUIUtil.openTxInBsqBlockExplorer(item.getTxId(), preferences)); + hyperlinkWithIcon.setOnAction(event -> GUIUtil.openTxInBlockExplorer(transactionId, true)); hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForTx", transactionId))); setGraphic(hyperlinkWithIcon); } else { diff --git a/desktop/src/main/java/bisq/desktop/main/dao/bonding/roles/RolesView.java b/desktop/src/main/java/bisq/desktop/main/dao/bonding/roles/RolesView.java index c189b3b6b1..da0006c4f0 100644 --- a/desktop/src/main/java/bisq/desktop/main/dao/bonding/roles/RolesView.java +++ b/desktop/src/main/java/bisq/desktop/main/dao/bonding/roles/RolesView.java @@ -33,7 +33,6 @@ import bisq.core.dao.DaoFacade; import bisq.core.dao.SignVerifyService; import bisq.core.dao.governance.bond.role.BondedRole; import bisq.core.locale.Res; -import bisq.core.user.Preferences; import bisq.core.util.coin.BsqFormatter; import javax.inject.Inject; @@ -68,7 +67,6 @@ public class RolesView extends ActivatableView { private final SignVerifyService signVerifyService; private final BsqFormatter bsqFormatter; private final DaoFacade daoFacade; - private final Preferences preferences; private final ObservableList observableList = FXCollections.observableArrayList(); private final SortedList sortedList = new SortedList<>(observableList); @@ -84,13 +82,11 @@ public class RolesView extends ActivatableView { private RolesView(BsqFormatter bsqFormatter, BondingViewUtils bondingViewUtils, SignVerifyService signVerifyService, - DaoFacade daoFacade, - Preferences preferences) { + DaoFacade daoFacade) { this.bsqFormatter = bsqFormatter; this.bondingViewUtils = bondingViewUtils; this.signVerifyService = signVerifyService; this.daoFacade = daoFacade; - this.preferences = preferences; } @Override @@ -245,7 +241,7 @@ public class RolesView extends ActivatableView { String lockupTxId = item.getLockupTxId(); if (lockupTxId != null) { hyperlinkWithIcon = new ExternalHyperlink(lockupTxId); - hyperlinkWithIcon.setOnAction(event -> GUIUtil.openTxInBsqBlockExplorer(lockupTxId, preferences)); + hyperlinkWithIcon.setOnAction(event -> GUIUtil.openTxInBlockExplorer(lockupTxId, true)); hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForTx", lockupTxId))); setGraphic(hyperlinkWithIcon); } else { diff --git a/desktop/src/main/java/bisq/desktop/main/dao/burnbsq/proofofburn/ProofOfBurnView.java b/desktop/src/main/java/bisq/desktop/main/dao/burnbsq/proofofburn/ProofOfBurnView.java index 1b56521beb..e86e02ae8c 100644 --- a/desktop/src/main/java/bisq/desktop/main/dao/burnbsq/proofofburn/ProofOfBurnView.java +++ b/desktop/src/main/java/bisq/desktop/main/dao/burnbsq/proofofburn/ProofOfBurnView.java @@ -39,7 +39,6 @@ import bisq.core.dao.governance.proofofburn.MyProofOfBurnListService; import bisq.core.dao.governance.proofofburn.ProofOfBurnService; import bisq.core.dao.governance.proposal.TxException; import bisq.core.locale.Res; -import bisq.core.user.Preferences; import bisq.core.util.FormattingUtils; import bisq.core.util.ParsingUtils; import bisq.core.util.coin.BsqFormatter; @@ -86,7 +85,6 @@ public class ProofOfBurnView extends ActivatableView implements private final ProofOfBurnService proofOfBurnService; private final SignVerifyService signVerifyService; private final MyProofOfBurnListService myProofOfBurnListService; - private final Preferences preferences; private final CoinFormatter btcFormatter; private final BsqFormatter bsqFormatter; private final BsqWalletService bsqWalletService; @@ -122,7 +120,6 @@ public class ProofOfBurnView extends ActivatableView implements ProofOfBurnService proofOfBurnService, SignVerifyService signVerifyService, MyProofOfBurnListService myProofOfBurnListService, - Preferences preferences, @Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter btcFormatter) { this.bsqFormatter = bsqFormatter; this.bsqWalletService = bsqWalletService; @@ -130,7 +127,6 @@ public class ProofOfBurnView extends ActivatableView implements this.proofOfBurnService = proofOfBurnService; this.signVerifyService = signVerifyService; this.myProofOfBurnListService = myProofOfBurnListService; - this.preferences = preferences; this.btcFormatter = btcFormatter; } @@ -417,7 +413,7 @@ public class ProofOfBurnView extends ActivatableView implements if (item != null && !empty) { String transactionId = item.getTxId(); hyperlinkWithIcon = new ExternalHyperlink(transactionId); - hyperlinkWithIcon.setOnAction(event -> GUIUtil.openTxInBsqBlockExplorer(item.getTxId(), preferences)); + hyperlinkWithIcon.setOnAction(event -> GUIUtil.openTxInBlockExplorer(transactionId, true)); hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForTx", transactionId))); setGraphic(hyperlinkWithIcon); } else { @@ -580,7 +576,7 @@ public class ProofOfBurnView extends ActivatableView implements if (item != null && !empty) { String transactionId = item.getTxId(); hyperlinkWithIcon = new ExternalHyperlink(transactionId); - hyperlinkWithIcon.setOnAction(event -> GUIUtil.openTxInBsqBlockExplorer(item.getTxId(), preferences)); + hyperlinkWithIcon.setOnAction(event -> GUIUtil.openTxInBlockExplorer(transactionId, true)); hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForTx", transactionId))); setGraphic(hyperlinkWithIcon); } else { diff --git a/desktop/src/main/java/bisq/desktop/main/dao/economy/transactions/BSQTransactionsView.java b/desktop/src/main/java/bisq/desktop/main/dao/economy/transactions/BSQTransactionsView.java index 36cd962320..3f55f53567 100644 --- a/desktop/src/main/java/bisq/desktop/main/dao/economy/transactions/BSQTransactionsView.java +++ b/desktop/src/main/java/bisq/desktop/main/dao/economy/transactions/BSQTransactionsView.java @@ -21,6 +21,7 @@ import bisq.desktop.common.view.ActivatableView; import bisq.desktop.common.view.FxmlView; import bisq.desktop.components.HyperlinkWithIcon; import bisq.desktop.components.TitledGroupBg; +import bisq.desktop.util.GUIUtil; import bisq.desktop.util.Layout; import bisq.core.dao.DaoFacade; @@ -28,7 +29,6 @@ import bisq.core.dao.state.DaoStateListener; import bisq.core.dao.state.model.blockchain.Block; import bisq.core.dao.state.model.governance.IssuanceType; import bisq.core.locale.Res; -import bisq.core.user.Preferences; import bisq.common.util.Tuple3; @@ -48,7 +48,6 @@ import static bisq.desktop.util.FormBuilder.addTopLabelReadOnlyTextField; public class BSQTransactionsView extends ActivatableView implements DaoStateListener { private final DaoFacade daoFacade; - private final Preferences preferences; private int gridRow = 0; private TextField allTxTextField, burntFeeTxsTextField, @@ -60,10 +59,8 @@ public class BSQTransactionsView extends ActivatableView impleme /////////////////////////////////////////////////////////////////////////////////////////// @Inject - private BSQTransactionsView(DaoFacade daoFacade, - Preferences preferences) { + private BSQTransactionsView(DaoFacade daoFacade) { this.daoFacade = daoFacade; - this.preferences = preferences; } @Override @@ -71,7 +68,7 @@ public class BSQTransactionsView extends ActivatableView impleme addTitledGroupBg(root, gridRow, 2, Res.get("dao.factsAndFigures.transactions.genesis")); String genTxHeight = String.valueOf(daoFacade.getGenesisBlockHeight()); String genesisTxId = daoFacade.getGenesisTxId(); - String url = preferences.getBsqBlockChainExplorer().txUrl + genesisTxId; + String url = GUIUtil.getTxUrl(genesisTxId, true); GridPane.setColumnSpan(addTopLabelReadOnlyTextField(root, gridRow, Res.get("dao.factsAndFigures.transactions.genesisBlockHeight"), genTxHeight, Layout.FIRST_ROW_DISTANCE).third, 2); diff --git a/desktop/src/main/java/bisq/desktop/main/dao/governance/ProposalDisplay.java b/desktop/src/main/java/bisq/desktop/main/dao/governance/ProposalDisplay.java index 4d7faf0b85..b67f367d42 100644 --- a/desktop/src/main/java/bisq/desktop/main/dao/governance/ProposalDisplay.java +++ b/desktop/src/main/java/bisq/desktop/main/dao/governance/ProposalDisplay.java @@ -56,7 +56,6 @@ import bisq.core.dao.state.model.governance.RoleProposal; import bisq.core.dao.state.model.governance.Vote; import bisq.core.locale.CurrencyUtil; import bisq.core.locale.Res; -import bisq.core.user.Preferences; import bisq.core.util.coin.BsqFormatter; import bisq.core.util.validation.InputValidator; import bisq.core.util.validation.RegexValidator; @@ -110,7 +109,6 @@ public class ProposalDisplay { @Nullable private final ChangeParamValidator changeParamValidator; private final Navigation navigation; - private final Preferences preferences; @Nullable private TextField proposalFeeTextField, comboBoxValueTextField, requiredBondForRoleTextField; @@ -152,14 +150,12 @@ public class ProposalDisplay { BsqFormatter bsqFormatter, DaoFacade daoFacade, @Nullable ChangeParamValidator changeParamValidator, - Navigation navigation, - @Nullable Preferences preferences) { + Navigation navigation) { this.gridPane = gridPane; this.bsqFormatter = bsqFormatter; this.daoFacade = daoFacade; this.changeParamValidator = changeParamValidator; this.navigation = navigation; - this.preferences = preferences; // focusOutListener = observable -> inputChangedListeners.forEach(Runnable::run); diff --git a/desktop/src/main/java/bisq/desktop/main/dao/governance/make/MakeProposalView.java b/desktop/src/main/java/bisq/desktop/main/dao/governance/make/MakeProposalView.java index e82b6c22a5..343a9ee51f 100644 --- a/desktop/src/main/java/bisq/desktop/main/dao/governance/make/MakeProposalView.java +++ b/desktop/src/main/java/bisq/desktop/main/dao/governance/make/MakeProposalView.java @@ -461,7 +461,7 @@ public class MakeProposalView extends ActivatableView implements private void addProposalDisplay() { if (selectedProposalType != null) { - proposalDisplay = new ProposalDisplay(root, bsqFormatter, daoFacade, changeParamValidator, navigation, null); + proposalDisplay = new ProposalDisplay(root, bsqFormatter, daoFacade, changeParamValidator, navigation); proposalDisplay.createAllFields(Res.get("dao.proposal.create.new"), alwaysVisibleGridRowIndex, Layout.GROUP_DISTANCE_WITHOUT_SEPARATOR, selectedProposalType, true); diff --git a/desktop/src/main/java/bisq/desktop/main/dao/wallet/send/BsqSendView.java b/desktop/src/main/java/bisq/desktop/main/dao/wallet/send/BsqSendView.java index 1f4f51eb33..010b58ea96 100644 --- a/desktop/src/main/java/bisq/desktop/main/dao/wallet/send/BsqSendView.java +++ b/desktop/src/main/java/bisq/desktop/main/dao/wallet/send/BsqSendView.java @@ -50,7 +50,6 @@ import bisq.core.dao.state.model.blockchain.TxType; import bisq.core.locale.Res; import bisq.core.monetary.Volume; import bisq.core.user.DontShowAgainLookup; -import bisq.core.user.Preferences; import bisq.core.util.FormattingUtils; import bisq.core.util.ParsingUtils; import bisq.core.util.VolumeUtil; @@ -104,7 +103,6 @@ public class BsqSendView extends ActivatableView implements BsqB private final BtcValidator btcValidator; private final BsqAddressValidator bsqAddressValidator; private final BtcAddressValidator btcAddressValidator; - private final Preferences preferences; private final WalletPasswordWindow walletPasswordWindow; private int gridRow = 0; @@ -138,7 +136,6 @@ public class BsqSendView extends ActivatableView implements BsqB BtcValidator btcValidator, BsqAddressValidator bsqAddressValidator, BtcAddressValidator btcAddressValidator, - Preferences preferences, WalletPasswordWindow walletPasswordWindow) { this.bsqWalletService = bsqWalletService; this.btcWalletService = btcWalletService; @@ -153,7 +150,6 @@ public class BsqSendView extends ActivatableView implements BsqB this.btcValidator = btcValidator; this.bsqAddressValidator = bsqAddressValidator; this.btcAddressValidator = btcAddressValidator; - this.preferences = preferences; this.walletPasswordWindow = walletPasswordWindow; } @@ -347,7 +343,6 @@ public class BsqSendView extends ActivatableView implements BsqB } TxInputSelectionWindow txInputSelectionWindow = new TxInputSelectionWindow(unspentTransactionOutputs, bsqUtxoCandidates, - preferences, bsqFormatter); txInputSelectionWindow.onAction(() -> setBsqUtxoCandidates(txInputSelectionWindow.getCandidates())) .show(); @@ -410,7 +405,6 @@ public class BsqSendView extends ActivatableView implements BsqB } TxInputSelectionWindow txInputSelectionWindow = new TxInputSelectionWindow(unspentTransactionOutputs, btcUtxoCandidates, - preferences, btcFormatter); txInputSelectionWindow.onAction(() -> setBtcUtxoCandidates(txInputSelectionWindow.getCandidates())). show(); diff --git a/desktop/src/main/java/bisq/desktop/main/dao/wallet/tx/BsqTxView.java b/desktop/src/main/java/bisq/desktop/main/dao/wallet/tx/BsqTxView.java index 60b7462378..bcf823de65 100644 --- a/desktop/src/main/java/bisq/desktop/main/dao/wallet/tx/BsqTxView.java +++ b/desktop/src/main/java/bisq/desktop/main/dao/wallet/tx/BsqTxView.java @@ -43,7 +43,6 @@ import bisq.core.dao.state.model.blockchain.TxType; import bisq.core.dao.state.model.governance.IssuanceType; import bisq.core.locale.Res; import bisq.core.trade.model.bsq_swap.BsqSwapTrade; -import bisq.core.user.Preferences; import bisq.core.util.coin.BsqFormatter; import bisq.common.Timer; @@ -105,7 +104,6 @@ public class BsqTxView extends ActivatableView implements BsqBal private final BsqWalletService bsqWalletService; private final BtcWalletService btcWalletService; private final BsqBalanceUtil bsqBalanceUtil; - private final Preferences preferences; private final TradableRepository tradableRepository; private final BsqTradeDetailsWindow bsqTradeDetailsWindow; @@ -130,7 +128,6 @@ public class BsqTxView extends ActivatableView implements BsqBal private BsqTxView(DaoFacade daoFacade, DaoStateService daoStateService, BsqWalletService bsqWalletService, - Preferences preferences, BtcWalletService btcWalletService, BsqBalanceUtil bsqBalanceUtil, BsqFormatter bsqFormatter, @@ -140,7 +137,6 @@ public class BsqTxView extends ActivatableView implements BsqBal this.daoStateService = daoStateService; this.bsqFormatter = bsqFormatter; this.bsqWalletService = bsqWalletService; - this.preferences = preferences; this.btcWalletService = btcWalletService; this.bsqBalanceUtil = bsqBalanceUtil; this.tradableRepository = tradableRepository; @@ -458,7 +454,7 @@ public class BsqTxView extends ActivatableView implements BsqBal if (item != null && !empty) { String transactionId = item.getTxId(); hyperlinkWithIcon = new ExternalHyperlink(transactionId); - hyperlinkWithIcon.setOnAction(event -> openTxInBlockExplorer(item)); + hyperlinkWithIcon.setOnAction(event -> GUIUtil.openTxInBlockExplorer(transactionId, true)); hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForTx", transactionId))); setGraphic(hyperlinkWithIcon); } else { @@ -538,7 +534,7 @@ public class BsqTxView extends ActivatableView implements BsqBal String addressString = item.getAddress(); field = new AddressWithIconAndDirection(item.getDirection(), addressString, item.isReceived()); - field.setOnAction(event -> openAddressInBlockExplorer(item)); + field.setOnAction(event -> GUIUtil.openAddressInBlockExplorer(addressString, true)); field.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForAddress", addressString))); setGraphic(field); } @@ -774,16 +770,5 @@ public class BsqTxView extends ActivatableView implements BsqBal tableView.getColumns().add(column); } - - private void openTxInBlockExplorer(BsqTxListItem item) { - if (item.getTxId() != null) - GUIUtil.openWebPage(preferences.getBsqBlockChainExplorer().txUrl + item.getTxId(), false); - } - - private void openAddressInBlockExplorer(BsqTxListItem item) { - if (item.getAddress() != null) { - GUIUtil.openWebPage(preferences.getBsqBlockChainExplorer().addressUrl + item.getAddress(), false); - } - } } diff --git a/desktop/src/main/java/bisq/desktop/main/funds/deposit/DepositView.java b/desktop/src/main/java/bisq/desktop/main/funds/deposit/DepositView.java index 0972531a17..f7692cef9f 100644 --- a/desktop/src/main/java/bisq/desktop/main/funds/deposit/DepositView.java +++ b/desktop/src/main/java/bisq/desktop/main/funds/deposit/DepositView.java @@ -35,7 +35,6 @@ import bisq.core.btc.listeners.BalanceListener; import bisq.core.btc.model.AddressEntry; import bisq.core.btc.wallet.BtcWalletService; import bisq.core.locale.Res; -import bisq.core.user.Preferences; import bisq.core.util.FormattingUtils; import bisq.core.util.ParsingUtils; import bisq.core.util.coin.CoinFormatter; @@ -117,7 +116,6 @@ public class DepositView extends ActivatableView { private InputTextField amountTextField; private final BtcWalletService walletService; - private final Preferences preferences; private final CoinFormatter formatter; private String paymentLabelString; private final ObservableList observableList = FXCollections.observableArrayList(); @@ -134,10 +132,8 @@ public class DepositView extends ActivatableView { @Inject private DepositView(BtcWalletService walletService, - Preferences preferences, @Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter) { this.walletService = walletService; - this.preferences = preferences; this.formatter = formatter; } @@ -313,11 +309,6 @@ public class DepositView extends ActivatableView { } } - private void openBlockExplorer(DepositListItem item) { - if (item.getAddressString() != null) - GUIUtil.openWebPage(preferences.getBlockChainExplorer().addressUrl + item.getAddressString(), false); - } - /////////////////////////////////////////////////////////////////////////////////////////// // Private /////////////////////////////////////////////////////////////////////////////////////////// @@ -390,7 +381,7 @@ public class DepositView extends ActivatableView { String address = item.getAddressString(); field = new ExternalHyperlink(address); field.setOnAction(event -> { - openBlockExplorer(item); + GUIUtil.openAddressInBlockExplorer(address); tableView.getSelectionModel().select(item); }); field.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForAddress", address))); diff --git a/desktop/src/main/java/bisq/desktop/main/funds/locked/LockedView.java b/desktop/src/main/java/bisq/desktop/main/funds/locked/LockedView.java index c9aaba3c1f..0a998ee6e0 100644 --- a/desktop/src/main/java/bisq/desktop/main/funds/locked/LockedView.java +++ b/desktop/src/main/java/bisq/desktop/main/funds/locked/LockedView.java @@ -37,7 +37,6 @@ import bisq.core.offer.OpenOfferManager; import bisq.core.trade.TradeManager; import bisq.core.trade.model.Tradable; import bisq.core.trade.model.bisq_v1.Trade; -import bisq.core.user.Preferences; import bisq.core.util.FormattingUtils; import bisq.core.util.coin.CoinFormatter; @@ -101,7 +100,6 @@ public class LockedView extends ActivatableView { private final BtcWalletService btcWalletService; private final TradeManager tradeManager; private final OpenOfferManager openOfferManager; - private final Preferences preferences; private final CoinFormatter formatter; private final OfferDetailsWindow offerDetailsWindow; private final TradeDetailsWindow tradeDetailsWindow; @@ -121,14 +119,12 @@ public class LockedView extends ActivatableView { private LockedView(BtcWalletService btcWalletService, TradeManager tradeManager, OpenOfferManager openOfferManager, - Preferences preferences, @Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter, OfferDetailsWindow offerDetailsWindow, TradeDetailsWindow tradeDetailsWindow) { this.btcWalletService = btcWalletService; this.tradeManager = tradeManager; this.openOfferManager = openOfferManager; - this.preferences = preferences; this.formatter = formatter; this.offerDetailsWindow = offerDetailsWindow; this.tradeDetailsWindow = tradeDetailsWindow; @@ -246,10 +242,6 @@ public class LockedView extends ActivatableView { .collect(Collectors.toList())); } - private void openBlockExplorer(LockedListItem item) { - GUIUtil.openWebPage(preferences.getBlockChainExplorer().addressUrl + item.getAddressString(), false); - } - private Optional getTradable(LockedListItem item) { String offerId = item.getAddressEntry().getOfferId(); Optional tradeOptional = tradeManager.getTradeById(offerId); @@ -387,7 +379,7 @@ public class LockedView extends ActivatableView { if (item != null && !empty) { String address = item.getAddressString(); hyperlinkWithIcon = new ExternalHyperlink(address); - hyperlinkWithIcon.setOnAction(event -> openBlockExplorer(item)); + hyperlinkWithIcon.setOnAction(event -> GUIUtil.openAddressInBlockExplorer(address)); hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForAddress", address))); setGraphic(hyperlinkWithIcon); } else { diff --git a/desktop/src/main/java/bisq/desktop/main/funds/reserved/ReservedView.java b/desktop/src/main/java/bisq/desktop/main/funds/reserved/ReservedView.java index 6ca9360323..7cb6f6965e 100644 --- a/desktop/src/main/java/bisq/desktop/main/funds/reserved/ReservedView.java +++ b/desktop/src/main/java/bisq/desktop/main/funds/reserved/ReservedView.java @@ -37,7 +37,6 @@ import bisq.core.offer.OpenOfferManager; import bisq.core.trade.TradeManager; import bisq.core.trade.model.Tradable; import bisq.core.trade.model.bisq_v1.Trade; -import bisq.core.user.Preferences; import bisq.core.util.FormattingUtils; import bisq.core.util.coin.CoinFormatter; @@ -101,7 +100,6 @@ public class ReservedView extends ActivatableView { private final BtcWalletService btcWalletService; private final TradeManager tradeManager; private final OpenOfferManager openOfferManager; - private final Preferences preferences; private final CoinFormatter formatter; private final OfferDetailsWindow offerDetailsWindow; private final TradeDetailsWindow tradeDetailsWindow; @@ -121,14 +119,12 @@ public class ReservedView extends ActivatableView { private ReservedView(BtcWalletService btcWalletService, TradeManager tradeManager, OpenOfferManager openOfferManager, - Preferences preferences, @Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter, OfferDetailsWindow offerDetailsWindow, TradeDetailsWindow tradeDetailsWindow) { this.btcWalletService = btcWalletService; this.tradeManager = tradeManager; this.openOfferManager = openOfferManager; - this.preferences = preferences; this.formatter = formatter; this.offerDetailsWindow = offerDetailsWindow; this.tradeDetailsWindow = tradeDetailsWindow; @@ -245,10 +241,6 @@ public class ReservedView extends ActivatableView { .collect(Collectors.toList())); } - private void openBlockExplorer(ReservedListItem item) { - GUIUtil.openWebPage(preferences.getBlockChainExplorer().addressUrl + item.getAddressString(), false); - } - private Optional getTradable(ReservedListItem item) { String offerId = item.getAddressEntry().getOfferId(); Optional tradeOptional = tradeManager.getTradeById(offerId); @@ -385,7 +377,7 @@ public class ReservedView extends ActivatableView { if (item != null && !empty) { String address = item.getAddressString(); hyperlinkWithIcon = new ExternalHyperlink(address); - hyperlinkWithIcon.setOnAction(event -> openBlockExplorer(item)); + hyperlinkWithIcon.setOnAction(event -> GUIUtil.openAddressInBlockExplorer(address)); hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForAddress", address))); setGraphic(hyperlinkWithIcon); } else { diff --git a/desktop/src/main/java/bisq/desktop/main/funds/transactions/TransactionsView.java b/desktop/src/main/java/bisq/desktop/main/funds/transactions/TransactionsView.java index c66a396322..9cd92e76cd 100644 --- a/desktop/src/main/java/bisq/desktop/main/funds/transactions/TransactionsView.java +++ b/desktop/src/main/java/bisq/desktop/main/funds/transactions/TransactionsView.java @@ -330,17 +330,6 @@ public class TransactionsView extends ActivatableView { observableList.setAll(transactionsListItems); } - private void openTxInBlockExplorer(TransactionsListItem item) { - if (item.getTxId() != null) - GUIUtil.openWebPage(preferences.getBlockChainExplorer().txUrl + item.getTxId(), false); - } - - private void openAddressInBlockExplorer(TransactionsListItem item) { - if (item.getAddressString() != null) { - GUIUtil.openWebPage(preferences.getBlockChainExplorer().addressUrl + item.getAddressString(), false); - } - } - private void openDetailPopup(TransactionsListItem item) { if (item.getTradable() instanceof OpenOffer) { offerDetailsWindow.show(item.getTradable().getOffer()); @@ -473,7 +462,7 @@ public class TransactionsView extends ActivatableView { String addressString = item.getAddressString(); field = new AddressWithIconAndDirection(item.getDirection(), addressString, item.getReceived()); - field.setOnAction(event -> openAddressInBlockExplorer(item)); + field.setOnAction(event -> GUIUtil.openAddressInBlockExplorer(addressString)); field.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForAddress", addressString))); setGraphic(field); } else { @@ -506,7 +495,7 @@ public class TransactionsView extends ActivatableView { if (item != null && !empty) { String transactionId = item.getTxId(); hyperlinkWithIcon = new ExternalHyperlink(transactionId); - hyperlinkWithIcon.setOnAction(event -> openTxInBlockExplorer(item)); + hyperlinkWithIcon.setOnAction(event -> GUIUtil.openTxInBlockExplorer(transactionId)); hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForTx", transactionId))); setGraphic(hyperlinkWithIcon); } else { diff --git a/desktop/src/main/java/bisq/desktop/main/funds/withdrawal/WithdrawalView.java b/desktop/src/main/java/bisq/desktop/main/funds/withdrawal/WithdrawalView.java index 2b1a801114..bc3fbafebe 100644 --- a/desktop/src/main/java/bisq/desktop/main/funds/withdrawal/WithdrawalView.java +++ b/desktop/src/main/java/bisq/desktop/main/funds/withdrawal/WithdrawalView.java @@ -547,11 +547,6 @@ public class WithdrawalView extends ActivatableView { } } - private void openBlockExplorer(WithdrawalListItem item) { - if (item.getAddressString() != null) - GUIUtil.openWebPage(preferences.getBlockChainExplorer().addressUrl + item.getAddressString(), false); - } - /////////////////////////////////////////////////////////////////////////////////////////// // Private @@ -676,7 +671,7 @@ public class WithdrawalView extends ActivatableView { if (item != null && !empty) { String address = item.getAddressString(); hyperlinkWithIcon = new ExternalHyperlink(address); - hyperlinkWithIcon.setOnAction(event -> openBlockExplorer(item)); + hyperlinkWithIcon.setOnAction(event -> GUIUtil.openAddressInBlockExplorer(address)); hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForAddress", address))); setAlignment(Pos.CENTER); setGraphic(hyperlinkWithIcon); diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/windows/ManualPayoutTxWindow.java b/desktop/src/main/java/bisq/desktop/main/overlays/windows/ManualPayoutTxWindow.java index 6686cf8136..926d646897 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/windows/ManualPayoutTxWindow.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/windows/ManualPayoutTxWindow.java @@ -36,8 +36,6 @@ import bisq.core.btc.wallet.WalletsManager; import bisq.core.locale.Res; import bisq.core.support.dispute.Dispute; import bisq.core.support.dispute.mediation.MediationManager; -import bisq.core.user.BlockChainExplorer; -import bisq.core.user.Preferences; import bisq.network.p2p.P2PService; @@ -110,7 +108,6 @@ public class ManualPayoutTxWindow extends Overlay { private final TradeWalletService tradeWalletService; private final P2PService p2PService; private final MediationManager mediationManager; - private final Preferences preferences; private final WalletsSetup walletsSetup; private final WalletsManager walletsManager; GridPane inputsGridPane; @@ -149,13 +146,11 @@ public class ManualPayoutTxWindow extends Overlay { public ManualPayoutTxWindow(TradeWalletService tradeWalletService, P2PService p2PService, MediationManager mediationManager, - Preferences preferences, WalletsSetup walletsSetup, WalletsManager walletsManager) { this.tradeWalletService = tradeWalletService; this.p2PService = p2PService; this.mediationManager = mediationManager; - this.preferences = preferences; this.walletsSetup = walletsSetup; this.walletsManager = walletsManager; type = Type.Attention; @@ -317,7 +312,10 @@ public class ManualPayoutTxWindow extends Overlay { blockExplorerIcon.setTooltip(tooltip); AwesomeDude.setIcon(blockExplorerIcon, AwesomeIcon.EXTERNAL_LINK); blockExplorerIcon.setMinWidth(20); - blockExplorerIcon.setOnMouseClicked(mouseEvent -> openBlockExplorer(depositTxHex.getText())); + blockExplorerIcon.setOnMouseClicked(mouseEvent -> { + if (depositTxHex.getText().length() == HEX_HASH_LENGTH) + GUIUtil.openTxInBlockExplorer(depositTxHex.getText()); + }); depositTxHex = addInputTextField(inputsGridPane, rowIndexA, "depositTxId"); HBox hBoxTx = new HBox(12, depositTxHex, blockExplorerIcon); hBoxTx.setAlignment(Pos.BASELINE_LEFT); @@ -626,15 +624,6 @@ public class ManualPayoutTxWindow extends Overlay { } } - private void openBlockExplorer(String txId) { - if (txId.length() != HEX_HASH_LENGTH) - return; - if (preferences != null) { - BlockChainExplorer blockChainExplorer = preferences.getBlockChainExplorer(); - GUIUtil.openWebPage(blockChainExplorer.txUrl + txId, false); - } - } - private String findPrivForPubOrAddress(String walletInfo, String searchKey) { // split the walletInfo into lines, strip whitespace // look for lines beginning " addr:" followed by "DeterministicKey{pub HEX=" .... ", priv HEX=" diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/windows/ProposalResultsWindow.java b/desktop/src/main/java/bisq/desktop/main/overlays/windows/ProposalResultsWindow.java index f9cfc160a1..3d84772c11 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/windows/ProposalResultsWindow.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/windows/ProposalResultsWindow.java @@ -35,7 +35,6 @@ import bisq.core.dao.state.model.governance.Ballot; import bisq.core.dao.state.model.governance.EvaluatedProposal; import bisq.core.dao.state.model.governance.Proposal; import bisq.core.locale.Res; -import bisq.core.user.Preferences; import bisq.core.util.coin.BsqFormatter; import bisq.common.util.Tuple2; @@ -78,7 +77,6 @@ public class ProposalResultsWindow extends TabbedOverlay private final BsqFormatter bsqFormatter; private final DaoFacade daoFacade; private final Navigation navigation; - private final Preferences preferences; private boolean isVoteIncludedInResult; private SortedList sortedVotes; private Tab proposalTab, votesTab; @@ -90,12 +88,10 @@ public class ProposalResultsWindow extends TabbedOverlay @Inject public ProposalResultsWindow(BsqFormatter bsqFormatter, DaoFacade daoFacade, - Navigation navigation, - Preferences preferences) { + Navigation navigation) { this.bsqFormatter = bsqFormatter; this.daoFacade = daoFacade; this.navigation = navigation; - this.preferences = preferences; } public void show(EvaluatedProposal evaluatedProposal, Ballot ballot, @@ -147,8 +143,7 @@ public class ProposalResultsWindow extends TabbedOverlay private void addContent(EvaluatedProposal evaluatedProposal, Ballot ballot) { Proposal proposal = evaluatedProposal.getProposal(); - ProposalDisplay proposalDisplay = new ProposalDisplay(gridPane, bsqFormatter, daoFacade, null, - navigation, preferences); + ProposalDisplay proposalDisplay = new ProposalDisplay(gridPane, bsqFormatter, daoFacade, null, navigation); proposalDisplay.createAllFields("", rowIndex, -Layout.FIRST_ROW_DISTANCE, proposal.getType(), false, "last"); proposalDisplay.setEditable(false); @@ -271,7 +266,7 @@ public class ProposalResultsWindow extends TabbedOverlay if (item != null && !empty) { String transactionId = item.getBlindVoteTxId(); hyperlinkWithIcon = new ExternalHyperlink(transactionId); - hyperlinkWithIcon.setOnAction(event -> openTxInBlockExplorer(item)); + hyperlinkWithIcon.setOnAction(event -> GUIUtil.openTxInBlockExplorer(transactionId, true)); hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForTx", transactionId))); setGraphic(hyperlinkWithIcon); } else { @@ -396,9 +391,4 @@ public class ProposalResultsWindow extends TabbedOverlay } }); } - - private void openTxInBlockExplorer(VoteListItem item) { - if (item.getBlindVoteTxId() != null) - GUIUtil.openWebPage(preferences.getBsqBlockChainExplorer().txUrl + item.getBlindVoteTxId(), false); - } } diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/windows/SelectProposalWindow.java b/desktop/src/main/java/bisq/desktop/main/overlays/windows/SelectProposalWindow.java index 82017d8303..abc827af15 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/windows/SelectProposalWindow.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/windows/SelectProposalWindow.java @@ -14,7 +14,6 @@ import bisq.core.dao.state.model.governance.EvaluatedProposal; import bisq.core.dao.state.model.governance.Proposal; import bisq.core.dao.state.model.governance.Vote; import bisq.core.locale.Res; -import bisq.core.user.Preferences; import bisq.core.util.coin.BsqFormatter; import bisq.common.util.Tuple2; @@ -44,7 +43,6 @@ public class SelectProposalWindow extends Overlay { private final DaoFacade daoFacade; private final ChangeParamValidator changeParamValidator; private final Navigation navigation; - private final Preferences preferences; private Optional acceptHandlerOptional; private Optional rejectHandlerOptional; private Optional ignoreHandlerOptional; @@ -60,13 +58,11 @@ public class SelectProposalWindow extends Overlay { @Inject public SelectProposalWindow(BsqFormatter bsqFormatter, DaoFacade daoFacade, - ChangeParamValidator changeParamValidator, Navigation navigation, - Preferences preferences) { + ChangeParamValidator changeParamValidator, Navigation navigation) { this.bsqFormatter = bsqFormatter; this.daoFacade = daoFacade; this.changeParamValidator = changeParamValidator; this.navigation = navigation; - this.preferences = preferences; } public void show(Proposal proposal, EvaluatedProposal evaluatedProposal, Ballot ballot) { @@ -140,7 +136,7 @@ public class SelectProposalWindow extends Overlay { private void addContent(Proposal proposal, EvaluatedProposal evaluatedProposal, Ballot ballot) { ProposalDisplay proposalDisplay = new ProposalDisplay(gridPane, bsqFormatter, daoFacade, changeParamValidator, - navigation, preferences); + navigation); proposalDisplay.onNavigate(this::doClose); diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/windows/TxInputSelectionWindow.java b/desktop/src/main/java/bisq/desktop/main/overlays/windows/TxInputSelectionWindow.java index 06a565d172..e7ef64d6f0 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/windows/TxInputSelectionWindow.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/windows/TxInputSelectionWindow.java @@ -29,7 +29,6 @@ import bisq.desktop.util.GUIUtil; import bisq.desktop.util.Layout; import bisq.core.locale.Res; -import bisq.core.user.Preferences; import bisq.core.util.coin.CoinFormatter; import org.bitcoinj.core.Coin; @@ -77,7 +76,6 @@ public class TxInputSelectionWindow extends Overlay { private final List spendableTransactionOutputs; @Getter private final Set candidates; - private final Preferences preferences; private final CoinFormatter formatter; private BalanceTextField balanceTextField; @@ -85,11 +83,9 @@ public class TxInputSelectionWindow extends Overlay { public TxInputSelectionWindow(List spendableTransactionOutputs, Set candidates, - Preferences preferences, CoinFormatter formatter) { this.spendableTransactionOutputs = spendableTransactionOutputs; this.candidates = candidates; - this.preferences = preferences; this.formatter = formatter; type = Type.Attention; } @@ -228,7 +224,7 @@ public class TxInputSelectionWindow extends Overlay { TransactionOutput transactionOutput = item.getTransactionOutput(); String txId = transactionOutput.getParentTransaction().getTxId().toString(); hyperlinkWithIcon = new ExternalHyperlink(txId + ":" + transactionOutput.getIndex()); - hyperlinkWithIcon.setOnAction(event -> GUIUtil.openWebPage(preferences.getBsqBlockChainExplorer().txUrl + txId, false)); + hyperlinkWithIcon.setOnAction(event -> GUIUtil.openTxInBlockExplorer(txId, true)); hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForTx", txId))); setGraphic(hyperlinkWithIcon); } else { 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 795203175d..333bc14f23 100644 --- a/desktop/src/main/java/bisq/desktop/main/presentation/MarketPricePresentation.java +++ b/desktop/src/main/java/bisq/desktop/main/presentation/MarketPricePresentation.java @@ -17,7 +17,6 @@ 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,9 +93,6 @@ public class MarketPricePresentation { this.priceFeedService = priceFeedService; this.preferences = preferences; - TxIdTextField.setPreferences(preferences); - ExplorerAddressTextField.setPreferences(preferences); - // TODO TxIdTextField.setWalletService(btcWalletService); diff --git a/desktop/src/main/java/bisq/desktop/util/GUIUtil.java b/desktop/src/main/java/bisq/desktop/util/GUIUtil.java index 82a1791d0e..c7f31c0a4f 100644 --- a/desktop/src/main/java/bisq/desktop/util/GUIUtil.java +++ b/desktop/src/main/java/bisq/desktop/util/GUIUtil.java @@ -49,6 +49,7 @@ import bisq.core.provider.fee.FeeService; import bisq.core.provider.price.MarketPrice; import bisq.core.provider.price.PriceFeedService; import bisq.core.trade.txproof.AssetTxProofResult; +import bisq.core.user.BlockChainExplorer; import bisq.core.user.DontShowAgainLookup; import bisq.core.user.Preferences; import bisq.core.user.User; @@ -1168,9 +1169,42 @@ public class GUIUtil { }; } - public static void openTxInBsqBlockExplorer(String txId, Preferences preferences) { + private static BlockChainExplorer getBlockExplorer(boolean isBsq) { + return isBsq ? preferences.getBsqBlockChainExplorer() : preferences.getBlockChainExplorer(); + } + + public static void openAddressInBlockExplorer(String address) { + openAddressInBlockExplorer(address, false); + } + + public static void openAddressInBlockExplorer(String address, boolean isBsq) { + if (address != null) + openWebPage(getAddressUrl(address, isBsq), false); + } + + public static void openTxInBlockExplorer(String txId) { + openTxInBlockExplorer(txId, false); + } + + public static void openTxInBlockExplorer(String txId, boolean isBsq) { if (txId != null) - GUIUtil.openWebPage(preferences.getBsqBlockChainExplorer().txUrl + txId, false); + openWebPage(getTxUrl(txId, isBsq), false); + } + + public static String getAddressUrl(String address) { + return getAddressUrl(address, false); + } + + public static String getAddressUrl(String address, boolean isBsq) { + return getBlockExplorer(isBsq).addressUrl + address; + } + + public static String getTxUrl(String txId) { + return getTxUrl(txId, false); + } + + public static String getTxUrl(String txId, boolean isBsq) { + return getBlockExplorer(isBsq).txUrl + txId; } public static String getBsqInUsd(Price bsqPrice,