mirror of
https://github.com/aljazceru/BTCPayServerPlugins.git
synced 2025-12-17 07:34:24 +01:00
BUMP
This commit is contained in:
@@ -100,9 +100,9 @@ public class BTCPayCoinjoinCoinSelector : IRoundCoinSelector
|
||||
var remainingPendingPayments = new List<PendingPayment>(pendingPayments);
|
||||
var solution = new SubsetSolution(remainingPendingPayments.Count, _wallet.AnonScoreTarget,
|
||||
utxoSelectionParameters);
|
||||
|
||||
if (remainingCoins.All(coin => coin.CoinColor(_wallet.AnonScoreTarget) == AnonsetType.Green) &&
|
||||
!remainingPendingPayments.Any())
|
||||
var fullyPrivate = remainingCoins.All(coin => coin.CoinColor(_wallet.AnonScoreTarget) == AnonsetType.Green);
|
||||
var coinjoiningOnlyForPayments = fullyPrivate && remainingPendingPayments.Any();
|
||||
if (fullyPrivate && !coinjoiningOnlyForPayments)
|
||||
{
|
||||
var rand = Random.Shared.Next(1, 1001);
|
||||
if (rand > _wallet.WabisabiStoreSettings.ExtraJoinProbability)
|
||||
@@ -200,6 +200,14 @@ public class BTCPayCoinjoinCoinSelector : IRoundCoinSelector
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (coinjoiningOnlyForPayments && solution.HandledPayments?.Any() is not true)
|
||||
{
|
||||
_logger.LogInformation(
|
||||
"Attempted to coinjoin only to fulfill payments but the coin selection results yieleded no handled payment.");
|
||||
return new SubsetSolution(remainingPendingPayments.Count, _wallet.AnonScoreTarget,
|
||||
utxoSelectionParameters);
|
||||
}
|
||||
return solution;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<PropertyGroup>
|
||||
<Product>Wabisabi Coinjoin</Product>
|
||||
<Description>Allows you to integrate your btcpayserver store with coinjoins.</Description>
|
||||
<Version>1.0.30</Version>
|
||||
<Version>1.0.31</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Plugin development properties -->
|
||||
|
||||
@@ -185,12 +185,21 @@ public class WabisabiCoordinatorService : PeriodicRunner
|
||||
public async Task StartCoordinator(CancellationToken cancellationToken)
|
||||
{
|
||||
await HostedServices.StartAllAsync(cancellationToken);
|
||||
if (_instanceManager.HostedServices.TryGetValue("local", out var instance))
|
||||
{
|
||||
instance.WasabiCoordinatorStatusFetcher.OverrideConnected = null;
|
||||
}
|
||||
_instanceManager.AddCoordinator("Local Coordinator", "local", _ => null, cachedSettings.TermsConditions);
|
||||
}
|
||||
|
||||
public async Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
if (_instanceManager.HostedServices.TryGetValue("local", out var instance))
|
||||
{
|
||||
instance.WasabiCoordinatorStatusFetcher.OverrideConnected = false;
|
||||
}
|
||||
await HostedServices.StopAllAsync(cancellationToken);
|
||||
|
||||
}
|
||||
|
||||
protected override async Task ActionAsync(CancellationToken cancel)
|
||||
|
||||
@@ -200,7 +200,7 @@ public class WabisabiCoordinatorClientInstance
|
||||
switch (e)
|
||||
{
|
||||
case CoinJoinStatusEventArgs coinJoinStatusEventArgs:
|
||||
_logger.LogTrace(coinJoinStatusEventArgs.CoinJoinProgressEventArgs.GetType() + " :" +
|
||||
_logger.LogInformation(coinJoinStatusEventArgs.CoinJoinProgressEventArgs.GetType() + " :" +
|
||||
e.Wallet.WalletName);
|
||||
break;
|
||||
case CompletedEventArgs completedEventArgs:
|
||||
@@ -234,10 +234,7 @@ public class WabisabiCoordinatorClientInstance
|
||||
_ = CoinJoinManager.StartAsync(loadedEventArgs.Wallet, stopWhenAllMixed, false, CancellationToken.None);
|
||||
break;
|
||||
case StartErrorEventArgs errorArgs:
|
||||
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);
|
||||
_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);
|
||||
@@ -250,7 +247,6 @@ public class WabisabiCoordinatorClientInstance
|
||||
|
||||
public Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
RoundStateUpdater.StartAsync(cancellationToken);
|
||||
WasabiCoordinatorStatusFetcher.StartAsync(cancellationToken);
|
||||
CoinJoinManager.StartAsync(cancellationToken);
|
||||
|
||||
@@ -75,7 +75,7 @@ public class WabisabiPlugin : BaseBTCPayServerPlugin
|
||||
"onchain-wallet-send"));
|
||||
|
||||
// applicationBuilder.AddSingleton<IPayoutProcessorFactory, WabisabiPayoutProcessor>();
|
||||
Logger.SetMinimumLevel(LogLevel.Debug);
|
||||
Logger.SetMinimumLevel(LogLevel.Warning);
|
||||
Logger.SetModes(LogMode.DotNetLoggers);
|
||||
|
||||
|
||||
|
||||
@@ -16,21 +16,17 @@ namespace BTCPayServer.Plugins.Wabisabi
|
||||
private readonly WabisabiCoordinatorClientInstanceManager _coordinatorClientInstanceManager;
|
||||
private readonly WalletProvider _walletProvider;
|
||||
private readonly WalletRepository _walletRepository;
|
||||
private readonly PayoutProcessorService _payoutProcessorService;
|
||||
private readonly EventAggregator _eventAggregator;
|
||||
private string[] _ids => _coordinatorClientInstanceManager.HostedServices.Keys.ToArray();
|
||||
|
||||
public WabisabiService( IStoreRepository storeRepository,
|
||||
public WabisabiService(IStoreRepository storeRepository,
|
||||
WabisabiCoordinatorClientInstanceManager coordinatorClientInstanceManager,
|
||||
WalletProvider walletProvider,
|
||||
WalletRepository walletRepository,PayoutProcessorService payoutProcessorService, EventAggregator eventAggregator)
|
||||
WalletRepository walletRepository)
|
||||
{
|
||||
_storeRepository = storeRepository;
|
||||
_coordinatorClientInstanceManager = coordinatorClientInstanceManager;
|
||||
_walletProvider = walletProvider;
|
||||
_walletRepository = walletRepository;
|
||||
_payoutProcessorService = payoutProcessorService;
|
||||
_eventAggregator = eventAggregator;
|
||||
}
|
||||
|
||||
public async Task<WabisabiStoreSettings> GetWabisabiForStore(string storeId)
|
||||
|
||||
@@ -15,6 +15,7 @@ public class WasabiCoordinatorStatusFetcher : PeriodicRunner, IWasabiBackendStat
|
||||
private readonly IWabiSabiApiRequestHandler _wasabiClient;
|
||||
private readonly ILogger _logger;
|
||||
public bool Connected { get; set; } = false;
|
||||
public bool? OverrideConnected { get; set; }
|
||||
public WasabiCoordinatorStatusFetcher(IWabiSabiApiRequestHandler wasabiClient, ILogger logger) :
|
||||
base(TimeSpan.FromSeconds(30))
|
||||
{
|
||||
@@ -25,15 +26,23 @@ public class WasabiCoordinatorStatusFetcher : PeriodicRunner, IWasabiBackendStat
|
||||
protected override async Task ActionAsync(CancellationToken cancel)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (OverrideConnected is { })
|
||||
{
|
||||
Connected = OverrideConnected.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
await _wasabiClient.GetStatusAsync(new RoundStateRequest(ImmutableList<RoundStateCheckpoint>.Empty), cancel);
|
||||
if (!Connected)
|
||||
{
|
||||
_logger.LogInformation("Connected to coordinator" );
|
||||
}
|
||||
|
||||
Connected = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Connected = false;
|
||||
|
||||
Submodule submodules/walletwasabi updated: 6c653a0e14...c133070ecf
Reference in New Issue
Block a user