rename services and objects from Monero to Xmr for consistency

This commit is contained in:
woodser 2023-11-25 12:44:27 -05:00
parent 497f987541
commit 644bb72957
52 changed files with 334 additions and 334 deletions

View file

@ -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<MoneroRpcConnection> getMoneroConnections() {
return coreMoneroConnectionsService.getConnections();
public List<MoneroRpcConnection> 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<MoneroRpcConnection> checkMoneroConnections() {
return coreMoneroConnectionsService.checkConnections();
public List<MoneroRpcConnection> 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();
}
///////////////////////////////////////////////////////////////////////////////////////////

View file

@ -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<List<MoneroPeer>> peers = new SimpleObjectProperty<>();
@ -76,14 +76,14 @@ public final class CoreMoneroConnectionsService {
private List<MoneroConnectionManagerListener> 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) {

View file

@ -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<LocalMoneroNodeListener> listeners = new ArrayList<>();
private final List<XmrLocalNodeListener> listeners = new ArrayList<>();
// required arguments
private static final List<String> MONEROD_ARGS = new ArrayList<String>();
@ -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();

View file

@ -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) {}

View file

@ -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);
});

View file

@ -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));
}
}

View file

@ -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<Runnable> tasks = new HashSet<Runnable>();
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();
});
});

View file

@ -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() {

View file

@ -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;

View file

@ -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<Throwable> walletServiceException = new SimpleObjectProperty<>();
xmrInfoBinding = EasyBind.combine(connectionService.downloadPercentageProperty(),
connectionService.chainHeightProperty(),
xmrInfoBinding = EasyBind.combine(xmrConnectionService.downloadPercentageProperty(),
xmrConnectionService.chainHeightProperty(),
xmrWalletService.downloadPercentageProperty(),
xmrWalletService.walletHeightProperty(),
walletServiceException,

View file

@ -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<Runnable> tasks = new HashSet<Runnable>();
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();
});
});

View file

@ -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));
}
}

View file

@ -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<OfferBookChangedListener> 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<String, MoneroKeyImageSpentStatus> 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) {

View file

@ -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<String, MoneroKeyImageSpentStatus> spentStatuses) {
for (Entry<String, MoneroKeyImageSpentStatus> 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);

View file

@ -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<String, Timer> 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();
}

View file

@ -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<T extends DisputeList<Dispute>> 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<T extends DisputeList<Dispute>> extends Sup
DisputeListService<T> 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<T extends DisputeList<Dispute>> 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<T extends DisputeList<Dispute>> extends Sup
tryApplyMessages();
});
connectionService.numPeersProperty().addListener((observable, oldValue, newValue) -> {
if (connectionService.hasSufficientPeersForBroadcast())
xmrConnectionService.numPeersProperty().addListener((observable, oldValue, newValue) -> {
if (xmrConnectionService.hasSufficientPeersForBroadcast())
tryApplyMessages();
});

View file

@ -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<ArbitrationDisputeL
public ArbitrationManager(P2PService p2PService,
TradeWalletService tradeWalletService,
XmrWalletService walletService,
CoreMoneroConnectionsService connectionService,
XmrConnectionService xmrConnectionService,
CoreNotificationService notificationService,
ArbitratorManager arbitratorManager,
TradeManager tradeManager,
@ -94,7 +94,7 @@ public final class ArbitrationManager extends DisputeManager<ArbitrationDisputeL
ArbitrationDisputeListService arbitrationDisputeListService,
Config config,
PriceFeedService priceFeedService) {
super(p2PService, tradeWalletService, walletService, connectionService, notificationService, tradeManager, closedTradableManager,
super(p2PService, tradeWalletService, walletService, xmrConnectionService, notificationService, tradeManager, closedTradableManager,
openOfferManager, keyRing, arbitrationDisputeListService, config, priceFeedService);
this.arbitratorManager = arbitratorManager;
HavenoUtils.arbitrationManager = this; // TODO: storing static reference, better way?

View file

@ -26,7 +26,7 @@ import haveno.common.config.Config;
import haveno.common.crypto.KeyRing;
import haveno.common.handlers.ErrorMessageHandler;
import haveno.common.handlers.ResultHandler;
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;
@ -71,7 +71,7 @@ public final class MediationManager extends DisputeManager<MediationDisputeList>
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<MediationDisputeList>
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);
}

View file

@ -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<RefundDisputeList> {
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<RefundDisputeList> {
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);
}

View file

@ -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;
}

View file

@ -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");
}

View file

@ -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);
}
}

View file

@ -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())
);
}
}

View file

@ -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);
}
}

View file

@ -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);
}

View file

@ -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<String> 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));

View file

@ -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;
}

View file

@ -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 {

View file

@ -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.

View file

@ -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<String> keyImages = new ArrayList<String>();
private Set<MoneroKeyImageListener> listeners = new HashSet<MoneroKeyImageListener>();
private Set<XmrKeyImageListener> listeners = new HashSet<XmrKeyImageListener>();
private TaskLooper looper;
private Map<String, MoneroKeyImageSpentStatus> lastStatuses = new HashMap<String, MoneroKeyImageSpentStatus>();
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<MoneroKeyImageListener>(listeners)) {
for (XmrKeyImageListener listener : new ArrayList<XmrKeyImageListener>(listeners)) {
listener.onSpentStatusChanged(changedStatuses);
}
}

View file

@ -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<MoneroTx> 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());
}