lnwallet: add distinct channel to send close details over

This commit modifies the actions of the closeObserver goroutine to
utilize a _new_ channel to send channel close details over. The
original close signal channel is still used to notify observers that a
channel _has_ been closed, but this new channel will provide a single
observer with details w.r.t _how_ a channel was closed.
This commit is contained in:
Olaoluwa Osuntokun 2017-05-04 15:39:35 -07:00
parent 5e48cf1273
commit 521c76d65a
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2

View File

@ -644,6 +644,10 @@ type LightningChannel struct {
// their version of the commitment transaction on-chain.
UnilateralCloseSignal chan struct{}
// UnilateralClose is a channel that will be sent upon by the close
// observer once the unilateral close of a channel is detected.
UnilateralClose chan *chainntnfs.SpendDetail
// ContractBreach is a channel that is used to communicate the data
// necessary to fully resolve the channel in the case that a contract
// breach is detected. A contract breach occurs it is detected that the
@ -687,6 +691,7 @@ func NewLightningChannel(signer Signer, events chainntnfs.ChainNotifier,
RemoteDeliveryScript: state.TheirDeliveryScript,
FundingWitnessScript: state.FundingWitnessScript,
ForceCloseSignal: make(chan struct{}),
UnilateralClose: make(chan *chainntnfs.SpendDetail, 1),
UnilateralCloseSignal: make(chan struct{}),
ContractBreach: make(chan *BreachRetribution, 1),
LocalFundingKey: state.OurMultiSigKey,
@ -1022,6 +1027,7 @@ func (lc *LightningChannel) closeObserver(channelCloseNtfn *chainntnfs.SpendEven
// Notify any subscribers that we've detected a unilateral
// commitment transaction broadcast.
close(lc.UnilateralCloseSignal)
lc.UnilateralClose <- commitSpend
// If the state number broadcast is lower than the remote node's
// current un-revoked height, then THEY'RE ATTEMPTING TO VIOLATE THE