mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-09 09:15:35 +02:00
lnwallet/channel: return error in case of htlc index mismatch
This commit make us return an error in case a restored HTLC from a pending remote commit has an index that is different from our local update log index. It is appended with the assumption that these indexes are the same, and if they are not we cannot really continue.
This commit is contained in:
@@ -1765,6 +1765,16 @@ func (lc *LightningChannel) restoreStateLogs(
|
||||
}
|
||||
|
||||
if payDesc.EntryType == Add {
|
||||
// The HtlcIndex of the added HTLC _must_ be equal to
|
||||
// the log's htlcCounter at this point. If it is not we
|
||||
// panic to catch this.
|
||||
// TODO(halseth): remove when cause of htlc entry bug
|
||||
// is found.
|
||||
if payDesc.HtlcIndex != lc.localUpdateLog.htlcCounter {
|
||||
panic(fmt.Sprintf("htlc index mismatch: "+
|
||||
"%v vs %v", payDesc.HtlcIndex,
|
||||
lc.localUpdateLog.htlcCounter))
|
||||
}
|
||||
lc.localUpdateLog.appendHtlc(payDesc)
|
||||
} else {
|
||||
lc.localUpdateLog.appendUpdate(payDesc)
|
||||
|
Reference in New Issue
Block a user