lnwallet: properly detect initiator cooperative close in closeObserver

This commit modifies the logic of the closeObserver slightly to not
incorrectly mark the broadcast of the commitment transaction triggered
by a cooperative channel closure as an unprompted broadcast.
This commit is contained in:
Olaoluwa Osuntokun 2017-01-12 18:29:55 -08:00
parent e057684c8e
commit c451258fd2
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
1 changed files with 4 additions and 3 deletions

View File

@ -695,7 +695,8 @@ func (lc *LightningChannel) closeObserver(channelCloseNtfn *chainntnfs.SpendEven
// If we've already initiated a local cooperative or unilateral close
// locally, then we have nothing more to do.
lc.RLock()
if lc.status == channelClosed || lc.status == channelDispute {
if lc.status == channelClosed || lc.status == channelDispute ||
lc.status == channelClosing {
lc.RUnlock()
return
}
@ -2031,7 +2032,7 @@ func (lc *LightningChannel) InitCooperativeClose() ([]byte, *chainhash.Hash, err
closeTxSha := closeTx.TxHash()
// Finally, sign the completed cooperative closure transaction. As the
// initiator we'll simply send our signature over the the remote party,
// initiator we'll simply send our signature over to the remote party,
// using the generated txid to be notified once the closure transaction
// has been confirmed.
lc.signDesc.SigHashes = txscript.NewTxSigHashes(closeTx)
@ -2186,7 +2187,7 @@ func CreateCooperativeCloseTx(fundingTxIn *wire.TxIn,
closeTx := wire.NewMsgTx(2)
closeTx.AddTxIn(fundingTxIn)
// The initiator the a cooperative closure pays the fee in entirety.
// The initiator of a cooperative closure pays the fee in entirety.
// Determine if we're the initiator so we can compute fees properly.
if initiator {
// TODO(roasbeef): take sat/byte here instead of properly calc