channeldb+invoices: make htlc cancelation stricter

Previously it was possible to cancel a canceled htlc. This would
subtract the htlc amount from the invoice amount again.
This commit is contained in:
Joost Jager committed 2019-09-16 10:10:13 +02:00
1 parent 35d4652d23
commit 49a20a87a2
2 files changed
+18 -4

No files matched your search

+3 -3
View File
@@ -1224,9 +1224,9 @@ func (d *DB) updateInvoice(hash lntypes.Hash, invoices, settleIndex *bbolt.Bucke
if !ok {
return nil, fmt.Errorf("unknown htlc %v", key)
}
if htlc.State == HtlcStateSettled {
return nil, fmt.Errorf("cannot cancel a " +
"settled htlc")
if htlc.State != HtlcStateAccepted {
return nil, fmt.Errorf("can only cancel " +
"accepted htlcs")
}
htlc.State = HtlcStateCancelled