This commit is contained in:
Kukks
2024-09-03 11:42:12 +02:00
parent 4cf6f51d29
commit bd882340e6
12 changed files with 11 additions and 49 deletions

View File

@@ -72,12 +72,6 @@ SmartCoin[] FilterCoinsMore(IEnumerable<SmartCoin> coins)
return true; return true;
} }
if (_wallet.WabisabiStoreSettings.PlebMode ||
_wallet.WabisabiStoreSettings.CrossMixBetweenCoordinatorsMode ==
WabisabiStoreSettings.CrossMixMode.WhenFree)
{
return coin.Amount <= roundParameters.CoordinationFeeRate.PlebsDontPayThreshold;
}
return false; return false;

View File

@@ -44,7 +44,7 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="NNostr.Client" Version="0.0.48"></PackageReference> <PackageReference Include="NNostr.Client" Version="0.0.51"></PackageReference>
<PackageReference Include="WabiSabi" Version="1.0.1.2"/> <PackageReference Include="WabiSabi" Version="1.0.1.2"/>
</ItemGroup> </ItemGroup>
<Target Name="DeleteExampleFile" AfterTargets="Publish"> <Target Name="DeleteExampleFile" AfterTargets="Publish">

View File

@@ -286,8 +286,7 @@ public class BTCPayWallet : IWallet, IDestinationProvider
{ {
return coordSettings.RoundWhenEnabled is not null && return coordSettings.RoundWhenEnabled is not null &&
roundParameters.CoordinationFeeRate.Rate <= coordSettings.RoundWhenEnabled.CoordinationFeeRate && roundParameters.CoordinationFeeRate.Rate <= coordSettings.RoundWhenEnabled.CoordinationFeeRate &&
roundParameters.CoordinationFeeRate.PlebsDontPayThreshold <=
coordSettings.RoundWhenEnabled.PlebsDontPayThresholdM &&
roundParameters.MinInputCountByRound <= coordSettings.RoundWhenEnabled.MinInputCountByRound; roundParameters.MinInputCountByRound <= coordSettings.RoundWhenEnabled.MinInputCountByRound;
} }
catch (Exception e) catch (Exception e)

View File

@@ -24,7 +24,7 @@ public static class CoordinatorExtensions
return null; return null;
} }
return new WabiSabiController(s.IdempotencyRequestCache, s.WabiSabiCoordinator.Arena, return new WabiSabiController(s.IdempotencyRequestCache, s.WabiSabiCoordinator.Arena,
s.WabiSabiCoordinator.CoinJoinFeeRateStatStore, s.WabiSabiCoordinator.AffiliationManager); s.WabiSabiCoordinator.CoinJoinFeeRateStatStore);
}); });
services.AddHostedService((sp) => sp.GetRequiredService<WabisabiCoordinatorService>()); services.AddHostedService((sp) => sp.GetRequiredService<WabisabiCoordinatorService>());

View File

@@ -6,7 +6,6 @@ using Microsoft.Extensions.Logging;
using Newtonsoft.Json; using Newtonsoft.Json;
using NLog; using NLog;
using WabiSabi.Crypto; using WabiSabi.Crypto;
using WalletWasabi.Affiliation;
using WalletWasabi.WabiSabi; using WalletWasabi.WabiSabi;
using WalletWasabi.WabiSabi.Backend.Models; using WalletWasabi.WabiSabi.Backend.Models;
using WalletWasabi.WabiSabi.Models; using WalletWasabi.WabiSabi.Models;
@@ -43,14 +42,6 @@ public class ExceptionTranslateAttribute : ExceptionFilterAttribute
{ {
StatusCode = (int) HttpStatusCode.InternalServerError StatusCode = (int) HttpStatusCode.InternalServerError
}, },
AffiliationException e => new JsonResult(new Error(
Type: AffiliationConstants.RequestSecrecyViolationType,
ErrorCode: "undefined",
Description: e.Message,
ExceptionData: EmptyExceptionData.Instance), serializerSettings)
{
StatusCode = (int) HttpStatusCode.InternalServerError
},
_ => new StatusCodeResult((int) HttpStatusCode.InternalServerError) _ => new StatusCodeResult((int) HttpStatusCode.InternalServerError)
}; };
} }

View File

