mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-04-08 03:58:05 +02:00
channeldb: do not change the update descriptor when cancelling htlcs
This commit is contained in:
parent
7298b2d190
commit
ef5a31733e
@ -1944,15 +1944,13 @@ func (d *DB) cancelHTLCs(invoices kvdb.RwBucket, invoiceNum []byte,
|
||||
htlcsAmpUpdate := make(map[invpkg.SetID]map[models.CircuitKey]*invpkg.InvoiceHTLC) //nolint:lll
|
||||
|
||||
// Process cancel actions from update descriptor.
|
||||
cancelHtlcs := update.CancelHtlcs
|
||||
for key, htlc := range invoice.Htlcs {
|
||||
htlc := htlc
|
||||
for key := range update.CancelHtlcs {
|
||||
htlc, exists := invoice.Htlcs[key]
|
||||
|
||||
// Check whether this htlc needs to be canceled. If it does,
|
||||
// update the htlc state to Canceled.
|
||||
_, cancel := cancelHtlcs[key]
|
||||
if !cancel {
|
||||
continue
|
||||
// Verify that we don't get an action for htlcs that are not
|
||||
// present on the invoice.
|
||||
if !exists {
|
||||
return nil, fmt.Errorf("cancel of non-existent htlc")
|
||||
}
|
||||
|
||||
err := cancelSingleHtlc(timestamp, htlc, invoice.State)
|
||||
@ -1960,10 +1958,6 @@ func (d *DB) cancelHTLCs(invoices kvdb.RwBucket, invoiceNum []byte,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Delete processed cancel action, so that we can check later
|
||||
// that there are no actions left.
|
||||
delete(cancelHtlcs, key)
|
||||
|
||||
// Tally this into the set of HTLCs that need to be updated on
|
||||
// disk, but once again, only if this is an AMP invoice.
|
||||
if invoice.IsAMP() {
|
||||
@ -1976,12 +1970,6 @@ func (d *DB) cancelHTLCs(invoices kvdb.RwBucket, invoiceNum []byte,
|
||||
}
|
||||
}
|
||||
|
||||
// Verify that we didn't get an action for htlcs that are not present on
|
||||
// the invoice.
|
||||
if len(cancelHtlcs) > 0 {
|
||||
return nil, errors.New("cancel action on non-existent htlc(s)")
|
||||
}
|
||||
|
||||
err := d.cancelHTLCsStoreUpdate(
|
||||
invoices, invoiceNum, invoice, htlcsAmpUpdate,
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user