Moved transaction broadcasting logic to BroadcastTransactionAsync
MODIFY
WalletWasabi/Services/WalletService.cs
WalletWasabi/Services/WalletService.cs
@@ -823,19 +823,7 @@ namespace WalletWasabi.Services
public async Task SendTransactionAsync(SmartTransaction transaction)
{
- using (var torClient = new TorHttpClient(IndexDownloader.Client.DestinationUri, IndexDownloader.Client.TorSocks5EndPoint, isolateStream: true))
- using (var content = new StringContent($"'{transaction.Transaction.ToHex()}'", Encoding.UTF8, "application/json"))
- using (var response = await torClient.SendAsync(HttpMethod.Post, "/api/v1/btc/blockchain/broadcast", content))
- {
- if (response.StatusCode == HttpStatusCode.BadRequest)
- {
- throw new HttpRequestException($"Couldn't broadcast transaction. Reason: {await response.Content.ReadAsStringAsync()}");
- }
- if (response.StatusCode != HttpStatusCode.OK) // Try again.
- {
- throw new HttpRequestException($"Couldn't broadcast transaction. Reason: {response.StatusCode.ToReasonString()}");
- }
- }
+ await WasabiClient.BroadcastTransactionAsync(transaction);
ProcessTransaction(new SmartTransaction(transaction.Transaction, Height.MemPool));

MODIFY
WalletWasabi/WebClients/ChaumianCoinJoin/WasabiClient.cs
WalletWasabi/WebClients/ChaumianCoinJoin/WasabiClient.cs
@@ -9,6 +9,8 @@ using WalletWasabi.Backend.Models;
using WalletWasabi.Services;
using WalletWasabi.TorSocks5;
using WalletWasabi.Bases;
+using WalletWasabi.Models;
+using System.Text;
namespace WalletWasabi.WebClients.ChaumianCoinJoin
{
@@ -36,5 +38,21 @@ namespace WalletWasabi.WebClients.ChaumianCoinJoin
}
}
}
+
+ public async Task BroadcastTransactionAsync(SmartTransaction transaction)
+ {
+ using (var content = new StringContent($"'{transaction.Transaction.ToHex()}'", Encoding.UTF8, "application/json"))
+ using (var response = await TorClient.SendAsync(HttpMethod.Post, "/api/v1/btc/blockchain/broadcast", content))
+ {
+ if (response.StatusCode == HttpStatusCode.BadRequest)
+ {
+ throw new HttpRequestException($"Couldn't broadcast transaction. Reason: {await response.Content.ReadAsStringAsync()}");
+ }
+ if (response.StatusCode != HttpStatusCode.OK) // Try again.
+ {
+ throw new HttpRequestException($"Couldn't broadcast transaction. Reason: {response.StatusCode.ToReasonString()}");
+ }
+ }
+ }
}
}

Moved transaction broadcasting logic to BroadcastTransactionAsync