mirror of
https://github.com/aljazceru/BTCPayServerPlugins.git
synced 2025-12-17 07:34:24 +01:00
fix 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.4</Version>
|
||||
<Version>1.0.5</Version>
|
||||
</PropertyGroup>
|
||||
<!-- Plugin development properties -->
|
||||
<PropertyGroup>
|
||||
|
||||
@@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Cors;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using NBitcoin.DataEncoders;
|
||||
using NBitcoin.Secp256k1;
|
||||
using NNostr.Client;
|
||||
using NNostr.Client.Protocols;
|
||||
@@ -65,11 +66,15 @@ public class Nip5Controller : Controller
|
||||
catch (Exception)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!HexEncoder.IsWellFormed(settings.PubKey))
|
||||
{
|
||||
|
||||
var note = (NIP19.NosteProfileNote) settings.PubKey.FromNIP19Note();
|
||||
settings.PubKey = note.PubKey;
|
||||
settings.Relays = (settings.Relays ?? new string[0])?.Concat(note.Relays).ToArray();
|
||||
settings.Relays = (settings.Relays ?? Array.Empty<string>())?.Concat(note.Relays).ToArray();
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -101,6 +106,7 @@ k = settings.PrivateKey.FromNIP19Nsec();
|
||||
k = NostrExtensions.ParseKey(settings.PrivateKey);
|
||||
}
|
||||
|
||||
settings.PrivateKey = k.ToHex();
|
||||
if (string.IsNullOrEmpty(settings.PubKey))
|
||||
{
|
||||
|
||||
@@ -113,7 +119,7 @@ k = settings.PrivateKey.FromNIP19Nsec();
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
ModelState.AddModelError(nameof(settings.PubKey), "invalid private key");
|
||||
ModelState.AddModelError(nameof(settings.PrivateKey), "invalid private key");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,13 +3,13 @@ using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace BTCPayServer.Plugins.NIP05
|
||||
{
|
||||
}
|
||||
|
||||
public class Nip5StoreSettings
|
||||
{
|
||||
[Required] public string PubKey { get; set; }
|
||||
public string PrivateKey { get; set; }
|
||||
|
||||
public string? PrivateKey { get; set; }
|
||||
[Required] public string Name { get; set; }
|
||||
|
||||
public string[]? Relays { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
@using BTCPayServer.Abstractions.Extensions
|
||||
@using BTCPayServer.Abstractions.TagHelpers
|
||||
@using Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
@model Nip5StoreSettings
|
||||
@using BTCPayServer.Abstractions.Contracts
|
||||
@model BTCPayServer.Plugins.NIP05.Nip5StoreSettings
|
||||
@inject IScopeProvider ScopeProvider
|
||||
@{
|
||||
ViewData.SetActivePage("Nostr", "Nostr", "Nostr");
|
||||
}
|
||||
@@ -26,8 +29,9 @@
|
||||
<div class="form-group">
|
||||
<label asp-for="PrivateKey" class="form-label">Private key for zaps</label>
|
||||
<input asp-for="PrivateKey" class="form-control"/>
|
||||
<span asp-validation-for="PubKey" class="text-danger"></span>
|
||||
<p class="text-muted">You'll also need to enable a lightning address with the same name.</p>
|
||||
<span asp-validation-for="PrivateKey" class="text-danger"></span>
|
||||
<p class="text-muted">You'll also need to <a asp-action="EditLightningAddress" asp-controller="UILNURL" asp-route-storeId="@ScopeProvider.GetCurrentStoreId()">enable a lightning address</a> with the same name.</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
permission="@Policies.CanModifyStoreSettings">
|
||||
<svg role="img" class="icon">
|
||||
</svg>
|
||||
<span>NIP05</span>
|
||||
<span>Nostr</span>
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user