rpc/client: drop neoscan support
It was used as getunspents substitute and it's not longer relevant for NEO 3.
This commit is contained in:
parent
31ef0c4339
commit
ed0a3e4af5
2 changed files with 32 additions and 125 deletions
|
@ -8,6 +8,7 @@ import (
|
|||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"sort"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
|
@ -227,3 +228,34 @@ func (c *Client) Ping() error {
|
|||
_ = conn.Close()
|
||||
return nil
|
||||
}
|
||||
|
||||
// unspentsToInputs uses UnspentBalances to create a slice of inputs for a new
|
||||
// transcation containing the required amount of asset.
|
||||
func unspentsToInputs(utxos state.UnspentBalances, required util.Fixed8) ([]transaction.Input, util.Fixed8, error) {
|
||||
var (
|
||||
num, i uint16
|
||||
selected = util.Fixed8(0)
|
||||
)
|
||||
sort.Sort(utxos)
|
||||
|
||||
for _, us := range utxos {
|
||||
if selected >= required {
|
||||
break
|
||||
}
|
||||
selected += us.Value
|
||||
num++
|
||||
}
|
||||
if selected < required {
|
||||
return nil, util.Fixed8(0), errors.New("cannot compose inputs for transaction; check sender balance")
|
||||
}
|
||||
|
||||
inputs := make([]transaction.Input, 0, num)
|
||||
for i = 0; i < num; i++ {
|
||||
inputs = append(inputs, transaction.Input{
|
||||
PrevHash: utxos[i].Tx,
|
||||
PrevIndex: utxos[i].Index,
|
||||
})
|
||||
}
|
||||
|
||||
return inputs, selected, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue