2018-12-21 09:32:18 +00:00
|
|
|
package rpc
|
|
|
|
|
|
|
|
import "github.com/CityOfZion/neo-go/pkg/util"
|
|
|
|
|
|
|
|
/*
|
|
|
|
Definition of types, helper functions and variables
|
|
|
|
required for calculation of transaction inputs using
|
|
|
|
NeoScan API.
|
|
|
|
*/
|
|
|
|
|
|
|
|
type (
|
2019-10-22 14:56:03 +00:00
|
|
|
// NeoScanServer stores NEOSCAN URL and API path.
|
2018-12-21 09:32:18 +00:00
|
|
|
NeoScanServer struct {
|
|
|
|
URL string // "protocol://host:port/"
|
|
|
|
Path string // path to API endpoint without wallet address
|
|
|
|
}
|
|
|
|
|
2019-09-03 14:51:37 +00:00
|
|
|
// UTXO stores unspent TX output for some transaction.
|
2018-12-21 09:32:18 +00:00
|
|
|
UTXO struct {
|
|
|
|
Value util.Fixed8
|
|
|
|
TxID util.Uint256
|
|
|
|
N uint16
|
|
|
|
}
|
|
|
|
|
2019-09-03 14:51:37 +00:00
|
|
|
// Unspents is a slice of UTXOs (TODO: drop it?).
|
2018-12-21 09:32:18 +00:00
|
|
|
Unspents []UTXO
|
|
|
|
|
2019-09-03 14:51:37 +00:00
|
|
|
// Unspent stores Unspents per asset
|
2018-12-21 09:32:18 +00:00
|
|
|
Unspent struct {
|
|
|
|
Unspent Unspents
|
|
|
|
Asset string // "NEO" / "GAS"
|
|
|
|
Amount util.Fixed8 // total unspent of this asset
|
|
|
|
}
|
|
|
|
|
2019-09-03 14:51:37 +00:00
|
|
|
// NeoScanBalance is a struct of NeoScan response to 'get_balance' request
|
2018-12-21 09:32:18 +00:00
|
|
|
NeoScanBalance struct {
|
|
|
|
Balance []*Unspent
|
|
|
|
Address string
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
// functions for sorting array of `Unspents`
|
|
|
|
func (us Unspents) Len() int { return len(us) }
|
|
|
|
func (us Unspents) Less(i, j int) bool { return us[i].Value < us[j].Value }
|
|
|
|
func (us Unspents) Swap(i, j int) { us[i], us[j] = us[j], us[i] }
|