This commit is contained in:
Kukks
2023-04-19 14:05:23 +02:00
parent 16a8b55e92
commit f98b3a3db1
10 changed files with 44 additions and 37 deletions

View File

@@ -114,7 +114,7 @@ public class AffiliateServerController:Controller
return Json(response, AffiliationJsonSerializationOptions.Settings);
}
Payload payload = new(Header.Instance, request.Body);
Payload payload = new(Header.Create(AffiliationConstants.NonDefaultAffiliationId), request.Body);
try
{

View File

@@ -13,7 +13,7 @@
<PropertyGroup>
<Product>Wabisabi Coinjoin</Product>
<Description>Allows you to integrate your btcpayserver store with coinjoins.</Description>
<Version>1.0.27</Version>
<Version>1.0.28</Version>
</PropertyGroup>
<!-- Plugin development properties -->
@@ -44,6 +44,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="NNostr.Client" Version="0.0.24" />
<PackageReference Include="WabiSabi" Version="1.0.1.2" />
</ItemGroup>
<Target Name="DeleteExampleFile" AfterTargets="Publish">
<RemoveDir Directories="$(PublishDir)\Microservices" />

View File

@@ -83,7 +83,6 @@ public class BTCPayWallet : IWallet, IDestinationProvider
UtxoLocker = utxoLocker;
_storeRepository = storeRepository;
_bannedCoins = bannedCoins;
_eventAggregator = eventAggregator;
Logger = loggerFactory.CreateLogger($"BTCPayWallet_{storeId}");
}
@@ -103,12 +102,13 @@ public class BTCPayWallet : IWallet, IDestinationProvider
public IKeyChain KeyChain { get; }
public IDestinationProvider DestinationProvider => this;
public int AnonScoreTarget => WabisabiStoreSettings.PlebMode? 2: WabisabiStoreSettings.AnonymitySetTarget;
public int AnonScoreTarget => WabisabiStoreSettings.PlebMode? 5: WabisabiStoreSettings.AnonymitySetTarget;
public bool ConsolidationMode => !WabisabiStoreSettings.PlebMode && WabisabiStoreSettings.ConsolidationMode;
public TimeSpan FeeRateMedianTimeFrame => TimeSpan.FromHours(WabisabiStoreSettings.PlebMode?
KeyManager.DefaultFeeRateMedianTimeFrameHours: WabisabiStoreSettings.FeeRateMedianTimeFrameHours);
public bool RedCoinIsolation => !WabisabiStoreSettings.PlebMode &&WabisabiStoreSettings.RedCoinIsolation;
public bool BatchPayments => WabisabiStoreSettings.PlebMode || WabisabiStoreSettings.BatchPayments;
public long? MinimumDenominationAmount => WabisabiStoreSettings.PlebMode? 20000 : WabisabiStoreSettings.MinimumDenominationAmount;
public async Task<bool> IsWalletPrivateAsync()
{
@@ -150,7 +150,6 @@ public class BTCPayWallet : IWallet, IDestinationProvider
public Smartifier _smartifier => (KeyChain as BTCPayKeyChain)?.Smartifier;
private readonly StoreRepository _storeRepository;
private readonly ConcurrentDictionary<string, Dictionary<OutPoint, DateTimeOffset>> _bannedCoins;
private readonly EventAggregator _eventAggregator;
public IRoundCoinSelector GetCoinSelector()
{
@@ -346,15 +345,21 @@ public class BTCPayWallet : IWallet, IDestinationProvider
public async Task RegisterCoinjoinTransaction(SuccessfulCoinJoinResult result, string coordinatorName)
{
Console.WriteLine($"{WalletName}_RegisterCoinjoinTransaction");
Console.WriteLine($"{WalletName}_savingProgress");
await _savingProgress;
Console.WriteLine($"{WalletName}_savingProgress_done");
_savingProgress = RegisterCoinjoinTransactionInternal(result, coordinatorName);
Console.WriteLine($"{WalletName}_savingProgress");
await _savingProgress;
Console.WriteLine($"{WalletName}_savingProgress_done");
}
private async Task RegisterCoinjoinTransactionInternal(SuccessfulCoinJoinResult result, string coordinatorName)
{

View File

@@ -2,6 +2,7 @@ using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Newtonsoft.Json;
using WabiSabi.Crypto;
using WalletWasabi.WabiSabi;
using WalletWasabi.WabiSabi.Backend.Models;
using WalletWasabi.WabiSabi.Crypto;

View File

@@ -10,6 +10,7 @@ using NBitcoin.Secp256k1;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NNostr.Client;
using WabiSabi.Crypto;
using WalletWasabi.Logging;
using WalletWasabi.WabiSabi;
using WalletWasabi.WabiSabi.Backend.Models;

View File

@@ -103,6 +103,12 @@
<input type="number" class="form-control" asp-for="FeeRateMedianTimeFrameHours" placeholder="hours" min="0">
<p class="text-muted">Only coinjoin if the mining fee is below the median of the specified number of hours</p>
</div>>
<div class="form-group">
<label asp-for="MinimumDenominationAmount" class="form-label">Minimum denomination (in sats)</label>
<input type="number" class="form-control" asp-for="MinimumDenominationAmount" placeholder="sats" min="0">
<p class="text-muted">Do no use any of the standard denominations below this amount (creates change (which will get remixed) but prevent tiny utxos)</p>
</div>
<div class="form-group form-check">
<label asp-for="ConsolidationMode" class="form-check-label">Coinsolidation mode</label>

View File

@@ -10,9 +10,7 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using NBitcoin;
using WalletWasabi.Backend.Controllers;
using WalletWasabi.Services;
using WalletWasabi.Tor.Socks5.Pool.Circuits;
using WalletWasabi.Userfacing;
using WalletWasabi.WabiSabi.Backend.PostRequests;
@@ -20,7 +18,6 @@ using WalletWasabi.WabiSabi.Client;
using WalletWasabi.WabiSabi.Client.RoundStateAwaiters;
using WalletWasabi.WabiSabi.Client.StatusChangedEvents;
using WalletWasabi.Wallets;
using WalletWasabi.WebClients.Wasabi;
using HttpClientFactory = WalletWasabi.WebClients.Wasabi.HttpClientFactory;
namespace BTCPayServer.Plugins.Wabisabi;
@@ -199,7 +196,7 @@ public class WabisabiCoordinatorClientInstance
private void OnStatusChanged(object sender, StatusChangedEventArgs e)
{
bool stopWhenAllMixed;
switch (e)
{
case CoinJoinStatusEventArgs coinJoinStatusEventArgs:
@@ -233,11 +230,14 @@ public class WabisabiCoordinatorClientInstance
_logger.LogTrace("Coinjoin complete! :" + e.Wallet.WalletName);
break;
case LoadedEventArgs loadedEventArgs:
var stopWhenAllMixed = !((BTCPayWallet)loadedEventArgs.Wallet).BatchPayments;
stopWhenAllMixed = !((BTCPayWallet)loadedEventArgs.Wallet).BatchPayments;
_ = CoinJoinManager.StartAsync(loadedEventArgs.Wallet, stopWhenAllMixed, false, CancellationToken.None);
break;
case StartErrorEventArgs errorArgs:
_logger.LogInformation("Could not start wallet for coinjoin:" + errorArgs.Error.ToString() + " :" + e.Wallet.WalletName);
stopWhenAllMixed = !((BTCPayWallet)errorArgs.Wallet).BatchPayments;
_ = CoinJoinManager.StartAsync(errorArgs.Wallet, stopWhenAllMixed, false, CancellationToken.None);
// _logger.LogInformation("Could not start wallet for coinjoin:" + errorArgs.Error.ToString() + " :" + e.Wallet.WalletName);
break;
case StoppedEventArgs stoppedEventArgs:
_logger.LogInformation("Stopped wallet for coinjoin: " + stoppedEventArgs.Reason + " :" + e.Wallet.WalletName);

View File

@@ -1,20 +1,12 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using BTCPayServer.Abstractions.Contracts;
using BTCPayServer.Abstractions.Models;
using BTCPayServer.Abstractions.Services;
using BTCPayServer.Client.Models;
using BTCPayServer.Common;
using BTCPayServer.Payments;
using BTCPayServer.PayoutProcessors;
using BTCPayServer.Services.Stores;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using NBitcoin;
using WalletWasabi.Backend.Controllers;
@@ -38,22 +30,22 @@ public class WabisabiPlugin : BaseBTCPayServerPlugin
{
var res = ActivatorUtilities.CreateInstance<WabisabiCoordinatorClientInstanceManager>(provider);
res.UTXOLocker = utxoLocker;
res.AddCoordinator("zkSNACKS Coordinator", "zksnacks", provider =>
{
var chain = provider.GetService<IExplorerClientProvider>().GetExplorerClient("BTC").Network
.NBitcoinNetwork.ChainName;
if (chain == ChainName.Mainnet)
{
return new Uri("https://wasabiwallet.io/");
}
if (chain == ChainName.Testnet)
{
return new Uri("https://wasabiwallet.co/");
}
return new Uri("http://localhost:37127");
});
// res.AddCoordinator("zkSNACKS Coordinator", "zksnacks", provider =>
// {
// var chain = provider.GetService<IExplorerClientProvider>().GetExplorerClient("BTC").Network
// .NBitcoinNetwork.ChainName;
// if (chain == ChainName.Mainnet)
// {
// return new Uri("https://wasabiwallet.io/");
// }
//
// if (chain == ChainName.Testnet)
// {
// return new Uri("https://wasabiwallet.co/");
// }
//
// return new Uri("http://localhost:37127");
// });
return res;
});
applicationBuilder.AddHostedService(provider =>
@@ -83,7 +75,7 @@ public class WabisabiPlugin : BaseBTCPayServerPlugin
"onchain-wallet-send"));
// applicationBuilder.AddSingleton<IPayoutProcessorFactory, WabisabiPayoutProcessor>();
Logger.SetMinimumLevel(LogLevel.Warning);
Logger.SetMinimumLevel(LogLevel.Debug);
Logger.SetModes(LogMode.DotNetLoggers);

View File

@@ -25,6 +25,7 @@ public class WabisabiStoreSettings
public int ExtraJoinProbability { get; set; } = 0;
public CrossMixMode CrossMixBetweenCoordinatorsMode { get; set; } = CrossMixMode.WhenFree;
public int FeeRateMedianTimeFrameHours { get; set; }
public long MinimumDenominationAmount { get; set; } = 10000;
public enum CrossMixMode
{