mirror of
https://github.com/aljazceru/BTCPayServerPlugins.git
synced 2025-12-17 07:34:24 +01:00
update nostr plugin
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
<PropertyGroup>
|
||||
<Product>Nostr </Product>
|
||||
<Description>Allows you to verify your nostr account with NIP5 and zap like the rest of the crazies</Description>
|
||||
<Version>1.0.15</Version>
|
||||
<Version>1.0.16</Version>
|
||||
</PropertyGroup>
|
||||
<!-- Plugin development properties -->
|
||||
<PropertyGroup>
|
||||
|
||||
@@ -34,8 +34,12 @@ public class LnurlDescriptionFilter : PluginHookFilter<string>
|
||||
|
||||
public override async Task<string> Execute(string arg)
|
||||
{
|
||||
if(_httpContextAccessor.HttpContext is null)
|
||||
return arg;
|
||||
if (_httpContextAccessor.HttpContext.Request.Query.TryGetValue("nostr", out var nostr) &&
|
||||
_httpContextAccessor.HttpContext.Request.RouteValues.TryGetValue("invoiceId", out var invoiceId))
|
||||
(_httpContextAccessor.HttpContext.Request.RouteValues.TryGetValue("invoiceId", out var invoiceId) ||
|
||||
_httpContextAccessor.HttpContext.Items.TryGetValue("invoiceId", out invoiceId)
|
||||
))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -47,21 +51,17 @@ public class LnurlDescriptionFilter : PluginHookFilter<string>
|
||||
{
|
||||
return arg;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
var lnAddress = await _lightningAddressService.ResolveByAddress(username);
|
||||
if (lnAddress is null)
|
||||
{
|
||||
return arg;
|
||||
}
|
||||
|
||||
var user = await _nip5Controller.Get(username);
|
||||
if (user.storeId is not null)
|
||||
{
|
||||
if (user.storeId != lnAddress.StoreDataId)
|
||||
{
|
||||
return arg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
var parsedNote = System.Text.Json.JsonSerializer.Deserialize<NostrEvent>(nostr);
|
||||
if (parsedNote?.Kind != 9734)
|
||||
{
|
||||
@@ -79,7 +79,6 @@ public class LnurlDescriptionFilter : PluginHookFilter<string>
|
||||
entry.SetValue(nostr);
|
||||
return nostr;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, $"Error while processing nostr zap request for invoice {invoiceId}\n{nostr}");
|
||||
|
||||
@@ -38,12 +38,7 @@ public class ZapperSettings
|
||||
public ECXOnlyPubKey ZappingPublicKey => ZappingKey.CreateXOnlyPubKey();
|
||||
[JsonIgnore]
|
||||
public string ZappingPublicKeyHex => ZappingPublicKey.ToHex();
|
||||
public string ZapperPrivateKey { get; init; }
|
||||
|
||||
public void Deconstruct(out string ZapperPrivateKey)
|
||||
{
|
||||
ZapperPrivateKey = this.ZapperPrivateKey;
|
||||
}
|
||||
public string ZapperPrivateKey { get; set; }
|
||||
}
|
||||
public class Zapper : IHostedService
|
||||
{
|
||||
@@ -55,11 +50,18 @@ public class Zapper : IHostedService
|
||||
private readonly ILogger<Zapper> _logger;
|
||||
private readonly SettingsRepository _settingsRepository;
|
||||
private IEventAggregatorSubscription _subscription;
|
||||
private ConcurrentBag<PendingZapEvent> _pendingZapEvents = new();
|
||||
private readonly ConcurrentBag<PendingZapEvent> _pendingZapEvents = new();
|
||||
|
||||
public async Task<ZapperSettings> GetSettings()
|
||||
{ var result = await _settingsRepository.GetSettingAsync<ZapperSettings>( "Zapper");
|
||||
if (result is not null) return result;
|
||||
{
|
||||
var result = await _settingsRepository.GetSettingAsync<ZapperSettings>("Zapper");
|
||||
|
||||
if (result is not null)
|
||||
{
|
||||
result.ZapperPrivateKey ??= Convert.ToHexString(RandomUtils.GetBytes(32));
|
||||
return result;
|
||||
}
|
||||
|
||||
result = new ZapperSettings(Convert.ToHexString(RandomUtils.GetBytes(32)));
|
||||
await _settingsRepository.UpdateSetting(result, "Zapper");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user