mirror of
https://github.com/aljazceru/BTCPayServerPlugins.git
synced 2025-12-17 07:34:24 +01:00
handle resp better for payment
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Product>Nostr</Product>
|
<Product>Nostr</Product>
|
||||||
<Description>NIP5 addresses, Zap support, Nostr Wallet Connect Lightning support</Description>
|
<Description>NIP5 addresses, Zap support, Nostr Wallet Connect Lightning support</Description>
|
||||||
<Version>1.1.10</Version>
|
<Version>1.1.11</Version>
|
||||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<!-- Plugin development properties -->
|
<!-- Plugin development properties -->
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ using NBitcoin;
|
|||||||
using NBitcoin.Secp256k1;
|
using NBitcoin.Secp256k1;
|
||||||
using NNostr.Client;
|
using NNostr.Client;
|
||||||
using NNostr.Client.Protocols;
|
using NNostr.Client.Protocols;
|
||||||
|
using SHA256 = System.Security.Cryptography.SHA256;
|
||||||
|
|
||||||
namespace BTCPayServer.Plugins.NIP05;
|
namespace BTCPayServer.Plugins.NIP05;
|
||||||
|
|
||||||
@@ -122,10 +123,10 @@ public class NostrWalletConnectLightningClient : ILightningClient
|
|||||||
|
|
||||||
private LightningPayment? ToLightningPayment(NIP47.Nip47Transaction tx)
|
private LightningPayment? ToLightningPayment(NIP47.Nip47Transaction tx)
|
||||||
{
|
{
|
||||||
if (tx.Type != "outgoing")
|
// if (tx.Type != "outgoing")
|
||||||
{
|
// {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
|
||||||
var isPaid = tx.SettledAt.HasValue || !string.IsNullOrEmpty(tx.Preimage);
|
var isPaid = tx.SettledAt.HasValue || !string.IsNullOrEmpty(tx.Preimage);
|
||||||
var invoice = BOLT11PaymentRequest.Parse(tx.Invoice, _network);
|
var invoice = BOLT11PaymentRequest.Parse(tx.Invoice, _network);
|
||||||
@@ -415,7 +416,19 @@ public class NostrWalletConnectLightningClient : ILightningClient
|
|||||||
? Convert.ToDecimal(payParams.Amount.MilliSatoshi)
|
? Convert.ToDecimal(payParams.Amount.MilliSatoshi)
|
||||||
: null,
|
: null,
|
||||||
}, cancellation);
|
}, 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<NIP47.Nip47Transaction>(_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,
|
return new PayResponse(lp.Status == LightningPaymentStatus.Complete ? PayResult.Ok : PayResult.Error,
|
||||||
new PayDetails()
|
new PayDetails()
|
||||||
{
|
{
|
||||||
@@ -426,7 +439,7 @@ public class NostrWalletConnectLightningClient : ILightningClient
|
|||||||
FeeAmount = lp.Fee
|
FeeAmount = lp.Fee
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
return new PayResponse()
|
return new PayResponse()
|
||||||
|
|||||||
Reference in New Issue
Block a user