Remove NewBackendTorHttpClient and add NewBackendHttpClient to HttpClientFactory.
MODIFY
WalletWasabi/Blockchain/TransactionBroadcasting/TransactionBroadcaster.cs
WalletWasabi/Blockchain/TransactionBroadcasting/TransactionBroadcaster.cs
@@ -86,9 +86,11 @@ namespace WalletWasabi.Blockchain.TransactionBroadcasting
private async Task BroadcastTransactionToBackendAsync(SmartTransaction transaction)
{
Logger.LogInfo("Broadcasting with backend...");
- using (TorHttpClient torHttpClient = Synchronizer.HttpClientFactory.NewBackendTorHttpClient(isolateStream: true))
+ IHttpClient httpClient = Synchronizer.HttpClientFactory.NewBackendHttpClient(isolateStream: true);
+
+ try
{
- var client = new WasabiClient(torHttpClient);
+ var client = new WasabiClient(httpClient);
try
{
@@ -108,6 +110,10 @@ namespace WalletWasabi.Blockchain.TransactionBroadcasting
throw;
}
}
+ finally
+ {
+ (httpClient as IDisposable)?.Dispose();
+ }
BelieveTransaction(transaction);

MODIFY
WalletWasabi/CoinJoin/Client/Clients/CoinJoinClient.cs
WalletWasabi/CoinJoin/Client/Clients/CoinJoinClient.cs
@@ -425,15 +425,20 @@ namespace WalletWasabi.CoinJoin.Client.Clients
shuffledOutputs.Shuffle();
foreach (var activeOutput in shuffledOutputs)
{
- using (TorHttpClient torHttpClient = Synchronizer.HttpClientFactory.NewBackendTorHttpClient(isolateStream: true))
+ IHttpClient httpClient = Synchronizer.HttpClientFactory.NewBackendHttpClient(isolateStream: true);
+ try
{
- var bobClient = new BobClient(torHttpClient);
+ var bobClient = new BobClient(httpClient);
if (!await bobClient.PostOutputAsync(ongoingRound.RoundId, activeOutput).ConfigureAwait(false))
{
Logger.LogWarning($"Round ({ongoingRound.State.RoundId}) Bobs did not have enough time to post outputs before timeout. If you see this message, contact nopara73, so he can optimize the phase timeout periods to the worst Internet/Tor connections, which may be yours.");
break;
}
}
+ finally
+ {
+ (httpClient as IDisposable)?.Dispose();
+ }
// Unblind our exposed links.
foreach (OutPoint input in registeredInputs)
@@ -1081,11 +1086,16 @@ namespace WalletWasabi.CoinJoin.Client.Clients
RoundStateResponse4 state;
HttpClientFactory factory = Synchronizer.HttpClientFactory;
- using (TorHttpClient torHttpClient = factory.NewBackendTorHttpClient(isolateStream: true))
+ IHttpClient satoshiHttpClient = factory.NewBackendHttpClient(isolateStream: true);
+ try
{
- var satoshiClient = new SatoshiClient(torHttpClient);
+ var satoshiClient = new SatoshiClient(satoshiHttpClient);
state = (RoundStateResponse4)await satoshiClient.GetRoundStateAsync(roundId).ConfigureAwait(false);
}
+ finally
+ {
+ (satoshiHttpClient as IDisposable)?.Dispose();
+ }
PubKey[] signerPubKeys = state.SignerPubKeys.ToArray();
PublicNonceWithIndex[] numerateNonces = state.RPubKeys.ToArray();

MODIFY
WalletWasabi/WebClients/Wasabi/HttpClientFactory.cs
WalletWasabi/WebClients/Wasabi/HttpClientFactory.cs
@@ -67,11 +67,11 @@ namespace WalletWasabi.WebClients.Wasabi
}
/// <summary>
- /// Creates new <see cref="TorHttpClient"/>.
+ /// Creates a new <see cref="IHttpClient"/> with the base URI is set to Wasabi Backend.
/// </summary>
- public TorHttpClient NewBackendTorHttpClient(bool isolateStream)
+ public IHttpClient NewBackendHttpClient(bool isolateStream)
{
- return new TorHttpClient(BackendUriGetter, TorEndpoint, isolateStream);
+ return NewHttpClient(BackendUriGetter, isolateStream);
}
// Protected implementation of Dispose pattern.

Remove NewBackendTorHttpClient and add NewBackendHttpClient to HttpClientFactory.