github-vet / github-vet/rangeloop-pointer-findings
fsn-dev/cryptoCoins: coins/btc/utxo_btcd.go; 35 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [fsn-dev/cryptoCoins](https://www.github.com/fsn-dev/cryptoCoins) at [coins/btc/utxo_btcd.go](https://github.com/fsn-dev/cryptoCoins/blob/89ef0e5d42061b920032cc945707f4812b496bcf/coins/btc/utxo_btcd.go#L143-L177)
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 tx used in defer or goroutine at line 163
[Click here to see the code in its original context.](https://github.com/fsn-dev/cryptoCoins/blob/89ef0e5d42061b920032cc945707f4812b496bcf/coins/btc/utxo_btcd.go#L143-L177)
Click here to show the 35 line(s) of Go which triggered the analyzer.
```go
for _, tx := range txs {
txid, err := chainhash.NewHashFromStr(tx.Txid)
if err != nil {
continue
}
for i := 0; i < len(tx.Vout); i++ {
vout := tx.Vout[i]
addr := ""
if len(vout.ScriptPubKey.Addresses) > 0 {
addr = vout.ScriptPubKey.Addresses[0]
}
if addr != toaddr.String() {
continue
}
fr_gt := client.GetTxOutAsync(txid, uint32(i), false)
go func() {
wg.Add(1)
defer wg.Done()
if txo, err := fr_gt.Receive(); err == nil && txo != nil {
utxo := btcjson.ListUnspentResult{
TxID: tx.Txid,
Vout: uint32(len(tx.Vout)),
Address: addr,
ScriptPubKey: vout.ScriptPubKey.Hex,
Amount: vout.Value,
Confirmations: int64(tx.Confirmations),
Spendable: true,
}
utxolock.Lock()
utxos = append(utxos, utxo)
utxolock.Unlock()
}
}()
}
}
```
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: 89ef0e5d42061b920032cc945707f4812b496bcf
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.