@@ -4,7 +4,6 @@ using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using WalletWasabi.Affiliation;
using WalletWasabi.Backend.Filters; using WalletWasabi.Backend.Filters;
using WalletWasabi.Cache; using WalletWasabi.Cache;
using WalletWasabi.WabiSabi.Backend.PostRequests; using WalletWasabi.WabiSabi.Backend.PostRequests;
@@ -24,27 +23,24 @@ namespace WalletWasabi.Backend.Controllers;
[Produces("application/json")] [Produces("application/json")]
public class WabiSabiController : ControllerBase, IWabiSabiApiRequestHandler public class WabiSabiController : ControllerBase, IWabiSabiApiRequestHandler
{ {
public WabiSabiController(IdempotencyRequestCache idempotencyRequestCache, Arena arena, CoinJoinFeeRateStatStore coinJoinFeeRateStatStore, AffiliationManager affiliationManager) public WabiSabiController(IdempotencyRequestCache idempotencyRequestCache, Arena arena, CoinJoinFeeRateStatStore coinJoinFeeRateStatStore)
{ {
IdempotencyRequestCache = idempotencyRequestCache; IdempotencyRequestCache = idempotencyRequestCache;
Arena = arena; Arena = arena;
CoinJoinFeeRateStatStore = coinJoinFeeRateStatStore; CoinJoinFeeRateStatStore = coinJoinFeeRateStatStore;
AffiliationManager = affiliationManager;
} }
private static TimeSpan RequestTimeout { get; } = TimeSpan.FromMinutes(5); private static TimeSpan RequestTimeout { get; } = TimeSpan.FromMinutes(5);
private IdempotencyRequestCache IdempotencyRequestCache { get; } private IdempotencyRequestCache IdempotencyRequestCache { get; }
private Arena Arena { get; } private Arena Arena { get; }
private CoinJoinFeeRateStatStore CoinJoinFeeRateStatStore { get; } private CoinJoinFeeRateStatStore CoinJoinFeeRateStatStore { get; }
private AffiliationManager AffiliationManager { get; }
[HttpPost("status")] [HttpPost("status")]
public async Task<RoundStateResponse> GetStatusAsync(RoundStateRequest request, CancellationToken cancellationToken) public async Task<RoundStateResponse> GetStatusAsync(RoundStateRequest request, CancellationToken cancellationToken)
{ {
var response = await Arena.GetStatusAsync(request, cancellationToken); var response = await Arena.GetStatusAsync(request, cancellationToken);
var medians = CoinJoinFeeRateStatStore.GetDefaultMedians(); var medians = CoinJoinFeeRateStatStore.GetDefaultMedians();
var affiliateInformation = AffiliationManager.GetAffiliateInformation(); var ret = new RoundStateResponse(response.RoundStates, medians);
var ret = new RoundStateResponse(response.RoundStates, medians, affiliateInformation);
return ret; return ret;
} }

View File

@@ -31,7 +31,6 @@ using WalletWasabi.Services;
using WalletWasabi.Tor.Socks5.Pool.Circuits; using WalletWasabi.Tor.Socks5.Pool.Circuits;
using WalletWasabi.WabiSabi; using WalletWasabi.WabiSabi;
using WalletWasabi.WabiSabi.Backend; using WalletWasabi.WabiSabi.Backend;
using WalletWasabi.WabiSabi.Backend.Rounds.CoinJoinStorage;
using WalletWasabi.WabiSabi.Backend.Statistics; using WalletWasabi.WabiSabi.Backend.Statistics;
using WalletWasabi.WabiSabi.Client; using WalletWasabi.WabiSabi.Client;
using WalletWasabi.WabiSabi.Models; using WalletWasabi.WabiSabi.Models;
@@ -230,12 +229,10 @@ public class WabisabiCoordinatorService : PeriodicRunner
var network = _networkProvider.GetNetwork<BTCPayNetwork>("BTC"); var network = _networkProvider.GetNetwork<BTCPayNetwork>("BTC");
var coordinatorParameters = var coordinatorParameters =
new CoordinatorParameters(Path.Combine(_dataDirectories.Value.DataDir, "Plugins", "Coinjoin")); new CoordinatorParameters(Path.Combine(_dataDirectories.Value.DataDir, "Plugins", "Coinjoin"));
var coinJoinIdStore =
CoinJoinIdStore.Create( coordinatorParameters.CoinJoinIdStoreFilePath);
var coinJoinScriptStore = CoinJoinScriptStore.LoadFromFile(coordinatorParameters.CoinJoinScriptStoreFilePath); var coinJoinScriptStore = CoinJoinScriptStore.LoadFromFile(coordinatorParameters.CoinJoinScriptStoreFilePath);
var rpc = new BtcPayRpcClient(_feeProviderFactory.CreateFeeProvider(network),explorerClient.RPCClient, _memoryCache, explorerClient); var rpc = new BtcPayRpcClient(_feeProviderFactory.CreateFeeProvider(network),explorerClient.RPCClient, _memoryCache, explorerClient);
WabiSabiCoordinator = new WabiSabiCoordinator(coordinatorParameters, rpc, coinJoinIdStore, coinJoinScriptStore, WabiSabiCoordinator = new WabiSabiCoordinator(coordinatorParameters, rpc, coinJoinScriptStore,
_httpClientFactory, _coordinatorScriptResolver); _httpClientFactory, _coordinatorScriptResolver);
HostedServices.Register<WabiSabiCoordinator>(() => WabiSabiCoordinator, "WabiSabi Coordinator"); HostedServices.Register<WabiSabiCoordinator>(() => WabiSabiCoordinator, "WabiSabi Coordinator");
@@ -267,8 +264,8 @@ public class WabisabiCoordinatorService : PeriodicRunner
{ {
instance.WasabiCoordinatorStatusFetcher.OverrideConnected = null; instance.WasabiCoordinatorStatusFetcher.OverrideConnected = null;
} }
var coinjoinConfig = new CoinJoinConfiguration(WabiSabiCoordinator.Config.CoordinatorIdentifier, 10m, 100m); var coinjoinConfig = new CoinJoinConfiguration(WabiSabiCoordinator.Config.CoordinatorIdentifier,150m, WabiSabiCoordinator.Config.MinInputCountByRound, false);
_instanceManager.AddCoordinator("Local Coordinator", _instanceManager.AddCoordinator("Local Coordinator",
"local", _ => null, "local", _ => null,
cachedSettings.TermsConditions, cachedSettings.TermsConditions,

View File

@@ -379,7 +379,7 @@
<tr> <tr>
<th scope="row">Fee charged</th> <th scope="row">Fee charged</th>
@{ @{
var fee = $"{roundParameters.CoordinationFeeRate.Rate * 100}% + Free remixing {(roundParameters.CoordinationFeeRate.PlebsDontPayThreshold <= 0 ? string.Empty : $"+ Free under {roundParameters.CoordinationFeeRate.PlebsDontPayThreshold.ToDecimal(MoneyUnit.BTC)} BTC")}"; var fee = $"{roundParameters.CoordinationFeeRate.Rate * 100}%";
} }
<td> <td>
@(fee) @(fee)
@@ -450,7 +450,6 @@
@if (Model.Settings[index].RoundWhenEnabled is not null) @if (Model.Settings[index].RoundWhenEnabled is not null)
{ {
<input type="hidden" asp-for="Settings[index].RoundWhenEnabled.CoordinationFeeRate"/> <input type="hidden" asp-for="Settings[index].RoundWhenEnabled.CoordinationFeeRate"/>
<input type="hidden" asp-for="Settings[index].RoundWhenEnabled.PlebsDontPayThreshold"/>
<input type="hidden" asp-for="Settings[index].RoundWhenEnabled.MinInputCountByRound"/> <input type="hidden" asp-for="Settings[index].RoundWhenEnabled.MinInputCountByRound"/>
} }

View File

@@ -50,15 +50,6 @@ namespace BTCPayServer.Plugins.Wabisabi
nameof(WabisabiStoreSettings)); nameof(WabisabiStoreSettings));
res ??= new WabisabiStoreSettings(); res ??= new WabisabiStoreSettings();
res.Settings = res.Settings.Where(settings => _ids.Contains(settings.Coordinator)).ToList(); res.Settings = res.Settings.Where(settings => _ids.Contains(settings.Coordinator)).ToList();
res.Settings.ForEach(settings =>
{
if (settings.RoundWhenEnabled != null &&
string.IsNullOrEmpty(settings.RoundWhenEnabled.PlebsDontPayThreshold))
{
settings.RoundWhenEnabled.PlebsDontPayThreshold = "1000000";
}
});
await EnablePayoutProcessorBasedOnSettings(storeId, res); await EnablePayoutProcessorBasedOnSettings(storeId, res);
return res; return res;
@@ -126,8 +117,6 @@ namespace BTCPayServer.Plugins.Wabisabi
? new LastCoordinatorRoundConfig() ? new LastCoordinatorRoundConfig()
{ {
CoordinationFeeRate = roundParameters.CoordinationFeeRate.Rate, CoordinationFeeRate = roundParameters.CoordinationFeeRate.Rate,
PlebsDontPayThreshold = roundParameters.CoordinationFeeRate
.PlebsDontPayThreshold.Satoshi.ToString(),
MinInputCountByRound = roundParameters.MinInputCountByRound, MinInputCountByRound = roundParameters.MinInputCountByRound,
} }
: null; : null;

View File

@@ -245,7 +245,7 @@ namespace BTCPayServer.Plugins.Wabisabi
{ {
coordSettings.DiscoveredCoordinators.Add(viewModel); coordSettings.DiscoveredCoordinators.Add(viewModel);
await _wabisabiCoordinatorService.UpdateSettings(coordSettings); await _wabisabiCoordinatorService.UpdateSettings(coordSettings);
var config = new CoinJoinConfiguration(); var config = new CoinJoinConfiguration("CoordinatorIdentifier",150m, 1, false);
_instanceManager.AddCoordinator(viewModel.Name, viewModel.Name, provider => viewModel.Uri, null,viewModel.Description, config); _instanceManager.AddCoordinator(viewModel.Name, viewModel.Name, provider => viewModel.Uri, null,viewModel.Description, config);
TempData["SuccessMessage"] = $"Coordinator {viewModel.Name } added and started"; TempData["SuccessMessage"] = $"Coordinator {viewModel.Name } added and started";

View File

@@ -84,9 +84,6 @@ public class LastCoordinatorRoundConfig
{ {
public decimal CoordinationFeeRate { get; set; } public decimal CoordinationFeeRate { get; set; }
public string PlebsDontPayThreshold { get; set; }
[JsonIgnore]
public Money PlebsDontPayThresholdM => Money.Parse(PlebsDontPayThreshold);
public int MinInputCountByRound { get; set; } public int MinInputCountByRound { get; set; }
} }