Created client class for the non-tumbler related HTTP queries
MODIFY
WalletWasabi.Tests/P2pTests.cs
WalletWasabi.Tests/P2pTests.cs
@@ -16,6 +16,7 @@ using WalletWasabi.Models;
using WalletWasabi.Services;
using WalletWasabi.Tests.NodeBuilding;
using WalletWasabi.Tests.XunitConfiguration;
+using WalletWasabi.WebClients.ChaumianCoinJoin;
using Xunit;
namespace WalletWasabi.Tests
@@ -89,13 +90,15 @@ namespace WalletWasabi.Tests
});
KeyManager keyManager = KeyManager.CreateNew(out _, "password");
+ WasabiClient wasabiClient = new WasabiClient(new Uri("http://localhost:1337"));
WalletService walletService = new WalletService(
keyManager,
new IndexDownloader(network, Path.Combine(SharedFixture.DataDir, nameof(TestServicesAsync), "IndexDownloader.txt"), new Uri("http://localhost:12345")),
new CcjClient(network, new BlindingRsaKey().PubKey, keyManager, new Uri("http://localhost:12345")),
memPoolService,
nodes,
- blocksFolderPath);
+ blocksFolderPath,
+ wasabiClient);
Assert.True(Directory.Exists(blocksFolderPath));
try

MODIFY
WalletWasabi.Tests/RegTests.cs
WalletWasabi.Tests/RegTests.cs
@@ -445,7 +445,8 @@ namespace WalletWasabi.Tests
// 5. Create wallet service.
var blocksFolderPath = Path.Combine(SharedFixture.DataDir, nameof(WalletTestsAsync), $"Blocks");
- var wallet = new WalletService(keyManager, indexDownloader, chaumianClient, memPoolService, nodes, blocksFolderPath);
+ WasabiClient wasabiClient = new WasabiClient(new Uri(RegTestFixture.BackendEndPoint));
+ var wallet = new WalletService(keyManager, indexDownloader, chaumianClient, memPoolService, nodes, blocksFolderPath, wasabiClient);
wallet.NewFilterProcessed += Wallet_NewFilterProcessed;
// Get some money, make it confirm.
@@ -678,7 +679,8 @@ namespace WalletWasabi.Tests
// 6. Create wallet service.
var blocksFolderPath = Path.Combine(SharedFixture.DataDir, nameof(SendTestsFromHiddenWalletAsync), $"Blocks");
- var wallet = new WalletService(keyManager, indexDownloader, chaumianClient, memPoolService, nodes, blocksFolderPath);
+ WasabiClient wasabiClient = new WasabiClient(new Uri(RegTestFixture.BackendEndPoint));
+ var wallet = new WalletService(keyManager, indexDownloader, chaumianClient, memPoolService, nodes, blocksFolderPath, wasabiClient);
wallet.NewFilterProcessed += Wallet_NewFilterProcessed;
// Get some money, make it confirm.
@@ -1120,7 +1122,8 @@ namespace WalletWasabi.Tests
// 6. Create wallet service.
var blocksFolderPath = Path.Combine(SharedFixture.DataDir, nameof(SendTestsFromHiddenWalletAsync), $"Blocks");
- var wallet = new WalletService(keyManager, indexDownloader, chaumianClient, memPoolService, nodes, blocksFolderPath);
+ WasabiClient wasabiClient = new WasabiClient(new Uri(RegTestFixture.BackendEndPoint));
+ var wallet = new WalletService(keyManager, indexDownloader, chaumianClient, memPoolService, nodes, blocksFolderPath, wasabiClient);
wallet.NewFilterProcessed += Wallet_NewFilterProcessed;
var scp = new Key().ScriptPubKey;
@@ -1300,7 +1303,8 @@ namespace WalletWasabi.Tests
// 6. Create wallet service.
var blocksFolderPath = Path.Combine(SharedFixture.DataDir, nameof(SendTestsFromHiddenWalletAsync), $"Blocks");
- var wallet = new WalletService(keyManager, indexDownloader, chaumianClient, memPoolService, nodes, blocksFolderPath);
+ WasabiClient wasabiClient = new WasabiClient(new Uri(RegTestFixture.BackendEndPoint));
+ var wallet = new WalletService(keyManager, indexDownloader, chaumianClient, memPoolService, nodes, blocksFolderPath, wasabiClient);
wallet.NewFilterProcessed += Wallet_NewFilterProcessed;
Assert.Empty(wallet.Coins);
@@ -1473,7 +1477,8 @@ namespace WalletWasabi.Tests
// 6. Create wallet service.
var blocksFolderPath = Path.Combine(SharedFixture.DataDir, nameof(SendTestsFromHiddenWalletAsync), $"Blocks");
- var wallet = new WalletService(keyManager, indexDownloader, chaumianClient, memPoolService, nodes, blocksFolderPath);
+ WasabiClient wasabiClient = new WasabiClient(new Uri(RegTestFixture.BackendEndPoint));
+ var wallet = new WalletService(keyManager, indexDownloader, chaumianClient, memPoolService, nodes, blocksFolderPath, wasabiClient);
wallet.NewFilterProcessed += Wallet_NewFilterProcessed;
Assert.Empty(wallet.Coins);
@@ -2585,11 +2590,13 @@ namespace WalletWasabi.Tests
// 6. Create wallet service.
var blocksFolderPath = Path.Combine(SharedFixture.DataDir, nameof(CoinJoinMultipleRoundTestsAsync), $"Blocks");
- var wallet = new WalletService(keyManager, indexDownloader, chaumianClient, memPoolService, nodes, blocksFolderPath);
+ WasabiClient wasabiClient = new WasabiClient(new Uri(RegTestFixture.BackendEndPoint));
+ var wallet = new WalletService(keyManager, indexDownloader, chaumianClient, memPoolService, nodes, blocksFolderPath, wasabiClient);
wallet.NewFilterProcessed += Wallet_NewFilterProcessed;
var blocksFolderPath2 = Path.Combine(SharedFixture.DataDir, nameof(CoinJoinMultipleRoundTestsAsync), $"Blocks2");
- var wallet2 = new WalletService(keyManager2, indexDownloader2, chaumianClient2, memPoolService2, nodes2, blocksFolderPath2);
+ WasabiClient wasabiClient2 = new WasabiClient(new Uri(RegTestFixture.BackendEndPoint));
+ var wallet2 = new WalletService(keyManager2, indexDownloader2, chaumianClient2, memPoolService2, nodes2, blocksFolderPath2, wasabiClient2);
// Get some money, make it confirm.
var key = wallet.GetReceiveKey("fundZeroLink");

