Skip to content

Commit

Permalink
Revert "Remove default coordinator and help to find one (WalletWasabi…
Browse files Browse the repository at this point in the history
…#13317)" (WalletWasabi#13357)

This reverts commit b7c7ca4.
  • Loading branch information
lontivero authored Sep 5, 2024
1 parent 7712ac8 commit 15f0384
Show file tree
Hide file tree
Showing 19 changed files with 47 additions and 161 deletions.
4 changes: 2 additions & 2 deletions WalletWasabi.Daemon/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public Uri GetBackendUri()
throw new NotSupportedNetworkException(Network);
}

public Uri? GetCoordinatorUri()
public Uri GetCoordinatorUri()
{
var result = Network switch
{
Expand All @@ -260,7 +260,7 @@ public Uri GetBackendUri()
_ => throw new NotSupportedNetworkException(Network)
};

return result is "" ? null : new Uri(result);
return new Uri(result);
}

public IEnumerable<(string ParameterName, string Hint)> GetConfigOptionsMetadata() =>
Expand Down
29 changes: 10 additions & 19 deletions WalletWasabi.Daemon/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,7 @@ public Global(string dataDir, string configFilePath, Config config)

BitcoinStore = new BitcoinStore(IndexStore, AllTransactionStore, mempoolService, smartHeaderChain, blocks);
HttpClientFactory = BuildHttpClientFactory(() => Config.GetBackendUri());

if (Config.GetCoordinatorUri() is { } coordinatorUri)
{
CoordinatorHttpClientFactory = BuildHttpClientFactory(() => coordinatorUri);
CoinPrison = CoinPrison.CreateOrLoadFromFile(Path.Combine(DataDir, coordinatorUri.Host));
}
else
{
CoinPrison = CoinPrison.CreateDummyPrison();
}
CoordinatorHttpClientFactory = BuildHttpClientFactory(() => Config.GetCoordinatorUri());

HostedServices.Register<UpdateManager>(() => new UpdateManager(TimeSpan.FromDays(1), DataDir, Config.DownloadNewVersion, HttpClientFactory.NewHttpClient(Mode.DefaultCircuit, maximumRedirects: 10), HttpClientFactory.SharedWasabiClient), "Update Manager");
UpdateManager = HostedServices.Get<UpdateManager>();
Expand Down Expand Up @@ -166,6 +157,8 @@ 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;
}

Expand All @@ -185,7 +178,7 @@ public Global(string dataDir, string configFilePath, Config config)
/// <summary>HTTP client factory for sending HTTP requests.</summary>
public WasabiHttpClientFactory HttpClientFactory { get; }

public WasabiHttpClientFactory? CoordinatorHttpClientFactory { get; }
public WasabiHttpClientFactory CoordinatorHttpClientFactory { get; }

public string ConfigFilePath { get; }
public Config Config { get; }
Expand All @@ -204,7 +197,7 @@ public Global(string dataDir, string configFilePath, Config config)
public Network Network => Config.Network;

public IMemoryCache Cache { get; private set; }
private CoinPrison CoinPrison { get; }
public CoinPrison CoinPrison { get; }
public JsonRpcServer? RpcServer { get; private set; }

public Uri? OnionServiceUri { get; private set; }
Expand Down Expand Up @@ -421,10 +414,11 @@ private void RegisterFeeRateProviders()

private void RegisterCoinJoinComponents()
{
var coordinatorUri = CoordinatorHttpClientFactory?.BackendUriGetter?.Invoke().AbsoluteUri;
var hasCoordinatorConfigured = !(coordinatorUri is null or "https://api.wasabiwallet.io/" or "https://api.wasabiwallet.co/");
Tor.Http.IHttpClient roundStateUpdaterHttpClient = CoordinatorHttpClientFactory.NewHttpClient(Mode.SingleCircuitPerLifetime, RoundStateUpdaterCircuit);
HostedServices.Register<RoundStateUpdater>(() => new RoundStateUpdater(TimeSpan.FromSeconds(10), new WabiSabiHttpApiClient(roundStateUpdaterHttpClient)), "Round info updater");

var coinJoinConfiguration = new CoinJoinConfiguration(Config.CoordinatorIdentifier, Config.MaxCoinjoinMiningFeeRate, Config.AbsoluteMinInputCount, AllowSoloCoinjoining: false);
HostedServices.Register<CoinJoinManager>(() => new CoinJoinManager(WalletManager, CoordinatorHttpClientFactory, HostedServices.Get<WasabiSynchronizer>(), coinJoinConfiguration, CoinPrison, hasCoordinatorConfigured), "CoinJoin Manager");
HostedServices.Register<CoinJoinManager>(() => new CoinJoinManager(WalletManager, HostedServices.Get<RoundStateUpdater>(), CoordinatorHttpClientFactory, HostedServices.Get<WasabiSynchronizer>(), coinJoinConfiguration, CoinPrison), "CoinJoin Manager");
}

