Fix: Lightning Listener not listening on Lightning payment after activating when using lazy payments (#2524)

This commit is contained in:
Andrew Camilleri 2021-05-14 10:17:07 +02:00 committed by GitHub
parent a8cf6ee8a2
commit 778a0f7e8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 1 deletions

View file

@ -1,4 +1,4 @@
using BTCPayServer.Services.Invoices;
using BTCPayServer.Services.Invoices;
namespace BTCPayServer.Events
{

View file

@ -0,0 +1,24 @@
using BTCPayServer.Payments;
using BTCPayServer.Services.Invoices;
namespace BTCPayServer.Events
{
public class InvoicePaymentMethodActivated : IHasInvoiceId
{
public PaymentMethodId PaymentMethodId { get; }
public InvoiceEntity InvoiceEntity { get; }
public InvoicePaymentMethodActivated(PaymentMethodId paymentMethodId, InvoiceEntity invoiceEntity)
{
PaymentMethodId = paymentMethodId;
InvoiceEntity = invoiceEntity;
}
public string InvoiceId => InvoiceEntity.Id;
public override string ToString()
{
return $"Invoice {InvoiceId} activated payment method {PaymentMethodId}";
}
}
}

View file

@ -168,6 +168,13 @@ namespace BTCPayServer.Payments.Lightning
}
}));
leases.Add(_Aggregator.Subscribe<Events.InvoicePaymentMethodActivated>(async inv =>
{
if (inv.PaymentMethodId.PaymentType == LightningPaymentType.Instance)
{
_CheckInvoices.Writer.TryWrite(inv.InvoiceId);
}
}));
_CheckingInvoice = CheckingInvoice(_Cts.Token);
_ListenPoller = new Timer(async s =>
{

View file

@ -33,6 +33,7 @@ namespace BTCPayServer.Services.Invoices
prepare);
eligibleMethodToActivate.SetPaymentMethodDetails(newDetails);
await invoiceRepository.UpdateInvoicePaymentMethod(invoice.Id, eligibleMethodToActivate);
eventAggregator.Publish(new InvoicePaymentMethodActivated(paymentMethodId, invoice));
}
catch (PaymentMethodUnavailableException ex)
{