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.
This commit is contained in:
Andras Banki-Horvath 2025-01-10 11:18:44 +01:00
parent 0839d4ba7b
commit 5e3ef3ec0c
No known key found for this signature in database
GPG Key ID: 80E5375C094198D8

View File

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