diff --git a/lnwallet/channel.go b/lnwallet/channel.go index 34775d07..5a36f44a 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -2234,10 +2234,6 @@ func (lc *LightningChannel) InitCooperativeClose() ([]byte, *chainhash.Hash, err return nil, nil, ErrChanClosing } - // Otherwise, indicate in the channel status that a channel closure has - // been initiated. - lc.status = channelClosing - closeTx := CreateCooperativeCloseTx(lc.fundingTxIn, lc.channelState.OurBalance, lc.channelState.TheirBalance, lc.channelState.OurDeliveryScript, lc.channelState.TheirDeliveryScript, @@ -2254,6 +2250,10 @@ func (lc *LightningChannel) InitCooperativeClose() ([]byte, *chainhash.Hash, err return nil, nil, err } + // As everything checks out, indicate in the channel status that a + // channel closure has been initiated. + lc.status = channelClosing + return closeSig, &closeTxSha, nil } @@ -2275,8 +2275,6 @@ func (lc *LightningChannel) CompleteCooperativeClose(remoteSig []byte) (*wire.Ms return nil, ErrChanClosing } - lc.status = channelClosed - // Create the transaction used to return the current settled balance // on this active channel back to both parties. In this current model, // the initiator pays full fees for the cooperative close transaction. @@ -2315,6 +2313,11 @@ func (lc *LightningChannel) CompleteCooperativeClose(remoteSig []byte) (*wire.Ms return nil, err } + // As the transaction is sane, and the scripts are valid we'll mark the + // channel now as closed as the closure transaction should get into the + // chain in a timely manner and possibly be re-broadcast by the wallet. + lc.status = channelClosed + return closeTx, nil }