diff --git a/core/src/main/java/haveno/core/api/XmrLocalNode.java b/core/src/main/java/haveno/core/api/XmrLocalNode.java index d19b2745..80682e9a 100644 --- a/core/src/main/java/haveno/core/api/XmrLocalNode.java +++ b/core/src/main/java/haveno/core/api/XmrLocalNode.java @@ -68,15 +68,6 @@ public class XmrLocalNode { if (!Config.baseCurrencyNetwork().isMainnet()) MONEROD_ARGS.add("--" + Config.baseCurrencyNetwork().getNetwork().toLowerCase()); } - // default rpc ports - private static Integer rpcPort; - static { - if (Config.baseCurrencyNetwork().isMainnet()) rpcPort = 18081; - else if (Config.baseCurrencyNetwork().isTestnet()) rpcPort = 28081; - else if (Config.baseCurrencyNetwork().isStagenet()) rpcPort = 38081; - else throw new RuntimeException("Base network is not local testnet, stagenet, or mainnet"); - } - @Inject public XmrLocalNode(Config config, Preferences preferences) { this.config = config; @@ -93,7 +84,7 @@ public class XmrLocalNode { } public String getUri() { - return "http://" + HavenoUtils.LOOPBACK_HOST + ":" + rpcPort; + return "http://" + HavenoUtils.LOOPBACK_HOST + ":" + HavenoUtils.getDefaultMoneroPort(); } /** @@ -129,7 +120,7 @@ public class XmrLocalNode { } public boolean equalsUri(String uri) { - return HavenoUtils.isLocalHost(uri) && MoneroUtils.parseUri(uri).getPort() == rpcPort; + return HavenoUtils.isLocalHost(uri) && MoneroUtils.parseUri(uri).getPort() == HavenoUtils.getDefaultMoneroPort(); } /** diff --git a/core/src/main/java/haveno/core/trade/HavenoUtils.java b/core/src/main/java/haveno/core/trade/HavenoUtils.java index 22e29d8a..ba631876 100644 --- a/core/src/main/java/haveno/core/trade/HavenoUtils.java +++ b/core/src/main/java/haveno/core/trade/HavenoUtils.java @@ -515,4 +515,11 @@ public class HavenoUtils { for (MoneroOutput input : tx.getInputs()) inputKeyImages.add(input.getKeyImage().getHex()); return inputKeyImages; } + + public static int getDefaultMoneroPort() { + if (Config.baseCurrencyNetwork().isMainnet()) return 18081; + else if (Config.baseCurrencyNetwork().isTestnet()) return 28081; + else if (Config.baseCurrencyNetwork().isStagenet()) return 38081; + else throw new RuntimeException("Base network is not local testnet, stagenet, or mainnet"); + } } diff --git a/core/src/main/java/haveno/core/xmr/nodes/XmrNodes.java b/core/src/main/java/haveno/core/xmr/nodes/XmrNodes.java index 7330a4cb..25df963b 100644 --- a/core/src/main/java/haveno/core/xmr/nodes/XmrNodes.java +++ b/core/src/main/java/haveno/core/xmr/nodes/XmrNodes.java @@ -35,6 +35,7 @@ package haveno.core.xmr.nodes; import haveno.common.config.Config; +import haveno.core.trade.HavenoUtils; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -127,7 +128,6 @@ public class XmrNodes { @EqualsAndHashCode @Getter public static class XmrNode { - private static final int DEFAULT_PORT = Config.baseCurrencyNetworkParameters().getPort(); private final MoneroNodesOption type; @Nullable @@ -138,7 +138,7 @@ public class XmrNodes { private final String operator; // null in case the user provides a list of custom btc nodes @Nullable private final String address; // IPv4 address - private int port = DEFAULT_PORT; + private int port = HavenoUtils.getDefaultMoneroPort(); private int priority = 0; /** @@ -149,7 +149,7 @@ public class XmrNodes { String[] parts = fullAddress.split("]"); checkArgument(parts.length > 0); String host = ""; - int port = DEFAULT_PORT; + int port = HavenoUtils.getDefaultMoneroPort(); if (parts[0].contains("[") && parts[0].contains(":")) { // IPv6 address and optional port number // address part delimited by square brackets e.g. [2a01:123:456:789::2]:8333 diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index f631fd8a..de12827a 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -1345,7 +1345,7 @@ settings.net.notKnownYet=Not known yet... settings.net.sentData=Sent data: {0}, {1} messages, {2} messages/sec settings.net.receivedData=Received data: {0}, {1} messages, {2} messages/sec settings.net.chainHeight=Monero Peers chain height: {0} -settings.net.ips=[IP address:port | host name:port | onion address:port] (comma separated). Port can be omitted if default is used (8333). +settings.net.ips=[IP address:port | host name:port | onion address:port] (comma separated). Port can be omitted if default is used ({0}). settings.net.seedNode=Seed node settings.net.directPeer=Peer (direct) settings.net.initialDataExchange={0} [Bootstrapping] diff --git a/desktop/src/main/java/haveno/desktop/main/settings/network/NetworkSettingsView.java b/desktop/src/main/java/haveno/desktop/main/settings/network/NetworkSettingsView.java index c3226ec9..89c0e750 100644 --- a/desktop/src/main/java/haveno/desktop/main/settings/network/NetworkSettingsView.java +++ b/desktop/src/main/java/haveno/desktop/main/settings/network/NetworkSettingsView.java @@ -25,6 +25,7 @@ import haveno.core.api.XmrLocalNode; import haveno.core.filter.Filter; import haveno.core.filter.FilterManager; import haveno.core.locale.Res; +import haveno.core.trade.HavenoUtils; import haveno.core.user.Preferences; import haveno.core.util.FormattingUtils; import haveno.core.util.validation.RegexValidator; @@ -266,7 +267,7 @@ public class NetworkSettingsView extends ActivatableView { } }; - xmrNodesInputTextField.setPromptText(Res.get("settings.net.ips")); + xmrNodesInputTextField.setPromptText(Res.get("settings.net.ips", "" + HavenoUtils.getDefaultMoneroPort())); RegexValidator regexValidator = RegexValidatorFactory.addressRegexValidator(); xmrNodesInputTextField.setValidator(regexValidator); xmrNodesInputTextField.setErrorMessage(Res.get("validation.invalidAddressList"));