Fix the incompatile requests issue
MODIFY
WalletWasabi.Gui/Tabs/AboutViewModel.cs
WalletWasabi.Gui/Tabs/AboutViewModel.cs
@@ -13,6 +13,9 @@ using WalletWasabi.Logging;
using System.Reactive.Linq;
using WalletWasabi.WebClients.Wasabi;
using System.Reactive.Disposables;
+using Splat;
+using WalletWasabi.Models;
+using WalletWasabi.Services;
namespace WalletWasabi.Gui.Tabs
{
@@ -22,8 +25,6 @@ namespace WalletWasabi.Gui.Tabs
public AboutViewModel() : base("About")
{
- CurrentBackendMajorVersion = WasabiClient.CurrentBackendMajorVersion;
-
OpenBrowserCommand = ReactiveCommand.CreateFromTask<string>(IoHelpers.OpenBrowserAsync);
OpenBrowserCommand.ThrownExceptions
@@ -65,19 +66,19 @@ namespace WalletWasabi.Gui.Tabs
{
base.OnOpen(disposables);
- WasabiClient.CurrentBackendMajorVersionChanged += WasabiClient_CurrentBackendMajorVersionChanged;
+ var global = Locator.Current.GetService<Global>();
+ var hostedServices = global.HostedServices;
+
+ var updateChecker = hostedServices.FirstOrDefault<UpdateChecker>();
+ Observable.FromEventPattern<UpdateStatus>(updateChecker, nameof(updateChecker.UpdateStatusChanged))
+ .ObserveOn(RxApp.MainThreadScheduler)
+ .Subscribe(e => CurrentBackendMajorVersion = e.EventArgs.CurrentBackendApiVersion)
+ .DisposeWith(disposables);
}
public override bool OnClose()
{
- WasabiClient.CurrentBackendMajorVersionChanged -= WasabiClient_CurrentBackendMajorVersionChanged;
-
return base.OnClose();
}
-
- private void WasabiClient_CurrentBackendMajorVersionChanged(object sender, string currentBackendMajorVersion)
- {
- CurrentBackendMajorVersion = currentBackendMajorVersion;
- }
}
}

MODIFY
WalletWasabi.Tests/IntegrationTests/LiveServerTests.cs
WalletWasabi.Tests/IntegrationTests/LiveServerTests.cs
@@ -133,10 +133,12 @@ namespace WalletWasabi.Tests.IntegrationTests
var updateStatus = await client.CheckUpdatesAsync(CancellationToken.None);
var expectedVersion = new Version(2, 0);
- Assert.Equal(new UpdateStatus(true, true, expectedVersion), updateStatus);
+ var backendVersion = "3";
+ Assert.Equal(new UpdateStatus(true, true, expectedVersion, backendVersion), updateStatus);
Assert.True(updateStatus.BackendCompatible);
Assert.True(updateStatus.ClientUpToDate);
Assert.Equal(expectedVersion, updateStatus.LegalDocumentsVersion);
+ Assert.Equal(backendVersion, updateStatus.CurrentBackendApiVersion);
var versions = await client.GetVersionsAsync(CancellationToken.None);
Assert.Equal(versions.LegalDocumentsVersion, updateStatus.LegalDocumentsVersion);

MODIFY
WalletWasabi.Tests/UnitTests/Clients/WasabiClientTests.cs
WalletWasabi.Tests/UnitTests/Clients/WasabiClientTests.cs
@@ -95,22 +95,26 @@ namespace WalletWasabi.Tests.UnitTests.Clients
[Fact]
public void UpdateStatusEqualityTests()
{
- var u1 = new UpdateStatus(true, true, new Version(1, 0));
- var u2 = new UpdateStatus(true, true, new Version(1, 0));
+ var u1 = new UpdateStatus(true, true, new Version(1, 0), "3");
+ var u2 = new UpdateStatus(true, true, new Version(1, 0), "3");
Assert.Equal(u1, u2);
Assert.Equal(u1.GetHashCode(), u2.GetHashCode());
- var u3 = new UpdateStatus(false, true, new Version(1, 0));
+ var u3 = new UpdateStatus(false, true, new Version(1, 0), "3");
Assert.NotEqual(u1, u3);
Assert.NotEqual(u1.GetHashCode(), u3.GetHashCode());
- var u4 = new UpdateStatus(true, false, new Version(1, 0));
+ var u4 = new UpdateStatus(true, false, new Version(1, 0), "3");
Assert.NotEqual(u1, u4);
Assert.NotEqual(u1.GetHashCode(), u4.GetHashCode());
- var u5 = new UpdateStatus(true, true, new Version(1, 0, 1));
+ var u5 = new UpdateStatus(true, true, new Version(1, 0, 1), "3");
Assert.NotEqual(u1, u5);
Assert.NotEqual(u1.GetHashCode(), u5.GetHashCode());
+
+ var u6 = new UpdateStatus(true, true, new Version(1, 0), "4");
+ Assert.NotEqual(u1, u6);
+ Assert.NotEqual(u1.GetHashCode(), u6.GetHashCode());
}
}
}

