-
@(coordinator.WasabiCoordinatorStatusFetcher.Connected? "Coordinator Status: Not connected": "Coordinator Status: Connected")
+
@(!coordinator.WasabiCoordinatorStatusFetcher.Connected? "Coordinator Status: Not connected": "Coordinator Status: Connected")
@if (!string.IsNullOrEmpty(coordinator.Description))
{
diff --git a/Plugins/BTCPayServer.Plugins.Wabisabi/WabisabiCoordinatorClientInstance.cs b/Plugins/BTCPayServer.Plugins.Wabisabi/WabisabiCoordinatorClientInstance.cs
index 8c69b90..f0c2bf0 100644
--- a/Plugins/BTCPayServer.Plugins.Wabisabi/WabisabiCoordinatorClientInstance.cs
+++ b/Plugins/BTCPayServer.Plugins.Wabisabi/WabisabiCoordinatorClientInstance.cs
@@ -109,6 +109,8 @@ public class WabisabiCoordinatorClientInstanceManager:IHostedService
{
if(started)
_ = instance.StartAsync(CancellationToken.None);
+ if(name == "local")
+ instance.WasabiCoordinatorStatusFetcher.OverrideConnected = null;
}
}
diff --git a/Plugins/BTCPayServer.Plugins.Wabisabi/WabisabiService.cs b/Plugins/BTCPayServer.Plugins.Wabisabi/WabisabiService.cs
index 2a44fbf..d14649c 100644
--- a/Plugins/BTCPayServer.Plugins.Wabisabi/WabisabiService.cs
+++ b/Plugins/BTCPayServer.Plugins.Wabisabi/WabisabiService.cs
@@ -5,6 +5,7 @@ using BTCPayServer.Abstractions.Contracts;
using BTCPayServer.Data;
using BTCPayServer.PayoutProcessors;
using BTCPayServer.Services;
+using Microsoft.Extensions.Caching.Memory;
using NBitcoin;
using Newtonsoft.Json.Linq;
@@ -16,32 +17,44 @@ namespace BTCPayServer.Plugins.Wabisabi
private readonly WabisabiCoordinatorClientInstanceManager _coordinatorClientInstanceManager;
private readonly WalletProvider _walletProvider;
private readonly WalletRepository _walletRepository;
+ private readonly IMemoryCache _memoryCache;
private string[] _ids => _coordinatorClientInstanceManager.HostedServices.Keys.ToArray();
public WabisabiService(IStoreRepository storeRepository,
WabisabiCoordinatorClientInstanceManager coordinatorClientInstanceManager,
WalletProvider walletProvider,
- WalletRepository walletRepository)
+ WalletRepository walletRepository,
+ IMemoryCache memoryCache)
{
_storeRepository = storeRepository;
_coordinatorClientInstanceManager = coordinatorClientInstanceManager;
_walletProvider = walletProvider;
_walletRepository = walletRepository;
+ _memoryCache = memoryCache;
}
+ private string GetCacheKey(string storeId)
+ {
+ return $"{nameof(WabisabiStoreSettings)}-{storeId}";
+ }
public async Task
GetWabisabiForStore(string storeId)
{
- var res = await _storeRepository.GetSettingAsync(storeId, nameof(WabisabiStoreSettings));
- res ??= new WabisabiStoreSettings();
- res.Settings = res.Settings.Where(settings => _ids.Contains(settings.Coordinator)).ToList();
- res.Settings.ForEach(settings =>
+ var res = await _memoryCache.GetOrCreate(GetCacheKey(storeId), async entry =>
{
- if(settings.RoundWhenEnabled != null && string.IsNullOrEmpty(settings.RoundWhenEnabled.PlebsDontPayThreshold))
+ var res = await _storeRepository.GetSettingAsync(storeId, nameof(WabisabiStoreSettings));
+ res ??= new WabisabiStoreSettings();
+ res.Settings = res.Settings.Where(settings => _ids.Contains(settings.Coordinator)).ToList();
+ res.Settings.ForEach(settings =>
{
- settings.RoundWhenEnabled.PlebsDontPayThreshold = "1000000";
- }
+ if(settings.RoundWhenEnabled != null && string.IsNullOrEmpty(settings.RoundWhenEnabled.PlebsDontPayThreshold))
+ {
+ settings.RoundWhenEnabled.PlebsDontPayThreshold = "1000000";
+ }
+ });
+ return res;
});
+
foreach (var wabisabiCoordinatorManager in _coordinatorClientInstanceManager.HostedServices)
{
if (res.Settings.All(settings => settings.Coordinator != wabisabiCoordinatorManager.Key))
@@ -75,7 +88,7 @@ namespace BTCPayServer.Plugins.Wabisabi
}
else
{
- var res = await _storeRepository.GetSettingAsync(storeId, nameof(WabisabiStoreSettings));
+ var res = await GetWabisabiForStore(storeId);
foreach (var wabisabiStoreCoordinatorSettings in wabisabiSettings.Settings)
{
if (!wabisabiStoreCoordinatorSettings.Enabled)
@@ -101,7 +114,7 @@ namespace BTCPayServer.Plugins.Wabisabi
}
await _storeRepository.UpdateSetting(storeId, nameof(WabisabiStoreSettings), wabisabiSettings!);
}
-
+ _memoryCache.Remove(GetCacheKey(storeId));
await _walletProvider.SettingsUpdated(storeId, wabisabiSettings);
// var existingProcessor = (await _payoutProcessorService.GetProcessors(new PayoutProcessorService.PayoutProcessorQuery()
// {
diff --git a/Plugins/BTCPayServer.Plugins.Wabisabi/WabisabiStoreController.cs b/Plugins/BTCPayServer.Plugins.Wabisabi/WabisabiStoreController.cs
index 4bcde99..a6e46e1 100644
--- a/Plugins/BTCPayServer.Plugins.Wabisabi/WabisabiStoreController.cs
+++ b/Plugins/BTCPayServer.Plugins.Wabisabi/WabisabiStoreController.cs
@@ -1,36 +1,27 @@
using System;
using System.Collections.Generic;
-using System.Diagnostics;
using System.Linq;
using System.Security.Claims;
using System.Security.Cryptography;
using System.Threading;
using System.Threading.Tasks;
-using AngleSharp.Dom.Events;
using BTCPayServer.Abstractions.Constants;
using BTCPayServer.Abstractions.Contracts;
using BTCPayServer.Client;
using BTCPayServer.Client.Models;
using BTCPayServer.Common;
using BTCPayServer.Configuration;
-using BTCPayServer.Data;
-using BTCPayServer.Filters;
-using BTCPayServer.Models.WalletViewModels;
using BTCPayServer.Security;
using BTCPayServer.Services;
using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.ModelBinding;
+using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.DependencyInjection;
using NBitcoin;
using NBitcoin.Payment;
using NBitcoin.Secp256k1;
-using NBXplorer;
using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
using NNostr.Client;
-using Org.BouncyCastle.Security;
using WalletWasabi.Backend.Controllers;
using WalletWasabi.Blockchain.TransactionBuilding;
using WalletWasabi.Blockchain.TransactionOutputs;
@@ -48,18 +39,15 @@ namespace BTCPayServer.Plugins.Wabisabi
private readonly IExplorerClientProvider _explorerClientProvider;
private readonly WabisabiCoordinatorService _wabisabiCoordinatorService;
private readonly IAuthorizationService _authorizationService;
- private readonly BTCPayServerOptions _options;
private readonly WabisabiCoordinatorClientInstanceManager _instanceManager;
private readonly Socks5HttpClientHandler _socks5HttpClientHandler;
-
public WabisabiStoreController(WabisabiService WabisabiService, WalletProvider walletProvider,
IBTCPayServerClientFactory btcPayServerClientFactory,
IExplorerClientProvider explorerClientProvider,
WabisabiCoordinatorService wabisabiCoordinatorService,
WabisabiCoordinatorClientInstanceManager instanceManager,
IAuthorizationService authorizationService,
- IServiceProvider serviceProvider,
- BTCPayServerOptions options)
+ IServiceProvider serviceProvider)
{
_WabisabiService = WabisabiService;
_walletProvider = walletProvider;
@@ -67,13 +55,11 @@ namespace BTCPayServer.Plugins.Wabisabi
_explorerClientProvider = explorerClientProvider;
_wabisabiCoordinatorService = wabisabiCoordinatorService;
_authorizationService = authorizationService;
- _options = options;
_instanceManager = instanceManager;
_socks5HttpClientHandler = serviceProvider.GetRequiredService();
}
[HttpGet("")]
- [HttpGet("add-coordinator")]
public async Task UpdateWabisabiStoreSettings(string storeId)
{
WabisabiStoreSettings Wabisabi = null;
diff --git a/submodules/btcpayserver b/submodules/btcpayserver
index 717f161..8db5e7e 160000
--- a/submodules/btcpayserver
+++ b/submodules/btcpayserver
@@ -1 +1 @@
-Subproject commit 717f1610f5723ee40a11dec6cf43a615af0fb8e4
+Subproject commit 8db5e7e043225d84220ff43f004d09d22a78c6e3