mirror of
https://github.com/aljazceru/BTCPayServerPlugins.git
synced 2025-12-17 07:34:24 +01:00
update discovery
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Product>Wabisabi Coinjoin</Product>
|
<Product>Wabisabi Coinjoin</Product>
|
||||||
<Description>Allows you to integrate your btcpayserver store with coinjoins.</Description>
|
<Description>Allows you to integrate your btcpayserver store with coinjoins.</Description>
|
||||||
<Version>1.0.39</Version>
|
<Version>1.0.40</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<!-- Plugin development properties -->
|
<!-- Plugin development properties -->
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ public class WabisabiCoordinatorService : PeriodicRunner
|
|||||||
{
|
{
|
||||||
foreach (var discoveredCoordinator in settings.DiscoveredCoordinators)
|
foreach (var discoveredCoordinator in settings.DiscoveredCoordinators)
|
||||||
{
|
{
|
||||||
_instanceManager.AddCoordinator(discoveredCoordinator.Name, discoveredCoordinator.Name, _ => discoveredCoordinator.Uri );
|
_instanceManager.AddCoordinator(discoveredCoordinator.Name, discoveredCoordinator.Name, _ => discoveredCoordinator.Uri, null, discoveredCoordinator.Description );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (settings.Enabled)
|
if (settings.Enabled)
|
||||||
@@ -197,7 +197,7 @@ public class WabisabiCoordinatorService : PeriodicRunner
|
|||||||
{
|
{
|
||||||
instance.WasabiCoordinatorStatusFetcher.OverrideConnected = null;
|
instance.WasabiCoordinatorStatusFetcher.OverrideConnected = null;
|
||||||
}
|
}
|
||||||
_instanceManager.AddCoordinator("Local Coordinator", "local", _ => null, cachedSettings.TermsConditions);
|
_instanceManager.AddCoordinator("Local Coordinator", "local", _ => null, cachedSettings.TermsConditions, cachedSettings.CoordinatorDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task StopAsync(CancellationToken cancellationToken)
|
public async Task StopAsync(CancellationToken cancellationToken)
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<span class="text-muted">@Model.Uri</span>
|
<span class="text-muted">@Model.Uri</span>
|
||||||
|
<p>@Model.Description</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group form-check">
|
<div class="form-group form-check">
|
||||||
<button name="command" type="submit" class="btn btn-primary btn-lg">Add</button>
|
<button name="command" type="submit" class="btn btn-primary btn-lg">Add</button>
|
||||||
|
|||||||
@@ -217,18 +217,12 @@
|
|||||||
|
|
||||||
<span class="text-muted">@coordinator.Coordinator</span>
|
<span class="text-muted">@coordinator.Coordinator</span>
|
||||||
<div>
|
<div>
|
||||||
@if (!coordinator.WasabiCoordinatorStatusFetcher.Connected)
|
<div>@(coordinator.WasabiCoordinatorStatusFetcher.Connected? "Coordinator Status: Not connected": "Coordinator Status: Connected")</div>
|
||||||
{
|
|
||||||
<p>Coordinator Status: Not connected</p>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<p>
|
|
||||||
Coordinator Status: Connected
|
|
||||||
|
|
||||||
</p>
|
@if (!string.IsNullOrEmpty(coordinator.Description))
|
||||||
|
{
|
||||||
|
<p class="text-muted">@coordinator.Description</p>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (coordinator.RoundStateUpdater.AnyRound && coordinator.RoundStateUpdater.RoundStates.Any(pair => pair.Value.BlameOf == uint256.Zero))
|
@if (coordinator.RoundStateUpdater.AnyRound && coordinator.RoundStateUpdater.RoundStates.Any(pair => pair.Value.BlameOf == uint256.Zero))
|
||||||
{
|
{
|
||||||
var round = coordinator.RoundStateUpdater.RoundStates.Last(pair => pair.Value.BlameOf == uint256.Zero).Value;
|
var round = coordinator.RoundStateUpdater.RoundStates.Last(pair => pair.Value.BlameOf == uint256.Zero).Value;
|
||||||
@@ -309,6 +303,7 @@
|
|||||||
By enabling this coordinator, you agree to their terms and conditions.
|
By enabling this coordinator, you agree to their terms and conditions.
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@{
|
@{
|
||||||
var canEnable = coordinator.WasabiCoordinatorStatusFetcher.Connected && coordinator.RoundStateUpdater.AnyRound;
|
var canEnable = coordinator.WasabiCoordinatorStatusFetcher.Connected && coordinator.RoundStateUpdater.AnyRound;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ using WalletWasabi.WabiSabi.Client;
|
|||||||
using WalletWasabi.WabiSabi.Client.RoundStateAwaiters;
|
using WalletWasabi.WabiSabi.Client.RoundStateAwaiters;
|
||||||
using WalletWasabi.WabiSabi.Client.StatusChangedEvents;
|
using WalletWasabi.WabiSabi.Client.StatusChangedEvents;
|
||||||
using WalletWasabi.Wallets;
|
using WalletWasabi.Wallets;
|
||||||
|
using WalletWasabi.WebClients.Wasabi;
|
||||||
using HttpClientFactory = WalletWasabi.WebClients.Wasabi.HttpClientFactory;
|
using HttpClientFactory = WalletWasabi.WebClients.Wasabi.HttpClientFactory;
|
||||||
|
|
||||||
namespace BTCPayServer.Plugins.Wabisabi;
|
namespace BTCPayServer.Plugins.Wabisabi;
|
||||||
@@ -78,7 +79,7 @@ public class WabisabiCoordinatorClientInstanceManager:IHostedService
|
|||||||
|
|
||||||
|
|
||||||
public void AddCoordinator(string displayName, string name,
|
public void AddCoordinator(string displayName, string name,
|
||||||
Func<IServiceProvider, Uri> fetcher, string termsConditions = null)
|
Func<IServiceProvider, Uri> fetcher, string termsConditions = null, string description = null)
|
||||||
{
|
{
|
||||||
if (termsConditions is null && name == "zksnacks")
|
if (termsConditions is null && name == "zksnacks")
|
||||||
{
|
{
|
||||||
@@ -98,7 +99,7 @@ public class WabisabiCoordinatorClientInstanceManager:IHostedService
|
|||||||
var instance = new WabisabiCoordinatorClientInstance(
|
var instance = new WabisabiCoordinatorClientInstance(
|
||||||
displayName,
|
displayName,
|
||||||
name, new Uri(url), _provider.GetService<ILoggerFactory>(), _provider, UTXOLocker,
|
name, new Uri(url), _provider.GetService<ILoggerFactory>(), _provider, UTXOLocker,
|
||||||
_provider.GetService<WalletProvider>(), termsConditions);
|
_provider.GetService<WalletProvider>(), termsConditions, description);
|
||||||
if (HostedServices.TryAdd(instance.CoordinatorName, instance))
|
if (HostedServices.TryAdd(instance.CoordinatorName, instance))
|
||||||
{
|
{
|
||||||
if(started)
|
if(started)
|
||||||
@@ -131,6 +132,7 @@ public class WabisabiCoordinatorClientInstance
|
|||||||
public RoundStateUpdater RoundStateUpdater { get; set; }
|
public RoundStateUpdater RoundStateUpdater { get; set; }
|
||||||
public WasabiCoordinatorStatusFetcher WasabiCoordinatorStatusFetcher { get; set; }
|
public WasabiCoordinatorStatusFetcher WasabiCoordinatorStatusFetcher { get; set; }
|
||||||
public CoinJoinManager CoinJoinManager { get; set; }
|
public CoinJoinManager CoinJoinManager { get; set; }
|
||||||
|
public string Description { get; set; }
|
||||||
|
|
||||||
public WabisabiCoordinatorClientInstance(string coordinatorDisplayName,
|
public WabisabiCoordinatorClientInstance(string coordinatorDisplayName,
|
||||||
string coordinatorName,
|
string coordinatorName,
|
||||||
@@ -138,7 +140,7 @@ public class WabisabiCoordinatorClientInstance
|
|||||||
ILoggerFactory loggerFactory,
|
ILoggerFactory loggerFactory,
|
||||||
IServiceProvider serviceProvider,
|
IServiceProvider serviceProvider,
|
||||||
IUTXOLocker utxoLocker,
|
IUTXOLocker utxoLocker,
|
||||||
WalletProvider walletProvider, string termsConditions, string coordinatorIdentifier = "CoinJoinCoordinatorIdentifier")
|
WalletProvider walletProvider, string termsConditions, string description,string coordinatorIdentifier = "CoinJoinCoordinatorIdentifier")
|
||||||
{
|
{
|
||||||
|
|
||||||
_utxoLocker = utxoLocker;
|
_utxoLocker = utxoLocker;
|
||||||
@@ -154,6 +156,7 @@ public class WabisabiCoordinatorClientInstance
|
|||||||
Coordinator = coordinator;
|
Coordinator = coordinator;
|
||||||
WalletProvider = walletProvider;
|
WalletProvider = walletProvider;
|
||||||
TermsConditions = termsConditions;
|
TermsConditions = termsConditions;
|
||||||
|
Description = description;
|
||||||
_logger = loggerFactory.CreateLogger(coordinatorName);
|
_logger = loggerFactory.CreateLogger(coordinatorName);
|
||||||
IWabiSabiApiRequestHandler sharedWabisabiClient;
|
IWabiSabiApiRequestHandler sharedWabisabiClient;
|
||||||
if (coordinatorName == "local")
|
if (coordinatorName == "local")
|
||||||
@@ -167,6 +170,18 @@ public class WabisabiCoordinatorClientInstance
|
|||||||
var roundStateUpdaterCircuit = new PersonCircuit();
|
var roundStateUpdaterCircuit = new PersonCircuit();
|
||||||
var roundStateUpdaterHttpClient =
|
var roundStateUpdaterHttpClient =
|
||||||
WasabiHttpClientFactory.NewHttpClient(Mode.SingleCircuitPerLifetime, roundStateUpdaterCircuit);
|
WasabiHttpClientFactory.NewHttpClient(Mode.SingleCircuitPerLifetime, roundStateUpdaterCircuit);
|
||||||
|
if (termsConditions is null)
|
||||||
|
{
|
||||||
|
_ = new WasabiClient(roundStateUpdaterHttpClient)
|
||||||
|
.GetLegalDocumentsAsync(CancellationToken.None)
|
||||||
|
.ContinueWith(task =>
|
||||||
|
{
|
||||||
|
if (task.Status == TaskStatus.RanToCompletion)
|
||||||
|
{
|
||||||
|
TermsConditions = task.Result;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
sharedWabisabiClient = new WabiSabiHttpApiClient(roundStateUpdaterHttpClient);
|
sharedWabisabiClient = new WabiSabiHttpApiClient(roundStateUpdaterHttpClient);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ namespace BTCPayServer.Plugins.Wabisabi
|
|||||||
{
|
{
|
||||||
coordSettings.DiscoveredCoordinators.Add(viewModel);
|
coordSettings.DiscoveredCoordinators.Add(viewModel);
|
||||||
await _wabisabiCoordinatorService.UpdateSettings(coordSettings);
|
await _wabisabiCoordinatorService.UpdateSettings(coordSettings);
|
||||||
_instanceManager.AddCoordinator(viewModel.Name, viewModel.Name, provider => viewModel.Uri);
|
_instanceManager.AddCoordinator(viewModel.Name, viewModel.Name, provider => viewModel.Uri, viewModel.Description);
|
||||||
|
|
||||||
TempData["SuccessMessage"] = $"Coordinator {viewModel.Name } added and started";
|
TempData["SuccessMessage"] = $"Coordinator {viewModel.Name } added and started";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user