MODIFY
WalletWasabi/CoinJoin/Client/Clients/BobClient.cs
WalletWasabi/CoinJoin/Client/Clients/BobClient.cs
@@ -30,7 +30,7 @@ namespace WalletWasabi.CoinJoin.Client.Clients
Guard.NotNull(nameof(activeOutput), activeOutput);
var request = new OutputRequest { OutputAddress = activeOutput.Address, UnblindedSignature = activeOutput.Signature, Level = activeOutput.MixingLevel };
- using var response = await TorClient.SendAsync(HttpMethod.Post, $"/api/v{WasabiClient.CurrentBackendMajorVersion}/btc/chaumiancoinjoin/output?roundId={roundId}", request.ToHttpStringContent()).ConfigureAwait(false);
+ using var response = await TorClient.SendAsync(HttpMethod.Post, $"/api/v{WasabiClient.ApiVersion}/btc/chaumiancoinjoin/output?roundId={roundId}", request.ToHttpStringContent()).ConfigureAwait(false);
if (response.StatusCode == HttpStatusCode.Conflict)
{
return false;

MODIFY
WalletWasabi/CoinJoin/Client/Clients/SatoshiClient.cs
WalletWasabi/CoinJoin/Client/Clients/SatoshiClient.cs
@@ -24,7 +24,7 @@ namespace WalletWasabi.CoinJoin.Client.Clients
public async Task<IEnumerable<RoundStateResponseBase>> GetAllRoundStatesAsync()
{
- using var response = await TorClient.SendAsync(HttpMethod.Get, $"/api/v{WasabiClient.CurrentBackendMajorVersion}/btc/chaumiancoinjoin/states/").ConfigureAwait(false);
+ using var response = await TorClient.SendAsync(HttpMethod.Get, $"/api/v{WasabiClient.ApiVersion}/btc/chaumiancoinjoin/states/").ConfigureAwait(false);
if (response.StatusCode != HttpStatusCode.OK)
{
await response.ThrowRequestExceptionFromContentAsync().ConfigureAwait(false);

MODIFY
WalletWasabi/Extensions/HttpContentExtensions.cs
WalletWasabi/Extensions/HttpContentExtensions.cs
@@ -15,8 +15,9 @@ namespace System.Net.Http
return default;
}
- var settings = new JsonSerializerSettings{
- Converters = new [] { new RoundStateResponseJsonConverter(WasabiClient.CurrentBackendMajorVersion) }
+ var settings = new JsonSerializerSettings
+ {
+ Converters = new[] { new RoundStateResponseJsonConverter(WasabiClient.ApiVersion) }
};
var jsonString = await me.ReadAsStringAsync();
return JsonConvert.DeserializeObject<T>(jsonString, settings);

MODIFY
WalletWasabi/Models/UpdateStatus.cs
WalletWasabi/Models/UpdateStatus.cs
@@ -6,17 +6,19 @@ namespace WalletWasabi.Models
{
public class UpdateStatus : IEquatable<UpdateStatus>
{
- public UpdateStatus(bool backendCompatible, bool clientUpToDate, Version legalDocumentsVersion)
+ public UpdateStatus(bool backendCompatible, bool clientUpToDate, Version legalDocumentsVersion, string currentBackendApiVersion)
{
BackendCompatible = backendCompatible;
ClientUpToDate = clientUpToDate;
LegalDocumentsVersion = legalDocumentsVersion;
+ CurrentBackendApiVersion = currentBackendApiVersion;
}
public bool ClientUpToDate { get; private set; }
public bool BackendCompatible { get; private set; }
public Version LegalDocumentsVersion { get; private set; }
+ public string CurrentBackendApiVersion { get; private set; }
#region EqualityAndComparison

MODIFY
WalletWasabi/Services/UpdateChecker.cs
WalletWasabi/Services/UpdateChecker.cs
@@ -19,7 +19,7 @@ namespace WalletWasabi.Services
{
Synchronizer = Guard.NotNull(nameof(synchronizer), synchronizer);
WasabiClient = synchronizer.WasabiClient;
- UpdateStatus = new UpdateStatus(true, true, new Version());
+ UpdateStatus = new UpdateStatus(true, true, new Version(), null);
Synchronizer.PropertyChanged += Synchronizer_PropertyChanged;
}

MODIFY
WalletWasabi/Wallets/Wallet.cs
WalletWasabi/Wallets/Wallet.cs
@@ -127,7 +127,7 @@ namespace WalletWasabi.Wallets
ServiceConfiguration = Guard.NotNull(nameof(serviceConfiguration), serviceConfiguration);
FeeProvider = Guard.NotNull(nameof(feeProvider), feeProvider);
- if (WasabiClient.CurrentBackendMajorVersion == "3")
+ if (WasabiClient.ApiVersion == "3")
{
ChaumianClient = new CoinJoinClient(Synchronizer, Network, KeyManager);
}

MODIFY
WalletWasabi/WebClients/Wasabi/WasabiClient.cs
WalletWasabi/WebClients/Wasabi/WasabiClient.cs
@@ -35,13 +35,10 @@ namespace WalletWasabi.WebClients.Wasabi
{
}
- public static event EventHandler<string> CurrentBackendMajorVersionChanged;
-
public static Dictionary<uint256, Transaction> TransactionCache { get; } = new Dictionary<uint256, Transaction>();
private static Queue<uint256> TransactionIdQueue { get; } = new Queue<uint256>();
public static object TransactionCacheLock { get; } = new object();
-
- public static string CurrentBackendMajorVersion { get; private set; } = Constants.BackendMajorVersion;
+ public static string ApiVersion { get; private set; } = Constants.BackendMajorVersion;
#region batch
@@ -50,7 +47,7 @@ namespace WalletWasabi.WebClients.Wasabi
/// </remarks>
public async Task<SynchronizeResponse> GetSynchronizeAsync(uint256 bestKnownBlockHash, int count, EstimateSmartFeeMode? estimateMode = null, CancellationToken cancel = default)
{
- string relativeUri = $"/api/v{CurrentBackendMajorVersion}/btc/batch/synchronize?bestKnownBlockHash={bestKnownBlockHash}&maxNumberOfFilters={count}";
+ string relativeUri = $"/api/v{ApiVersion}/btc/batch/synchronize?bestKnownBlockHash={bestKnownBlockHash}&maxNumberOfFilters={count}";
if (estimateMode != null)
{
relativeUri = $"{relativeUri}&estimateSmartFeeMode={estimateMode}";
@@ -79,7 +76,7 @@ namespace WalletWasabi.WebClients.Wasabi
using var response = await TorClient.SendAndRetryAsync(
HttpMethod.Get,
HttpStatusCode.OK,
- $"/api/v{CurrentBackendMajorVersion}/btc/blockchain/filters?bestKnownBlockHash={bestKnownBlockHash}&count={count}",
+ $"/api/v{ApiVersion}/btc/blockchain/filters?bestKnownBlockHash={bestKnownBlockHash}&count={count}",
cancel: cancel);
if (response.StatusCode == HttpStatusCode.NoContent)
{
@@ -113,7 +110,7 @@ namespace WalletWasabi.WebClients.Wasabi
using var response = await TorClient.SendAndRetryAsync(
HttpMethod.Get,
HttpStatusCode.OK,
- $"/api/v{CurrentBackendMajorVersion}/btc/blockchain/transaction-hexes?&transactionIds={string.Join("&transactionIds=", chunk.Select(x => x.ToString()))}",
+ $"/api/v{ApiVersion}/btc/blockchain/transaction-hexes?&transactionIds={string.Join("&transactionIds=", chunk.Select(x => x.ToString()))}",
cancel: cancel);
if (response.StatusCode != HttpStatusCode.OK)
{
@@ -150,7 +147,7 @@ namespace WalletWasabi.WebClients.Wasabi
{
var confirmationTargetsString = string.Join(",", confirmationTargets);
- using var response = await TorClient.SendAndRetryAsync(HttpMethod.Get, HttpStatusCode.OK, $"/api/v{CurrentBackendMajorVersion}/btc/blockchain/fees/{confirmationTargetsString}");
+ using var response = await TorClient.SendAndRetryAsync(HttpMethod.Get, HttpStatusCode.OK, $"/api/v{ApiVersion}/btc/blockchain/fees/{confirmationTargetsString}");
if (response.StatusCode != HttpStatusCode.OK)
{
await response.ThrowRequestExceptionFromContentAsync();
@@ -164,7 +161,7 @@ namespace WalletWasabi.WebClients.Wasabi
public async Task BroadcastAsync(string hex)
{
using var content = new StringContent($"'{hex}'", Encoding.UTF8, "application/json");
- using var response = await TorClient.SendAsync(HttpMethod.Post, $"/api/v{CurrentBackendMajorVersion}/btc/blockchain/broadcast", content);
+ using var response = await TorClient.SendAsync(HttpMethod.Post, $"/api/v{ApiVersion}/btc/blockchain/broadcast", content);
if (response.StatusCode != HttpStatusCode.OK)
{
await response.ThrowRequestExceptionFromContentAsync();
@@ -186,7 +183,7 @@ namespace WalletWasabi.WebClients.Wasabi
using var response = await TorClient.SendAndRetryAsync(
HttpMethod.Get,
HttpStatusCode.OK,
- $"/api/v{CurrentBackendMajorVersion}/btc/blockchain/mempool-hashes",
+ $"/api/v{ApiVersion}/btc/blockchain/mempool-hashes",
cancel: cancel);
if (response.StatusCode != HttpStatusCode.OK)
{
@@ -208,7 +205,7 @@ namespace WalletWasabi.WebClients.Wasabi
using var response = await TorClient.SendAndRetryAsync(
HttpMethod.Get,
HttpStatusCode.OK,
- $"/api/v{CurrentBackendMajorVersion}/btc/blockchain/mempool-hashes?compactness={compactness}",
+ $"/api/v{ApiVersion}/btc/blockchain/mempool-hashes?compactness={compactness}",
cancel: cancel);
if (response.StatusCode != HttpStatusCode.OK)
{
@@ -226,7 +223,7 @@ namespace WalletWasabi.WebClients.Wasabi
public async Task<IEnumerable<ExchangeRate>> GetExchangeRatesAsync()
{
- using var response = await TorClient.SendAndRetryAsync(HttpMethod.Get, HttpStatusCode.OK, $"/api/v{CurrentBackendMajorVersion}/btc/offchain/exchange-rates");
+ using var response = await TorClient.SendAndRetryAsync(HttpMethod.Get, HttpStatusCode.OK, $"/api/v{ApiVersion}/btc/offchain/exchange-rates");
if (response.StatusCode != HttpStatusCode.OK)
{
await response.ThrowRequestExceptionFromContentAsync();
@@ -261,14 +258,15 @@ namespace WalletWasabi.WebClients.Wasabi
var versions = await GetVersionsAsync(cancel);
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.ClientSupportBackendVersionMax) >= versions.BackendMajorVersion && versions.BackendMajorVersion >= int.Parse(Constants.ClientSupportBackendVersionMin); // If ClientSupportBackendVersionMin <= backend major <= ClientSupportBackendVersionMax, then our software is compatible.
- var currentBackendMajorVersion = versions.BackendMajorVersion.ToString();
- if (CurrentBackendMajorVersion != currentBackendMajorVersion)
+ var currentApiVersion = versions.BackendMajorVersion.ToString();
+
+ if (backendCompatible)
{
- CurrentBackendMajorVersion = currentBackendMajorVersion;
- CurrentBackendMajorVersionChanged?.Invoke(this, CurrentBackendMajorVersion);
+ // Only refresh if compatible.
+ ApiVersion = currentApiVersion;
}
- return new UpdateStatus(backendCompatible, clientUpToDate, versions.LegalDocumentsVersion);
+ return new UpdateStatus(backendCompatible, clientUpToDate, versions.LegalDocumentsVersion, currentApiVersion);
}
#endregion software
@@ -280,7 +278,7 @@ namespace WalletWasabi.WebClients.Wasabi
using var response = await TorClient.SendAndRetryAsync(
HttpMethod.Get,
HttpStatusCode.OK,
- $"/api/v{CurrentBackendMajorVersion}/wasabi/legaldocuments",
+ $"/api/v{ApiVersion}/wasabi/legaldocuments",
cancel: cancel).ConfigureAwait(false);
if (response.StatusCode != HttpStatusCode.OK)
{

Fix the incompatile requests issue