Skip to content

Commit 2645eee

Browse files
committed
tapchannel: detect both HTLC add types
Since we now have two different candidate types for adding HTLCs, we use the helper method that checks against both of them.
1 parent 74525b7 commit 2645eee

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

tapchannel/commitment.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ func ComputeView(ourBalance, theirBalance uint64,
9898
remoteHtlcIndex := make(map[uint64]lnwallet.AuxHtlcDescriptor)
9999

100100
for _, entry := range original.Updates.Local {
101-
if entry.EntryType == lnwallet.Add {
101+
if entry.IsAdd() {
102102
localHtlcIndex[entry.HtlcIndex] = entry
103103
}
104104
}
105105
for _, entry := range original.Updates.Remote {
106-
if entry.EntryType == lnwallet.Add {
106+
if entry.IsAdd() {
107107
remoteHtlcIndex[entry.HtlcIndex] = entry
108108
}
109109
}
@@ -115,6 +115,13 @@ func ComputeView(ourBalance, theirBalance uint64,
115115
case lnwallet.Add:
116116
continue
117117

118+
// Skip noop adds, they will also be processed below. This type
119+
// of entry only settles the assets and not the sats that carry
120+
// them. This is not something we have to worry about here since
121+
// we only care about the assets at this point.
122+
case lnwallet.NoOpAdd:
123+
continue
124+
118125
// Fee updates don't concern us at the asset level.
119126
case lnwallet.FeeUpdate:
120127
continue
@@ -162,6 +169,13 @@ func ComputeView(ourBalance, theirBalance uint64,
162169
case lnwallet.Add:
163170
continue
164171

172+
// Skip noop adds, they will also be processed below. This type
173+
// of entry only settles the assets and not the sats that carry
174+
// them. This is not something we have to worry about here since
175+
// we only care about the assets at this point.
176+
case lnwallet.NoOpAdd:
177+
continue
178+
165179
// Fee updates don't concern us at the asset level.
166180
case lnwallet.FeeUpdate:
167181
continue
@@ -207,7 +221,7 @@ func ComputeView(ourBalance, theirBalance uint64,
207221
// settled HTLCs, and debiting the chain state balance due to any newly
208222
// added HTLCs.
209223
for _, entry := range original.Updates.Local {
210-
isAdd := entry.EntryType == lnwallet.Add
224+
isAdd := entry.IsAdd()
211225

212226
// Skip any entries that aren't adds or adds that were already
213227
// settled or failed by a child HTLC entry we processed above.
@@ -249,7 +263,7 @@ func ComputeView(ourBalance, theirBalance uint64,
249263
newView.OurUpdates = append(newView.OurUpdates, decodedEntry)
250264
}
251265
for _, entry := range original.Updates.Remote {
252-
isAdd := entry.EntryType == lnwallet.Add
266+
isAdd := entry.IsAdd()
253267

254268
// Skip any entries that aren't adds or adds that were already
255269
// settled or failed by a child HTLC entry we processed above.

0 commit comments

Comments
 (0)