Implement connection between client and server.
MODIFY
WalletWasabi/Models/UpdateStatus.cs
WalletWasabi/Models/UpdateStatus.cs
@@ -6,24 +6,28 @@ namespace WalletWasabi.Models
{
public class UpdateStatus : IEquatable<UpdateStatus>
{
- public UpdateStatus(bool backendCompatible, bool clientUpToDate)
+ public UpdateStatus(bool backendCompatible, bool clientUpToDate, Version legalDocumentsVersion)
{
BackendCompatible = backendCompatible;
ClientUpToDate = clientUpToDate;
+ LegalDocumentsVersion = legalDocumentsVersion;
}
public bool ClientUpToDate { get; private set; }
public bool BackendCompatible { get; private set; }
+ public Version LegalDocumentsVersion { get; private set; }
+
#region EqualityAndComparison
public override bool Equals(object obj) => Equals(obj as UpdateStatus);
public bool Equals(UpdateStatus other) => this == other;
- public override int GetHashCode() => (ClientUpToDate, BackendCompatible).GetHashCode();
+ public override int GetHashCode() => (ClientUpToDate, BackendCompatible, LegalDocumentsVersion).GetHashCode();
- public static bool operator ==(UpdateStatus x, UpdateStatus y) => y?.ClientUpToDate == x?.ClientUpToDate && y?.BackendCompatible == x?.BackendCompatible;
+ public static bool operator ==(UpdateStatus x, UpdateStatus y)
+ => (x?.ClientUpToDate, x?.BackendCompatible, x?.LegalDocumentsVersion) == (y?.ClientUpToDate, y?.BackendCompatible, y?.LegalDocumentsVersion);
public static bool operator !=(UpdateStatus x, UpdateStatus y) => !(x == y);

MODIFY
WalletWasabi/Services/UpdateChecker.cs
WalletWasabi/Services/UpdateChecker.cs
@@ -18,7 +18,7 @@ namespace WalletWasabi.Services
public UpdateChecker(TimeSpan period, WasabiClient client) : base(period)
{
WasabiClient = Guard.NotNull(nameof(client), client);
- UpdateStatus = new UpdateStatus(true, true);
+ UpdateStatus = new UpdateStatus(true, true, new Version());
}
public event EventHandler<UpdateStatus> UpdateStatusChanged;

MODIFY
WalletWasabi/WebClients/Wasabi/WasabiClient.cs
WalletWasabi/WebClients/Wasabi/WasabiClient.cs
@@ -237,14 +237,9 @@ namespace WalletWasabi.WebClients.Wasabi
#region software
- public async Task<(Version ClientVersion, int BackendMajorVersion)> GetVersionsAsync(CancellationToken cancel)
+ public async Task<(Version ClientVersion, int BackendMajorVersion, Version LegalDocumentsVersion)> GetVersionsAsync(CancellationToken cancel)
{
using var response = await TorClient.SendAndRetryAsync(HttpMethod.Get, HttpStatusCode.OK, "/api/software/versions", cancel: cancel);
- if (response.StatusCode == HttpStatusCode.NotFound)
- {
- // Meaning this things was not just yet implemented on the running server.
- return (new Version(0, 7), 1);
- }
if (response.StatusCode != HttpStatusCode.OK)
{
@@ -253,7 +248,8 @@ namespace WalletWasabi.WebClients.Wasabi
using HttpContent content = response.Content;
var resp = await content.ReadAsJsonAsync<VersionsResponse>();
- return (Version.Parse(resp.ClientVersion), int.Parse(resp.BackendMajorVersion));
+
+ return (Version.Parse(resp.ClientVersion), int.Parse(resp.BackendMajorVersion), Version.Parse(resp.LegalDocumentsVersion));
}
public async Task<UpdateStatus> CheckUpdatesAsync(CancellationToken cancel)
@@ -262,9 +258,30 @@ namespace WalletWasabi.WebClients.Wasabi
var clientUpToDate = Constants.ClientVersion >= versions.ClientVersion; // If the client version locally is greater than or equal to the backend's reported client version, then good.
var backendCompatible = int.Parse(Constants.BackendMajorVersion) == versions.BackendMajorVersion; // If the backend major and the client major are equal, then our software is compatible.
- return new UpdateStatus(backendCompatible, clientUpToDate);
+ return new UpdateStatus(backendCompatible, clientUpToDate, versions.LegalDocumentsVersion);
}
#endregion software
+
+ #region wasabi
+
+ public async Task<string> GetLegalDocumentsAsync(CancellationToken cancel)
+ {
+ using var response = await TorClient.SendAndRetryAsync(
+ HttpMethod.Get,
+ HttpStatusCode.OK,
+ $"/api/v{Constants.BackendMajorVersion}/wasabi/legaldocuments",
+ cancel: cancel).ConfigureAwait(false);
+ if (response.StatusCode != HttpStatusCode.OK)
+ {
+ await response.ThrowRequestExceptionFromContentAsync();
+ }
+
+ using HttpContent content = response.Content;
+ var ret = await content.ReadAsStringAsync().ConfigureAwait(false);
+ return ret;
+ }
+
+ #endregion wasabi
}
}

Implement connection between client and server.