private void WalletManager_WalletStateChanged(object? sender, WalletState e)
Expand Down Expand Up @@ -515,10 +509,7 @@ public async Task DisposeAsync()
Logger.LogInfo($"{nameof(HttpClientFactory)} is disposed.");
}

if (CoordinatorHttpClientFactory is not null)
{
await CoordinatorHttpClientFactory.DisposeAsync().ConfigureAwait(false);
}
await CoordinatorHttpClientFactory.DisposeAsync().ConfigureAwait(false);
Logger.LogInfo($"{nameof(CoordinatorHttpClientFactory)} is disposed.");

if (BitcoinCoreNode is { } bitcoinCoreNode)
Expand Down
12 changes: 6 additions & 6 deletions WalletWasabi.Daemon/PersistentConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ public record PersistentConfig
{
public Network Network { get; init; } = Network.Main;

public string MainNetBackendUri { get; init; } = Constants.DefaultBackendUri;
public string MainNetBackendUri { get; init; } = Constants.BackendUri;

public string TestNetBackendUri { get; init; } = Constants.DefaultTestnetBackendUri;
public string TestNetBackendUri { get; init; } = Constants.TestnetBackendUri;

public string RegTestBackendUri { get; init; } = Constants.DefaultRegtestBackendUri;
public string RegTestBackendUri { get; init; } = "http://localhost:37127/";

public string MainNetCoordinatorUri { get; init; } = Constants.DefaultCoordinatorUri;
public string MainNetCoordinatorUri { get; init; } = Constants.BackendUri;

public string TestNetCoordinatorUri { get; init; } = Constants.DefaultTestnetCoordinatorUri;
public string TestNetCoordinatorUri { get; init; } = Constants.TestnetBackendUri;

public string RegTestCoordinatorUri { get; init; } = Constants.DefaultRegtestCoordinatorUri;
public string RegTestCoordinatorUri { get; init; } = "http://localhost:37127/";

/// <remarks>
/// For backward compatibility this was changed to an object.
Expand Down
6 changes: 0 additions & 6 deletions WalletWasabi.Fluent/Styles/HyperlinkMenuItem.axaml

This file was deleted.

1 change: 0 additions & 1 deletion WalletWasabi.Fluent/Styles/Styles.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
<StyleInclude Source="avares://WalletWasabi.Fluent/Styles/TextBox.axaml" />
<StyleInclude Source="avares://WalletWasabi.Fluent/Styles/NotificationCard.axaml" />
<StyleInclude Source="avares://WalletWasabi.Fluent/Styles/HyperlinkButton.axaml" />
<StyleInclude Source="avares://WalletWasabi.Fluent/Styles/HyperlinkMenuItem.axaml" />
<StyleInclude Source="avares://WalletWasabi.Fluent/Styles/CurrencyEntryBox.axaml" />
<StyleInclude Source="avares://WalletWasabi.Fluent/Styles/TreeDataGrid.axaml" />
<StyleInclude Source="avares://WalletWasabi.Fluent/Styles/RadioButton.axaml" />
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion WalletWasabi.Fluent/ViewModels/MainViewModelExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public static void RegisterAllViewModels(this MainViewModel mainViewModel, UiCon
UserSupportViewModel.RegisterLazy(() => new UserSupportViewModel(uiContext));
BugReportLinkViewModel.RegisterLazy(() => new BugReportLinkViewModel(uiContext));
DocsLinkViewModel.RegisterLazy(() => new DocsLinkViewModel(uiContext));
FindCoordinatorViewModel.RegisterLazy(() => new FindCoordinatorViewModel(uiContext));
OpenDataFolderViewModel.RegisterLazy(() => new OpenDataFolderViewModel(uiContext));
OpenWalletsFolderViewModel.RegisterLazy(() => new OpenWalletsFolderViewModel(uiContext));
OpenLogsViewModel.RegisterLazy(() => new OpenLogsViewModel(uiContext));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using WalletWasabi.Fluent.State;
using WalletWasabi.Fluent.ViewModels.Wallets.Settings;
using WalletWasabi.WabiSabi.Backend.Rounds;
using WalletWasabi.WabiSabi.Client;
using WalletWasabi.WabiSabi.Client.CoinJoinProgressEvents;
using WalletWasabi.WabiSabi.Client.StatusChangedEvents;

Expand Down Expand Up @@ -46,7 +45,6 @@ public partial class CoinJoinStateViewModel : ViewModelBase
private const string CoinsRejectedMessage = "Some funds are rejected from coinjoining";
private const string OnlyImmatureCoinsAvailableMessage = "Only immature funds are available";
private const string OnlyExcludedCoinsAvailableMessage = "Only excluded funds are available";
private const string NoCoordinatorConfiguredMessage = "Configure a coordinator to start coinjoin";

private readonly IWalletModel _wallet;
private readonly StateMachine<State, Trigger> _stateMachine;
Expand Down Expand Up @@ -167,7 +165,6 @@ public CoinJoinStateViewModel(UiContext uiContext, IWalletModel wallet, WalletSe
},
Observable.Return(!_wallet.IsWatchOnlyWallet));

OpenFindCoordinatorLinkCommand = ReactiveCommand.CreateFromTask(() => UiContext.FileSystem.OpenBrowserAsync(FindCoordinatorLink));
NavigateToSettingsCommand = coinJoinSettingsCommand;
CanNavigateToCoinjoinSettings = coinJoinSettingsCommand.CanExecute;
NavigateToExcludedCoinsCommand = ReactiveCommand.Create(() => UiContext.Navigate().To().ExcludedCoins(_wallet));
Expand Down Expand Up @@ -204,18 +201,14 @@ private enum Trigger
AreAllCoinsPrivateChanged
}

