diff --git a/Plugins/BTCPayServer.Plugins.NIP05/BTCPayServer.Plugins.NIP05.csproj b/Plugins/BTCPayServer.Plugins.NIP05/BTCPayServer.Plugins.NIP05.csproj index ec82866..0ee3bf5 100644 --- a/Plugins/BTCPayServer.Plugins.NIP05/BTCPayServer.Plugins.NIP05.csproj +++ b/Plugins/BTCPayServer.Plugins.NIP05/BTCPayServer.Plugins.NIP05.csproj @@ -11,7 +11,7 @@ Nostr NIP5 addresses, Zap support, Nostr Wallet Connect Lightning support - 1.1.10 + 1.1.11 true diff --git a/Plugins/BTCPayServer.Plugins.NIP05/NostrWalletConnectLightningClient.cs b/Plugins/BTCPayServer.Plugins.NIP05/NostrWalletConnectLightningClient.cs index 364b63e..78d3774 100644 --- a/Plugins/BTCPayServer.Plugins.NIP05/NostrWalletConnectLightningClient.cs +++ b/Plugins/BTCPayServer.Plugins.NIP05/NostrWalletConnectLightningClient.cs @@ -11,6 +11,7 @@ using NBitcoin; using NBitcoin.Secp256k1; using NNostr.Client; using NNostr.Client.Protocols; +using SHA256 = System.Security.Cryptography.SHA256; namespace BTCPayServer.Plugins.NIP05; @@ -122,10 +123,10 @@ public class NostrWalletConnectLightningClient : ILightningClient private LightningPayment? ToLightningPayment(NIP47.Nip47Transaction tx) { - if (tx.Type != "outgoing") - { - return null; - } + // if (tx.Type != "outgoing") + // { + // return null; + // } var isPaid = tx.SettledAt.HasValue || !string.IsNullOrEmpty(tx.Preimage); var invoice = BOLT11PaymentRequest.Parse(tx.Invoice, _network); @@ -415,7 +416,19 @@ public class NostrWalletConnectLightningClient : ILightningClient ? Convert.ToDecimal(payParams.Amount.MilliSatoshi) : null, }, cancellation); - var lp = ToLightningPayment(response); + + var payHash = response.PaymentHash?? + payParams?.PaymentHash?.ToString()?? + (response.Preimage is not null? + ConvertHelper.ToHexString(SHA256.HashData(Convert.FromHexString(response.Preimage))): + BOLT11PaymentRequest.Parse(bolt11, _network).PaymentHash.ToString()); + + var tx = await client.SendNIP47Request(_connectParams.pubkey, _connectParams.secret, + new NIP47 .LookupInvoiceRequest() + { + PaymentHash = payHash + }, cancellation); + var lp = ToLightningPayment(tx)!; return new PayResponse(lp.Status == LightningPaymentStatus.Complete ? PayResult.Ok : PayResult.Error, new PayDetails() { @@ -426,7 +439,7 @@ public class NostrWalletConnectLightningClient : ILightningClient FeeAmount = lp.Fee }); } - } + } catch (Exception e) { return new PayResponse()