@@ -153,38 +153,6 @@ func (e *ErrCommitSyncLocalDataLoss) Error() string {
153
153
e .CommitPoint .SerializeCompressed ())
154
154
}
155
155
156
- // channelState is an enum like type which represents the current state of a
157
- // particular channel.
158
- // TODO(roasbeef): actually update state
159
- type channelState uint8
160
-
161
- const (
162
- // channelPending indicates this channel is still going through the
163
- // funding workflow, and isn't yet open.
164
- channelPending channelState = iota // nolint: unused
165
-
166
- // channelOpen represents an open, active channel capable of
167
- // sending/receiving HTLCs.
168
- channelOpen
169
-
170
- // channelClosing represents a channel which is in the process of being
171
- // closed.
172
- channelClosing
173
-
174
- // channelClosed represents a channel which has been fully closed. Note
175
- // that before a channel can be closed, ALL pending HTLCs must be
176
- // settled/removed.
177
- channelClosed
178
-
179
- // channelDispute indicates that an un-cooperative closure has been
180
- // detected within the channel.
181
- channelDispute
182
-
183
- // channelPendingPayment indicates that there a currently outstanding
184
- // HTLCs within the channel.
185
- channelPendingPayment // nolint:unused
186
- )
187
-
188
156
// PaymentHash represents the sha256 of a random value. This hash is used to
189
157
// uniquely track incoming/outgoing payments within this channel, as well as
190
158
// payments requested by the wallet/daemon.
@@ -1283,7 +1251,7 @@ type LightningChannel struct {
1283
1251
// the commitment transaction that spends the multi-sig output.
1284
1252
signDesc * input.SignDescriptor
1285
1253
1286
- status channelState
1254
+ isClosed bool
1287
1255
1288
1256
// ChanPoint is the funding outpoint of this channel.
1289
1257
ChanPoint * wire.OutPoint
@@ -1538,7 +1506,7 @@ func (lc *LightningChannel) createSignDesc() error {
1538
1506
// events do so properly.
1539
1507
func (lc * LightningChannel ) ResetState () {
1540
1508
lc .Lock ()
1541
- lc .status = channelOpen
1509
+ lc .isClosed = false
1542
1510
lc .Unlock ()
1543
1511
}
1544
1512
@@ -7593,9 +7561,8 @@ func (lc *LightningChannel) ForceClose() (*LocalForceCloseSummary, error) {
7593
7561
"summary: %w" , err )
7594
7562
}
7595
7563
7596
- // Set the channel state to indicate that the channel is now in a
7597
- // contested state.
7598
- lc .status = channelDispute
7564
+ // Mark the channel as closed to block future closure requests.
7565
+ lc .isClosed = true
7599
7566
7600
7567
return summary , nil
7601
7568
}
@@ -7789,8 +7756,8 @@ func (lc *LightningChannel) CreateCloseProposal(proposedFee btcutil.Amount,
7789
7756
lc .Lock ()
7790
7757
defer lc .Unlock ()
7791
7758
7792
- // If we've already closed the channel, then ignore this request.
7793
- if lc .status == channelClosed {
7759
+ // If we're already closing the channel, then ignore this request.
7760
+ if lc .isClosed {
7794
7761
// TODO(roasbeef): check to ensure no pending payments
7795
7762
return nil , nil , 0 , ErrChanClosing
7796
7763
}
@@ -7853,10 +7820,6 @@ func (lc *LightningChannel) CreateCloseProposal(proposedFee btcutil.Amount,
7853
7820
}
7854
7821
}
7855
7822
7856
- // As everything checks out, indicate in the channel status that a
7857
- // channel closure has been initiated.
7858
- lc .status = channelClosing
7859
-
7860
7823
closeTXID := closeTx .TxHash ()
7861
7824
return sig , & closeTXID , ourBalance , nil
7862
7825
}
@@ -7877,8 +7840,8 @@ func (lc *LightningChannel) CompleteCooperativeClose(
7877
7840
lc .Lock ()
7878
7841
defer lc .Unlock ()
7879
7842
7880
- // If the channel is already closed , then ignore this request.
7881
- if lc .status == channelClosed {
7843
+ // If the channel is already closing , then ignore this request.
7844
+ if lc .isClosed {
7882
7845
// TODO(roasbeef): check to ensure no pending payments
7883
7846
return nil , 0 , ErrChanClosing
7884
7847
}
@@ -7982,7 +7945,7 @@ func (lc *LightningChannel) CompleteCooperativeClose(
7982
7945
// As the transaction is sane, and the scripts are valid we'll mark the
7983
7946
// channel now as closed as the closure transaction should get into the
7984
7947
// chain in a timely manner and possibly be re-broadcast by the wallet.
7985
- lc .status = channelClosed
7948
+ lc .isClosed = true
7986
7949
7987
7950
return closeTx , ourBalance , nil
7988
7951
}
0 commit comments