public static string FindCoordinatorLink { get; } = "https://docs.wasabiwallet.io/FAQ/FAQ-UseWasabi.html#how-do-i-find-a-coordinator";

public IObservable<bool> CanNavigateToCoinjoinSettings { get; }

public ICommand OpenFindCoordinatorLinkCommand { get; }
public ICommand NavigateToSettingsCommand { get; }

public ICommand NavigateToExcludedCoinsCommand { get; }

public ICommand NavigateToCoordinatorSettingsCommand { get; }

public bool NoCoordinatorConfigured => !Services.HostedServices.Get<CoinJoinManager>().HasCoordinatorConfigured;
public bool IsAutoCoinJoinEnabled => _wallet.Settings.AutoCoinjoin;

public IObservable<bool> AutoCoinJoinObservable { get; }
Expand Down Expand Up @@ -393,7 +386,6 @@ private void ProcessStatusChange(StatusChangedEventArgs e)
CoinjoinError.RandomlySkippedRound => RandomlySkippedRoundMessage,
CoinjoinError.MiningFeeRateTooHigh => CoinjoinMiningFeeRateTooHighMessage,
CoinjoinError.MinInputCountTooLow => MinInputCountTooLowMessage,
CoinjoinError.NoCoordinatorConfigured => NoCoordinatorConfiguredMessage,
_ => GeneralErrorMessage
};

Expand Down
4 changes: 2 additions & 2 deletions WalletWasabi.Fluent/Views/Wallets/MusicControlsView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@
<Button Classes="plain" IsVisible="{Binding CanNavigateToCoinjoinSettings^}">
<Button.Flyout>
<MenuFlyout Placement="Top">
<MenuItem ToolTip.Tip="{Binding FindCoordinatorLink}" Classes="hyperLinkMenuItem" Header="Find a Coordinator" Command="{Binding OpenFindCoordinatorLinkCommand}" IsVisible="{Binding NoCoordinatorConfigured}">
<MenuItem Header="Coinjoin Settings" Command="{Binding NavigateToSettingsCommand}">
<MenuItem.Icon>
<PathIcon Data="{StaticResource book_question_mark_regular}" />
<PathIcon Data="{StaticResource settings_general_regular}" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Coordinator Settings" Command="{Binding NavigateToCoordinatorSettingsCommand}">
Expand Down
4 changes: 2 additions & 2 deletions WalletWasabi.Tests/UnitTests/Bases/ConfigManagerNgTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ static string GetConfigString(string localBitcoinCoreDataDir)
"MainNetBackendUri": "https://api.wasabiwallet.io/",
"TestNetBackendUri": "https://api.wasabiwallet.co/",
"RegTestBackendUri": "http://localhost:37127/",
"MainNetCoordinatorUri": "",
"TestNetCoordinatorUri": "",
"MainNetCoordinatorUri": "https://api.wasabiwallet.io/",
"TestNetCoordinatorUri": "https://api.wasabiwallet.co/",
"RegTestCoordinatorUri": "http://localhost:37127/",
"UseTor": "Enabled",
"TerminateTorOnExit": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ public string Name
public IObservable<bool> HasBalance => throw new NotSupportedException();
public IAmountProvider AmountProvider => throw new NotSupportedException();
public IBuyAnythingModel BuyAnything => throw new NotSupportedException();

