diff --git a/BTCPayServer/Payments/Bitcoin/NBXplorerListener.cs b/BTCPayServer/Payments/Bitcoin/NBXplorerListener.cs index 9bc744b81..f6bef01af 100644 --- a/BTCPayServer/Payments/Bitcoin/NBXplorerListener.cs +++ b/BTCPayServer/Payments/Bitcoin/NBXplorerListener.cs @@ -238,6 +238,10 @@ namespace BTCPayServer.Payments.Bitcoin } } + // if needed add invoice back to pending to track number of confirmations + if (paymentData.ConfirmationCount < wallet.Network.MaxTrackedConfirmation) + await _InvoiceRepository.AddPendingInvoiceIfNotPresent(invoice.Id); + if (updated) updatedPaymentEntities.Add(payment); } diff --git a/BTCPayServer/Services/Invoices/InvoiceRepository.cs b/BTCPayServer/Services/Invoices/InvoiceRepository.cs index 529cd7184..41b0524de 100644 --- a/BTCPayServer/Services/Invoices/InvoiceRepository.cs +++ b/BTCPayServer/Services/Invoices/InvoiceRepository.cs @@ -274,6 +274,18 @@ retry: } } + public async Task AddPendingInvoiceIfNotPresent(string invoiceId) + { + using (var context = _ContextFactory.CreateContext()) + { + if (!context.PendingInvoices.Any(a => a.Id == invoiceId)) + { + context.PendingInvoices.Add(new PendingInvoiceData() { Id = invoiceId }); + await context.SaveChangesAsync(); + } + } + } + public async Task AddInvoiceEvent(string invoiceId, object evt) { using (var context = _ContextFactory.CreateContext())