mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-29 15:11:09 +02:00
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:
@@ -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
|
||||
|
Reference in New Issue
Block a user