public bool IsLoggedIn { get => throw new NotSupportedException(); set => throw new NotSupportedException(); }

public bool IsLoaded { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class LiveServerTestsFixture
{
public Dictionary<Network, Uri> UriMappings { get; } = new Dictionary<Network, Uri>
{
{ Network.Main, new Uri(Constants.DefaultBackendUri) },
{ Network.TestNet, new Uri(Constants.DefaultTestnetBackendUri) }
{ Network.Main, new Uri(Constants.BackendUri) },
{ Network.TestNet, new Uri(Constants.TestnetBackendUri) }
};
}
10 changes: 2 additions & 8 deletions WalletWasabi/Helpers/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,8 @@ public static class Constants
public const string ClientSupportBackendVersionMin = "4";
public const string ClientSupportBackendVersionMax = "4";

public const string DefaultBackendUri = "https://api.wasabiwallet.io/";
public const string DefaultTestnetBackendUri = "https://api.wasabiwallet.co/";
public const string DefaultRegtestBackendUri = "http://localhost:37127/";

public const string DefaultCoordinatorUri = "";
public const string DefaultTestnetCoordinatorUri = "";
public const string DefaultRegtestCoordinatorUri = "http://localhost:37127/";

public const string BackendUri = "https://api.wasabiwallet.io/";
public const string TestnetBackendUri = "https://api.wasabiwallet.co/";
public const string BackendMajorVersion = "4";

public const string WabiSabiFallBackCoordinatorExtPubKey = "xpub6C13JhXzjAhVRgeTcRSWqKEPe1vHi3Tmh2K9PN1cZaZFVjjSaj76y5NNyqYjc2bugj64LVDFYu8NZWtJsXNYKFb9J94nehLAPAKqKiXcebC";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@

namespace WalletWasabi.WabiSabi.Backend.PostRequests;

public interface IWabiSabiStatusApiRequestHandler
{
Task<RoundStateResponse> GetStatusAsync(RoundStateRequest request, CancellationToken cancellationToken);
}

public interface IWabiSabiApiRequestHandler : IWabiSabiStatusApiRequestHandler
public interface IWabiSabiApiRequestHandler
{
Task<InputRegistrationResponse> RegisterInputAsync(InputRegistrationRequest request, CancellationToken cancellationToken);

Expand All @@ -23,13 +18,7 @@ public interface IWabiSabiApiRequestHandler : IWabiSabiStatusApiRequestHandler

Task<ReissueCredentialResponse> ReissuanceAsync(ReissueCredentialRequest request, CancellationToken cancellationToken);

Task ReadyToSignAsync(ReadyToSignRequestRequest request, CancellationToken cancellationToken);
}
Task<RoundStateResponse> GetStatusAsync(RoundStateRequest request, CancellationToken cancellationToken);

public class NullWabiSabiStatusApiRequestHandler : IWabiSabiStatusApiRequestHandler
{
public Task<RoundStateResponse> GetStatusAsync(RoundStateRequest request, CancellationToken cancellationToken)
{
return Task.FromResult(new RoundStateResponse([], []));
}
Task ReadyToSignAsync(ReadyToSignRequestRequest request, CancellationToken cancellationToken);
}
7 changes: 1 addition & 6 deletions WalletWasabi/WabiSabi/Client/Banning/CoinPrison.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace WalletWasabi.WabiSabi.Client.Banning;

public class CoinPrison(string? filePath, Dictionary<OutPoint, PrisonedCoinRecord> bannedCoins) : IDisposable
public class CoinPrison(string filePath, Dictionary<OutPoint, PrisonedCoinRecord> bannedCoins) : IDisposable
{
enum BanningStatus
{
Expand Down Expand Up @@ -48,11 +48,6 @@ public bool IsBanned(OutPoint outpoint)
}
}

public static CoinPrison CreateDummyPrison()
{
return new(null, []);
}

public static CoinPrison CreateOrLoadFromFile(string containingDirectory)
{
string prisonFilePath = Path.Combine(containingDirectory, "PrisonedCoins.json");
Expand Down
Loading

0 comments on commit 15f0384

Please sign in to comment.