diff --git a/core/src/main/java/haveno/core/api/CoreApi.java b/core/src/main/java/haveno/core/api/CoreApi.java index ab0479b261..a7f4c81760 100644 --- a/core/src/main/java/haveno/core/api/CoreApi.java +++ b/core/src/main/java/haveno/core/api/CoreApi.java @@ -43,7 +43,7 @@ import haveno.core.support.messages.ChatMessage; import haveno.core.trade.Trade; import haveno.core.trade.statistics.TradeStatistics3; import haveno.core.trade.statistics.TradeStatisticsManager; -import haveno.core.xmr.MoneroNodeSettings; +import haveno.core.xmr.XmrNodeSettings; import haveno.proto.grpc.NotificationMessage; import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -86,8 +86,8 @@ public class CoreApi { private final CoreWalletsService walletsService; private final TradeStatisticsManager tradeStatisticsManager; private final CoreNotificationService notificationService; - private final CoreMoneroConnectionsService coreMoneroConnectionsService; - private final LocalMoneroNode coreMoneroNodeService; + private final XmrConnectionService xmrConnectionService; + private final XmrLocalNode xmrLocalNode; @Inject public CoreApi(Config config, @@ -103,8 +103,8 @@ public class CoreApi { CoreWalletsService walletsService, TradeStatisticsManager tradeStatisticsManager, CoreNotificationService notificationService, - CoreMoneroConnectionsService coreMoneroConnectionsService, - LocalMoneroNode coreMoneroNodeService) { + XmrConnectionService xmrConnectionService, + XmrLocalNode xmrLocalNode) { this.config = config; this.appStartupState = appStartupState; this.coreAccountService = coreAccountService; @@ -118,8 +118,8 @@ public class CoreApi { this.walletsService = walletsService; this.tradeStatisticsManager = tradeStatisticsManager; this.notificationService = notificationService; - this.coreMoneroConnectionsService = coreMoneroConnectionsService; - this.coreMoneroNodeService = coreMoneroNodeService; + this.xmrConnectionService = xmrConnectionService; + this.xmrLocalNode = xmrLocalNode; } @SuppressWarnings("SameReturnValue") @@ -184,71 +184,71 @@ public class CoreApi { /////////////////////////////////////////////////////////////////////////////////////////// public void addMoneroConnection(MoneroRpcConnection connection) { - coreMoneroConnectionsService.addConnection(connection); + xmrConnectionService.addConnection(connection); } public void removeMoneroConnection(String connectionUri) { - coreMoneroConnectionsService.removeConnection(connectionUri); + xmrConnectionService.removeConnection(connectionUri); } public MoneroRpcConnection getMoneroConnection() { - return coreMoneroConnectionsService.getConnection(); + return xmrConnectionService.getConnection(); } - public List getMoneroConnections() { - return coreMoneroConnectionsService.getConnections(); + public List getXmrConnections() { + return xmrConnectionService.getConnections(); } public void setMoneroConnection(String connectionUri) { - coreMoneroConnectionsService.setConnection(connectionUri); + xmrConnectionService.setConnection(connectionUri); } public void setMoneroConnection(MoneroRpcConnection connection) { - coreMoneroConnectionsService.setConnection(connection); + xmrConnectionService.setConnection(connection); } public MoneroRpcConnection checkMoneroConnection() { - return coreMoneroConnectionsService.checkConnection(); + return xmrConnectionService.checkConnection(); } - public List checkMoneroConnections() { - return coreMoneroConnectionsService.checkConnections(); + public List checkXmrConnections() { + return xmrConnectionService.checkConnections(); } public void startCheckingMoneroConnection(Long refreshPeriod) { - coreMoneroConnectionsService.startCheckingConnection(refreshPeriod); + xmrConnectionService.startCheckingConnection(refreshPeriod); } public void stopCheckingMoneroConnection() { - coreMoneroConnectionsService.stopCheckingConnection(); + xmrConnectionService.stopCheckingConnection(); } public MoneroRpcConnection getBestAvailableMoneroConnection() { - return coreMoneroConnectionsService.getBestAvailableConnection(); + return xmrConnectionService.getBestAvailableConnection(); } public void setMoneroConnectionAutoSwitch(boolean autoSwitch) { - coreMoneroConnectionsService.setAutoSwitch(autoSwitch); + xmrConnectionService.setAutoSwitch(autoSwitch); } /////////////////////////////////////////////////////////////////////////////////////////// // Monero node /////////////////////////////////////////////////////////////////////////////////////////// - public boolean isMoneroNodeOnline() { - return coreMoneroNodeService.isDetected(); + public boolean isXmrNodeOnline() { + return xmrLocalNode.isDetected(); } - public MoneroNodeSettings getMoneroNodeSettings() { - return coreMoneroNodeService.getMoneroNodeSettings(); + public XmrNodeSettings getXmrNodeSettings() { + return xmrLocalNode.getNodeSettings(); } - public void startMoneroNode(MoneroNodeSettings settings) throws IOException { - coreMoneroNodeService.startMoneroNode(settings); + public void startXmrNode(XmrNodeSettings settings) throws IOException { + xmrLocalNode.startNode(settings); } - public void stopMoneroNode() { - coreMoneroNodeService.stopMoneroNode(); + public void stopXmrNode() { + xmrLocalNode.stopNode(); } /////////////////////////////////////////////////////////////////////////////////////////// diff --git a/core/src/main/java/haveno/core/api/CoreMoneroConnectionsService.java b/core/src/main/java/haveno/core/api/XmrConnectionService.java similarity index 96% rename from core/src/main/java/haveno/core/api/CoreMoneroConnectionsService.java rename to core/src/main/java/haveno/core/api/XmrConnectionService.java index 09c9722dbd..a28261ea8e 100644 --- a/core/src/main/java/haveno/core/api/CoreMoneroConnectionsService.java +++ b/core/src/main/java/haveno/core/api/XmrConnectionService.java @@ -42,7 +42,7 @@ import java.util.stream.Collectors; @Slf4j @Singleton -public final class CoreMoneroConnectionsService { +public final class XmrConnectionService { private static final int MIN_BROADCAST_CONNECTIONS = 0; // TODO: 0 for stagenet, 5+ for mainnet private static final long REFRESH_PERIOD_HTTP_MS = 20000; // refresh period when connected to remote node over http @@ -57,7 +57,7 @@ public final class CoreMoneroConnectionsService { private final Preferences preferences; private final CoreAccountService accountService; private final XmrNodes xmrNodes; - private final LocalMoneroNode nodeService; + private final XmrLocalNode xmrLocalNode; private final MoneroConnectionManager connectionManager; private final EncryptedConnectionList connectionList; private final ObjectProperty> peers = new SimpleObjectProperty<>(); @@ -76,14 +76,14 @@ public final class CoreMoneroConnectionsService { private List listeners = new ArrayList<>(); @Inject - public CoreMoneroConnectionsService(P2PService p2PService, + public XmrConnectionService(P2PService p2PService, Config config, CoreContext coreContext, Preferences preferences, WalletsSetup walletsSetup, CoreAccountService accountService, XmrNodes xmrNodes, - LocalMoneroNode nodeService, + XmrLocalNode xmrLocalNode, MoneroConnectionManager connectionManager, EncryptedConnectionList connectionList, Socks5ProxyProvider socks5ProxyProvider) { @@ -92,7 +92,7 @@ public final class CoreMoneroConnectionsService { this.preferences = preferences; this.accountService = accountService; this.xmrNodes = xmrNodes; - this.nodeService = nodeService; + this.xmrLocalNode = xmrLocalNode; this.connectionManager = connectionManager; this.connectionList = connectionList; this.socks5ProxyProvider = socks5ProxyProvider; @@ -313,10 +313,10 @@ public final class CoreMoneroConnectionsService { private long getDefaultRefreshPeriodMs() { MoneroRpcConnection connection = getConnection(); - if (connection == null) return LocalMoneroNode.REFRESH_PERIOD_LOCAL_MS; + if (connection == null) return XmrLocalNode.REFRESH_PERIOD_LOCAL_MS; if (isConnectionLocal(connection)) { if (lastInfo != null && (lastInfo.isBusySyncing() || (lastInfo.getHeightWithoutBootstrap() != null && lastInfo.getHeightWithoutBootstrap() > 0 && lastInfo.getHeightWithoutBootstrap() < lastInfo.getHeight()))) return REFRESH_PERIOD_HTTP_MS; // refresh slower if syncing or bootstrapped - else return LocalMoneroNode.REFRESH_PERIOD_LOCAL_MS; // TODO: announce faster refresh after done syncing + else return XmrLocalNode.REFRESH_PERIOD_LOCAL_MS; // TODO: announce faster refresh after done syncing } else if (useProxy(connection)) { return REFRESH_PERIOD_ONION_MS; } else { @@ -366,7 +366,7 @@ public final class CoreMoneroConnectionsService { if (!isInitialized) { // register local node listener - nodeService.addListener(new LocalMoneroNodeListener() { + xmrLocalNode.addListener(new XmrLocalNodeListener() { @Override public void onNodeStarted(MoneroDaemonRpc daemon) { log.info("Local monero node started"); @@ -381,7 +381,7 @@ public final class CoreMoneroConnectionsService { public void onConnectionChanged(MoneroRpcConnection connection) { log.info("Local monerod connection changed: " + connection); if (isShutDownStarted || !connectionManager.getAutoSwitch() || !accountService.isAccountOpen()) return; - if (nodeService.isConnected()) { + if (xmrLocalNode.isConnected()) { setConnection(connection.getUri()); // switch to local node if connected } else if (getConnection() != null && getConnection().getUri().equals(connection.getUri())) { setConnection(getBestAvailableConnection()); // switch to best available if disconnected from local node @@ -487,10 +487,10 @@ public final class CoreMoneroConnectionsService { if (HavenoUtils.havenoSetup == null) return; // start local node if offline and used as last connection - if (connectionManager.getConnection() != null && nodeService.equalsUri(connectionManager.getConnection().getUri()) && !nodeService.isDetected()) { + if (connectionManager.getConnection() != null && xmrLocalNode.equalsUri(connectionManager.getConnection().getUri()) && !xmrLocalNode.isDetected()) { try { log.info("Starting local node"); - nodeService.startMoneroNode(); + xmrLocalNode.startMoneroNode(); } catch (Exception e) { log.warn("Unable to start local monero node: " + e.getMessage()); e.printStackTrace(); @@ -499,7 +499,7 @@ public final class CoreMoneroConnectionsService { } private void onConnectionChanged(MoneroRpcConnection currentConnection) { - log.info("CoreMoneroConnectionsService.onConnectionChanged() uri={}, connected={}", currentConnection == null ? null : currentConnection.getUri(), currentConnection == null ? "false" : currentConnection.isConnected()); + log.info("XmrConnectionService.onConnectionChanged() uri={}, connected={}", currentConnection == null ? null : currentConnection.getUri(), currentConnection == null ? "false" : currentConnection.isConnected()); if (isShutDownStarted) return; synchronized (lock) { if (currentConnection == null) { diff --git a/core/src/main/java/haveno/core/api/LocalMoneroNode.java b/core/src/main/java/haveno/core/api/XmrLocalNode.java similarity index 89% rename from core/src/main/java/haveno/core/api/LocalMoneroNode.java rename to core/src/main/java/haveno/core/api/XmrLocalNode.java index cae0d0d737..9d8786ea24 100644 --- a/core/src/main/java/haveno/core/api/LocalMoneroNode.java +++ b/core/src/main/java/haveno/core/api/XmrLocalNode.java @@ -21,7 +21,7 @@ import haveno.common.config.Config; import haveno.common.util.Utilities; import haveno.core.trade.HavenoUtils; import haveno.core.user.Preferences; -import haveno.core.xmr.MoneroNodeSettings; +import haveno.core.xmr.XmrNodeSettings; import lombok.extern.slf4j.Slf4j; import monero.common.MoneroConnectionManager; import monero.common.MoneroUtils; @@ -38,7 +38,7 @@ import java.util.List; */ @Slf4j @Singleton -public class LocalMoneroNode { +public class XmrLocalNode { // constants public static final long REFRESH_PERIOD_LOCAL_MS = 5000; // refresh period for local node @@ -52,7 +52,7 @@ public class LocalMoneroNode { private MoneroConnectionManager connectionManager; private final Config config; private final Preferences preferences; - private final List listeners = new ArrayList<>(); + private final List listeners = new ArrayList<>(); // required arguments private static final List MONEROD_ARGS = new ArrayList(); @@ -73,7 +73,7 @@ public class LocalMoneroNode { } @Inject - public LocalMoneroNode(Config config, Preferences preferences) { + public XmrLocalNode(Config config, Preferences preferences) { this.config = config; this.preferences = preferences; this.daemon = new MoneroDaemonRpc("http://" + HavenoUtils.LOOPBACK_HOST + ":" + rpcPort); @@ -105,11 +105,11 @@ public class LocalMoneroNode { return config.ignoreLocalXmrNode; } - public void addListener(LocalMoneroNodeListener listener) { + public void addListener(XmrLocalNodeListener listener) { listeners.add(listener); } - public boolean removeListener(LocalMoneroNodeListener listener) { + public boolean removeListener(XmrLocalNodeListener listener) { return listeners.remove(listener); } @@ -144,23 +144,23 @@ public class LocalMoneroNode { connectionManager.checkConnection(); } - public MoneroNodeSettings getMoneroNodeSettings() { - return preferences.getMoneroNodeSettings(); + public XmrNodeSettings getNodeSettings() { + return preferences.getXmrNodeSettings(); } /** * Start a local Monero node from settings. */ public void startMoneroNode() throws IOException { - var settings = preferences.getMoneroNodeSettings(); - this.startMoneroNode(settings); + var settings = preferences.getXmrNodeSettings(); + this.startNode(settings); } /** * Start local Monero node. Throws MoneroError if the node cannot be started. * Persist the settings to preferences if the node started successfully. */ - public void startMoneroNode(MoneroNodeSettings settings) throws IOException { + public void startNode(XmrNodeSettings settings) throws IOException { if (isDetected()) throw new IllegalStateException("Local Monero node already online"); log.info("Starting local Monero node: " + settings); @@ -184,15 +184,15 @@ public class LocalMoneroNode { } daemon = new MoneroDaemonRpc(args); // start daemon as process and re-assign client - preferences.setMoneroNodeSettings(settings); + preferences.setXmrNodeSettings(settings); for (var listener : listeners) listener.onNodeStarted(daemon); } /** * Stop the current local Monero node if we own its process. - * Does not remove the last MoneroNodeSettings. + * Does not remove the last XmrNodeSettings. */ - public void stopMoneroNode() { + public void stopNode() { if (!isDetected()) throw new IllegalStateException("Local Monero node is not running"); if (daemon.getProcess() == null || !daemon.getProcess().isAlive()) throw new IllegalStateException("Cannot stop local Monero node because we don't own its process"); // TODO (woodser): remove isAlive() check after monero-java 0.5.4 which nullifies internal process daemon.stopProcess(); diff --git a/core/src/main/java/haveno/core/api/LocalMoneroNodeListener.java b/core/src/main/java/haveno/core/api/XmrLocalNodeListener.java similarity index 96% rename from core/src/main/java/haveno/core/api/LocalMoneroNodeListener.java rename to core/src/main/java/haveno/core/api/XmrLocalNodeListener.java index d5c3eeee9f..e55cd945cc 100644 --- a/core/src/main/java/haveno/core/api/LocalMoneroNodeListener.java +++ b/core/src/main/java/haveno/core/api/XmrLocalNodeListener.java @@ -19,7 +19,7 @@ package haveno.core.api; import monero.common.MoneroRpcConnection; import monero.daemon.MoneroDaemonRpc; -public class LocalMoneroNodeListener { +public class XmrLocalNodeListener { public void onNodeStarted(MoneroDaemonRpc daemon) {} public void onNodeStopped() {} public void onConnectionChanged(MoneroRpcConnection connection) {} diff --git a/core/src/main/java/haveno/core/app/AppStartupState.java b/core/src/main/java/haveno/core/app/AppStartupState.java index 3f2ba57436..08d3f152a5 100644 --- a/core/src/main/java/haveno/core/app/AppStartupState.java +++ b/core/src/main/java/haveno/core/app/AppStartupState.java @@ -17,7 +17,7 @@ package haveno.core.app; -import haveno.core.api.CoreMoneroConnectionsService; +import haveno.core.api.XmrConnectionService; import haveno.core.api.CoreNotificationService; import haveno.core.xmr.wallet.XmrWalletService; import haveno.network.p2p.BootstrapListener; @@ -53,7 +53,7 @@ public class AppStartupState { @Inject public AppStartupState(CoreNotificationService notificationService, - CoreMoneroConnectionsService connectionsService, + XmrConnectionService xmrConnectionService, XmrWalletService xmrWalletService, P2PService p2PService) { @@ -64,8 +64,8 @@ public class AppStartupState { } }); - connectionsService.downloadPercentageProperty().addListener((observable, oldValue, newValue) -> { - if (connectionsService.isDownloadComplete()) + xmrConnectionService.downloadPercentageProperty().addListener((observable, oldValue, newValue) -> { + if (xmrConnectionService.isDownloadComplete()) isBlockDownloadComplete.set(true); }); @@ -74,8 +74,8 @@ public class AppStartupState { isWalletSynced.set(true); }); - connectionsService.numPeersProperty().addListener((observable, oldValue, newValue) -> { - if (connectionsService.hasSufficientPeersForBroadcast()) + xmrConnectionService.numPeersProperty().addListener((observable, oldValue, newValue) -> { + if (xmrConnectionService.hasSufficientPeersForBroadcast()) hasSufficientPeersForBroadcast.set(true); }); diff --git a/core/src/main/java/haveno/core/app/CoreModule.java b/core/src/main/java/haveno/core/app/CoreModule.java index c84496ce09..7df16c3fb8 100644 --- a/core/src/main/java/haveno/core/app/CoreModule.java +++ b/core/src/main/java/haveno/core/app/CoreModule.java @@ -35,8 +35,8 @@ import haveno.core.user.Preferences; import haveno.core.util.FormattingUtils; import haveno.core.util.coin.CoinFormatter; import haveno.core.util.coin.ImmutableCoinFormatter; -import haveno.core.xmr.MoneroConnectionModule; -import haveno.core.xmr.MoneroModule; +import haveno.core.xmr.XmrConnectionModule; +import haveno.core.xmr.XmrModule; import haveno.network.crypto.EncryptionServiceModule; import haveno.network.p2p.P2PModule; import haveno.network.p2p.network.BanFilter; @@ -88,10 +88,10 @@ public class CoreModule extends AppModule { install(new EncryptionServiceModule(config)); install(new OfferModule(config)); install(new P2PModule(config)); - install(new MoneroModule(config)); + install(new XmrModule(config)); install(new AlertModule(config)); install(new FilterModule(config)); install(new CorePresentationModule(config)); - install(new MoneroConnectionModule(config)); + install(new XmrConnectionModule(config)); } } diff --git a/core/src/main/java/haveno/core/app/HavenoExecutable.java b/core/src/main/java/haveno/core/app/HavenoExecutable.java index 3365001841..eb155bd6b7 100644 --- a/core/src/main/java/haveno/core/app/HavenoExecutable.java +++ b/core/src/main/java/haveno/core/app/HavenoExecutable.java @@ -34,7 +34,7 @@ import haveno.common.setup.UncaughtExceptionHandler; import haveno.common.util.Utilities; import haveno.core.api.AccountServiceListener; import haveno.core.api.CoreAccountService; -import haveno.core.api.CoreMoneroConnectionsService; +import haveno.core.api.XmrConnectionService; import haveno.core.offer.OfferBookService; import haveno.core.offer.OpenOfferManager; import haveno.core.provider.price.PriceFeedService; @@ -336,7 +336,7 @@ public abstract class HavenoExecutable implements GracefulShutDownHandler, Haven // notify trade protocols and wallets to prepare for shut down before shutting down Set tasks = new HashSet(); tasks.add(() -> injector.getInstance(XmrWalletService.class).onShutDownStarted()); - tasks.add(() -> injector.getInstance(CoreMoneroConnectionsService.class).onShutDownStarted()); + tasks.add(() -> injector.getInstance(XmrConnectionService.class).onShutDownStarted()); HavenoUtils.executeTasks(tasks); // notify in parallel injector.getInstance(PriceFeedService.class).shutDown(); @@ -363,7 +363,7 @@ public abstract class HavenoExecutable implements GracefulShutDownHandler, Haven }); injector.getInstance(BtcWalletService.class).shutDown(); injector.getInstance(XmrWalletService.class).shutDown(); - injector.getInstance(CoreMoneroConnectionsService.class).shutDown(); + injector.getInstance(XmrConnectionService.class).shutDown(); injector.getInstance(WalletsSetup.class).shutDown(); }); }); diff --git a/core/src/main/java/haveno/core/app/HavenoSetup.java b/core/src/main/java/haveno/core/app/HavenoSetup.java index c06d0948b3..624e6bd2aa 100644 --- a/core/src/main/java/haveno/core/app/HavenoSetup.java +++ b/core/src/main/java/haveno/core/app/HavenoSetup.java @@ -33,7 +33,7 @@ import haveno.core.alert.Alert; import haveno.core.alert.AlertManager; import haveno.core.alert.PrivateNotificationManager; import haveno.core.alert.PrivateNotificationPayload; -import haveno.core.api.LocalMoneroNode; +import haveno.core.api.XmrLocalNode; import haveno.core.locale.Res; import haveno.core.offer.OpenOfferManager; import haveno.core.payment.AmazonGiftCardAccount; @@ -122,7 +122,7 @@ public class HavenoSetup { private final AccountAgeWitnessService accountAgeWitnessService; private final TorSetup torSetup; private final CoinFormatter formatter; - private final LocalMoneroNode localMoneroNode; + private final XmrLocalNode xmrLocalNode; private final AppStartupState appStartupState; private final MediationManager mediationManager; private final RefundManager refundManager; @@ -216,7 +216,7 @@ public class HavenoSetup { AccountAgeWitnessService accountAgeWitnessService, TorSetup torSetup, @Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter, - LocalMoneroNode localMoneroNode, + XmrLocalNode xmrLocalNode, AppStartupState appStartupState, Socks5ProxyProvider socks5ProxyProvider, MediationManager mediationManager, @@ -241,7 +241,7 @@ public class HavenoSetup { this.accountAgeWitnessService = accountAgeWitnessService; this.torSetup = torSetup; this.formatter = formatter; - this.localMoneroNode = localMoneroNode; + this.xmrLocalNode = xmrLocalNode; this.appStartupState = appStartupState; this.mediationManager = mediationManager; this.refundManager = refundManager; @@ -340,12 +340,12 @@ public class HavenoSetup { private void maybeInstallDependencies() { try { - File monerodFile = new File(LocalMoneroNode.MONEROD_PATH); - String monerodResourcePath = "bin/" + LocalMoneroNode.MONEROD_NAME; + File monerodFile = new File(XmrLocalNode.MONEROD_PATH); + String monerodResourcePath = "bin/" + XmrLocalNode.MONEROD_NAME; if (!monerodFile.exists() || !FileUtil.resourceEqualToFile(monerodResourcePath, monerodFile)) { log.info("Installing monerod"); monerodFile.getParentFile().mkdirs(); - FileUtil.resourceToFile("bin/" + LocalMoneroNode.MONEROD_NAME, monerodFile); + FileUtil.resourceToFile("bin/" + XmrLocalNode.MONEROD_NAME, monerodFile); monerodFile.setExecutable(true); } @@ -622,7 +622,7 @@ public class HavenoSetup { } private void maybeShowLocalhostRunningInfo() { - maybeTriggerDisplayHandler("moneroLocalhostNode", displayLocalhostHandler, localMoneroNode.shouldBeUsed()); + maybeTriggerDisplayHandler("xmrLocalNode", displayLocalhostHandler, xmrLocalNode.shouldBeUsed()); } private void maybeShowAccountSigningStateInfo() { diff --git a/core/src/main/java/haveno/core/app/P2PNetworkSetup.java b/core/src/main/java/haveno/core/app/P2PNetworkSetup.java index bd52aab41c..359cc27f46 100644 --- a/core/src/main/java/haveno/core/app/P2PNetworkSetup.java +++ b/core/src/main/java/haveno/core/app/P2PNetworkSetup.java @@ -18,7 +18,7 @@ package haveno.core.app; import haveno.common.UserThread; -import haveno.core.api.CoreMoneroConnectionsService; +import haveno.core.api.XmrConnectionService; import haveno.core.locale.Res; import haveno.core.provider.price.PriceFeedService; import haveno.core.user.Preferences; @@ -46,7 +46,7 @@ import java.util.function.Consumer; public class P2PNetworkSetup { private final PriceFeedService priceFeedService; private final P2PService p2PService; - private final CoreMoneroConnectionsService connectionService; + private final XmrConnectionService xmrConnectionService; private final Preferences preferences; @SuppressWarnings("FieldCanBeLocal") @@ -72,12 +72,12 @@ public class P2PNetworkSetup { @Inject public P2PNetworkSetup(PriceFeedService priceFeedService, P2PService p2PService, - CoreMoneroConnectionsService connectionService, + XmrConnectionService xmrConnectionService, Preferences preferences) { this.priceFeedService = priceFeedService; this.p2PService = p2PService; - this.connectionService = connectionService; + this.xmrConnectionService = xmrConnectionService; this.preferences = preferences; } @@ -88,7 +88,7 @@ public class P2PNetworkSetup { BooleanProperty initialP2PNetworkDataReceived = new SimpleBooleanProperty(); p2PNetworkInfoBinding = EasyBind.combine(bootstrapState, bootstrapWarning, p2PService.getNumConnectedPeers(), - connectionService.numPeersProperty(), hiddenServicePublished, initialP2PNetworkDataReceived, + xmrConnectionService.numPeersProperty(), hiddenServicePublished, initialP2PNetworkDataReceived, (state, warning, numP2pPeers, numXmrPeers, hiddenService, dataReceived) -> { String result; int p2pPeers = (int) numP2pPeers; diff --git a/core/src/main/java/haveno/core/app/WalletAppSetup.java b/core/src/main/java/haveno/core/app/WalletAppSetup.java index 3b4aa907a2..9c731c89c0 100644 --- a/core/src/main/java/haveno/core/app/WalletAppSetup.java +++ b/core/src/main/java/haveno/core/app/WalletAppSetup.java @@ -20,7 +20,7 @@ package haveno.core.app; import haveno.common.UserThread; import haveno.common.config.Config; import haveno.core.api.CoreContext; -import haveno.core.api.CoreMoneroConnectionsService; +import haveno.core.api.XmrConnectionService; import haveno.core.locale.Res; import haveno.core.offer.OpenOfferManager; import haveno.core.trade.TradeManager; @@ -60,7 +60,7 @@ public class WalletAppSetup { private final CoreContext coreContext; private final WalletsManager walletsManager; private final WalletsSetup walletsSetup; - private final CoreMoneroConnectionsService connectionService; + private final XmrConnectionService xmrConnectionService; private final XmrWalletService xmrWalletService; private final Config config; private final Preferences preferences; @@ -85,14 +85,14 @@ public class WalletAppSetup { public WalletAppSetup(CoreContext coreContext, WalletsManager walletsManager, WalletsSetup walletsSetup, - CoreMoneroConnectionsService connectionService, + XmrConnectionService xmrConnectionService, XmrWalletService xmrWalletService, Config config, Preferences preferences) { this.coreContext = coreContext; this.walletsManager = walletsManager; this.walletsSetup = walletsSetup; - this.connectionService = connectionService; + this.xmrConnectionService = xmrConnectionService; this.xmrWalletService = xmrWalletService; this.config = config; this.preferences = preferences; @@ -107,8 +107,8 @@ public class WalletAppSetup { log.info("Initialize WalletAppSetup with monero-java version {}", MoneroUtils.getVersion()); ObjectProperty walletServiceException = new SimpleObjectProperty<>(); - xmrInfoBinding = EasyBind.combine(connectionService.downloadPercentageProperty(), - connectionService.chainHeightProperty(), + xmrInfoBinding = EasyBind.combine(xmrConnectionService.downloadPercentageProperty(), + xmrConnectionService.chainHeightProperty(), xmrWalletService.downloadPercentageProperty(), xmrWalletService.walletHeightProperty(), walletServiceException, diff --git a/core/src/main/java/haveno/core/app/misc/ExecutableForAppWithP2p.java b/core/src/main/java/haveno/core/app/misc/ExecutableForAppWithP2p.java index f6f7331d9e..793717ed3c 100644 --- a/core/src/main/java/haveno/core/app/misc/ExecutableForAppWithP2p.java +++ b/core/src/main/java/haveno/core/app/misc/ExecutableForAppWithP2p.java @@ -26,7 +26,7 @@ import haveno.common.handlers.ResultHandler; import haveno.common.persistence.PersistenceManager; import haveno.common.setup.GracefulShutDownHandler; import haveno.common.util.Profiler; -import haveno.core.api.CoreMoneroConnectionsService; +import haveno.core.api.XmrConnectionService; import haveno.core.app.HavenoExecutable; import haveno.core.offer.OfferBookService; import haveno.core.offer.OpenOfferManager; @@ -96,7 +96,7 @@ public abstract class ExecutableForAppWithP2p extends HavenoExecutable { // notify trade protocols and wallets to prepare for shut down before shutting down Set tasks = new HashSet(); tasks.add(() -> injector.getInstance(XmrWalletService.class).onShutDownStarted()); - tasks.add(() -> injector.getInstance(CoreMoneroConnectionsService.class).onShutDownStarted()); + tasks.add(() -> injector.getInstance(XmrConnectionService.class).onShutDownStarted()); HavenoUtils.executeTasks(tasks); // notify in parallel JsonFileManager.shutDownAllInstances(); @@ -124,7 +124,7 @@ public abstract class ExecutableForAppWithP2p extends HavenoExecutable { }); injector.getInstance(BtcWalletService.class).shutDown(); injector.getInstance(XmrWalletService.class).shutDown(); - injector.getInstance(CoreMoneroConnectionsService.class).shutDown(); + injector.getInstance(XmrConnectionService.class).shutDown(); injector.getInstance(WalletsSetup.class).shutDown(); }); }); diff --git a/core/src/main/java/haveno/core/app/misc/ModuleForAppWithP2p.java b/core/src/main/java/haveno/core/app/misc/ModuleForAppWithP2p.java index 7bef375dc4..934350e229 100644 --- a/core/src/main/java/haveno/core/app/misc/ModuleForAppWithP2p.java +++ b/core/src/main/java/haveno/core/app/misc/ModuleForAppWithP2p.java @@ -36,8 +36,8 @@ import haveno.core.proto.persistable.CorePersistenceProtoResolver; import haveno.core.trade.TradeModule; import haveno.core.user.Preferences; import haveno.core.user.User; -import haveno.core.xmr.MoneroConnectionModule; -import haveno.core.xmr.MoneroModule; +import haveno.core.xmr.XmrConnectionModule; +import haveno.core.xmr.XmrModule; import haveno.network.crypto.EncryptionServiceModule; import haveno.network.p2p.P2PModule; import haveno.network.p2p.network.BanFilter; @@ -92,9 +92,9 @@ public class ModuleForAppWithP2p extends AppModule { install(new EncryptionServiceModule(config)); install(new OfferModule(config)); install(new P2PModule(config)); - install(new MoneroModule(config)); + install(new XmrModule(config)); install(new AlertModule(config)); install(new FilterModule(config)); - install(new MoneroConnectionModule(config)); + install(new XmrConnectionModule(config)); } } diff --git a/core/src/main/java/haveno/core/offer/OfferBookService.java b/core/src/main/java/haveno/core/offer/OfferBookService.java index 42f07ad71c..833d36d9ff 100644 --- a/core/src/main/java/haveno/core/offer/OfferBookService.java +++ b/core/src/main/java/haveno/core/offer/OfferBookService.java @@ -23,13 +23,13 @@ import haveno.common.config.Config; import haveno.common.file.JsonFileManager; import haveno.common.handlers.ErrorMessageHandler; import haveno.common.handlers.ResultHandler; -import haveno.core.api.CoreMoneroConnectionsService; +import haveno.core.api.XmrConnectionService; import haveno.core.filter.FilterManager; import haveno.core.locale.Res; import haveno.core.provider.price.PriceFeedService; import haveno.core.util.JsonUtil; -import haveno.core.xmr.wallet.MoneroKeyImageListener; -import haveno.core.xmr.wallet.MoneroKeyImagePoller; +import haveno.core.xmr.wallet.XmrKeyImageListener; +import haveno.core.xmr.wallet.XmrKeyImagePoller; import haveno.network.p2p.BootstrapListener; import haveno.network.p2p.P2PService; import haveno.network.p2p.storage.HashMapChangedListener; @@ -63,10 +63,10 @@ public class OfferBookService { private final List offerBookChangedListeners = new LinkedList<>(); private final FilterManager filterManager; private final JsonFileManager jsonFileManager; - private final CoreMoneroConnectionsService connectionsService; + private final XmrConnectionService xmrConnectionService; // poll key images of offers - private MoneroKeyImagePoller keyImagePoller; + private XmrKeyImagePoller keyImagePoller; private static final long KEY_IMAGE_REFRESH_PERIOD_MS_LOCAL = 20000; // 20 seconds private static final long KEY_IMAGE_REFRESH_PERIOD_MS_REMOTE = 300000; // 5 minutes @@ -84,21 +84,21 @@ public class OfferBookService { public OfferBookService(P2PService p2PService, PriceFeedService priceFeedService, FilterManager filterManager, - CoreMoneroConnectionsService connectionsService, + XmrConnectionService xmrConnectionService, @Named(Config.STORAGE_DIR) File storageDir, @Named(Config.DUMP_STATISTICS) boolean dumpStatistics) { this.p2PService = p2PService; this.priceFeedService = priceFeedService; this.filterManager = filterManager; - this.connectionsService = connectionsService; + this.xmrConnectionService = xmrConnectionService; jsonFileManager = new JsonFileManager(storageDir); // listen for connection changes to monerod - connectionsService.addConnectionListener(new MoneroConnectionManagerListener() { + xmrConnectionService.addConnectionListener(new MoneroConnectionManagerListener() { @Override public void onConnectionChanged(MoneroRpcConnection connection) { maybeInitializeKeyImagePoller(); - keyImagePoller.setDaemon(connectionsService.getDaemon()); + keyImagePoller.setDaemon(xmrConnectionService.getDaemon()); keyImagePoller.setRefreshPeriodMs(getKeyImageRefreshPeriodMs()); } }); @@ -268,10 +268,10 @@ public class OfferBookService { private synchronized void maybeInitializeKeyImagePoller() { if (keyImagePoller != null) return; - keyImagePoller = new MoneroKeyImagePoller(connectionsService.getDaemon(), getKeyImageRefreshPeriodMs()); + keyImagePoller = new XmrKeyImagePoller(xmrConnectionService.getDaemon(), getKeyImageRefreshPeriodMs()); // handle when key images spent - keyImagePoller.addListener(new MoneroKeyImageListener() { + keyImagePoller.addListener(new XmrKeyImageListener() { @Override public void onSpentStatusChanged(Map spentStatuses) { for (String keyImage : spentStatuses.keySet()) { @@ -289,7 +289,7 @@ public class OfferBookService { } private long getKeyImageRefreshPeriodMs() { - return connectionsService.isConnectionLocal() ? KEY_IMAGE_REFRESH_PERIOD_MS_LOCAL : KEY_IMAGE_REFRESH_PERIOD_MS_REMOTE; + return xmrConnectionService.isConnectionLocal() ? KEY_IMAGE_REFRESH_PERIOD_MS_LOCAL : KEY_IMAGE_REFRESH_PERIOD_MS_REMOTE; } private void updateAffectedOffers(String keyImage) { diff --git a/core/src/main/java/haveno/core/offer/OpenOfferManager.java b/core/src/main/java/haveno/core/offer/OpenOfferManager.java index 705e87b43f..802132e83d 100644 --- a/core/src/main/java/haveno/core/offer/OpenOfferManager.java +++ b/core/src/main/java/haveno/core/offer/OpenOfferManager.java @@ -33,7 +33,7 @@ import haveno.common.proto.persistable.PersistedDataHost; import haveno.common.util.Tuple2; import haveno.core.account.witness.AccountAgeWitnessService; import haveno.core.api.CoreContext; -import haveno.core.api.CoreMoneroConnectionsService; +import haveno.core.api.XmrConnectionService; import haveno.core.exceptions.TradePriceOutOfToleranceException; import haveno.core.filter.FilterManager; import haveno.core.offer.OfferBookService.OfferBookChangedListener; @@ -58,8 +58,8 @@ import haveno.core.util.JsonUtil; import haveno.core.util.Validator; import haveno.core.xmr.model.XmrAddressEntry; import haveno.core.xmr.wallet.BtcWalletService; -import haveno.core.xmr.wallet.MoneroKeyImageListener; -import haveno.core.xmr.wallet.MoneroKeyImagePoller; +import haveno.core.xmr.wallet.XmrKeyImageListener; +import haveno.core.xmr.wallet.XmrKeyImagePoller; import haveno.core.xmr.wallet.TradeWalletService; import haveno.core.xmr.wallet.XmrWalletService; import haveno.network.p2p.AckMessage; @@ -121,7 +121,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe private final User user; private final P2PService p2PService; @Getter - private final CoreMoneroConnectionsService connectionsService; + private final XmrConnectionService xmrConnectionService; private final BtcWalletService btcWalletService; @Getter private final XmrWalletService xmrWalletService; @@ -150,7 +150,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe private final AccountAgeWitnessService accountAgeWitnessService; // poll key images of signed offers - private MoneroKeyImagePoller signedOfferKeyImagePoller; + private XmrKeyImagePoller signedOfferKeyImagePoller; private static final long KEY_IMAGE_REFRESH_PERIOD_MS_LOCAL = 20000; // 20 seconds private static final long KEY_IMAGE_REFRESH_PERIOD_MS_REMOTE = 300000; // 5 minutes @@ -166,7 +166,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe KeyRing keyRing, User user, P2PService p2PService, - CoreMoneroConnectionsService connectionsService, + XmrConnectionService xmrConnectionService, BtcWalletService btcWalletService, XmrWalletService xmrWalletService, TradeWalletService tradeWalletService, @@ -186,7 +186,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe this.keyRing = keyRing; this.user = user; this.p2PService = p2PService; - this.connectionsService = connectionsService; + this.xmrConnectionService = xmrConnectionService; this.btcWalletService = btcWalletService; this.xmrWalletService = xmrWalletService; this.tradeWalletService = tradeWalletService; @@ -207,7 +207,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe this.signedOfferPersistenceManager.initialize(signedOffers, "SignedOffers", PersistenceManager.Source.PRIVATE); // arbitrator stores reserve tx for signed offers // listen for connection changes to monerod - connectionsService.addConnectionListener(new MoneroConnectionManagerListener() { + xmrConnectionService.addConnectionListener(new MoneroConnectionManagerListener() { @Override public void onConnectionChanged(MoneroRpcConnection connection) { maybeInitializeKeyImagePoller(); @@ -250,10 +250,10 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe private synchronized void maybeInitializeKeyImagePoller() { if (signedOfferKeyImagePoller != null) return; - signedOfferKeyImagePoller = new MoneroKeyImagePoller(connectionsService.getDaemon(), getKeyImageRefreshPeriodMs()); + signedOfferKeyImagePoller = new XmrKeyImagePoller(xmrConnectionService.getDaemon(), getKeyImageRefreshPeriodMs()); // handle when key images confirmed spent - signedOfferKeyImagePoller.addListener(new MoneroKeyImageListener() { + signedOfferKeyImagePoller.addListener(new XmrKeyImageListener() { @Override public void onSpentStatusChanged(Map spentStatuses) { for (Entry entry : spentStatuses.entrySet()) { @@ -273,7 +273,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe } private long getKeyImageRefreshPeriodMs() { - return connectionsService.isConnectionLocal() ? KEY_IMAGE_REFRESH_PERIOD_MS_LOCAL : KEY_IMAGE_REFRESH_PERIOD_MS_REMOTE; + return xmrConnectionService.isConnectionLocal() ? KEY_IMAGE_REFRESH_PERIOD_MS_LOCAL : KEY_IMAGE_REFRESH_PERIOD_MS_REMOTE; } public void onAllServicesInitialized() { @@ -1284,7 +1284,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe } // Don't allow trade start if Monero node is not fully synced - if (!connectionsService.isSyncedWithinTolerance()) { + if (!xmrConnectionService.isSyncedWithinTolerance()) { errorMessage = "We got a handleOfferAvailabilityRequest but our chain is not synced."; log.info(errorMessage); sendAckMessage(request.getClass(), peer, request.getPubKeyRing(), request.getOfferId(), request.getUid(), false, errorMessage); diff --git a/core/src/main/java/haveno/core/support/SupportManager.java b/core/src/main/java/haveno/core/support/SupportManager.java index 3f05d10417..de4957a459 100644 --- a/core/src/main/java/haveno/core/support/SupportManager.java +++ b/core/src/main/java/haveno/core/support/SupportManager.java @@ -21,7 +21,7 @@ import haveno.common.Timer; import haveno.common.UserThread; import haveno.common.crypto.PubKeyRing; import haveno.common.proto.network.NetworkEnvelope; -import haveno.core.api.CoreMoneroConnectionsService; +import haveno.core.api.XmrConnectionService; import haveno.core.api.CoreNotificationService; import haveno.core.locale.Res; import haveno.core.support.dispute.Dispute; @@ -53,7 +53,7 @@ import java.util.concurrent.CopyOnWriteArraySet; public abstract class SupportManager { protected final P2PService p2PService; protected final TradeManager tradeManager; - protected final CoreMoneroConnectionsService connectionService; + protected final XmrConnectionService xmrConnectionService; protected final XmrWalletService xmrWalletService; protected final CoreNotificationService notificationService; protected final Map delayMsgMap = new HashMap<>(); @@ -69,12 +69,12 @@ public abstract class SupportManager { /////////////////////////////////////////////////////////////////////////////////////////// public SupportManager(P2PService p2PService, - CoreMoneroConnectionsService connectionService, + XmrConnectionService xmrConnectionService, XmrWalletService xmrWalletService, CoreNotificationService notificationService, TradeManager tradeManager) { this.p2PService = p2PService; - this.connectionService = connectionService; + this.xmrConnectionService = xmrConnectionService; this.xmrWalletService = xmrWalletService; this.mailboxMessageService = p2PService.getMailboxMessageService(); this.notificationService = notificationService; @@ -336,8 +336,8 @@ public abstract class SupportManager { private boolean isReady() { return allServicesInitialized && p2PService.isBootstrapped() && - connectionService.isDownloadComplete() && - connectionService.hasSufficientPeersForBroadcast() && + xmrConnectionService.isDownloadComplete() && + xmrConnectionService.hasSufficientPeersForBroadcast() && xmrWalletService.isWalletSynced(); } diff --git a/core/src/main/java/haveno/core/support/dispute/DisputeManager.java b/core/src/main/java/haveno/core/support/dispute/DisputeManager.java index dc461d1e7b..0a7e0bf80a 100644 --- a/core/src/main/java/haveno/core/support/dispute/DisputeManager.java +++ b/core/src/main/java/haveno/core/support/dispute/DisputeManager.java @@ -26,7 +26,7 @@ import haveno.common.handlers.FaultHandler; import haveno.common.handlers.ResultHandler; import haveno.common.util.MathUtils; import haveno.common.util.Tuple2; -import haveno.core.api.CoreMoneroConnectionsService; +import haveno.core.api.XmrConnectionService; import haveno.core.api.CoreNotificationService; import haveno.core.locale.CurrencyUtil; import haveno.core.locale.Res; @@ -105,7 +105,7 @@ public abstract class DisputeManager> extends Sup public DisputeManager(P2PService p2PService, TradeWalletService tradeWalletService, XmrWalletService xmrWalletService, - CoreMoneroConnectionsService connectionService, + XmrConnectionService xmrConnectionService, CoreNotificationService notificationService, TradeManager tradeManager, ClosedTradableManager closedTradableManager, @@ -114,7 +114,7 @@ public abstract class DisputeManager> extends Sup DisputeListService disputeListService, Config config, PriceFeedService priceFeedService) { - super(p2PService, connectionService, xmrWalletService, notificationService, tradeManager); + super(p2PService, xmrConnectionService, xmrWalletService, notificationService, tradeManager); this.tradeWalletService = tradeWalletService; this.xmrWalletService = xmrWalletService; @@ -252,8 +252,8 @@ public abstract class DisputeManager> extends Sup } }); - connectionService.downloadPercentageProperty().addListener((observable, oldValue, newValue) -> { - if (connectionService.isDownloadComplete()) + xmrConnectionService.downloadPercentageProperty().addListener((observable, oldValue, newValue) -> { + if (xmrConnectionService.isDownloadComplete()) tryApplyMessages(); }); @@ -262,8 +262,8 @@ public abstract class DisputeManager> extends Sup tryApplyMessages(); }); - connectionService.numPeersProperty().addListener((observable, oldValue, newValue) -> { - if (connectionService.hasSufficientPeersForBroadcast()) + xmrConnectionService.numPeersProperty().addListener((observable, oldValue, newValue) -> { + if (xmrConnectionService.hasSufficientPeersForBroadcast()) tryApplyMessages(); }); diff --git a/core/src/main/java/haveno/core/support/dispute/arbitration/ArbitrationManager.java b/core/src/main/java/haveno/core/support/dispute/arbitration/ArbitrationManager.java index 17ededd8aa..aadea08f3f 100644 --- a/core/src/main/java/haveno/core/support/dispute/arbitration/ArbitrationManager.java +++ b/core/src/main/java/haveno/core/support/dispute/arbitration/ArbitrationManager.java @@ -25,7 +25,7 @@ import haveno.common.UserThread; import haveno.common.app.Version; import haveno.common.config.Config; import haveno.common.crypto.KeyRing; -import haveno.core.api.CoreMoneroConnectionsService; +import haveno.core.api.XmrConnectionService; import haveno.core.api.CoreNotificationService; import haveno.core.locale.Res; import haveno.core.offer.OpenOfferManager; @@ -84,7 +84,7 @@ public final class ArbitrationManager extends DisputeManager public MediationManager(P2PService p2PService, TradeWalletService tradeWalletService, XmrWalletService walletService, - CoreMoneroConnectionsService connectionService, + XmrConnectionService xmrConnectionService, CoreNotificationService notificationService, TradeManager tradeManager, ClosedTradableManager closedTradableManager, @@ -80,7 +80,7 @@ public final class MediationManager extends DisputeManager MediationDisputeListService mediationDisputeListService, Config config, PriceFeedService priceFeedService) { - super(p2PService, tradeWalletService, walletService, connectionService, notificationService, tradeManager, closedTradableManager, + super(p2PService, tradeWalletService, walletService, xmrConnectionService, notificationService, tradeManager, closedTradableManager, openOfferManager, keyRing, mediationDisputeListService, config, priceFeedService); } diff --git a/core/src/main/java/haveno/core/support/dispute/refund/RefundManager.java b/core/src/main/java/haveno/core/support/dispute/refund/RefundManager.java index 15b50af1ba..20271806de 100644 --- a/core/src/main/java/haveno/core/support/dispute/refund/RefundManager.java +++ b/core/src/main/java/haveno/core/support/dispute/refund/RefundManager.java @@ -24,7 +24,7 @@ import haveno.common.UserThread; import haveno.common.app.Version; import haveno.common.config.Config; import haveno.common.crypto.KeyRing; -import haveno.core.api.CoreMoneroConnectionsService; +import haveno.core.api.XmrConnectionService; import haveno.core.api.CoreNotificationService; import haveno.core.locale.Res; import haveno.core.offer.OpenOffer; @@ -66,7 +66,7 @@ public final class RefundManager extends DisputeManager { public RefundManager(P2PService p2PService, TradeWalletService tradeWalletService, XmrWalletService walletService, - CoreMoneroConnectionsService connectionService, + XmrConnectionService xmrConnectionService, CoreNotificationService notificationService, TradeManager tradeManager, ClosedTradableManager closedTradableManager, @@ -76,7 +76,7 @@ public final class RefundManager extends DisputeManager { RefundDisputeListService refundDisputeListService, Config config, PriceFeedService priceFeedService) { - super(p2PService, tradeWalletService, walletService, connectionService, notificationService, tradeManager, closedTradableManager, + super(p2PService, tradeWalletService, walletService, xmrConnectionService, notificationService, tradeManager, closedTradableManager, openOfferManager, keyRing, refundDisputeListService, config, priceFeedService); } diff --git a/core/src/main/java/haveno/core/support/traderchat/TraderChatManager.java b/core/src/main/java/haveno/core/support/traderchat/TraderChatManager.java index e82d3c0cae..665b3a078b 100644 --- a/core/src/main/java/haveno/core/support/traderchat/TraderChatManager.java +++ b/core/src/main/java/haveno/core/support/traderchat/TraderChatManager.java @@ -19,7 +19,7 @@ package haveno.core.support.traderchat; import haveno.common.crypto.PubKeyRing; import haveno.common.crypto.PubKeyRingProvider; -import haveno.core.api.CoreMoneroConnectionsService; +import haveno.core.api.XmrConnectionService; import haveno.core.api.CoreNotificationService; import haveno.core.locale.Res; import haveno.core.support.SupportManager; @@ -53,12 +53,12 @@ public class TraderChatManager extends SupportManager { @Inject public TraderChatManager(P2PService p2PService, - CoreMoneroConnectionsService connectionService, + XmrConnectionService xmrConnectionService, XmrWalletService xmrWalletService, CoreNotificationService notificationService, TradeManager tradeManager, PubKeyRingProvider pubKeyRingProvider) { - super(p2PService, connectionService, xmrWalletService, notificationService, tradeManager); + super(p2PService, xmrConnectionService, xmrWalletService, notificationService, tradeManager); this.pubKeyRingProvider = pubKeyRingProvider; } diff --git a/core/src/main/java/haveno/core/trade/Trade.java b/core/src/main/java/haveno/core/trade/Trade.java index 7534ef39d9..c027ffc0ac 100644 --- a/core/src/main/java/haveno/core/trade/Trade.java +++ b/core/src/main/java/haveno/core/trade/Trade.java @@ -28,7 +28,7 @@ import haveno.common.crypto.PubKeyRing; import haveno.common.proto.ProtoUtil; import haveno.common.taskrunner.Model; import haveno.common.util.Utilities; -import haveno.core.api.CoreMoneroConnectionsService; +import haveno.core.api.XmrConnectionService; import haveno.core.monetary.Price; import haveno.core.monetary.Volume; import haveno.core.offer.Offer; @@ -758,9 +758,9 @@ public abstract class Trade implements Tradable, Model { } public void checkDaemonConnection() { - CoreMoneroConnectionsService connectionService = xmrWalletService.getConnectionsService(); - connectionService.checkConnection(); - connectionService.verifyConnection(); + XmrConnectionService xmrConnectionService = xmrWalletService.getConnectionsService(); + xmrConnectionService.checkConnection(); + xmrConnectionService.verifyConnection(); if (!getWallet().isConnectedToDaemon()) throw new RuntimeException("Trade wallet is not connected to a Monero node"); } diff --git a/core/src/main/java/haveno/core/user/Preferences.java b/core/src/main/java/haveno/core/user/Preferences.java index 4d08046a9b..7915146c78 100644 --- a/core/src/main/java/haveno/core/user/Preferences.java +++ b/core/src/main/java/haveno/core/user/Preferences.java @@ -31,7 +31,7 @@ import haveno.core.locale.GlobalSettings; import haveno.core.locale.TradeCurrency; import haveno.core.payment.PaymentAccount; import haveno.core.payment.PaymentAccountUtil; -import haveno.core.xmr.MoneroNodeSettings; +import haveno.core.xmr.XmrNodeSettings; import haveno.core.xmr.nodes.XmrNodes; import haveno.core.xmr.wallet.Restrictions; import haveno.network.p2p.network.BridgeAddressProvider; @@ -724,8 +724,8 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid requestPersistence(); } - public void setMoneroNodeSettings(MoneroNodeSettings settings) { - prefPayload.setMoneroNodeSettings(settings); + public void setXmrNodeSettings(XmrNodeSettings settings) { + prefPayload.setXmrNodeSettings(settings); requestPersistence(); } @@ -977,6 +977,6 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid void setNotifyOnPreRelease(boolean value); - void setMoneroNodeSettings(MoneroNodeSettings settings); + void setXmrNodeSettings(XmrNodeSettings settings); } } diff --git a/core/src/main/java/haveno/core/user/PreferencesPayload.java b/core/src/main/java/haveno/core/user/PreferencesPayload.java index d40cc1f49c..b8c89f45b3 100644 --- a/core/src/main/java/haveno/core/user/PreferencesPayload.java +++ b/core/src/main/java/haveno/core/user/PreferencesPayload.java @@ -28,7 +28,7 @@ import haveno.core.locale.TraditionalCurrency; import haveno.core.locale.TradeCurrency; import haveno.core.payment.PaymentAccount; import haveno.core.proto.CoreProtoResolver; -import haveno.core.xmr.MoneroNodeSettings; +import haveno.core.xmr.XmrNodeSettings; import lombok.AllArgsConstructor; import lombok.Data; import lombok.extern.slf4j.Slf4j; @@ -131,7 +131,7 @@ public final class PreferencesPayload implements PersistableEnvelope { private boolean denyApiTaker; private boolean notifyOnPreRelease; - private MoneroNodeSettings moneroNodeSettings = new MoneroNodeSettings(); + private XmrNodeSettings xmrNodeSettings = new XmrNodeSettings(); /////////////////////////////////////////////////////////////////////////////////////////// // Constructor @@ -217,7 +217,7 @@ public final class PreferencesPayload implements PersistableEnvelope { Optional.ofNullable(rpcUser).ifPresent(builder::setRpcUser); Optional.ofNullable(rpcPw).ifPresent(builder::setRpcPw); Optional.ofNullable(takeOfferSelectedPaymentAccountId).ifPresent(builder::setTakeOfferSelectedPaymentAccountId); - Optional.ofNullable(moneroNodeSettings).ifPresent(settings -> builder.setMoneroNodeSettings(settings.toProtoMessage())); + Optional.ofNullable(xmrNodeSettings).ifPresent(settings -> builder.setXmrNodeSettings(settings.toProtoMessage())); return protobuf.PersistableEnvelope.newBuilder().setPreferencesPayload(builder).build(); } @@ -298,7 +298,7 @@ public final class PreferencesPayload implements PersistableEnvelope { proto.getShowOffersMatchingMyAccounts(), proto.getDenyApiTaker(), proto.getNotifyOnPreRelease(), - MoneroNodeSettings.fromProto(proto.getMoneroNodeSettings()) + XmrNodeSettings.fromProto(proto.getXmrNodeSettings()) ); } } diff --git a/core/src/main/java/haveno/core/xmr/MoneroConnectionModule.java b/core/src/main/java/haveno/core/xmr/XmrConnectionModule.java similarity index 62% rename from core/src/main/java/haveno/core/xmr/MoneroConnectionModule.java rename to core/src/main/java/haveno/core/xmr/XmrConnectionModule.java index 9f6ef91ed0..3749463b3b 100644 --- a/core/src/main/java/haveno/core/xmr/MoneroConnectionModule.java +++ b/core/src/main/java/haveno/core/xmr/XmrConnectionModule.java @@ -3,20 +3,20 @@ package haveno.core.xmr; import com.google.inject.Singleton; import haveno.common.app.AppModule; import haveno.common.config.Config; -import haveno.core.api.CoreMoneroConnectionsService; +import haveno.core.api.XmrConnectionService; import haveno.core.xmr.model.EncryptedConnectionList; import lombok.extern.slf4j.Slf4j; @Slf4j -public class MoneroConnectionModule extends AppModule { +public class XmrConnectionModule extends AppModule { - public MoneroConnectionModule(Config config) { + public XmrConnectionModule(Config config) { super(config); } @Override protected final void configure() { bind(EncryptedConnectionList.class).in(Singleton.class); - bind(CoreMoneroConnectionsService.class).in(Singleton.class); + bind(XmrConnectionService.class).in(Singleton.class); } } diff --git a/core/src/main/java/haveno/core/xmr/MoneroModule.java b/core/src/main/java/haveno/core/xmr/XmrModule.java similarity index 98% rename from core/src/main/java/haveno/core/xmr/MoneroModule.java rename to core/src/main/java/haveno/core/xmr/XmrModule.java index ca535b3193..ecca89b802 100644 --- a/core/src/main/java/haveno/core/xmr/MoneroModule.java +++ b/core/src/main/java/haveno/core/xmr/XmrModule.java @@ -44,9 +44,9 @@ import static haveno.common.config.Config.PROVIDERS; import static haveno.common.config.Config.WALLET_DIR; import static haveno.common.config.Config.WALLET_RPC_BIND_PORT; -public class MoneroModule extends AppModule { +public class XmrModule extends AppModule { - public MoneroModule(Config config) { + public XmrModule(Config config) { super(config); } diff --git a/core/src/main/java/haveno/core/xmr/MoneroNodeSettings.java b/core/src/main/java/haveno/core/xmr/XmrNodeSettings.java similarity index 81% rename from core/src/main/java/haveno/core/xmr/MoneroNodeSettings.java rename to core/src/main/java/haveno/core/xmr/XmrNodeSettings.java index 43fe785632..8be7a575fd 100644 --- a/core/src/main/java/haveno/core/xmr/MoneroNodeSettings.java +++ b/core/src/main/java/haveno/core/xmr/XmrNodeSettings.java @@ -27,7 +27,7 @@ import javax.annotation.Nullable; @Slf4j @Data @AllArgsConstructor -public class MoneroNodeSettings implements PersistableEnvelope { +public class XmrNodeSettings implements PersistableEnvelope { @Nullable String blockchainPath; @@ -36,19 +36,19 @@ public class MoneroNodeSettings implements PersistableEnvelope { @Nullable List startupFlags; - public MoneroNodeSettings() { + public XmrNodeSettings() { } - public static MoneroNodeSettings fromProto(protobuf.MoneroNodeSettings proto) { - return new MoneroNodeSettings( + public static XmrNodeSettings fromProto(protobuf.XmrNodeSettings proto) { + return new XmrNodeSettings( proto.getBlockchainPath(), proto.getBootstrapUrl(), proto.getStartupFlagsList()); } @Override - public protobuf.MoneroNodeSettings toProtoMessage() { - protobuf.MoneroNodeSettings.Builder builder = protobuf.MoneroNodeSettings.newBuilder(); + public protobuf.XmrNodeSettings toProtoMessage() { + protobuf.XmrNodeSettings.Builder builder = protobuf.XmrNodeSettings.newBuilder(); Optional.ofNullable(blockchainPath).ifPresent(e -> builder.setBlockchainPath(blockchainPath)); Optional.ofNullable(bootstrapUrl).ifPresent(e -> builder.setBlockchainPath(bootstrapUrl)); Optional.ofNullable(startupFlags).ifPresent(e -> builder.addAllStartupFlags(startupFlags)); diff --git a/core/src/main/java/haveno/core/xmr/setup/WalletConfig.java b/core/src/main/java/haveno/core/xmr/setup/WalletConfig.java index 903c02558a..553d2ac3f2 100644 --- a/core/src/main/java/haveno/core/xmr/setup/WalletConfig.java +++ b/core/src/main/java/haveno/core/xmr/setup/WalletConfig.java @@ -22,7 +22,7 @@ import com.google.common.util.concurrent.AbstractIdleService; import com.runjva.sourceforge.jsocks.protocol.Socks5Proxy; import haveno.common.config.Config; import haveno.common.file.FileUtil; -import haveno.core.api.LocalMoneroNode; +import haveno.core.api.XmrLocalNode; import javafx.beans.property.BooleanProperty; import javafx.beans.property.SimpleBooleanProperty; import lombok.Getter; @@ -101,7 +101,7 @@ public class WalletConfig extends AbstractIdleService { protected volatile Context context; protected Config config; - protected LocalMoneroNode localMoneroNode; + protected XmrLocalNode xmrLocalNode; protected Socks5Proxy socks5Proxy; protected int numConnectionsForBtc; @Getter @@ -141,9 +141,9 @@ public class WalletConfig extends AbstractIdleService { return this; } - public WalletConfig setLocalMoneroNodeService(LocalMoneroNode localMoneroNode) { + public WalletConfig setXmrLocalNode(XmrLocalNode xmrLocalNode) { checkState(state() == State.NEW, "Cannot call after startup"); - this.localMoneroNode = localMoneroNode; + this.xmrLocalNode = xmrLocalNode; return this; } diff --git a/core/src/main/java/haveno/core/xmr/setup/WalletsSetup.java b/core/src/main/java/haveno/core/xmr/setup/WalletsSetup.java index e7e8b37d4a..de134a11f7 100644 --- a/core/src/main/java/haveno/core/xmr/setup/WalletsSetup.java +++ b/core/src/main/java/haveno/core/xmr/setup/WalletsSetup.java @@ -29,7 +29,7 @@ import haveno.common.config.Config; import haveno.common.file.FileUtil; import haveno.common.handlers.ExceptionHandler; import haveno.common.handlers.ResultHandler; -import haveno.core.api.LocalMoneroNode; +import haveno.core.api.XmrLocalNode; import haveno.core.user.Preferences; import haveno.core.xmr.exceptions.InvalidHostException; import haveno.core.xmr.model.AddressEntry; @@ -94,7 +94,7 @@ public class WalletsSetup { private final Preferences preferences; private final Socks5ProxyProvider socks5ProxyProvider; private final Config config; - private final LocalMoneroNode localMoneroNode; + private final XmrLocalNode xmrLocalNode; private final XmrNodes xmrNodes; private final int numConnectionsForBtc; private final String userAgent; @@ -117,7 +117,7 @@ public class WalletsSetup { Preferences preferences, Socks5ProxyProvider socks5ProxyProvider, Config config, - LocalMoneroNode localMoneroNode, + XmrLocalNode xmrLocalNode, XmrNodes xmrNodes, @Named(Config.USER_AGENT) String userAgent, @Named(Config.WALLET_DIR) File walletDir, @@ -129,7 +129,7 @@ public class WalletsSetup { this.preferences = preferences; this.socks5ProxyProvider = socks5ProxyProvider; this.config = config; - this.localMoneroNode = localMoneroNode; + this.xmrLocalNode = xmrLocalNode; this.xmrNodes = xmrNodes; this.numConnectionsForBtc = numConnectionsForBtc; this.useAllProvidedNodes = useAllProvidedNodes; @@ -186,7 +186,7 @@ public class WalletsSetup { }; walletConfig.setSocks5Proxy(socks5Proxy); walletConfig.setConfig(config); - walletConfig.setLocalMoneroNodeService(localMoneroNode); // TODO: adapt to xmr or remove + walletConfig.setXmrLocalNode(xmrLocalNode); // TODO: adapt to xmr or remove walletConfig.setUserAgent(userAgent, Version.VERSION); walletConfig.setNumConnectionsForBtc(numConnectionsForBtc); @@ -221,7 +221,7 @@ public class WalletsSetup { return; } } - } else if (localMoneroNode.shouldBeUsed()) { + } else if (xmrLocalNode.shouldBeUsed()) { walletConfig.setMinBroadcastConnections(1); walletConfig.connectToLocalHost(); } else { diff --git a/core/src/main/java/haveno/core/xmr/wallet/MoneroKeyImageListener.java b/core/src/main/java/haveno/core/xmr/wallet/XmrKeyImageListener.java similarity index 87% rename from core/src/main/java/haveno/core/xmr/wallet/MoneroKeyImageListener.java rename to core/src/main/java/haveno/core/xmr/wallet/XmrKeyImageListener.java index 80dbca5522..f4176f16f3 100644 --- a/core/src/main/java/haveno/core/xmr/wallet/MoneroKeyImageListener.java +++ b/core/src/main/java/haveno/core/xmr/wallet/XmrKeyImageListener.java @@ -4,7 +4,7 @@ import monero.daemon.model.MoneroKeyImageSpentStatus; import java.util.Map; -public interface MoneroKeyImageListener { +public interface XmrKeyImageListener { /** * Called with changes to the spent status of key images. diff --git a/core/src/main/java/haveno/core/xmr/wallet/MoneroKeyImagePoller.java b/core/src/main/java/haveno/core/xmr/wallet/XmrKeyImagePoller.java similarity index 94% rename from core/src/main/java/haveno/core/xmr/wallet/MoneroKeyImagePoller.java rename to core/src/main/java/haveno/core/xmr/wallet/XmrKeyImagePoller.java index 71f90bf8a9..158f4fe116 100644 --- a/core/src/main/java/haveno/core/xmr/wallet/MoneroKeyImagePoller.java +++ b/core/src/main/java/haveno/core/xmr/wallet/XmrKeyImagePoller.java @@ -21,12 +21,12 @@ import java.util.Set; * TODO: move to monero-java? */ @Slf4j -public class MoneroKeyImagePoller { +public class XmrKeyImagePoller { private MoneroDaemon daemon; private long refreshPeriodMs; private List keyImages = new ArrayList(); - private Set listeners = new HashSet(); + private Set listeners = new HashSet(); private TaskLooper looper; private Map lastStatuses = new HashMap(); private boolean isPolling = false; @@ -37,7 +37,7 @@ public class MoneroKeyImagePoller { * @param refreshPeriodMs - refresh period in milliseconds * @param keyImages - key images to listen to */ - public MoneroKeyImagePoller() { + public XmrKeyImagePoller() { looper = new TaskLooper(() -> poll()); } @@ -47,7 +47,7 @@ public class MoneroKeyImagePoller { * @param refreshPeriodMs - refresh period in milliseconds * @param keyImages - key images to listen to */ - public MoneroKeyImagePoller(MoneroDaemon daemon, long refreshPeriodMs, String... keyImages) { + public XmrKeyImagePoller(MoneroDaemon daemon, long refreshPeriodMs, String... keyImages) { looper = new TaskLooper(() -> poll()); setDaemon(daemon); setRefreshPeriodMs(refreshPeriodMs); @@ -59,7 +59,7 @@ public class MoneroKeyImagePoller { * * @param listener - the listener to add */ - public void addListener(MoneroKeyImageListener listener) { + public void addListener(XmrKeyImageListener listener) { listeners.add(listener); refreshPolling(); } @@ -69,7 +69,7 @@ public class MoneroKeyImagePoller { * * @param listener - the listener to remove */ - public void removeListener(MoneroKeyImageListener listener) { + public void removeListener(XmrKeyImageListener listener) { if (!listeners.contains(listener)) throw new MoneroError("Listener is not registered"); listeners.remove(listener); refreshPolling(); @@ -265,7 +265,7 @@ public class MoneroKeyImagePoller { // announce changes if (!changedStatuses.isEmpty()) { - for (MoneroKeyImageListener listener : new ArrayList(listeners)) { + for (XmrKeyImageListener listener : new ArrayList(listeners)) { listener.onSpentStatusChanged(changedStatuses); } } diff --git a/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java b/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java index 9e35d575dc..3df7f2aade 100644 --- a/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java +++ b/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java @@ -11,7 +11,7 @@ import haveno.common.util.Tuple2; import haveno.common.util.Utilities; import haveno.core.api.AccountServiceListener; import haveno.core.api.CoreAccountService; -import haveno.core.api.CoreMoneroConnectionsService; +import haveno.core.api.XmrConnectionService; import haveno.core.trade.BuyerTrade; import haveno.core.trade.HavenoUtils; import haveno.core.trade.MakerTrade; @@ -106,7 +106,7 @@ public class XmrWalletService { private final Preferences preferences; private final CoreAccountService accountService; - private final CoreMoneroConnectionsService connectionsService; + private final XmrConnectionService xmrConnectionService; private final XmrAddressEntryList xmrAddressEntryList; private final WalletsSetup walletsSetup; private final DownloadListener downloadListener = new DownloadListener(); @@ -129,14 +129,14 @@ public class XmrWalletService { @Inject XmrWalletService(Preferences preferences, CoreAccountService accountService, - CoreMoneroConnectionsService connectionsService, + XmrConnectionService xmrConnectionService, WalletsSetup walletsSetup, XmrAddressEntryList xmrAddressEntryList, @Named(Config.WALLET_DIR) File walletDir, @Named(Config.WALLET_RPC_BIND_PORT) int rpcBindPort) { this.preferences = preferences; this.accountService = accountService; - this.connectionsService = connectionsService; + this.xmrConnectionService = xmrConnectionService; this.walletsSetup = walletsSetup; this.xmrAddressEntryList = xmrAddressEntryList; this.walletDir = walletDir; @@ -232,11 +232,11 @@ public class XmrWalletService { } public MoneroDaemonRpc getDaemon() { - return connectionsService.getDaemon(); + return xmrConnectionService.getDaemon(); } - public CoreMoneroConnectionsService getConnectionsService() { - return connectionsService; + public XmrConnectionService getConnectionsService() { + return xmrConnectionService; } public boolean isProxyApplied(boolean wasWalletSynced) { @@ -601,7 +601,7 @@ public class XmrWalletService { synchronized (txCache) { // fetch txs - if (getDaemon() == null) connectionsService.verifyConnection(); // will throw + if (getDaemon() == null) xmrConnectionService.verifyConnection(); // will throw List txs = getDaemon().getTxs(txHashes, true); // store to cache @@ -612,7 +612,7 @@ public class XmrWalletService { synchronized (txCache) { for (MoneroTx tx : txs) txCache.remove(tx.getHash()); } - }, connectionsService.getRefreshPeriodMs() / 1000); + }, xmrConnectionService.getRefreshPeriodMs() / 1000); return txs; } } @@ -675,13 +675,13 @@ public class XmrWalletService { private void initialize() { // listen for connection changes - connectionsService.addConnectionListener(newConnection -> onConnectionChanged(newConnection)); + xmrConnectionService.addConnectionListener(newConnection -> onConnectionChanged(newConnection)); // wait for monerod to sync - if (connectionsService.downloadPercentageProperty().get() != 1) { + if (xmrConnectionService.downloadPercentageProperty().get() != 1) { CountDownLatch latch = new CountDownLatch(1); - connectionsService.downloadPercentageProperty().addListener((obs, oldVal, newVal) -> { - if (connectionsService.downloadPercentageProperty().get() == 1) latch.countDown(); + xmrConnectionService.downloadPercentageProperty().addListener((obs, oldVal, newVal) -> { + if (xmrConnectionService.downloadPercentageProperty().get() == 1) latch.countDown(); }); HavenoUtils.awaitLatch(latch); } @@ -699,12 +699,12 @@ public class XmrWalletService { // open or create wallet main wallet if (wallet == null) { - MoneroDaemonRpc daemon = connectionsService.getDaemon(); + MoneroDaemonRpc daemon = xmrConnectionService.getDaemon(); log.info("Initializing main wallet with monerod=" + (daemon == null ? "null" : daemon.getRpcConnection().getUri())); MoneroWalletConfig walletConfig = new MoneroWalletConfig().setPath(MONERO_WALLET_NAME).setPassword(getWalletPassword()); if (MoneroUtils.walletExists(xmrWalletFile.getPath())) { wallet = openWalletRpc(walletConfig, rpcBindPort, isProxyApplied(wasWalletSynced)); - } else if (connectionsService.getConnection() != null && Boolean.TRUE.equals(connectionsService.getConnection().isConnected())) { + } else if (xmrConnectionService.getConnection() != null && Boolean.TRUE.equals(xmrConnectionService.getConnection().isConnected())) { wallet = createWalletRpc(walletConfig, rpcBindPort); } } @@ -723,12 +723,12 @@ public class XmrWalletService { wallet.sync(); // blocking wasWalletSynced = true; log.info("Done syncing main wallet in " + (System.currentTimeMillis() - time) + " ms"); - wallet.startSyncing(connectionsService.getRefreshPeriodMs()); + wallet.startSyncing(xmrConnectionService.getRefreshPeriodMs()); wallet.getTxs(new MoneroTxQuery().setIsLocked(true)); // TODO: main wallet's balance does update on startup with 0 conf PaymentReceivedMessage until pool txs fetched? if (getMoneroNetworkType() != MoneroNetworkType.MAINNET) log.info("Monero wallet balance={}, unlocked balance={}", wallet.getBalance(0), wallet.getUnlockedBalance(0)); // reapply connection after wallet synced - onConnectionChanged(connectionsService.getConnection()); + onConnectionChanged(xmrConnectionService.getConnection()); // signal that main wallet is synced doneDownload(); @@ -750,12 +750,12 @@ public class XmrWalletService { // reschedule to init main wallet UserThread.runAfter(() -> { new Thread(() -> maybeInitMainWallet(true, MAX_SYNC_ATTEMPTS)).start(); - }, connectionsService.getRefreshPeriodMs() / 1000); + }, xmrConnectionService.getRefreshPeriodMs() / 1000); } else { - log.warn("Trying again in {} seconds", connectionsService.getRefreshPeriodMs() / 1000); + log.warn("Trying again in {} seconds", xmrConnectionService.getRefreshPeriodMs() / 1000); UserThread.runAfter(() -> { new Thread(() -> maybeInitMainWallet(true, numAttempts - 1)).start(); - }, connectionsService.getRefreshPeriodMs() / 1000); + }, xmrConnectionService.getRefreshPeriodMs() / 1000); } } } @@ -769,7 +769,7 @@ public class XmrWalletService { private MoneroWalletRpc createWalletRpc(MoneroWalletConfig config, Integer port) { // must be connected to daemon - MoneroRpcConnection connection = connectionsService.getConnection(); + MoneroRpcConnection connection = xmrConnectionService.getConnection(); if (connection == null || !Boolean.TRUE.equals(connection.isConnected())) throw new RuntimeException("Must be connected to daemon before creating wallet"); // create wallet @@ -809,7 +809,7 @@ public class XmrWalletService { walletRpc.stopSyncing(); // configure connection - MoneroRpcConnection connection = new MoneroRpcConnection(connectionsService.getConnection()); + MoneroRpcConnection connection = new MoneroRpcConnection(xmrConnectionService.getConnection()); if (!applyProxyUri) connection.setProxyUri(null); // open wallet @@ -842,7 +842,7 @@ public class XmrWalletService { cmd.add("--" + MONERO_NETWORK_TYPE.toString().toLowerCase()); } - MoneroRpcConnection connection = connectionsService.getConnection(); + MoneroRpcConnection connection = xmrConnectionService.getConnection(); if (connection != null) { cmd.add("--daemon-address"); cmd.add(connection.getUri()); @@ -887,7 +887,7 @@ public class XmrWalletService { new Thread(() -> { try { if (!Boolean.FALSE.equals(connection.isConnected())) wallet.sync(); - wallet.startSyncing(connectionsService.getRefreshPeriodMs()); + wallet.startSyncing(xmrConnectionService.getRefreshPeriodMs()); } catch (Exception e) { log.warn("Failed to sync main wallet after setting daemon connection: " + e.getMessage()); } diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 31e556cc25..85fcdbe7ee 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -2178,7 +2178,7 @@ popup.warn.daoRequiresRestart=There was a problem with synchronizing the DAO sta popup.privateNotification.headline=Important private notification! -popup.moneroLocalhostNode.msg=Haveno detected a Monero node running on this machine (at localhost).\n\n\Please ensure the node is fully synced before starting Haveno. +popup.xmrLocalNode.msg=Haveno detected a Monero node running on this machine (at localhost).\n\n\Please ensure the node is fully synced before starting Haveno. popup.shutDownInProgress.headline=Shut down in progress popup.shutDownInProgress.msg=Shutting down application can take a few seconds.\nPlease don't interrupt this process. diff --git a/core/src/main/resources/i18n/displayStrings_cs.properties b/core/src/main/resources/i18n/displayStrings_cs.properties index 5f07af0199..a46b792e20 100644 --- a/core/src/main/resources/i18n/displayStrings_cs.properties +++ b/core/src/main/resources/i18n/displayStrings_cs.properties @@ -1624,7 +1624,7 @@ popup.privateNotification.headline=Důležité soukromé oznámení! popup.securityRecommendation.headline=Důležité bezpečnostní doporučení popup.securityRecommendation.msg=Chtěli bychom vám připomenout, abyste zvážili použití ochrany heslem pro vaši peněženku, pokud jste ji již neaktivovali.\n\nDůrazně se také doporučuje zapsat seed slova peněženky. Tato seed slova jsou jako hlavní heslo pro obnovení vaší moneroové peněženky.\nV sekci "Seed peněženky" naleznete další informace.\n\nDále byste měli zálohovat úplnou složku dat aplikace v sekci \"Záloha\". -popup.moneroLocalhostNode.msg=Haveno zjistil, že na tomto stroji (na localhostu) běží Monero node.\n\nUjistěte se, prosím, že tento node je plně synchronizován před spuštěním Havena. +popup.xmrLocalNode.msg=Haveno zjistil, že na tomto stroji (na localhostu) běží Monero node.\n\nUjistěte se, prosím, že tento node je plně synchronizován před spuštěním Havena. popup.shutDownInProgress.headline=Probíhá vypínání popup.shutDownInProgress.msg=Vypnutí aplikace může trvat několik sekund.\nProsím, nepřerušujte tento proces. diff --git a/core/src/main/resources/i18n/displayStrings_de.properties b/core/src/main/resources/i18n/displayStrings_de.properties index c9beb2efdd..a8f3795991 100644 --- a/core/src/main/resources/i18n/displayStrings_de.properties +++ b/core/src/main/resources/i18n/displayStrings_de.properties @@ -1624,7 +1624,7 @@ popup.privateNotification.headline=Wichtige private Benachrichtigung! popup.securityRecommendation.headline=Wichtige Sicherheitsempfehlung popup.securityRecommendation.msg=Wir würden Sie gerne daran erinnern, sich zu überlegen, den Passwortschutz Ihrer Wallet zu verwenden, falls Sie diesen noch nicht aktiviert haben.\n\nEs wird außerdem dringend empfohlen, dass Sie die Wallet-Seed-Wörter aufschreiben. Diese Seed-Wörter sind wie ein Master-Passwort zum Wiederherstellen ihrer Monero-Wallet.\nIm \"Wallet-Seed\"-Abschnitt finden Sie weitere Informationen.\n\nZusätzlich sollten Sie ein Backup des ganzen Anwendungsdatenordners im \"Backup\"-Abschnitt erstellen. -popup.moneroLocalhostNode.msg=Haveno hat einen Monero-Knoten entdeckt, der auf diesem Rechner (auf localhost) läuft.\n\nBitte stellen Sie sicher, dass der Knoten vollständig synchronisiert ist, bevor Sie Haveno starten. +popup.xmrLocalNode.msg=Haveno hat einen Monero-Knoten entdeckt, der auf diesem Rechner (auf localhost) läuft.\n\nBitte stellen Sie sicher, dass der Knoten vollständig synchronisiert ist, bevor Sie Haveno starten. popup.shutDownInProgress.headline=Anwendung wird heruntergefahren popup.shutDownInProgress.msg=Das Herunterfahren der Anwendung kann einige Sekunden dauern.\nBitte unterbrechen Sie diesen Vorgang nicht. diff --git a/core/src/main/resources/i18n/displayStrings_es.properties b/core/src/main/resources/i18n/displayStrings_es.properties index 905ef1c77b..6d001ead29 100644 --- a/core/src/main/resources/i18n/displayStrings_es.properties +++ b/core/src/main/resources/i18n/displayStrings_es.properties @@ -1624,7 +1624,7 @@ popup.privateNotification.headline=Notificación privada importante! popup.securityRecommendation.headline=Recomendación de seguridad importante popup.securityRecommendation.msg=Nos gustaría recordarle que considere usar protección por contraseña para su cartera, si no la ha activado ya.\n\nTambién es muy recomendable que escriba en un papel las palabras semilla del monedero. Esas palabras semilla son como una contraseña maestra para recuperar su cartera Monero.\nEn la sección \"Semilla de cartera\" encontrará más información.\n\nAdicionalmente, debería hacer una copia de seguridad completa del directorio de aplicación en la sección \"Copia de seguridad\" -popup.moneroLocalhostNode.msg=Haveno ha detectado un nodo de Monero ejecutándose en esta máquina (en el localhost).\n\nPor favor, asegúrese de que el nodo esté completamente sincronizado antes de iniciar Haveno. +popup.xmrLocalNode.msg=Haveno ha detectado un nodo de Monero ejecutándose en esta máquina (en el localhost).\n\nPor favor, asegúrese de que el nodo esté completamente sincronizado antes de iniciar Haveno. popup.shutDownInProgress.headline=Cerrando aplicación... popup.shutDownInProgress.msg=Cerrar la aplicación puede llevar unos segundos.\nPor favor no interrumpa el proceso. diff --git a/core/src/main/resources/i18n/displayStrings_fr.properties b/core/src/main/resources/i18n/displayStrings_fr.properties index bd0b787cd0..13ee0a96b2 100644 --- a/core/src/main/resources/i18n/displayStrings_fr.properties +++ b/core/src/main/resources/i18n/displayStrings_fr.properties @@ -1625,7 +1625,7 @@ popup.privateNotification.headline=Notification privée importante! popup.securityRecommendation.headline=Recommendation de sécurité importante popup.securityRecommendation.msg=Nous vous rappelons d'envisager d'utiliser la protection par mot de passe pour votre portefeuille si vous ne l'avez pas déjà activé.\n\nIl est également fortement recommandé d'écrire les mots de la seed de portefeuille. Ces mots de la seed sont comme un mot de passe principal pour récupérer votre portefeuille Monero.\nVous trouverez plus d'informations à ce sujet dans l'onglet \"seed du portefeuille\".\n\nDe plus, il est recommandé de sauvegarder le dossier complet des données de l'application dans l'onglet \"Sauvegarde". -popup.moneroLocalhostNode.msg=Haveno a détecté un nœud Monero en cours d'exécution sur cette machine (sur l'hôte local).\n\nVeuillez vous assurer que le nœud est complètement synchronisé avant de démarrer Haveno. +popup.xmrLocalNode.msg=Haveno a détecté un nœud Monero en cours d'exécution sur cette machine (sur l'hôte local).\n\nVeuillez vous assurer que le nœud est complètement synchronisé avant de démarrer Haveno. popup.shutDownInProgress.headline=Fermeture en cours popup.shutDownInProgress.msg=La fermeture de l'application nécessite quelques secondes.\nVeuillez ne pas interrompre ce processus. diff --git a/core/src/main/resources/i18n/displayStrings_ja.properties b/core/src/main/resources/i18n/displayStrings_ja.properties index 36e3f9f6a4..e8c7ef940f 100644 --- a/core/src/main/resources/i18n/displayStrings_ja.properties +++ b/core/src/main/resources/i18n/displayStrings_ja.properties @@ -1624,7 +1624,7 @@ popup.privateNotification.headline=重要なプライベート通知! popup.securityRecommendation.headline=重要なセキュリティ勧告 popup.securityRecommendation.msg=ウォレットのパスワード保護をまだ有効にしてない場合は、使用することを検討してください。\n\nウォレットシードワードを書き留めることも強くお勧めします。 これらのシードワードは、あなたのビットコインウォレットを復元するためのマスターパスワードのようなものです。\n「ウォレットシード」セクションにてより詳細な情報を確認できます。\n\nまた、「バックアップ」セクションのアプリケーションデータフォルダ全体をバックアップするべきでしょう。 -popup.moneroLocalhostNode.msg=Haveno检测到本机(localhost上)运行了一个门罗币节点。\n\n在启动Haveno之前,请确保节点已完全同步。 +popup.xmrLocalNode.msg=Haveno检测到本机(localhost上)运行了一个门罗币节点。\n\n在启动Haveno之前,请确保节点已完全同步。 popup.shutDownInProgress.headline=シャットダウン中 popup.shutDownInProgress.msg=アプリケーションのシャットダウンには数秒かかることがあります。\nこのプロセスを中断しないでください。 diff --git a/core/src/main/resources/i18n/displayStrings_zh-hans.properties b/core/src/main/resources/i18n/displayStrings_zh-hans.properties index 660c35eca2..f71e02d1d9 100644 --- a/core/src/main/resources/i18n/displayStrings_zh-hans.properties +++ b/core/src/main/resources/i18n/displayStrings_zh-hans.properties @@ -1628,7 +1628,7 @@ popup.privateNotification.headline=重要私人通知! popup.securityRecommendation.headline=重要安全建议 popup.securityRecommendation.msg=如果您还没有启用,我们想提醒您考虑为您的钱包使用密码保护。\n\n强烈建议你写下钱包还原密钥。 那些还原密钥就是恢复你的比特币钱包的主密码。\n在“钱包密钥”部分,您可以找到更多信息\n\n此外,您应该在“备份”界面备份完整的应用程序数据文件夹。 -popup.moneroLocalhostNode.msg=Haveno 侦测到本机(本地)运行着一个门罗币节点(位于 localhost)。\n\n请确保在启动 Haveno 之前,节点已完全同步。 +popup.xmrLocalNode.msg=Haveno 侦测到本机(本地)运行着一个门罗币节点(位于 localhost)。\n\n请确保在启动 Haveno 之前,节点已完全同步。 popup.shutDownInProgress.headline=正在关闭 popup.shutDownInProgress.msg=关闭应用可能会花一点时间。\n请不要打断关闭过程。 diff --git a/core/src/test/java/haveno/core/offer/OpenOfferManagerTest.java b/core/src/test/java/haveno/core/offer/OpenOfferManagerTest.java index ed4b85312f..0fcde044a3 100644 --- a/core/src/test/java/haveno/core/offer/OpenOfferManagerTest.java +++ b/core/src/test/java/haveno/core/offer/OpenOfferManagerTest.java @@ -7,7 +7,7 @@ import haveno.common.handlers.ErrorMessageHandler; import haveno.common.handlers.ResultHandler; import haveno.common.persistence.PersistenceManager; import haveno.core.api.CoreContext; -import haveno.core.api.CoreMoneroConnectionsService; +import haveno.core.api.XmrConnectionService; import haveno.core.trade.TradableList; import haveno.network.p2p.P2PService; import haveno.network.p2p.peers.PeerManager; @@ -53,7 +53,7 @@ public class OpenOfferManagerTest { public void testStartEditOfferForActiveOffer() { P2PService p2PService = mock(P2PService.class); OfferBookService offerBookService = mock(OfferBookService.class); - CoreMoneroConnectionsService connectionsService = mock(CoreMoneroConnectionsService.class); + XmrConnectionService xmrConnectionService = mock(XmrConnectionService.class); when(p2PService.getPeerManager()).thenReturn(mock(PeerManager.class)); @@ -61,7 +61,7 @@ public class OpenOfferManagerTest { null, null, p2PService, - connectionsService, + xmrConnectionService, null, null, null, @@ -102,14 +102,14 @@ public class OpenOfferManagerTest { public void testStartEditOfferForDeactivatedOffer() { P2PService p2PService = mock(P2PService.class); OfferBookService offerBookService = mock(OfferBookService.class); - CoreMoneroConnectionsService connectionsService = mock(CoreMoneroConnectionsService.class); + XmrConnectionService xmrConnectionService = mock(XmrConnectionService.class); when(p2PService.getPeerManager()).thenReturn(mock(PeerManager.class)); final OpenOfferManager manager = new OpenOfferManager(coreContext, null, null, p2PService, - connectionsService, + xmrConnectionService, null, null, null, @@ -142,7 +142,7 @@ public class OpenOfferManagerTest { public void testStartEditOfferForOfferThatIsCurrentlyEdited() { P2PService p2PService = mock(P2PService.class); OfferBookService offerBookService = mock(OfferBookService.class); - CoreMoneroConnectionsService connectionsService = mock(CoreMoneroConnectionsService.class); + XmrConnectionService xmrConnectionService = mock(XmrConnectionService.class); when(p2PService.getPeerManager()).thenReturn(mock(PeerManager.class)); @@ -151,7 +151,7 @@ public class OpenOfferManagerTest { null, null, p2PService, - connectionsService, + xmrConnectionService, null, null, null, diff --git a/core/src/test/java/haveno/core/user/PreferencesTest.java b/core/src/test/java/haveno/core/user/PreferencesTest.java index e84ca10023..4af2b7ec20 100644 --- a/core/src/test/java/haveno/core/user/PreferencesTest.java +++ b/core/src/test/java/haveno/core/user/PreferencesTest.java @@ -19,7 +19,7 @@ package haveno.core.user; import haveno.common.config.Config; import haveno.common.persistence.PersistenceManager; -import haveno.core.api.LocalMoneroNode; +import haveno.core.api.XmrLocalNode; import haveno.core.locale.CountryUtil; import haveno.core.locale.CryptoCurrency; import haveno.core.locale.CurrencyUtil; @@ -56,7 +56,7 @@ public class PreferencesTest { persistenceManager = mock(PersistenceManager.class); Config config = new Config(); - LocalMoneroNode localMoneroNode = new LocalMoneroNode(config, preferences); + XmrLocalNode xmrLocalNode = new XmrLocalNode(config, preferences); preferences = new Preferences( persistenceManager, config, null); } diff --git a/daemon/src/main/java/haveno/daemon/grpc/GrpcServer.java b/daemon/src/main/java/haveno/daemon/grpc/GrpcServer.java index c1fbd039db..9cfa3d2578 100644 --- a/daemon/src/main/java/haveno/daemon/grpc/GrpcServer.java +++ b/daemon/src/main/java/haveno/daemon/grpc/GrpcServer.java @@ -54,8 +54,8 @@ public class GrpcServer { GrpcTradesService tradesService, GrpcWalletsService walletsService, GrpcNotificationsService notificationsService, - GrpcMoneroConnectionsService moneroConnectionsService, - GrpcMoneroNodeService moneroNodeService) { + GrpcXmrConnectionService moneroConnectionsService, + GrpcXmrNodeService moneroNodeService) { this.server = ServerBuilder.forPort(config.apiPort) .addService(interceptForward(accountService, accountService.interceptors())) .addService(interceptForward(disputeAgentsService, disputeAgentsService.interceptors())) diff --git a/daemon/src/main/java/haveno/daemon/grpc/GrpcMoneroConnectionsService.java b/daemon/src/main/java/haveno/daemon/grpc/GrpcXmrConnectionService.java similarity index 90% rename from daemon/src/main/java/haveno/daemon/grpc/GrpcMoneroConnectionsService.java rename to daemon/src/main/java/haveno/daemon/grpc/GrpcXmrConnectionService.java index 4e85d318aa..c5be2146ad 100644 --- a/daemon/src/main/java/haveno/daemon/grpc/GrpcMoneroConnectionsService.java +++ b/daemon/src/main/java/haveno/daemon/grpc/GrpcXmrConnectionService.java @@ -57,28 +57,28 @@ import java.util.Optional; import java.util.stream.Collectors; import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; -import static haveno.proto.grpc.MoneroConnectionsGrpc.MoneroConnectionsImplBase; -import static haveno.proto.grpc.MoneroConnectionsGrpc.getAddConnectionMethod; -import static haveno.proto.grpc.MoneroConnectionsGrpc.getCheckConnectionMethod; -import static haveno.proto.grpc.MoneroConnectionsGrpc.getCheckConnectionsMethod; -import static haveno.proto.grpc.MoneroConnectionsGrpc.getGetBestAvailableConnectionMethod; -import static haveno.proto.grpc.MoneroConnectionsGrpc.getGetConnectionMethod; -import static haveno.proto.grpc.MoneroConnectionsGrpc.getGetConnectionsMethod; -import static haveno.proto.grpc.MoneroConnectionsGrpc.getRemoveConnectionMethod; -import static haveno.proto.grpc.MoneroConnectionsGrpc.getSetAutoSwitchMethod; -import static haveno.proto.grpc.MoneroConnectionsGrpc.getSetConnectionMethod; -import static haveno.proto.grpc.MoneroConnectionsGrpc.getStartCheckingConnectionsMethod; -import static haveno.proto.grpc.MoneroConnectionsGrpc.getStopCheckingConnectionsMethod; +import static haveno.proto.grpc.XmrConnectionsGrpc.XmrConnectionsImplBase; +import static haveno.proto.grpc.XmrConnectionsGrpc.getAddConnectionMethod; +import static haveno.proto.grpc.XmrConnectionsGrpc.getCheckConnectionMethod; +import static haveno.proto.grpc.XmrConnectionsGrpc.getCheckConnectionsMethod; +import static haveno.proto.grpc.XmrConnectionsGrpc.getGetBestAvailableConnectionMethod; +import static haveno.proto.grpc.XmrConnectionsGrpc.getGetConnectionMethod; +import static haveno.proto.grpc.XmrConnectionsGrpc.getGetConnectionsMethod; +import static haveno.proto.grpc.XmrConnectionsGrpc.getRemoveConnectionMethod; +import static haveno.proto.grpc.XmrConnectionsGrpc.getSetAutoSwitchMethod; +import static haveno.proto.grpc.XmrConnectionsGrpc.getSetConnectionMethod; +import static haveno.proto.grpc.XmrConnectionsGrpc.getStartCheckingConnectionsMethod; +import static haveno.proto.grpc.XmrConnectionsGrpc.getStopCheckingConnectionsMethod; import static java.util.concurrent.TimeUnit.SECONDS; @Slf4j -class GrpcMoneroConnectionsService extends MoneroConnectionsImplBase { +class GrpcXmrConnectionService extends XmrConnectionsImplBase { private final CoreApi coreApi; private final GrpcExceptionHandler exceptionHandler; @Inject - public GrpcMoneroConnectionsService(CoreApi coreApi, GrpcExceptionHandler exceptionHandler) { + public GrpcXmrConnectionService(CoreApi coreApi, GrpcExceptionHandler exceptionHandler) { this.coreApi = coreApi; this.exceptionHandler = exceptionHandler; } @@ -118,9 +118,9 @@ class GrpcMoneroConnectionsService extends MoneroConnectionsImplBase { public void getConnections(GetConnectionsRequest request, StreamObserver responseObserver) { handleRequest(responseObserver, () -> { - List connections = coreApi.getMoneroConnections(); + List connections = coreApi.getXmrConnections(); List replyConnections = connections.stream() - .map(GrpcMoneroConnectionsService::toUrlConnection).collect(Collectors.toList()); + .map(GrpcXmrConnectionService::toUrlConnection).collect(Collectors.toList()); return GetConnectionsReply.newBuilder().addAllConnections(replyConnections).build(); }); } @@ -156,9 +156,9 @@ class GrpcMoneroConnectionsService extends MoneroConnectionsImplBase { public void checkConnections(CheckConnectionsRequest request, StreamObserver responseObserver) { handleRequest(responseObserver, () -> { - List connections = coreApi.checkMoneroConnections(); + List connections = coreApi.checkXmrConnections(); List replyConnections = connections.stream() - .map(GrpcMoneroConnectionsService::toUrlConnection).collect(Collectors.toList()); + .map(GrpcXmrConnectionService::toUrlConnection).collect(Collectors.toList()); return CheckConnectionsReply.newBuilder().addAllConnections(replyConnections).build(); }); } diff --git a/daemon/src/main/java/haveno/daemon/grpc/GrpcMoneroNodeService.java b/daemon/src/main/java/haveno/daemon/grpc/GrpcXmrNodeService.java similarity index 63% rename from daemon/src/main/java/haveno/daemon/grpc/GrpcMoneroNodeService.java rename to daemon/src/main/java/haveno/daemon/grpc/GrpcXmrNodeService.java index b08cbe5188..97671fa5c6 100644 --- a/daemon/src/main/java/haveno/daemon/grpc/GrpcMoneroNodeService.java +++ b/daemon/src/main/java/haveno/daemon/grpc/GrpcXmrNodeService.java @@ -17,18 +17,18 @@ package haveno.daemon.grpc; import haveno.core.api.CoreApi; -import haveno.core.xmr.MoneroNodeSettings; +import haveno.core.xmr.XmrNodeSettings; import haveno.daemon.grpc.interceptor.CallRateMeteringInterceptor; import haveno.daemon.grpc.interceptor.GrpcCallRateMeter; -import haveno.proto.grpc.GetMoneroNodeSettingsReply; -import haveno.proto.grpc.GetMoneroNodeSettingsRequest; -import haveno.proto.grpc.IsMoneroNodeOnlineReply; -import haveno.proto.grpc.IsMoneroNodeOnlineRequest; -import haveno.proto.grpc.MoneroNodeGrpc.MoneroNodeImplBase; -import haveno.proto.grpc.StartMoneroNodeReply; -import haveno.proto.grpc.StartMoneroNodeRequest; -import haveno.proto.grpc.StopMoneroNodeReply; -import haveno.proto.grpc.StopMoneroNodeRequest; +import haveno.proto.grpc.GetXmrNodeSettingsReply; +import haveno.proto.grpc.GetXmrNodeSettingsRequest; +import haveno.proto.grpc.IsXmrNodeOnlineReply; +import haveno.proto.grpc.IsXmrNodeOnlineRequest; +import haveno.proto.grpc.XmrNodeGrpc.XmrNodeImplBase; +import haveno.proto.grpc.StartXmrNodeReply; +import haveno.proto.grpc.StartXmrNodeRequest; +import haveno.proto.grpc.StopXmrNodeReply; +import haveno.proto.grpc.StopXmrNodeRequest; import io.grpc.ServerInterceptor; import io.grpc.stub.StreamObserver; import lombok.extern.slf4j.Slf4j; @@ -39,30 +39,30 @@ import java.util.HashMap; import java.util.Optional; import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; -import static haveno.proto.grpc.MoneroNodeGrpc.getGetMoneroNodeSettingsMethod; -import static haveno.proto.grpc.MoneroNodeGrpc.getIsMoneroNodeOnlineMethod; -import static haveno.proto.grpc.MoneroNodeGrpc.getStartMoneroNodeMethod; -import static haveno.proto.grpc.MoneroNodeGrpc.getStopMoneroNodeMethod; +import static haveno.proto.grpc.XmrNodeGrpc.getGetXmrNodeSettingsMethod; +import static haveno.proto.grpc.XmrNodeGrpc.getIsXmrNodeOnlineMethod; +import static haveno.proto.grpc.XmrNodeGrpc.getStartXmrNodeMethod; +import static haveno.proto.grpc.XmrNodeGrpc.getStopXmrNodeMethod; import static java.util.concurrent.TimeUnit.SECONDS; @Slf4j -public class GrpcMoneroNodeService extends MoneroNodeImplBase { +public class GrpcXmrNodeService extends XmrNodeImplBase { private final CoreApi coreApi; private final GrpcExceptionHandler exceptionHandler; @Inject - public GrpcMoneroNodeService(CoreApi coreApi, GrpcExceptionHandler exceptionHandler) { + public GrpcXmrNodeService(CoreApi coreApi, GrpcExceptionHandler exceptionHandler) { this.coreApi = coreApi; this.exceptionHandler = exceptionHandler; } @Override - public void isMoneroNodeOnline(IsMoneroNodeOnlineRequest request, - StreamObserver responseObserver) { + public void isXmrNodeOnline(IsXmrNodeOnlineRequest request, + StreamObserver responseObserver) { try { - var reply = IsMoneroNodeOnlineReply.newBuilder() - .setIsRunning(coreApi.isMoneroNodeOnline()) + var reply = IsXmrNodeOnlineReply.newBuilder() + .setIsRunning(coreApi.isXmrNodeOnline()) .build(); responseObserver.onNext(reply); responseObserver.onCompleted(); @@ -72,11 +72,11 @@ public class GrpcMoneroNodeService extends MoneroNodeImplBase { } @Override - public void getMoneroNodeSettings(GetMoneroNodeSettingsRequest request, - StreamObserver responseObserver) { + public void getXmrNodeSettings(GetXmrNodeSettingsRequest request, + StreamObserver responseObserver) { try { - var settings = coreApi.getMoneroNodeSettings(); - var builder = GetMoneroNodeSettingsReply.newBuilder(); + var settings = coreApi.getXmrNodeSettings(); + var builder = GetXmrNodeSettingsReply.newBuilder(); if (settings != null) { builder.setSettings(settings.toProtoMessage()); } @@ -89,12 +89,12 @@ public class GrpcMoneroNodeService extends MoneroNodeImplBase { } @Override - public void startMoneroNode(StartMoneroNodeRequest request, - StreamObserver responseObserver) { + public void startXmrNode(StartXmrNodeRequest request, + StreamObserver responseObserver) { try { var settings = request.getSettings(); - coreApi.startMoneroNode(MoneroNodeSettings.fromProto(settings)); - var reply = StartMoneroNodeReply.newBuilder().build(); + coreApi.startXmrNode(XmrNodeSettings.fromProto(settings)); + var reply = StartXmrNodeReply.newBuilder().build(); responseObserver.onNext(reply); responseObserver.onCompleted(); } catch (MoneroError me) { @@ -105,11 +105,11 @@ public class GrpcMoneroNodeService extends MoneroNodeImplBase { } @Override - public void stopMoneroNode(StopMoneroNodeRequest request, - StreamObserver responseObserver) { + public void stopXmrNode(StopXmrNodeRequest request, + StreamObserver responseObserver) { try { - coreApi.stopMoneroNode(); - var reply = StopMoneroNodeReply.newBuilder().build(); + coreApi.stopXmrNode(); + var reply = StopXmrNodeReply.newBuilder().build(); responseObserver.onNext(reply); responseObserver.onCompleted(); } catch (MoneroError me) { @@ -141,10 +141,10 @@ public class GrpcMoneroNodeService extends MoneroNodeImplBase { .or(() -> Optional.of(CallRateMeteringInterceptor.valueOf( new HashMap<>() {{ int allowedCallsPerTimeWindow = 10; - put(getIsMoneroNodeOnlineMethod().getFullMethodName(), new GrpcCallRateMeter(allowedCallsPerTimeWindow, SECONDS)); - put(getGetMoneroNodeSettingsMethod().getFullMethodName(), new GrpcCallRateMeter(allowedCallsPerTimeWindow, SECONDS)); - put(getStartMoneroNodeMethod().getFullMethodName(), new GrpcCallRateMeter(allowedCallsPerTimeWindow, SECONDS)); - put(getStopMoneroNodeMethod().getFullMethodName(), new GrpcCallRateMeter(allowedCallsPerTimeWindow, SECONDS)); + put(getIsXmrNodeOnlineMethod().getFullMethodName(), new GrpcCallRateMeter(allowedCallsPerTimeWindow, SECONDS)); + put(getGetXmrNodeSettingsMethod().getFullMethodName(), new GrpcCallRateMeter(allowedCallsPerTimeWindow, SECONDS)); + put(getStartXmrNodeMethod().getFullMethodName(), new GrpcCallRateMeter(allowedCallsPerTimeWindow, SECONDS)); + put(getStopXmrNodeMethod().getFullMethodName(), new GrpcCallRateMeter(allowedCallsPerTimeWindow, SECONDS)); }} ))); } diff --git a/desktop/src/main/java/haveno/desktop/main/MainViewModel.java b/desktop/src/main/java/haveno/desktop/main/MainViewModel.java index 7ccb1968b6..bae021ba3e 100644 --- a/desktop/src/main/java/haveno/desktop/main/MainViewModel.java +++ b/desktop/src/main/java/haveno/desktop/main/MainViewModel.java @@ -29,7 +29,7 @@ import haveno.common.util.Tuple2; import haveno.core.account.sign.SignedWitnessService; import haveno.core.account.witness.AccountAgeWitnessService; import haveno.core.alert.PrivateNotificationManager; -import haveno.core.api.CoreMoneroConnectionsService; +import haveno.core.api.XmrConnectionService; import haveno.core.app.HavenoSetup; import haveno.core.locale.CryptoCurrency; import haveno.core.locale.CurrencyUtil; @@ -103,7 +103,7 @@ import java.util.concurrent.TimeUnit; @Slf4j public class MainViewModel implements ViewModel, HavenoSetup.HavenoSetupListener { private final HavenoSetup havenoSetup; - private final CoreMoneroConnectionsService connectionService; + private final XmrConnectionService xmrConnectionService; private final User user; private final BalancePresentation balancePresentation; private final TradePresentation tradePresentation; @@ -147,7 +147,7 @@ public class MainViewModel implements ViewModel, HavenoSetup.HavenoSetupListener @Inject public MainViewModel(HavenoSetup havenoSetup, - CoreMoneroConnectionsService connectionService, + XmrConnectionService xmrConnectionService, XmrWalletService xmrWalletService, User user, BalancePresentation balancePresentation, @@ -171,7 +171,7 @@ public class MainViewModel implements ViewModel, HavenoSetup.HavenoSetupListener CorruptedStorageFileHandler corruptedStorageFileHandler, Navigation navigation) { this.havenoSetup = havenoSetup; - this.connectionService = connectionService; + this.xmrConnectionService = xmrConnectionService; this.user = user; this.balancePresentation = balancePresentation; this.tradePresentation = tradePresentation; @@ -359,7 +359,7 @@ public class MainViewModel implements ViewModel, HavenoSetup.HavenoSetupListener havenoSetup.setDisplaySecurityRecommendationHandler(key -> {}); havenoSetup.setDisplayLocalhostHandler(key -> { if (!DevEnv.isDevMode()) { - Popup popup = new Popup().backgroundInfo(Res.get("popup.moneroLocalhostNode.msg")) + Popup popup = new Popup().backgroundInfo(Res.get("popup.xmrLocalNode.msg")) .dontShowAgainId(key); popup.setDisplayOrderPriority(5); popupQueue.add(popup); diff --git a/desktop/src/main/java/haveno/desktop/main/funds/transactions/TransactionsView.java b/desktop/src/main/java/haveno/desktop/main/funds/transactions/TransactionsView.java index bc7253bf85..0e8f50bc97 100644 --- a/desktop/src/main/java/haveno/desktop/main/funds/transactions/TransactionsView.java +++ b/desktop/src/main/java/haveno/desktop/main/funds/transactions/TransactionsView.java @@ -20,7 +20,7 @@ package haveno.desktop.main.funds.transactions; import com.googlecode.jcsv.writer.CSVEntryConverter; import de.jensd.fx.fontawesome.AwesomeIcon; import haveno.common.util.Utilities; -import haveno.core.api.CoreMoneroConnectionsService; +import haveno.core.api.XmrConnectionService; import haveno.core.locale.Res; import haveno.core.offer.OpenOffer; import haveno.core.trade.Trade; @@ -110,7 +110,7 @@ public class TransactionsView extends ActivatableView { @Inject private TransactionsView(XmrWalletService xmrWalletService, P2PService p2PService, - CoreMoneroConnectionsService connectionService, + XmrConnectionService xmrConnectionService, Preferences preferences, TradeDetailsWindow tradeDetailsWindow, OfferDetailsWindow offerDetailsWindow, diff --git a/desktop/src/main/java/haveno/desktop/main/offer/offerbook/OfferBookViewModel.java b/desktop/src/main/java/haveno/desktop/main/offer/offerbook/OfferBookViewModel.java index 44d6d21ffd..623940f45d 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/offerbook/OfferBookViewModel.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/offerbook/OfferBookViewModel.java @@ -553,7 +553,7 @@ abstract class OfferBookViewModel extends ActivatableViewModel { boolean canCreateOrTakeOffer() { return GUIUtil.canCreateOrTakeOfferOrShowPopup(user, navigation) && - GUIUtil.isChainHeightSyncedWithinToleranceOrShowPopup(openOfferManager.getConnectionsService()) && + GUIUtil.isChainHeightSyncedWithinToleranceOrShowPopup(openOfferManager.getXmrConnectionService()) && GUIUtil.isBootstrappedOrShowPopup(p2PService); } diff --git a/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesDataModel.java b/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesDataModel.java index ea2d60267d..b7a9df864f 100644 --- a/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesDataModel.java +++ b/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesDataModel.java @@ -26,7 +26,7 @@ import haveno.common.handlers.FaultHandler; import haveno.common.handlers.ResultHandler; import haveno.core.account.witness.AccountAgeWitnessService; import haveno.core.api.CoreDisputesService; -import haveno.core.api.CoreMoneroConnectionsService; +import haveno.core.api.XmrConnectionService; import haveno.core.locale.Res; import haveno.core.offer.Offer; import haveno.core.offer.OfferDirection; @@ -89,7 +89,7 @@ public class PendingTradesDataModel extends ActivatableDataModel { public final ArbitrationManager arbitrationManager; public final MediationManager mediationManager; private final P2PService p2PService; - private final CoreMoneroConnectionsService connectionService; + private final XmrConnectionService xmrConnectionService; @Getter private final AccountAgeWitnessService accountAgeWitnessService; public final Navigation navigation; @@ -129,7 +129,7 @@ public class PendingTradesDataModel extends ActivatableDataModel { TraderChatManager traderChatManager, Preferences preferences, P2PService p2PService, - CoreMoneroConnectionsService connectionService, + XmrConnectionService xmrConnectionService, AccountAgeWitnessService accountAgeWitnessService, Navigation navigation, WalletPasswordWindow walletPasswordWindow, @@ -145,7 +145,7 @@ public class PendingTradesDataModel extends ActivatableDataModel { this.traderChatManager = traderChatManager; this.preferences = preferences; this.p2PService = p2PService; - this.connectionService = connectionService; + this.xmrConnectionService = xmrConnectionService; this.accountAgeWitnessService = accountAgeWitnessService; this.navigation = navigation; this.walletPasswordWindow = walletPasswordWindow; @@ -544,7 +544,7 @@ public class PendingTradesDataModel extends ActivatableDataModel { } public boolean isReadyForTxBroadcast() { - return GUIUtil.isBootstrappedOrShowPopup(p2PService) && GUIUtil.isReadyForTxBroadcastOrShowPopup(connectionService); + return GUIUtil.isBootstrappedOrShowPopup(p2PService) && GUIUtil.isReadyForTxBroadcastOrShowPopup(xmrConnectionService); } public boolean isBootstrappedOrShowPopup() { 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 0215e6fbd6..de322b441b 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 @@ -19,8 +19,8 @@ package haveno.desktop.main.settings.network; import haveno.common.ClockWatcher; import haveno.common.UserThread; -import haveno.core.api.CoreMoneroConnectionsService; -import haveno.core.api.LocalMoneroNode; +import haveno.core.api.XmrConnectionService; +import haveno.core.api.XmrLocalNode; import haveno.core.filter.Filter; import haveno.core.filter.FilterManager; import haveno.core.locale.Res; @@ -103,12 +103,12 @@ public class NetworkSettingsView extends ActivatableView { private final Preferences preferences; private final XmrNodes xmrNodes; private final FilterManager filterManager; - private final LocalMoneroNode localMoneroNode; + private final XmrLocalNode xmrLocalNode; private final TorNetworkSettingsWindow torNetworkSettingsWindow; private final ClockWatcher clockWatcher; private final WalletsSetup walletsSetup; private final P2PService p2PService; - private final CoreMoneroConnectionsService connectionManager; + private final XmrConnectionService connectionManager; private final ObservableList p2pNetworkListItems = FXCollections.observableArrayList(); private final SortedList p2pSortedList = new SortedList<>(p2pNetworkListItems); @@ -132,11 +132,11 @@ public class NetworkSettingsView extends ActivatableView { @Inject public NetworkSettingsView(WalletsSetup walletsSetup, P2PService p2PService, - CoreMoneroConnectionsService connectionManager, + XmrConnectionService connectionManager, Preferences preferences, XmrNodes xmrNodes, FilterManager filterManager, - LocalMoneroNode localMoneroNode, + XmrLocalNode xmrLocalNode, TorNetworkSettingsWindow torNetworkSettingsWindow, ClockWatcher clockWatcher) { super(); @@ -146,7 +146,7 @@ public class NetworkSettingsView extends ActivatableView { this.preferences = preferences; this.xmrNodes = xmrNodes; this.filterManager = filterManager; - this.localMoneroNode = localMoneroNode; + this.xmrLocalNode = xmrLocalNode; this.torNetworkSettingsWindow = torNetworkSettingsWindow; this.clockWatcher = clockWatcher; } @@ -434,7 +434,7 @@ public class NetworkSettingsView extends ActivatableView { } private void onMoneroPeersToggleSelected(boolean calledFromUser) { - boolean localMoneroNodeShouldBeUsed = localMoneroNode.shouldBeUsed(); + boolean localMoneroNodeShouldBeUsed = xmrLocalNode.shouldBeUsed(); useTorForXmrLabel.setDisable(localMoneroNodeShouldBeUsed); moneroNodesLabel.setDisable(localMoneroNodeShouldBeUsed); xmrNodesLabel.setDisable(localMoneroNodeShouldBeUsed); @@ -501,7 +501,7 @@ public class NetworkSettingsView extends ActivatableView { private void applyPreventPublicXmrNetwork() { final boolean preventPublicXmrNetwork = isPreventPublicXmrNetwork(); - usePublicNodesRadio.setDisable(localMoneroNode.shouldBeUsed() || preventPublicXmrNetwork); + usePublicNodesRadio.setDisable(xmrLocalNode.shouldBeUsed() || preventPublicXmrNetwork); if (preventPublicXmrNetwork && selectedMoneroNodesOption == XmrNodes.MoneroNodesOption.PUBLIC) { selectedMoneroNodesOption = XmrNodes.MoneroNodesOption.PROVIDED; preferences.setMoneroNodesOptionOrdinal(selectedMoneroNodesOption.ordinal()); diff --git a/desktop/src/main/java/haveno/desktop/util/GUIUtil.java b/desktop/src/main/java/haveno/desktop/util/GUIUtil.java index cb1ee51deb..d32d0307e8 100644 --- a/desktop/src/main/java/haveno/desktop/util/GUIUtil.java +++ b/desktop/src/main/java/haveno/desktop/util/GUIUtil.java @@ -38,7 +38,7 @@ import haveno.common.util.Tuple3; import haveno.common.util.Utilities; import haveno.core.account.witness.AccountAgeWitness; import haveno.core.account.witness.AccountAgeWitnessService; -import haveno.core.api.CoreMoneroConnectionsService; +import haveno.core.api.XmrConnectionService; import haveno.core.locale.Country; import haveno.core.locale.CountryUtil; import haveno.core.locale.CurrencyUtil; @@ -689,19 +689,19 @@ public class GUIUtil { return false; } - public static boolean isReadyForTxBroadcastOrShowPopup(CoreMoneroConnectionsService connectionService) { - if (!connectionService.hasSufficientPeersForBroadcast()) { - new Popup().information(Res.get("popup.warning.notSufficientConnectionsToXmrNetwork", connectionService.getMinBroadcastConnections())).show(); + public static boolean isReadyForTxBroadcastOrShowPopup(XmrConnectionService xmrConnectionService) { + if (!xmrConnectionService.hasSufficientPeersForBroadcast()) { + new Popup().information(Res.get("popup.warning.notSufficientConnectionsToXmrNetwork", xmrConnectionService.getMinBroadcastConnections())).show(); return false; } - if (!connectionService.isDownloadComplete()) { + if (!xmrConnectionService.isDownloadComplete()) { new Popup().information(Res.get("popup.warning.downloadNotComplete")).show(); return false; } try { - connectionService.verifyConnection(); + xmrConnectionService.verifyConnection(); } catch (Exception e) { new Popup().information(e.getMessage()).show(); return false; @@ -710,8 +710,8 @@ public class GUIUtil { return true; } - public static boolean isChainHeightSyncedWithinToleranceOrShowPopup(CoreMoneroConnectionsService connectionService) { - if (!connectionService.isSyncedWithinTolerance()) { + public static boolean isChainHeightSyncedWithinToleranceOrShowPopup(XmrConnectionService xmrConnectionService) { + if (!xmrConnectionService.isSyncedWithinTolerance()) { new Popup().information(Res.get("popup.warning.chainNotSynced")).show(); return false; } diff --git a/desktop/src/test/java/haveno/desktop/maker/PreferenceMakers.java b/desktop/src/test/java/haveno/desktop/maker/PreferenceMakers.java index bfbb4be305..950db07d00 100644 --- a/desktop/src/test/java/haveno/desktop/maker/PreferenceMakers.java +++ b/desktop/src/test/java/haveno/desktop/maker/PreferenceMakers.java @@ -22,7 +22,7 @@ import com.natpryce.makeiteasy.Property; import com.natpryce.makeiteasy.SameValueDonor; import haveno.common.config.Config; import haveno.common.persistence.PersistenceManager; -import haveno.core.api.LocalMoneroNode; +import haveno.core.api.XmrLocalNode; import haveno.core.user.Preferences; import static com.natpryce.makeiteasy.MakeItEasy.a; @@ -32,7 +32,7 @@ public class PreferenceMakers { public static final Property storage = new Property<>(); public static final Property config = new Property<>(); - public static final Property localMoneroNode = new Property<>(); + public static final Property xmrLocalNode = new Property<>(); public static final Property useTorFlagFromOptions = new Property<>(); public static final Property referralID = new Property<>(); diff --git a/proto/src/main/proto/grpc.proto b/proto/src/main/proto/grpc.proto index b6eef9fe6b..20506eb2ef 100644 --- a/proto/src/main/proto/grpc.proto +++ b/proto/src/main/proto/grpc.proto @@ -280,10 +280,10 @@ message SendNotificationReply { } /////////////////////////////////////////////////////////////////////////////////////////// -// MoneroConnections +// XmrConnections /////////////////////////////////////////////////////////////////////////////////////////// -service MoneroConnections { +service XmrConnections { rpc AddConnection (AddConnectionRequest) returns (AddConnectionReply) { } rpc RemoveConnection(RemoveConnectionRequest) returns (RemoveConnectionReply) { @@ -394,45 +394,45 @@ message SetAutoSwitchRequest { message SetAutoSwitchReply {} /////////////////////////////////////////////////////////////////////////////////////////// -// MoneroNode +// XmrNode /////////////////////////////////////////////////////////////////////////////////////////// -service MoneroNode { - rpc IsMoneroNodeOnline (IsMoneroNodeOnlineRequest) returns (IsMoneroNodeOnlineReply) { +service XmrNode { + rpc IsXmrNodeOnline (IsXmrNodeOnlineRequest) returns (IsXmrNodeOnlineReply) { } - rpc GetMoneroNodeSettings (GetMoneroNodeSettingsRequest) returns (GetMoneroNodeSettingsReply) { + rpc GetXmrNodeSettings (GetXmrNodeSettingsRequest) returns (GetXmrNodeSettingsReply) { } - rpc StartMoneroNode (StartMoneroNodeRequest) returns (StartMoneroNodeReply) { + rpc StartXmrNode (StartXmrNodeRequest) returns (StartXmrNodeReply) { } - rpc StopMoneroNode (StopMoneroNodeRequest) returns (StopMoneroNodeReply) { + rpc StopXmrNode (StopXmrNodeRequest) returns (StopXmrNodeReply) { } } -message IsMoneroNodeOnlineRequest { +message IsXmrNodeOnlineRequest { } -message IsMoneroNodeOnlineReply { +message IsXmrNodeOnlineReply { bool is_running = 1; } -message GetMoneroNodeSettingsRequest { +message GetXmrNodeSettingsRequest { } -message GetMoneroNodeSettingsReply { - MoneroNodeSettings settings = 1; // pb.proto +message GetXmrNodeSettingsReply { + XmrNodeSettings settings = 1; // pb.proto } -message StartMoneroNodeRequest { - MoneroNodeSettings settings = 1; +message StartXmrNodeRequest { + XmrNodeSettings settings = 1; } -message StartMoneroNodeReply { +message StartXmrNodeReply { } -message StopMoneroNodeRequest { +message StopXmrNodeRequest { } -message StopMoneroNodeReply { +message StopXmrNodeReply { } /////////////////////////////////////////////////////////////////////////////////////////// diff --git a/proto/src/main/proto/pb.proto b/proto/src/main/proto/pb.proto index 9a9ce239d7..6420672da9 100644 --- a/proto/src/main/proto/pb.proto +++ b/proto/src/main/proto/pb.proto @@ -1712,7 +1712,7 @@ message PreferencesPayload { bool show_offers_matching_my_accounts = 55; bool deny_api_taker = 56; bool notify_on_pre_release = 57; - MoneroNodeSettings monero_node_settings = 58; + XmrNodeSettings xmr_node_settings = 58; int32 clear_data_after_days = 59; string buy_screen_crypto_currency_code = 60; string sell_screen_crypto_currency_code = 61; @@ -1727,7 +1727,7 @@ message AutoConfirmSettings { string currency_code = 5; } -message MoneroNodeSettings { +message XmrNodeSettings { string blockchain_path = 1; string bootstrap_url = 2; repeated string startup_flags = 3;