lnwallet: fix invalid value use in restoreUpdate

Updates were always restored with the same log index. This could cause a
crash when the logs were compacted and possibly other problems
elsewhere.

Extended unit test to cover the crash scenario.
This commit is contained in:
Joost Jager committed 2020-02-10 13:56:33 +01:00
1 parent 2cd26d7556
commit 88eae6eafe
2 files changed
+16 -2

No files matched your search

+1 -1
View File
@@ -1064,7 +1064,7 @@ func (u *updateLog) appendUpdate(pd *PaymentDescriptor) {
// also added to index accordingly. This function differs from appendUpdate in
// that it won't increment the log index counter.
func (u *updateLog) restoreUpdate(pd *PaymentDescriptor) {
u.updateIndex[u.logIndex] = u.PushBack(pd)
u.updateIndex[pd.LogIndex] = u.PushBack(pd)
}
// appendHtlc appends a new HTLC offer to the tip of the update log. The entry