Remove a bunch of dead code.
MODIFY
WalletWasabi.Backend/Controllers/BatchController.cs
WalletWasabi.Backend/Controllers/BatchController.cs
@@ -9,6 +9,7 @@ using System.Threading.Tasks;
using WalletWasabi.Backend.Models;
using WalletWasabi.Backend.Models.Responses;
using WalletWasabi.Helpers;
+using WalletWasabi.Logging;
using WalletWasabi.Models;
namespace WalletWasabi.Backend.Controllers
@@ -79,9 +80,16 @@ namespace WalletWasabi.Backend.Controllers
response.CcjRoundStates = ChaumianCoinJoinController.GetStatesCollection();
if (estimateSmartFee)
+ {
+ try
{
response.AllFeeEstimate = await BlockchainController.GetAllFeeEstimateAsync(mode);
}
+ catch (Exception ex)
+ {
+ Logger.LogError(ex);
+ }
+ }
response.ExchangeRates = await OffchainController.GetExchangeRatesCollectionAsync();

MODIFY
WalletWasabi.Backend/Controllers/BlockchainController.cs
WalletWasabi.Backend/Controllers/BlockchainController.cs
@@ -41,74 +41,6 @@ namespace WalletWasabi.Backend.Controllers
public IMemoryCache Cache { get; }
public Global Global { get; }
- /// <summary>
- /// Get fees for the requested confirmation targets based on Bitcoin Core's estimatesmartfee output.
- /// </summary>
- /// <remarks>
- /// Sample request:
- ///
- /// GET /fees/2,144,1008
- ///
- /// </remarks>
- /// <param name="confirmationTargets">Confirmation targets in blocks wit comma separation. (2 - 1008)</param>
- /// <returns>Array of fee estimations for the requested confirmation targets. A fee estimation contains estimation mode (Conservative/Economical) and byte per satoshi pairs.</returns>
- /// <response code="200">Returns array of fee estimations for the requested confirmation targets.</response>
- /// <response code="400">If invalid conformation targets were provided. (2 - 1008 integers)</response>
- [HttpGet("fees/{confirmationTargets}")]
- [ProducesResponseType(200)] // Note: If you add typeof(SortedDictionary<int, FeeEstimationPair>) then swagger UI will visualize incorrectly.
- [ProducesResponseType(400)]
- [ResponseCache(Duration = 300, Location = ResponseCacheLocation.Client)]
- public async Task<IActionResult> GetFeesAsync(string confirmationTargets)
- {
- if (string.IsNullOrWhiteSpace(confirmationTargets) || !ModelState.IsValid)
- {
- return BadRequest($"Invalid {nameof(confirmationTargets)} are provided.");
- }
-
- var confirmationTargetsInts = new HashSet<int>();
- foreach (var targetParam in confirmationTargets.Split(',', StringSplitOptions.RemoveEmptyEntries))
- {
- if (int.TryParse(targetParam, out var target))
- {
- if (target < 2 || target > Constants.SevenDaysConfirmationTarget)
- {
- return BadRequest($"All requested confirmation target must be >= 2 AND <= {Constants.SevenDaysConfirmationTarget}.");
- }
-
- if (confirmationTargetsInts.Contains(target))
- {
- continue;
- }
-
- confirmationTargetsInts.Add(target);
- }
- else
- {
- return BadRequest($"Invalid {nameof(confirmationTargets)} are provided.");
- }
- }
-
- var feeEstimations = new SortedDictionary<int, FeeEstimationPair>();
-
- foreach (int target in confirmationTargetsInts)
- {
- // 1. Use the sanity check that under 2 satoshi per byte should not be displayed. To correct possible rounding errors.
- // 2. Use the RPCResponse.Blocks output to avoid redundant RPC queries.
- // 3. Use caching.
- var conservativeResponse = await GetEstimateSmartFeeAsync(target, EstimateSmartFeeMode.Conservative);
- var economicalResponse = await GetEstimateSmartFeeAsync(target, EstimateSmartFeeMode.Economical);
- var conservativeFee = conservativeResponse.FeeRate.FeePerK.Satoshi / 1000;
- var economicalFee = economicalResponse.FeeRate.FeePerK.Satoshi / 1000;
-
- conservativeFee = Math.Max(conservativeFee, 2);
- economicalFee = Math.Max(economicalFee, 2);
-
- feeEstimations.Add(target, new FeeEstimationPair() { Conservative = conservativeFee, Economical = economicalFee });
- }
-
- return Ok(feeEstimations);
- }
-
/// <summary>
/// Get all fees.
/// </summary>
@@ -399,17 +331,6 @@ namespace WalletWasabi.Backend.Controllers
return Ok(response);
}
- private async Task<EstimateSmartFeeResponse> GetEstimateSmartFeeAsync(int target, EstimateSmartFeeMode mode)
- {
- var cacheKey = $"{nameof(GetEstimateSmartFeeAsync)}_{target}_{mode}";
- var cacheOptions = new MemoryCacheEntryOptions { AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(60) };
-
- return await Cache.AtomicGetOrCreateAsync(
- cacheKey,
- cacheOptions,
- () => RpcClient.EstimateSmartFeeAsync(target, mode, simulateIfRegTest: true, tryOtherFeeRates: true));
- }
-
[HttpGet("status")]
[ProducesResponseType(typeof(StatusResponse), 200)]
public async Task<StatusResponse> GetStatusAsync()

