mirror of
https://github.com/aljazceru/BTCPayServerPlugins.git
synced 2025-12-17 07:34:24 +01:00
coord poster
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Product>Coinjoin</Product>
|
<Product>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.80</Version>
|
<Version>1.0.81</Version>
|
||||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ using BTCPayServer.Services;
|
|||||||
using Microsoft.AspNetCore.Routing;
|
using Microsoft.AspNetCore.Routing;
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using NBitcoin;
|
using NBitcoin;
|
||||||
@@ -22,14 +23,18 @@ using NBitcoin.Secp256k1;
|
|||||||
using NBXplorer;
|
using NBXplorer;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using NNostr.Client;
|
using NNostr.Client;
|
||||||
|
using NNostr.Client.Protocols;
|
||||||
using WalletWasabi.Bases;
|
using WalletWasabi.Bases;
|
||||||
using WalletWasabi.BitcoinCore.Rpc;
|
using WalletWasabi.BitcoinCore.Rpc;
|
||||||
using WalletWasabi.Cache;
|
using WalletWasabi.Cache;
|
||||||
using WalletWasabi.Services;
|
using WalletWasabi.Services;
|
||||||
|
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.Rounds.CoinJoinStorage;
|
||||||
using WalletWasabi.WabiSabi.Backend.Statistics;
|
using WalletWasabi.WabiSabi.Backend.Statistics;
|
||||||
|
using WalletWasabi.WabiSabi.Models;
|
||||||
|
using WalletWasabi.WebClients.Wasabi;
|
||||||
|
|
||||||
namespace WalletWasabi.Backend.Controllers;
|
namespace WalletWasabi.Backend.Controllers;
|
||||||
|
|
||||||
@@ -267,6 +272,46 @@ public class WabisabiCoordinatorService : PeriodicRunner
|
|||||||
s.UriToAdvertise is not null)
|
s.UriToAdvertise is not null)
|
||||||
{
|
{
|
||||||
var k = s.GetKey();
|
var k = s.GetKey();
|
||||||
|
|
||||||
|
if(s.UriToAdvertise.Scheme.StartsWith("http", StringComparison.InvariantCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
//make sure the end is with plugins/wabisabi-coordinator/
|
||||||
|
var uri = new UriBuilder(s.UriToAdvertise);
|
||||||
|
|
||||||
|
uri.Path = uri.Path.Replace("plugins/wabisabi-coordinator/", "").TrimEnd('/') + "/plugins/wabisabi-coordinator/";
|
||||||
|
|
||||||
|
}
|
||||||
|
//verify the url
|
||||||
|
IWasabiHttpClientFactory factory = null;
|
||||||
|
if (s.UriToAdvertise.Scheme == "nostr" &&
|
||||||
|
s.UriToAdvertise.Host.FromNIP19Note() is NIP19.NosteProfileNote nostrProfileNote)
|
||||||
|
{
|
||||||
|
factory = new NostrWabisabiClientFactory(null, nostrProfileNote);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
factory = new WasabiHttpClientFactory(null, () => s.UriToAdvertise);
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
var handler = factory.NewWabiSabiApiRequestHandler(Mode.SingleCircuitPerLifetime);
|
||||||
|
var resp = await handler.GetStatusAsync(RoundStateRequest.Empty, cancel);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (factory is IHostedService hs)
|
||||||
|
{
|
||||||
|
await hs.StopAsync(cancel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_logger.LogInformation("Publishing coordinator discovery event with url {0}", s.UriToAdvertise);
|
||||||
|
|
||||||
|
|
||||||
await Nostr.Publish(s.NostrRelay,
|
await Nostr.Publish(s.NostrRelay,
|
||||||
new[]
|
new[]
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public class Nostr
|
|||||||
Socks5HttpClientHandler? httpClientHandler,
|
Socks5HttpClientHandler? httpClientHandler,
|
||||||
CancellationToken cancellationToken )
|
CancellationToken cancellationToken )
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!evts.Any())
|
if (!evts.Any())
|
||||||
return;
|
return;
|
||||||
var ct = CancellationTokenSource
|
var ct = CancellationTokenSource
|
||||||
@@ -57,7 +58,7 @@ public class Nostr
|
|||||||
Content = description??string.Empty,
|
Content = description??string.Empty,
|
||||||
Tags = new List<NostrEventTag>()
|
Tags = new List<NostrEventTag>()
|
||||||
{
|
{
|
||||||
new() {TagIdentifier = EndpointTagIdentifier, Data = new List<string>() {new Uri(coordinatorUri, "plugins/wabisabi-coordinator/").ToString()}},
|
new() {TagIdentifier = EndpointTagIdentifier, Data = new List<string>() {coordinatorUri.ToString()}},
|
||||||
new() {TagIdentifier = TypeTagIdentifier, Data = new List<string>() { TypeTagValue}},
|
new() {TagIdentifier = TypeTagIdentifier, Data = new List<string>() { TypeTagValue}},
|
||||||
new() {TagIdentifier = NetworkTagIdentifier, Data = new List<string>() {currentNetwork.ChainName.ToString().ToLower()}}
|
new() {TagIdentifier = NetworkTagIdentifier, Data = new List<string>() {currentNetwork.ChainName.ToString().ToLower()}}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user