github-vet / github-vet/rangeloop-pointer-findings
Colored-Coins/lnd-cc: utxonursery.go; 34 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [Colored-Coins/lnd-cc](https://www.github.com/Colored-Coins/lnd-cc) at [utxonursery.go](https://github.com/Colored-Coins/lnd-cc/blob/804e9ac7a26e0b87ba7ded1bbc117fcfd45bc53c/utxonursery.go#L103-L136)
Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first issue it finds, so please do not limit your consideration to the contents of the below message.
> range-loop variable immatureUtxo used in defer or goroutine at line 133
[Click here to see the code in its original context.](https://github.com/Colored-Coins/lnd-cc/blob/804e9ac7a26e0b87ba7ded1bbc117fcfd45bc53c/utxonursery.go#L103-L136)
Click here to show the 34 line(s) of Go which triggered the analyzer.
```go
for _, immatureUtxo := range earlyStagers.outputs {
outpoint := immatureUtxo.outPoint
sourceTXID := outpoint.Hash
// Register for a confirmation once the
// generating txn has been confirmed.
confChan, err := u.notifier.RegisterConfirmationsNtfn(&sourceTXID, 1)
if err != nil {
utxnLog.Errorf("unable to register for confirmations "+
"for txid: %v", sourceTXID)
continue
}
// TODO(roasbeef): should be an on-disk
// at-least-once task queue
u.unstagedOutputs[outpoint] = immatureUtxo
// Launch a dedicated goroutine which will send
// the output back to the incubator once the
// source txn has been confirmed.
go func() {
confHeight, ok := <-confChan.Confirmed
if !ok {
utxnLog.Errorf("notification chan "+
"closed, can't advance output %v", outpoint)
}
utxnLog.Infof("Outpoint %v confirmed in "+
"block %v moving to mid-stage",
outpoint, confHeight)
immatureUtxo.confHeight = uint32(confHeight)
midStageOutputs <- immatureUtxo
}()
}
```
Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.
commit ID: 804e9ac7a26e0b87ba7ded1bbc117fcfd45bc53c
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.