MODIFY
WalletWasabi/Services/WalletService.cs
WalletWasabi/Services/WalletService.cs
@@ -19,6 +19,7 @@ using NBitcoin;
using NBitcoin.Policy;
using NBitcoin.Protocol;
using Nito.AsyncEx;
+using WalletWasabi.WebClients.ChaumianCoinJoin;
namespace WalletWasabi.Services
{
@@ -27,6 +28,7 @@ namespace WalletWasabi.Services
public KeyManager KeyManager { get; }
public IndexDownloader IndexDownloader { get; }
public CcjClient ChaumianClient { get; }
+ public WasabiClient WasabiClient { get; }
public MemPoolService MemPool { get; }
public NodesGroup Nodes { get; }
@@ -52,12 +54,13 @@ namespace WalletWasabi.Services
public bool IsRunning => Interlocked.Read(ref _running) == 1;
public bool IsStopping => Interlocked.Read(ref _running) == 2;
- public WalletService(KeyManager keyManager, IndexDownloader indexDownloader, CcjClient chaumianClient, MemPoolService memPool, NodesGroup nodes, string blocksFolderPath)
+ public WalletService(KeyManager keyManager, IndexDownloader indexDownloader, CcjClient chaumianClient, MemPoolService memPool, NodesGroup nodes, string blocksFolderPath, WasabiClient wasabiClient)
{
KeyManager = Guard.NotNull(nameof(keyManager), keyManager);
Nodes = Guard.NotNull(nameof(nodes), nodes);
IndexDownloader = Guard.NotNull(nameof(indexDownloader), indexDownloader);
ChaumianClient = Guard.NotNull(nameof(chaumianClient), chaumianClient);
+ WasabiClient = Guard.NotNull(nameof(wasabiClient), wasabiClient);
MemPool = Guard.NotNull(nameof(memPool), memPool);
WalletBlocks = new SortedDictionary<Height, uint256>();
@@ -610,19 +613,7 @@ namespace WalletWasabi.Services
// 4. Get and calculate fee
Logger.LogInfo<WalletService>("Calculating dynamic transaction fee...");
- Money feePerBytes = null;
- using (var torClient = new TorHttpClient(IndexDownloader.Client.DestinationUri, IndexDownloader.Client.TorSocks5EndPoint, isolateStream: true))
- using (var response = await torClient.SendAndRetryAsync(HttpMethod.Get, HttpStatusCode.OK, $"/api/v1/btc/blockchain/fees/{feeTarget}"))
- {
- if (response.StatusCode != HttpStatusCode.OK)
- throw new HttpRequestException($"Couldn't query network fees. Reason: {response.StatusCode.ToReasonString()}");
-
- using (var content = response.Content)
- {
- var json = await content.ReadAsJsonAsync<SortedDictionary<int, FeeEstimationPair>>();
- feePerBytes = new Money(json.Single().Value.Conservative);
- }
- }
+ Money feePerBytes = await WasabiClient.GetAndCalculateFeesAsync(feeTarget);
bool spendAll = spendAllCount == 1;
int inNum;

Created client class for the non-tumbler related HTTP queries