Adding invoice back to pending to track confirmations if less than max

This commit is contained in:
rockstardev
2019-05-25 17:30:27 -05:00
parent b300404bc7
commit 112f9c4241
2 changed files with 16 additions and 0 deletions

View File

@@ -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);
}

View File

@@ -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())