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:
parent
7e1f2a7dc3
commit
9324bf7b1d
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user