mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-19 09:54:30 +01:00
Match Lightning payment based on payment hash if BOLT11 is not the same. (#2773)
* Match Lightning payment based on payment hash if BOLT11 is not the same. * Fixup * Fixup Co-authored-by: Nicolas Dorier <nicolas.dorier@gmail.com>
This commit is contained in:
parent
d3f9eb38a9
commit
039f88d14c
@ -114,6 +114,7 @@ namespace BTCPayServer.Payments.Lightning
|
||||
{
|
||||
Activated = true,
|
||||
BOLT11 = lightningInvoice.BOLT11,
|
||||
PaymentHash = BOLT11PaymentRequest.Parse(lightningInvoice.BOLT11, network.NBitcoinNetwork).PaymentHash,
|
||||
InvoiceId = lightningInvoice.Id,
|
||||
NodeInfo = nodeInfo.First().ToString()
|
||||
};
|
||||
|
@ -1,8 +1,12 @@
|
||||
using BTCPayServer.Lightning;
|
||||
using NBitcoin;
|
||||
|
||||
namespace BTCPayServer.Payments.Lightning
|
||||
{
|
||||
public class LightningLikePaymentMethodDetails : IPaymentMethodDetails
|
||||
{
|
||||
public string BOLT11 { get; set; }
|
||||
public uint256 PaymentHash { get; set; }
|
||||
public string InvoiceId { get; set; }
|
||||
public string NodeInfo { get; set; }
|
||||
|
||||
@ -11,6 +15,11 @@ namespace BTCPayServer.Payments.Lightning
|
||||
return BOLT11;
|
||||
}
|
||||
|
||||
public uint256 GetPaymentHash(Network network)
|
||||
{
|
||||
return PaymentHash ?? BOLT11PaymentRequest.Parse(BOLT11, network).PaymentHash;
|
||||
}
|
||||
|
||||
public PaymentType GetPaymentType()
|
||||
{
|
||||
return PaymentTypes.LightningLike;
|
||||
|
@ -344,7 +344,7 @@ namespace BTCPayServer.Payments.Lightning
|
||||
internal async Task<LightningInvoiceStatus?> PollPayment(ListenedInvoice listenedInvoice, CancellationToken cancellation)
|
||||
{
|
||||
var client = _lightningClientFactory.Create(ConnectionString, _network);
|
||||
LightningInvoice lightningInvoice = await client.GetInvoice(listenedInvoice.PaymentMethodDetails.InvoiceId);
|
||||
LightningInvoice lightningInvoice = await client.GetInvoice(listenedInvoice.PaymentMethodDetails.InvoiceId, cancellation);
|
||||
if (lightningInvoice?.Status is LightningInvoiceStatus.Paid &&
|
||||
await AddPayment(lightningInvoice, listenedInvoice.InvoiceId))
|
||||
{
|
||||
@ -385,7 +385,9 @@ namespace BTCPayServer.Payments.Lightning
|
||||
if (!_ListenedInvoices.TryGetValue(notification.Id, out var listenedInvoice))
|
||||
continue;
|
||||
if (notification.Id == listenedInvoice.PaymentMethodDetails.InvoiceId &&
|
||||
notification.BOLT11 == listenedInvoice.PaymentMethodDetails.BOLT11)
|
||||
(notification.BOLT11 == listenedInvoice.PaymentMethodDetails.BOLT11 ||
|
||||
BOLT11PaymentRequest.Parse(notification.BOLT11, _network.NBitcoinNetwork).PaymentHash ==
|
||||
listenedInvoice.PaymentMethodDetails.GetPaymentHash(_network.NBitcoinNetwork)))
|
||||
{
|
||||
if (notification.Status == LightningInvoiceStatus.Paid &&
|
||||
notification.PaidAt.HasValue && notification.Amount != null)
|
||||
|
Loading…
Reference in New Issue
Block a user