This commit is contained in:
Kukks
2023-08-18 11:42:29 +02:00
parent 4862617f3e
commit 4483806f82
3 changed files with 12 additions and 16 deletions

View File

@@ -217,24 +217,15 @@ public class WabisabiCoordinatorService : PeriodicRunner
{
var network = _clientProvider.GetExplorerClient("BTC").Network.NBitcoinNetwork;
var s = await GetSettings();
if (s.Enabled && !string.IsNullOrEmpty(s.NostrIdentity) && s.NostrRelay is not null &&
s.UriToAdvertise is not null)
{
ECPrivKey key;
try
{
key = NostrExtensions.ParseKey(s.NostrIdentity);
}
catch (Exception e)
{
s.NostrIdentity = null;
await UpdateSettings(s);
throw;
}
var k = s.GetKey();
await Nostr.Publish(s.NostrRelay,
new[]
{
await Nostr.CreateCoordinatorDiscoveryEvent(network, key, s.UriToAdvertise,
await Nostr.CreateCoordinatorDiscoveryEvent(network, k, s.UriToAdvertise,
s.CoordinatorDescription)
},s.UriToAdvertise.IsOnion()? _socks5HttpClientHandler: null, cancel);
}

View File

@@ -14,9 +14,14 @@ public class WabisabiCoordinatorSettings
public Uri NostrRelay { get; set; } = new Uri("wss://kukks.org/nostr");
public List<DiscoveredCoordinator> DiscoveredCoordinators { get; set; } = new();
[JsonIgnore] public ECPrivKey? Key => string.IsNullOrEmpty(NostrIdentity)? null: NostrExtensions.ParseKey(NostrIdentity);
[JsonIgnore] public ECXOnlyPubKey PubKey => Key?.CreatePubKey().ToXOnlyPubKey();
public ECPrivKey GetKey()
{
return string.IsNullOrEmpty(NostrIdentity) ? null : NostrExtensions.ParseKey(NostrIdentity);
}
public ECXOnlyPubKey GetPubKey() => GetKey()?.CreatePubKey().ToXOnlyPubKey();
public Uri UriToAdvertise { get; set; }
public string TermsConditions { get; set; } = @"
These terms and conditions govern your use of the Coinjoin Coordinator service. By using the service, you agree to be bound by these terms and conditions. If you do not agree to these terms and conditions, you should not use the service.

View File

@@ -183,7 +183,7 @@ namespace BTCPayServer.Plugins.Wabisabi
var result = await Nostr.Discover(
_socks5HttpClientHandler, relayUri,
network,
coordSettings.Key?.CreateXOnlyPubKey().ToHex(), CancellationToken.None);
coordSettings.GetPubKey()?.ToHex(), CancellationToken.None);
if(result.Any())
TempData["DiscoveredCoordinators"] = JsonConvert.SerializeObject(result);
else