From 521c76d65a0644d1dff44002fe722419989cd13e Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 4 May 2017 15:39:35 -0700 Subject: [PATCH] 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. --- lnwallet/channel.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lnwallet/channel.go b/lnwallet/channel.go index aded2fe5..0762e621 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -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