channeldb: use RemoteCommitment in NextLocalHtlcIndex
This commit changes the fallback in NextLocalHtlcIndex to RemoteCommitment since the LocalHtlcIndex field lags behind on the LocalCommitment. Without this bug fix, open circuits would get prematurely trimmed, resulting in more erroneous logs. A test case is included to check that the fix works.
This commit is contained in:
1 parent
f5e364071b
commit
f757bf48bd
2 files changed
+158
-3
No files matched your search
@@ -2171,7 +2171,7 @@ func (c *OpenChannel) AdvanceCommitChainTail(fwdPkg *FwdPkg) error {
|
||||
// NextLocalHtlcIndex returns the next unallocated local htlc index. To ensure
|
||||
// this always returns the next index that has been not been allocated, this
|
||||
// will first try to examine any pending commitments, before falling back to the
|
||||
// last locked-in local commitment.
|
||||
// last locked-in remote commitment.
|
||||
func (c *OpenChannel) NextLocalHtlcIndex() (uint64, error) {
|
||||
// First, load the most recent commit diff that we initiated for the
|
||||
// remote party. If no pending commit is found, this is not treated as
|
||||
@@ -2187,8 +2187,8 @@ func (c *OpenChannel) NextLocalHtlcIndex() (uint64, error) {
|
||||
return pendingRemoteCommit.Commitment.LocalHtlcIndex, nil
|
||||
}
|
||||
|
||||
// Otherwise, fallback to using the local htlc index of our commitment.
|
||||
return c.LocalCommitment.LocalHtlcIndex, nil
|
||||
// Otherwise, fallback to using the local htlc index of their commitment.
|
||||
return c.RemoteCommitment.LocalHtlcIndex, nil
|
||||
}
|
||||
|
||||
// LoadFwdPkgs scans the forwarding log for any packages that haven't been
|
||||
|
||||
Reference in new issue
Block a user