From 5e3ef3ec0c62f8954ac6dfbeda32c8afaeb83381 Mon Sep 17 00:00:00 2001 From: Andras Banki-Horvath Date: Fri, 10 Jan 2025 11:18:44 +0100 Subject: [PATCH] invoices+sql: use the stored AmtPaid value instead of recalculating Previously we'd recalculate the paid amount by summing amounts of settled HTLCs. This approach while correct would stop the SQL migration process as some KV invoices may have incorrectly stored paid amounts. --- invoices/sql_store.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/invoices/sql_store.go b/invoices/sql_store.go index f7ca02637..55517bfdd 100644 --- a/invoices/sql_store.go +++ b/invoices/sql_store.go @@ -1576,13 +1576,6 @@ func fetchInvoiceData(ctx context.Context, db SQLInvoiceQueries, if len(htlcs) > 0 { invoice.Htlcs = htlcs - var amountPaid lnwire.MilliSatoshi - for _, htlc := range htlcs { - if htlc.State == HtlcStateSettled { - amountPaid += htlc.Amt - } - } - invoice.AmtPaid = amountPaid } return hash, invoice, nil