(nostr);
+ if (parsedNote?.Kind != 9734)
+ {
+ throw new InvalidOperationException("Invalid zap note, kind must be 9734");
+ }
+
+ if (!parsedNote.Verify())
+ {
+ throw new InvalidOperationException("Zap note sig check failed");
+ }
+
+ var invoice = await _invoiceRepository.GetInvoice(invoiceId.ToString());
+
+ invoice.Metadata.SetAdditionalData("zapRequest", nostr);
+ await _invoiceRepository.UpdateInvoiceMetadata(invoiceId.ToString(), invoice.StoreId,
+ invoice.Metadata.ToJObject());
+ return nostr;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ }
+
+ return arg;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Plugins/BTCPayServer.Plugins.NIP05/Nip5Controller.cs b/Plugins/BTCPayServer.Plugins.NIP05/Nip5Controller.cs
index ef95760..caabe4c 100644
--- a/Plugins/BTCPayServer.Plugins.NIP05/Nip5Controller.cs
+++ b/Plugins/BTCPayServer.Plugins.NIP05/Nip5Controller.cs
@@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;
+using NBitcoin.Secp256k1;
using NNostr.Client;
using NNostr.Client.Protocols;
@@ -85,6 +86,38 @@ public class Nip5Controller : Controller
ModelState.AddModelError(nameof(settings.PubKey), "invalid public key");
}
+ if (!string.IsNullOrEmpty(settings.PrivateKey))
+ {
+ try
+ {
+ ECPrivKey k;
+ try
+ {
+k = settings.PrivateKey.FromNIP19Nsec();
+ }
+ catch (Exception e)
+ {
+
+ k = NostrExtensions.ParseKey(settings.PrivateKey);
+ }
+
+ if (string.IsNullOrEmpty(settings.PubKey))
+ {
+
+ settings.PubKey = k.CreateXOnlyPubKey().ToHex();
+ ModelState.Remove(nameof(settings.PubKey));
+ }
+ else if(settings.PubKey != k.CreateXOnlyPubKey().ToHex())
+ ModelState.AddModelError(nameof(settings.PrivateKey), "private key does not match public key provided. Clear the public key to generate it from the private key.");
+ }
+ catch (Exception e)
+ {
+
+ ModelState.AddModelError(nameof(settings.PubKey), "invalid private key");
+ }
+ }
+
+
if (!ModelState.IsValid)
{
return View(settings);
@@ -109,8 +142,8 @@ public class Nip5Controller : Controller
await _storeRepository.UpdateSetting(storeId, "NIP05", settings);
return RedirectToAction("Edit", new {storeId});
}
-
- private async Task<(string? storeId, Nip5StoreSettings? settings)> Get(string name)
+[NonAction]
+ public async Task<(string? storeId, Nip5StoreSettings? settings)> Get(string name)
{
var rex = await _memoryCache.GetOrCreateAsync<(string? storeId, Nip5StoreSettings? settings)>(
$"NIP05_{name.ToLowerInvariant()}",
diff --git a/Plugins/BTCPayServer.Plugins.NIP05/Nip5StoreSettings.cs b/Plugins/BTCPayServer.Plugins.NIP05/Nip5StoreSettings.cs
index d8d7c61..58130ce 100644
--- a/Plugins/BTCPayServer.Plugins.NIP05/Nip5StoreSettings.cs
+++ b/Plugins/BTCPayServer.Plugins.NIP05/Nip5StoreSettings.cs
@@ -8,6 +8,7 @@ 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 string[]? Relays { get; set; }
diff --git a/Plugins/BTCPayServer.Plugins.NIP05/Views/Nip5/Edit.cshtml b/Plugins/BTCPayServer.Plugins.NIP05/Views/Nip5/Edit.cshtml
index 8cec5cf..dca6d5b 100644
--- a/Plugins/BTCPayServer.Plugins.NIP05/Views/Nip5/Edit.cshtml
+++ b/Plugins/BTCPayServer.Plugins.NIP05/Views/Nip5/Edit.cshtml
@@ -2,7 +2,7 @@
@using Microsoft.AspNetCore.Mvc.TagHelpers
@model Nip5StoreSettings
@{
- ViewData.SetActivePage("Nostr NIP05", "Nostr NIP05", "Nostr NIP05");
+ ViewData.SetActivePage("Nostr", "Nostr", "Nostr");
}
@@ -23,6 +23,12 @@
+
diff --git a/submodules/btcpayserver b/submodules/btcpayserver
index 9d72b97..6388057 160000
--- a/submodules/btcpayserver
+++ b/submodules/btcpayserver
@@ -1 +1 @@
-Subproject commit 9d72b9779e9c1addaf7e101a2809619716d38f75
+Subproject commit 6388057806d8a04e90230645e07a6120ed4e17ff