From 7b88e40494b5519b47a422ec26cb8e30c65762f5 Mon Sep 17 00:00:00 2001 From: kiwiidb Date: Fri, 28 Jul 2023 10:55:14 +0200 Subject: [PATCH] don't process unsettled invoices --- reconciliation_lost_invoices/main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/reconciliation_lost_invoices/main.go b/reconciliation_lost_invoices/main.go index d15e84b8..73b66513 100644 --- a/reconciliation_lost_invoices/main.go +++ b/reconciliation_lost_invoices/main.go @@ -107,10 +107,14 @@ func main() { if creationDate.Before(time.Now().Add(-1 * time.Duration(rc.NumDays) * 24 * time.Hour)) { return } + //non-settled invoices don't matter + if !lndInvoice.Settled { + continue + } // - get payment hash and do a db query var dbInvoice models.Invoice - err := svc.DB.NewSelect().Model(&dbInvoice).Where("invoice.r_hash = ? AND state = ?", hex.EncodeToString(lndInvoice.RHash), common.InvoiceStateSettled).Limit(1).Scan(ctx) + err := svc.DB.NewSelect().Model(&dbInvoice).Where("type = ? AND invoice.r_hash = ? AND state = ?", common.InvoiceTypeIncoming, hex.EncodeToString(lndInvoice.RHash), common.InvoiceStateSettled).Limit(1).Scan(ctx) if err != nil { // - if not found, dump invoice json if errors.Is(err, sql.ErrNoRows) {