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>
|
<PropertyGroup>
|
||||||
<Product>Nostr </Product>
|
<Product>Nostr </Product>
|
||||||
<Description>Allows you to verify your nostr account with NIP5 and zap like the rest of the crazies</Description>
|
<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>
|
</PropertyGroup>
|
||||||
<!-- Plugin development properties -->
|
<!-- Plugin development properties -->
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Cors;
|
using Microsoft.AspNetCore.Cors;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
|
using NBitcoin.DataEncoders;
|
||||||
using NBitcoin.Secp256k1;
|
using NBitcoin.Secp256k1;
|
||||||
using NNostr.Client;
|
using NNostr.Client;
|
||||||
using NNostr.Client.Protocols;
|
using NNostr.Client.Protocols;
|
||||||
@@ -66,10 +67,14 @@ public class Nip5Controller : Controller
|
|||||||
{
|
{
|
||||||
try
|
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();
|
var note = (NIP19.NosteProfileNote) settings.PubKey.FromNIP19Note();
|
||||||
|
settings.PubKey = note.PubKey;
|
||||||
|
settings.Relays = (settings.Relays ?? Array.Empty<string>())?.Concat(note.Relays).ToArray();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
@@ -100,7 +105,8 @@ k = settings.PrivateKey.FromNIP19Nsec();
|
|||||||
|
|
||||||
k = NostrExtensions.ParseKey(settings.PrivateKey);
|
k = NostrExtensions.ParseKey(settings.PrivateKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
settings.PrivateKey = k.ToHex();
|
||||||
if (string.IsNullOrEmpty(settings.PubKey))
|
if (string.IsNullOrEmpty(settings.PubKey))
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -113,7 +119,7 @@ k = settings.PrivateKey.FromNIP19Nsec();
|
|||||||
catch (Exception e)
|
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
|
namespace BTCPayServer.Plugins.NIP05
|
||||||
{
|
{
|
||||||
}
|
public class Nip5StoreSettings
|
||||||
|
{
|
||||||
|
[Required] public string PubKey { get; set; }
|
||||||
|
|
||||||
|
public string? PrivateKey { get; set; }
|
||||||
|
[Required] public string Name { get; set; }
|
||||||
|
|
||||||
public class Nip5StoreSettings
|
public string[]? Relays { get; set; }
|
||||||
{
|
}
|
||||||
[Required] public string PubKey { 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.Extensions
|
||||||
|
@using BTCPayServer.Abstractions.TagHelpers
|
||||||
@using Microsoft.AspNetCore.Mvc.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");
|
ViewData.SetActivePage("Nostr", "Nostr", "Nostr");
|
||||||
}
|
}
|
||||||
@@ -26,8 +29,9 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="PrivateKey" class="form-label">Private key for zaps</label>
|
<label asp-for="PrivateKey" class="form-label">Private key for zaps</label>
|
||||||
<input asp-for="PrivateKey" class="form-control"/>
|
<input asp-for="PrivateKey" class="form-control"/>
|
||||||
<span asp-validation-for="PubKey" class="text-danger"></span>
|
<span asp-validation-for="PrivateKey" class="text-danger"></span>
|
||||||
<p class="text-muted">You'll also need to enable a lightning address with the same name.</p>
|
<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>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
permission="@Policies.CanModifyStoreSettings">
|
permission="@Policies.CanModifyStoreSettings">
|
||||||
<svg role="img" class="icon">
|
<svg role="img" class="icon">
|
||||||
</svg>
|
</svg>
|
||||||
<span>NIP05</span>
|
<span>Nostr</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user