use TorHttpClient instead of HttpClient
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
@@ -86,11 +86,8 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
Uri.IsWellFormedUriString(PayjoinEndPoint, UriKind.Absolute))
{
var payjoinEndPointUri = new Uri(PayjoinEndPoint);
- if (Global.Config.UseTor)
+ if (!Global.Config.UseTor)
{
- return new PayjoinClient(payjoinEndPointUri, Global.TorManager.TorSocks5EndPoint);
- }
-
if (payjoinEndPointUri.DnsSafeHost.EndsWith(".onion", StringComparison.OrdinalIgnoreCase))
{
Logger.LogWarning("Payjoin server is a hidden service but Tor is disabled. Ignoring...");
@@ -102,18 +99,9 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
Logger.LogWarning("Payjoin server is not using https. Ignoring...");
return null;
}
-
- // TODO: Use an IHttpClientFactory to construct the HttpClient
- if (Global.Config.Network == Network.RegTest)
- {
- HttpClientHandler clientHandler = new HttpClientHandler();
- clientHandler.ServerCertificateCustomValidationCallback =
- (sender, cert, chain, sslPolicyErrors) => true;
-
- return new PayjoinClient(payjoinEndPointUri, new HttpClient(clientHandler));
}
- return new PayjoinClient(payjoinEndPointUri, new HttpClient());
+ return new PayjoinClient(payjoinEndPointUri, Global.TorManager.TorSocks5EndPoint);
}
return null;

MODIFY
WalletWasabi/WebClients/PayJoin/PayjoinClient.cs
WalletWasabi/WebClients/PayJoin/PayjoinClient.cs
@@ -23,12 +23,6 @@ namespace WalletWasabi.WebClients.PayJoin
TorHttpClient = new TorHttpClient(PaymentUrl, TorSocks5EndPoint);
}
- public PayjoinClient(Uri paymentUrl, HttpClient httpClient)
- {
- PaymentUrl = Guard.NotNull(nameof(paymentUrl), paymentUrl);
- ClearnetHttpClient = Guard.NotNull(nameof(httpClient), httpClient);
- }
-
// For testing only
internal PayjoinClient(ITorHttpClient httpClient)
{
@@ -38,7 +32,6 @@ namespace WalletWasabi.WebClients.PayJoin
public Uri PaymentUrl { get; }
private EndPoint TorSocks5EndPoint { get; }
private ITorHttpClient TorHttpClient { get; }
- private HttpClient ClearnetHttpClient { get; }
public async Task<PSBT> RequestPayjoin(PSBT originalTx, IHDKey accountKey, RootedKeyPath rootedKeyPath, CancellationToken cancellationToken)
{
@@ -81,23 +74,7 @@ namespace WalletWasabi.WebClients.PayJoin
Content = new StringContent(cloned.ToHex(), Encoding.UTF8, "text/plain")
};
- HttpResponseMessage bpuResponse = null;
- if (TorHttpClient is null)
- {
- if (ClearnetHttpClient is null)
- {
- throw new NullReferenceException(
- "A Tor HttpClient OR a clearnet HttpClient needs to be provided to the Payjoin client");
- }
- else
- {
- bpuResponse = await ClearnetHttpClient.SendAsync(request, cancellationToken).ConfigureAwait(false);
- }
- }
- else
- {
- bpuResponse = await TorHttpClient.SendAsync(request, cancellationToken).ConfigureAwait(false);
- }
+ HttpResponseMessage bpuResponse = await TorHttpClient.SendAsync(request, cancellationToken).ConfigureAwait(false);
if (!bpuResponse.IsSuccessStatusCode)
{

use TorHttpClient instead of HttpClient