diff --git a/WalletWasabi.Daemon/Config.cs b/WalletWasabi.Daemon/Config.cs index 3330b06e2f6..1d2bec1abe1 100644 --- a/WalletWasabi.Daemon/Config.cs +++ b/WalletWasabi.Daemon/Config.cs @@ -250,7 +250,7 @@ public Uri GetBackendUri() throw new NotSupportedNetworkException(Network); } - public Uri GetCoordinatorUri() + public Uri? GetCoordinatorUri() { var result = Network switch { @@ -260,7 +260,7 @@ public Uri GetCoordinatorUri() _ => throw new NotSupportedNetworkException(Network) }; - return new Uri(result); + return result is "" ? null : new Uri(result); } public IEnumerable<(string ParameterName, string Hint)> GetConfigOptionsMetadata() => diff --git a/WalletWasabi.Daemon/Global.cs b/WalletWasabi.Daemon/Global.cs index c0c31aaad47..43e4d309cb9 100644 --- a/WalletWasabi.Daemon/Global.cs +++ b/WalletWasabi.Daemon/Global.cs @@ -74,7 +74,17 @@ public Global(string dataDir, string configFilePath, Config config) BitcoinStore = new BitcoinStore(IndexStore, AllTransactionStore, mempoolService, smartHeaderChain, blocks); HttpClientFactory = BuildHttpClientFactory(() => Config.GetBackendUri()); - CoordinatorHttpClientFactory = BuildHttpClientFactory(() => Config.GetCoordinatorUri()); + + if (Config.GetCoordinatorUri() is { } coordinatorUri) + { + CoordinatorHttpClientFactory = BuildHttpClientFactory(() => coordinatorUri); + var prisonForCoordinator = Path.Combine(DataDir, coordinatorUri.Host); + CoinPrison = CoinPrison.CreateOrLoadFromFile(prisonForCoordinator); + } + else + { + CoinPrison = CoinPrison.CreateDummyPrison(); + } HostedServices.Register(() => new UpdateManager(TimeSpan.FromDays(1), DataDir, Config.DownloadNewVersion, HttpClientFactory.NewHttpClient(Mode.DefaultCircuit, maximumRedirects: 10), HttpClientFactory.SharedWasabiClient), "Update Manager"); UpdateManager = HostedServices.Get(); @@ -157,8 +167,6 @@ public Global(string dataDir, string configFilePath, Config config) TransactionBroadcaster = new TransactionBroadcaster(broadcasters.ToArray(), BitcoinStore.MempoolService, WalletManager); - var prisonForCoordinator = Path.Combine(DataDir, config.GetCoordinatorUri().Host); - CoinPrison = CoinPrison.CreateOrLoadFromFile(prisonForCoordinator); WalletManager.WalletStateChanged += WalletManager_WalletStateChanged; } @@ -178,7 +186,7 @@ public Global(string dataDir, string configFilePath, Config config) /// HTTP client factory for sending HTTP requests. public WasabiHttpClientFactory HttpClientFactory { get; } - public WasabiHttpClientFactory CoordinatorHttpClientFactory { get; } + public WasabiHttpClientFactory? CoordinatorHttpClientFactory { get; } public string ConfigFilePath { get; } public Config Config { get; } @@ -197,7 +205,7 @@ public Global(string dataDir, string configFilePath, Config config) public Network Network => Config.Network; public IMemoryCache Cache { get; private set; } - public CoinPrison CoinPrison { get; } + private CoinPrison CoinPrison { get; } public JsonRpcServer? RpcServer { get; private set; } public Uri? OnionServiceUri { get; private set; } @@ -260,7 +268,7 @@ public async Task InitializeNoWalletAsync(bool initializeSleepInhibitor, Termina await BlockDownloadService.StartAsync(cancel).ConfigureAwait(false); - if (HasCoordinatorConfigured) + if (HasCoordinatorConfigured && CoordinatorHttpClientFactory is not null) { RegisterCoinJoinComponents(); @@ -421,6 +429,11 @@ private void RegisterFeeRateProviders() private void RegisterCoinJoinComponents() { + if (CoordinatorHttpClientFactory is null) + { + return; + } + Tor.Http.IHttpClient roundStateUpdaterHttpClient = CoordinatorHttpClientFactory.NewHttpClient(Mode.SingleCircuitPerLifetime, RoundStateUpdaterCircuit); HostedServices.Register(() => new RoundStateUpdater(TimeSpan.FromSeconds(10), new WabiSabiHttpApiClient(roundStateUpdaterHttpClient)), "Round info updater"); @@ -516,8 +529,11 @@ public async Task DisposeAsync() Logger.LogInfo($"{nameof(HttpClientFactory)} is disposed."); } - await CoordinatorHttpClientFactory.DisposeAsync().ConfigureAwait(false); - Logger.LogInfo($"{nameof(CoordinatorHttpClientFactory)} is disposed."); + if (CoordinatorHttpClientFactory is not null) + { + await CoordinatorHttpClientFactory.DisposeAsync().ConfigureAwait(false); + Logger.LogInfo($"{nameof(CoordinatorHttpClientFactory)} is disposed."); + } if (BitcoinCoreNode is { } bitcoinCoreNode) { diff --git a/WalletWasabi.Daemon/PersistentConfig.cs b/WalletWasabi.Daemon/PersistentConfig.cs index d34a4193ac5..7be2cbb320c 100644 --- a/WalletWasabi.Daemon/PersistentConfig.cs +++ b/WalletWasabi.Daemon/PersistentConfig.cs @@ -17,9 +17,9 @@ public record PersistentConfig public string RegTestBackendUri { get; init; } = "http://localhost:37127/"; - public string MainNetCoordinatorUri { get; init; } = Constants.BackendUri; + public string MainNetCoordinatorUri { get; init; } = ""; - public string TestNetCoordinatorUri { get; init; } = Constants.TestnetBackendUri; + public string TestNetCoordinatorUri { get; init; } = ""; public string RegTestCoordinatorUri { get; init; } = "http://localhost:37127/"; diff --git a/WalletWasabi.Fluent/ViewModels/Wallets/CoinJoinStateViewModel.cs b/WalletWasabi.Fluent/ViewModels/Wallets/CoinJoinStateViewModel.cs index 9ffc076ddbb..a5f2f934a72 100644 --- a/WalletWasabi.Fluent/ViewModels/Wallets/CoinJoinStateViewModel.cs +++ b/WalletWasabi.Fluent/ViewModels/Wallets/CoinJoinStateViewModel.cs @@ -179,8 +179,6 @@ public CoinJoinStateViewModel(UiContext uiContext, IWalletModel wallet, IWalletC } }); - CoordinatorHelpCommand = ReactiveCommand.CreateFromTask(() => UiContext.FileSystem.OpenBrowserAsync("https://www.google.com")); - IsCoinjoinSupported = _wallet.Coinjoin is not null; } @@ -227,8 +225,6 @@ private enum Trigger public ICommand StopPauseCommand { get; } public ICommand NavigateToCoordinatorSettingsCommand { get; } - public ICommand CoordinatorHelpCommand { get; } - private void ConfigureStateMachine() { _stateMachine.Configure(State.Disabled); diff --git a/WalletWasabi.Fluent/Views/Wallets/MusicControlsView.axaml b/WalletWasabi.Fluent/Views/Wallets/MusicControlsView.axaml index efa9205b260..a4a12f81128 100644 --- a/WalletWasabi.Fluent/Views/Wallets/MusicControlsView.axaml +++ b/WalletWasabi.Fluent/Views/Wallets/MusicControlsView.axaml @@ -143,7 +143,11 @@ - + + + + + @@ -151,7 +155,7 @@ - + diff --git a/WalletWasabi.Tests/UnitTests/Bases/ConfigManagerNgTests.cs b/WalletWasabi.Tests/UnitTests/Bases/ConfigManagerNgTests.cs index 8d62bb0a81a..f19c58826ab 100644 --- a/WalletWasabi.Tests/UnitTests/Bases/ConfigManagerNgTests.cs +++ b/WalletWasabi.Tests/UnitTests/Bases/ConfigManagerNgTests.cs @@ -52,8 +52,8 @@ static string GetConfigString(string localBitcoinCoreDataDir) "MainNetBackendUri": "https://api.wasabiwallet.io/", "TestNetBackendUri": "https://api.wasabiwallet.co/", "RegTestBackendUri": "http://localhost:37127/", - "MainNetCoordinatorUri": "https://api.wasabiwallet.io/", - "TestNetCoordinatorUri": "https://api.wasabiwallet.co/", + "MainNetCoordinatorUri": "", + "TestNetCoordinatorUri": "", "RegTestCoordinatorUri": "http://localhost:37127/", "UseTor": "Enabled", "TerminateTorOnExit": false, diff --git a/WalletWasabi/WabiSabi/Client/Banning/CoinPrison.cs b/WalletWasabi/WabiSabi/Client/Banning/CoinPrison.cs index dabf68c0d5d..cc328066d3d 100644 --- a/WalletWasabi/WabiSabi/Client/Banning/CoinPrison.cs +++ b/WalletWasabi/WabiSabi/Client/Banning/CoinPrison.cs @@ -10,7 +10,7 @@ namespace WalletWasabi.WabiSabi.Client.Banning; -public class CoinPrison(string filePath, Dictionary bannedCoins) : IDisposable +public class CoinPrison(string? filePath, Dictionary bannedCoins) : IDisposable { enum BanningStatus { @@ -74,6 +74,11 @@ public static CoinPrison CreateOrLoadFromFile(string containingDirectory) } } + public static CoinPrison CreateDummyPrison() + { + return new CoinPrison(null, []); + } + public void UpdateWallet(Wallet wallet) { lock (_lock)