update block explorer preferences for xmr, remove address url

This commit is contained in:
woodser 2023-10-04 09:53:06 -04:00
parent 9aea5e0c58
commit 75f5255050
10 changed files with 20 additions and 132 deletions

View File

@ -23,22 +23,19 @@ import haveno.common.proto.persistable.PersistablePayload;
public final class BlockChainExplorer implements PersistablePayload {
public final String name;
public final String txUrl;
public final String addressUrl;
public BlockChainExplorer(String name, String txUrl, String addressUrl) {
public BlockChainExplorer(String name, String txUrl) {
this.name = name;
this.txUrl = txUrl;
this.addressUrl = addressUrl;
}
@Override
public Message toProtoMessage() {
return protobuf.BlockChainExplorer.newBuilder().setName(name).setTxUrl(txUrl).setAddressUrl(addressUrl).build();
return protobuf.BlockChainExplorer.newBuilder().setName(name).setTxUrl(txUrl).build();
}
public static BlockChainExplorer fromProto(protobuf.BlockChainExplorer proto) {
return new BlockChainExplorer(proto.getName(),
proto.getTxUrl(),
proto.getAddressUrl());
proto.getTxUrl());
}
}

View File

@ -77,43 +77,11 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
}
}
private static final ArrayList<BlockChainExplorer> BTC_MAIN_NET_EXPLORERS = new ArrayList<>(Arrays.asList(
new BlockChainExplorer("mempool.space (@wiz)", "https://mempool.space/tx/", "https://mempool.space/address/"),
new BlockChainExplorer("mempool.space Tor V3", "http://mempoolhqx4isw62xs7abwphsq7ldayuidyx2v2oethdhhj6mlo2r6ad.onion/tx/", "http://mempoolhqx4isw62xs7abwphsq7ldayuidyx2v2oethdhhj6mlo2r6ad.onion/address/"),
new BlockChainExplorer("mempool.emzy.de (@emzy)", "https://mempool.emzy.de/tx/", "https://mempool.emzy.de/address/"),
new BlockChainExplorer("mempool.emzy.de Tor V3", "http://mempool4t6mypeemozyterviq3i5de4kpoua65r3qkn5i3kknu5l2cad.onion/tx/", "http://mempool4t6mypeemozyterviq3i5de4kpoua65r3qkn5i3kknu5l2cad.onion/address/"),
new BlockChainExplorer("mempool.haveno.services (@devinbileck)", "https://mempool.haveno.services/tx/", "https://mempool.haveno.services/address/"),
new BlockChainExplorer("mempool.haveno.services Tor V3", "http://mempoolusb2f67qi7mz2it7n5e77a6komdzx6wftobcduxszkdfun2yd.onion/tx/", "http://mempoolusb2f67qi7mz2it7n5e77a6komdzx6wftobcduxszkdfun2yd.onion/address/"),
new BlockChainExplorer("Blockstream.info", "https://blockstream.info/tx/", "https://blockstream.info/address/"),
new BlockChainExplorer("Blockstream.info Tor V3", "http://explorerzydxu5ecjrkwceayqybizmpjjznk5izmitf2modhcusuqlid.onion/tx/", "http://explorerzydxu5ecjrkwceayqybizmpjjznk5izmitf2modhcusuqlid.onion/address/"),
new BlockChainExplorer("OXT", "https://oxt.me/transaction/", "https://oxt.me/address/"),
new BlockChainExplorer("Bitaps", "https://bitaps.com/", "https://bitaps.com/"),
new BlockChainExplorer("Blockcypher", "https://live.blockcypher.com/btc/tx/", "https://live.blockcypher.com/btc/address/"),
new BlockChainExplorer("Tradeblock", "https://tradeblock.com/bitcoin/tx/", "https://tradeblock.com/bitcoin/address/"),
new BlockChainExplorer("Biteasy", "https://www.biteasy.com/transactions/", "https://www.biteasy.com/addresses/"),
new BlockChainExplorer("Blockonomics", "https://www.blockonomics.co/api/tx?txid=", "https://www.blockonomics.co/#/search?q="),
new BlockChainExplorer("Chainflyer", "http://chainflyer.bitflyer.jp/Transaction/", "http://chainflyer.bitflyer.jp/Address/"),
new BlockChainExplorer("Smartbit", "https://www.smartbit.com.au/tx/", "https://www.smartbit.com.au/address/"),
new BlockChainExplorer("SoChain. Wow.", "https://chain.so/tx/BTC/", "https://chain.so/address/BTC/"),
new BlockChainExplorer("Blockchain.info", "https://blockchain.info/tx/", "https://blockchain.info/address/"),
new BlockChainExplorer("Insight", "https://insight.bitpay.com/tx/", "https://insight.bitpay.com/address/"),
new BlockChainExplorer("Blockchair", "https://blockchair.com/bitcoin/transaction/", "https://blockchair.com/bitcoin/address/")
));
private static final ArrayList<BlockChainExplorer> BTC_TEST_NET_EXPLORERS = new ArrayList<>(Arrays.asList(
new BlockChainExplorer("Blockstream.info", "https://blockstream.info/testnet/tx/", "https://blockstream.info/testnet/address/"),
new BlockChainExplorer("Blockstream.info Tor V3", "http://explorerzydxu5ecjrkwceayqybizmpjjznk5izmitf2modhcusuqlid.onion/testnet/tx/", "http://explorerzydxu5ecjrkwceayqybizmpjjznk5izmitf2modhcusuqlid.onion/testnet/address/"),
new BlockChainExplorer("Blockcypher", "https://live.blockcypher.com/btc-testnet/tx/", "https://live.blockcypher.com/btc-testnet/address/"),
new BlockChainExplorer("Blocktrail", "https://www.blocktrail.com/tBTC/tx/", "https://www.blocktrail.com/tBTC/address/"),
new BlockChainExplorer("Biteasy", "https://www.biteasy.com/testnet/transactions/", "https://www.biteasy.com/testnet/addresses/"),
new BlockChainExplorer("Smartbit", "https://testnet.smartbit.com.au/tx/", "https://testnet.smartbit.com.au/address/"),
new BlockChainExplorer("SoChain. Wow.", "https://chain.so/tx/BTCTEST/", "https://chain.so/address/BTCTEST/"),
new BlockChainExplorer("Blockchair", "https://blockchair.com/bitcoin/testnet/transaction/", "https://blockchair.com/bitcoin/testnet/address/")
));
private static final ArrayList<BlockChainExplorer> XMR_MAIN_NET_EXPLORERS = new ArrayList<>(Arrays.asList(
new BlockChainExplorer("xmrchain.net", "https://xmrchain.net/tx/", "")
new BlockChainExplorer("xmrchain.net", "https://xmrchain.net/tx/")
));
private static final ArrayList<BlockChainExplorer> XMR_STAGE_NET_EXPLORERS = new ArrayList<>(Arrays.asList(
new BlockChainExplorer("stagenet.xmrchain.net", "https://stagenet.xmrchain.net/tx/", "")
new BlockChainExplorer("stagenet.xmrchain.net", "https://stagenet.xmrchain.net/tx/")
));
private static final ArrayList<String> XMR_TX_PROOF_SERVICES_CLEAR_NET = new ArrayList<>(Arrays.asList(
@ -265,10 +233,7 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
setCryptoCurrencies(CurrencyUtil.getMainCryptoCurrencies());
BaseCurrencyNetwork baseCurrencyNetwork = Config.baseCurrencyNetwork();
if ("BTC".equals(baseCurrencyNetwork.getCurrencyCode())) {
setBlockChainExplorerMainNet(BTC_MAIN_NET_EXPLORERS.get(0));
setBlockChainExplorerStageNet(BTC_TEST_NET_EXPLORERS.get(0));
} else if ("XMR".equals(baseCurrencyNetwork.getCurrencyCode())) {
if ("XMR".equals(baseCurrencyNetwork.getCurrencyCode())) {
setBlockChainExplorerMainNet(XMR_MAIN_NET_EXPLORERS.get(0));
setBlockChainExplorerStageNet(XMR_STAGE_NET_EXPLORERS.get(0));
} else {
@ -806,11 +771,11 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
BaseCurrencyNetwork baseCurrencyNetwork = Config.baseCurrencyNetwork();
switch (baseCurrencyNetwork) {
case XMR_MAINNET:
return BTC_MAIN_NET_EXPLORERS;
return XMR_MAIN_NET_EXPLORERS;
case XMR_STAGENET:
return BTC_TEST_NET_EXPLORERS;
return XMR_STAGE_NET_EXPLORERS;
case XMR_LOCAL:
return BTC_TEST_NET_EXPLORERS; // TODO: no testnet explorer for private testnet
return XMR_STAGE_NET_EXPLORERS; // TODO: no testnet explorer for private testnet
default:
throw new RuntimeException("BaseCurrencyNetwork not defined. BaseCurrencyNetwork=" + baseCurrencyNetwork);
}

View File

@ -22,9 +22,7 @@ import de.jensd.fx.fontawesome.AwesomeDude;
import de.jensd.fx.fontawesome.AwesomeIcon;
import haveno.common.util.Utilities;
import haveno.core.locale.Res;
import haveno.core.user.BlockChainExplorer;
import haveno.core.user.Preferences;
import haveno.desktop.util.GUIUtil;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.control.Tooltip;
@ -40,7 +38,7 @@ public class ExplorerAddressTextField extends AnchorPane {
@Getter
private final TextField textField;
private final Label copyIcon, blockExplorerIcon, missingAddressWarningIcon;
private final Label copyIcon, missingAddressWarningIcon;
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
@ -56,14 +54,6 @@ public class ExplorerAddressTextField extends AnchorPane {
Tooltip tooltip = new Tooltip(Res.get("explorerAddressTextField.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);
@ -81,15 +71,13 @@ public class ExplorerAddressTextField extends AnchorPane {
AnchorPane.setRightAnchor(textField, 80.0);
AnchorPane.setLeftAnchor(textField, 0.0);
textField.focusTraversableProperty().set(focusTraversableProperty().get());
getChildren().addAll(textField, missingAddressWarningIcon, blockExplorerIcon, copyIcon);
getChildren().addAll(textField, missingAddressWarningIcon, copyIcon);
}
public void setup(@Nullable String address) {
if (address == 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);
@ -98,26 +86,12 @@ public class ExplorerAddressTextField extends AnchorPane {
}
textField.setText(address);
textField.setOnMouseClicked(mouseEvent -> openBlockExplorer(address));
blockExplorerIcon.setOnMouseClicked(mouseEvent -> openBlockExplorer(address));
copyIcon.setOnMouseClicked(e -> Utilities.copyToClipboard(address));
}
public void cleanup() {
textField.setOnMouseClicked(null);
blockExplorerIcon.setOnMouseClicked(null);
copyIcon.setOnMouseClicked(null);
textField.setText("");
}
///////////////////////////////////////////////////////////////////////////////////////////
// Private
///////////////////////////////////////////////////////////////////////////////////////////
private void openBlockExplorer(String address) {
if (preferences != null) {
BlockChainExplorer blockChainExplorer = preferences.getBlockChainExplorer();
GUIUtil.openWebPage(blockChainExplorer.addressUrl + address, false);
}
}
}

View File

@ -33,7 +33,6 @@ import haveno.desktop.common.view.ActivatableView;
import haveno.desktop.common.view.FxmlView;
import haveno.desktop.components.AddressTextField;
import haveno.desktop.components.AutoTooltipLabel;
import haveno.desktop.components.ExternalHyperlink;
import haveno.desktop.components.HyperlinkWithIcon;
import haveno.desktop.components.InputTextField;
import haveno.desktop.components.TitledGroupBg;
@ -308,11 +307,6 @@ public class DepositView extends ActivatableView<VBox, Void> {
}
}
private void openBlockExplorer(DepositListItem item) {
if (item.getAddressString() != null)
GUIUtil.openWebPage(preferences.getBlockChainExplorer().addressUrl + item.getAddressString(), false);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Private
///////////////////////////////////////////////////////////////////////////////////////////
@ -391,13 +385,7 @@ public class DepositView extends ActivatableView<VBox, Void> {
if (item != null && !empty) {
String address = item.getAddressString();
field = new ExternalHyperlink(address);
field.setOnAction(event -> {
openBlockExplorer(item);
tableView.getSelectionModel().select(item);
});
field.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForAddress", address)));
setGraphic(field);
setGraphic(new AutoTooltipLabel(address));
} else {
setGraphic(null);
if (field != null)

View File

@ -35,7 +35,6 @@ import haveno.desktop.common.view.ActivatableView;
import haveno.desktop.common.view.FxmlView;
import haveno.desktop.components.AutoTooltipButton;
import haveno.desktop.components.AutoTooltipLabel;
import haveno.desktop.components.ExternalHyperlink;
import haveno.desktop.components.HyperlinkWithIcon;
import haveno.desktop.main.overlays.windows.OfferDetailsWindow;
import haveno.desktop.main.overlays.windows.TradeDetailsWindow;
@ -222,10 +221,6 @@ public class LockedView extends ActivatableView<VBox, Void> {
.collect(Collectors.toList()));
}
private void openBlockExplorer(LockedListItem item) {
GUIUtil.openWebPage(preferences.getBlockChainExplorer().addressUrl + item.getAddressString(), false);
}
private Optional<Tradable> getTradable(LockedListItem item) {
String offerId = item.getAddressEntry().getOfferId();
Optional<Trade> tradeOptional = tradeManager.getOpenTrade(offerId);
@ -330,7 +325,6 @@ public class LockedView extends ActivatableView<VBox, Void> {
public TableCell<LockedListItem, LockedListItem> call(TableColumn<LockedListItem,
LockedListItem> column) {
return new TableCell<>() {
private HyperlinkWithIcon hyperlinkWithIcon;
@Override
public void updateItem(final LockedListItem item, boolean empty) {
@ -338,14 +332,9 @@ public class LockedView extends ActivatableView<VBox, Void> {
if (item != null && !empty) {
String address = item.getAddressString();
hyperlinkWithIcon = new ExternalHyperlink(address);
hyperlinkWithIcon.setOnAction(event -> openBlockExplorer(item));
hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForAddress", address)));
setGraphic(hyperlinkWithIcon);
setGraphic(new AutoTooltipLabel(address));
} else {
setGraphic(null);
if (hyperlinkWithIcon != null)
hyperlinkWithIcon.setOnAction(null);
}
}
};

View File

@ -35,7 +35,6 @@ import haveno.desktop.common.view.ActivatableView;
import haveno.desktop.common.view.FxmlView;
import haveno.desktop.components.AutoTooltipButton;
import haveno.desktop.components.AutoTooltipLabel;
import haveno.desktop.components.ExternalHyperlink;
import haveno.desktop.components.HyperlinkWithIcon;
import haveno.desktop.main.overlays.windows.OfferDetailsWindow;
import haveno.desktop.main.overlays.windows.TradeDetailsWindow;
@ -221,10 +220,6 @@ public class ReservedView extends ActivatableView<VBox, Void> {
.collect(Collectors.toList()));
}
private void openBlockExplorer(ReservedListItem item) {
GUIUtil.openWebPage(preferences.getBlockChainExplorer().addressUrl + item.getAddressString(), false);
}
private Optional<Tradable> getTradable(ReservedListItem item) {
String offerId = item.getAddressEntry().getOfferId();
Optional<Trade> tradeOptional = tradeManager.getOpenTrade(offerId);
@ -329,7 +324,6 @@ public class ReservedView extends ActivatableView<VBox, Void> {
public TableCell<ReservedListItem, ReservedListItem> call(TableColumn<ReservedListItem,
ReservedListItem> column) {
return new TableCell<>() {
private HyperlinkWithIcon hyperlinkWithIcon;
@Override
public void updateItem(final ReservedListItem item, boolean empty) {
@ -337,14 +331,9 @@ public class ReservedView extends ActivatableView<VBox, Void> {
if (item != null && !empty) {
String address = item.getAddressString();
hyperlinkWithIcon = new ExternalHyperlink(address);
hyperlinkWithIcon.setOnAction(event -> openBlockExplorer(item));
hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForAddress", address)));
setGraphic(hyperlinkWithIcon);
setGraphic(new AutoTooltipLabel(address));
} else {
setGraphic(null);
if (hyperlinkWithIcon != null)
hyperlinkWithIcon.setOnAction(null);
}
}
};

View File

@ -244,12 +244,6 @@ public class TransactionsView extends ActivatableView<VBox, Void> {
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());
@ -349,7 +343,6 @@ public class TransactionsView extends ActivatableView<VBox, Void> {
String addressString = item.getAddressString();
field = new AddressWithIconAndDirection(item.getDirection(), addressString,
item.getReceived());
field.setOnAction(event -> openAddressInBlockExplorer(item));
field.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForAddress", addressString)));
setGraphic(field);
} else {

View File

@ -54,7 +54,7 @@ import static javafx.beans.binding.Bindings.createBooleanBinding;
public class EditCustomExplorerWindow extends Overlay<EditCustomExplorerWindow> {
private InputTextField nameInputTextField, txUrlInputTextField, addressUrlInputTextField;
private InputTextField nameInputTextField, txUrlInputTextField;
private UrlInputValidator urlInputValidator;
private BlockChainExplorer currentExplorer;
private ListView<BlockChainExplorer> listView;
@ -70,9 +70,10 @@ public class EditCustomExplorerWindow extends Overlay<EditCustomExplorerWindow>
public BlockChainExplorer getEditedBlockChainExplorer() {
return new BlockChainExplorer(nameInputTextField.getText(),
txUrlInputTextField.getText(), addressUrlInputTextField.getText());
txUrlInputTextField.getText());
}
@Override
public void show() {
width = 1000;
@ -83,20 +84,17 @@ public class EditCustomExplorerWindow extends Overlay<EditCustomExplorerWindow>
urlInputValidator = new UrlInputValidator();
txUrlInputTextField.setValidator(urlInputValidator);
addressUrlInputTextField.setValidator(urlInputValidator);
nameInputTextField.setValidator(new LengthValidator(1, 50));
actionButton.disableProperty().bind(createBooleanBinding(() -> {
String name = nameInputTextField.getText();
String txUrl = txUrlInputTextField.getText();
String addressUrl = addressUrlInputTextField.getText();
// Otherwise we require that input is valid
return !nameInputTextField.getValidator().validate(name).isValid ||
!txUrlInputTextField.getValidator().validate(txUrl).isValid ||
!addressUrlInputTextField.getValidator().validate(addressUrl).isValid;
!txUrlInputTextField.getValidator().validate(txUrl).isValid;
},
nameInputTextField.textProperty(), txUrlInputTextField.textProperty(), addressUrlInputTextField.textProperty()));
nameInputTextField.textProperty(), txUrlInputTextField.textProperty()));
applyStyles();
display();
@ -127,7 +125,6 @@ public class EditCustomExplorerWindow extends Overlay<EditCustomExplorerWindow>
if (blockChainExplorer != null) {
nameInputTextField.setText(blockChainExplorer.name);
txUrlInputTextField.setText(blockChainExplorer.txUrl);
addressUrlInputTextField.setText(blockChainExplorer.addressUrl);
}
});
button.setStyle("-fx-pref-width: 50px; -fx-pref-height: 30; -fx-padding: 3 3 3 3;");
@ -169,7 +166,6 @@ public class EditCustomExplorerWindow extends Overlay<EditCustomExplorerWindow>
BlockChainExplorer blockChainExplorer = listView.getSelectionModel().getSelectedItem();
nameInputTextField.setText(blockChainExplorer.name);
txUrlInputTextField.setText(blockChainExplorer.txUrl);
addressUrlInputTextField.setText(blockChainExplorer.addressUrl);
}
}
});
@ -186,9 +182,7 @@ public class EditCustomExplorerWindow extends Overlay<EditCustomExplorerWindow>
nameInputTextField = addInputTextField(autoConfirmGridPane, ++localRowIndex, Res.get("settings.preferences.editCustomExplorer.name"), Layout.FIRST_ROW_DISTANCE);
nameInputTextField.setPrefWidth(Layout.INITIAL_WINDOW_WIDTH);
txUrlInputTextField = addInputTextField(autoConfirmGridPane, ++localRowIndex, Res.get("settings.preferences.editCustomExplorer.txUrl"));
addressUrlInputTextField = addInputTextField(autoConfirmGridPane, ++localRowIndex, Res.get("settings.preferences.editCustomExplorer.addressUrl"));
nameInputTextField.setText(currentExplorer.name);
txUrlInputTextField.setText(currentExplorer.txUrl);
addressUrlInputTextField.setText(currentExplorer.addressUrl);
}
}

View File

@ -771,7 +771,7 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
resetDontShowAgainButton.setOnAction(e -> preferences.resetDontShowAgain());
editCustomBtcExplorer.setOnAction(e -> {
EditCustomExplorerWindow urlWindow = new EditCustomExplorerWindow("BTC",
EditCustomExplorerWindow urlWindow = new EditCustomExplorerWindow("XMR",
preferences.getBlockChainExplorer(), preferences.getBlockChainExplorers());
urlWindow
.actionButtonText(Res.get("shared.save"))

View File

@ -1748,7 +1748,6 @@ message UserPayload {
message BlockChainExplorer {
string name = 1;
string tx_url = 2;
string address_url = 3;
}
message PaymentAccount {