contractcourt: prevent scoping bug by re-binding channel pointer

In this commit, we attempt to fix a bug that's possible within the
Start() method of the ChainArbiter. We pass the channel pointer directly
into the newActiveChannelArbitrator function causing it to close over
the loop variable. We later use the channel point directly to send
messages to other sub-systems. It's possible that we actually have the
shadowed loop variable and will send an incorrect message. Defensively,
we now re-bind the loop variable in order to ensure we point to the
proper channel.
This commit is contained in:
Olaoluwa Osuntokun 2018-05-18 16:21:06 -07:00
parent 38a92b5ac9
commit 9dcd98ad9c
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

@ -330,6 +330,7 @@ func (c *ChainArbitrator) Start() error {
// ChannelArbitrator.
for _, channel := range openChannels {
chanPoint := channel.FundingOutpoint
channel := channel
// First, we'll create an active chainWatcher for this channel
// to ensure that we detect any relevant on chain events.