MODIFY
WalletWasabi.Backend/Global.cs
WalletWasabi.Backend/Global.cs
@@ -131,14 +131,6 @@ namespace WalletWasabi.Backend
Logger.LogInfo($"{Constants.BuiltinBitcoinNodeName} is fully synchronized.");
- var estimateSmartFeeResponse = await RpcClient.TryEstimateSmartFeeAsync(2, EstimateSmartFeeMode.Conservative, simulateIfRegTest: true, tryOtherFeeRates: true);
- if (estimateSmartFeeResponse is null)
- {
- throw new NotSupportedException($"{Constants.BuiltinBitcoinNodeName} cannot estimate network fees yet.");
- }
-
- Logger.LogInfo($"{Constants.BuiltinBitcoinNodeName} fee estimation is working.");
-
if (Config.Network == Network.RegTest) // Make sure there's at least 101 block, if not generate it
{
if (blocks < 101)

MODIFY
WalletWasabi.Tests/IntegrationTests/LiveServerTests.cs
WalletWasabi.Tests/IntegrationTests/LiveServerTests.cs
@@ -41,17 +41,6 @@ namespace WalletWasabi.Tests.IntegrationTests
#region Blockchain
- [Theory]
- [InlineData(NetworkType.Mainnet)]
- [InlineData(NetworkType.Testnet)]
- public async Task GetFeesAsync(NetworkType networkType)
- {
- using var client = new WasabiClient(LiveServerTestsFixture.UriMappings[networkType], Global.Instance.TorSocks5Endpoint);
- var feeEstimationPairs = await client.GetFeesAsync(1000);
-
- Assert.True(feeEstimationPairs.NotNullAndNotEmpty());
- }
-
[Theory]
[InlineData(NetworkType.Mainnet)]
[InlineData(NetworkType.Testnet)]

MODIFY
WalletWasabi/CoinJoin/Coordinator/Rounds/CoordinatorRound.cs
WalletWasabi/CoinJoin/Coordinator/Rounds/CoordinatorRound.cs
@@ -894,10 +894,6 @@ namespace WalletWasabi.CoinJoin.Coordinator.Rounds
try
{
var estimateSmartFeeResponse = await rpc.EstimateSmartFeeAsync(confirmationTarget, EstimateSmartFeeMode.Conservative, simulateIfRegTest: true, tryOtherFeeRates: true).ConfigureAwait(false);
- if (estimateSmartFeeResponse is null)
- {
- throw new InvalidOperationException($"{nameof(FeeRate)} is not yet initialized.");
- }
var feeRate = estimateSmartFeeResponse.FeeRate;
Money feePerBytes = feeRate.FeePerK / 1000;

MODIFY
WalletWasabi/Extensions/RPCClientExtensions.cs
WalletWasabi/Extensions/RPCClientExtensions.cs
@@ -14,29 +14,6 @@ namespace NBitcoin.RPC
{
public static class RPCClientExtensions
{
- /// <summary>
- /// Waits for a specific new block and returns useful info about it.
- /// </summary>
- /// <param name="timeout">Time in milliseconds to wait for a response. 0 indicates no timeout.</param>
- /// <returns>Returns the current block on timeout or exit</returns>
- public static async Task<(Height height, uint256 hash)> WaitForNewBlockAsync(this RPCClient rpc, long timeout = 0)
- {
- var resp = await rpc.SendCommandAsync("waitfornewblock", timeout);
- return (int.Parse(resp.Result["height"].ToString()), uint256.Parse(resp.Result["hash"].ToString()));
- }
-
- /// <summary>
- /// Waits for a specific new block and returns useful info about it.
- /// </summary>
- /// <param name="blockHash">Block hash to wait for</param>
- /// <param name="timeout">Time in milliseconds to wait for a response. 0 indicates no timeout.</param>
- /// <returns>Returns the current block on timeout or exit</returns>
- public static async Task<(Height height, uint256 hash)> WaitForBlockAsync(this RPCClient rpc, uint256 blockHash, long timeout = 0)
- {
- var resp = await rpc.SendCommandAsync("waitforblock", blockHash, timeout);
- return (int.Parse(resp.Result["height"].ToString()), uint256.Parse(resp.Result["hash"].ToString()));
- }
-
public static async Task<EstimateSmartFeeResponse> EstimateSmartFeeAsync(this IRPCClient rpc, int confirmationTarget, EstimateSmartFeeMode estimateMode = EstimateSmartFeeMode.Conservative, bool simulateIfRegTest = false, bool tryOtherFeeRates = true)
{
if (simulateIfRegTest && rpc.Network == Network.RegTest)
@@ -74,39 +51,6 @@ namespace NBitcoin.RPC
return await rpc.EstimateSmartFeeAsync(confirmationTarget, estimateMode);
}
- public static async Task<EstimateSmartFeeResponse> TryEstimateSmartFeeAsync(this IRPCClient rpc, int confirmationTarget, EstimateSmartFeeMode estimateMode = EstimateSmartFeeMode.Conservative, bool simulateIfRegTest = false, bool tryOtherFeeRates = false)
- {
- if (simulateIfRegTest && rpc.Network == Network.RegTest)
- {
- return SimulateRegTestFeeEstimation(confirmationTarget, estimateMode);
- }
-
- if (tryOtherFeeRates)
- {
- EstimateSmartFeeResponse response = await rpc.TryEstimateSmartFeeAsync(confirmationTarget, estimateMode);
- if (response is { })
- {
- return response;
- }
- else
- {
- // Hopefully Bitcoin Core brainfart: https://github.com/bitcoin/bitcoin/issues/14431
- for (int i = 2; i <= Constants.SevenDaysConfirmationTarget; i++)
- {
- response = await rpc.TryEstimateSmartFeeAsync(i, estimateMode);
- if (response is { })
- {
- return response;
- }
- }
- }
-
- // Let's try one more time, whatever.
- }
-
- return await rpc.TryEstimateSmartFeeAsync(confirmationTarget, estimateMode);
- }
-
private static EstimateSmartFeeResponse SimulateRegTestFeeEstimation(int confirmationTarget, EstimateSmartFeeMode estimateMode)
{
int satoshiPerByte = estimateMode == EstimateSmartFeeMode.Conservative

MODIFY
WalletWasabi/WebClients/Wasabi/WasabiClient.cs
WalletWasabi/WebClients/Wasabi/WasabiClient.cs
@@ -142,21 +142,6 @@ namespace WalletWasabi.WebClients.Wasabi
return allTxs.ToDependencyGraph().OrderByDependency();
}
- public async Task<IDictionary<int, FeeEstimationPair>> GetFeesAsync(params int[] confirmationTargets)
- {
- var confirmationTargetsString = string.Join(",", confirmationTargets);
-
- 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();
- }
-
- using HttpContent content = response.Content;
- var ret = await content.ReadAsJsonAsync<IDictionary<int, FeeEstimationPair>>();
- return ret;
- }
-
public async Task BroadcastAsync(string hex)
{
using var content = new StringContent($"'{hex}'", Encoding.UTF8, "application/json");

Remove a bunch of dead code.