2018-12-21 09:32:18 +00:00
|
|
|
package rpc
|
|
|
|
|
|
|
|
/*
|
|
|
|
Definition of types, interfaces and variables
|
|
|
|
required for raw transaction composing.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/CityOfZion/neo-go/pkg/core/transaction"
|
|
|
|
"github.com/CityOfZion/neo-go/pkg/util"
|
2019-08-27 13:29:42 +00:00
|
|
|
"github.com/CityOfZion/neo-go/pkg/crypto/keys"
|
2018-12-21 09:32:18 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
2019-09-03 14:51:37 +00:00
|
|
|
// ContractTxParams contains parameters for tx to transfer assets;
|
2018-12-21 09:32:18 +00:00
|
|
|
// includes parameters duplication `sendtoaddress` RPC call params
|
|
|
|
// and also some utility data;
|
|
|
|
ContractTxParams struct {
|
2019-09-03 15:11:13 +00:00
|
|
|
assetID util.Uint256
|
2018-12-21 09:32:18 +00:00
|
|
|
address string
|
|
|
|
value util.Fixed8
|
2019-08-27 13:29:42 +00:00
|
|
|
wif keys.WIF // a WIF to send the transaction
|
2018-12-21 09:32:18 +00:00
|
|
|
// since there are many ways to provide unspents,
|
|
|
|
// transaction composer stays agnostic to that how
|
|
|
|
// unspents was got;
|
|
|
|
balancer BalanceGetter
|
|
|
|
}
|
|
|
|
|
2019-09-03 14:51:37 +00:00
|
|
|
// BalanceGetter is an interface supporting CalculateInputs() method.
|
2018-12-21 09:32:18 +00:00
|
|
|
BalanceGetter interface {
|
|
|
|
// parameters
|
|
|
|
// address: base58-encoded address assets would be transferred from
|
2019-09-03 15:11:13 +00:00
|
|
|
// assetID: asset identifier
|
2018-12-21 09:32:18 +00:00
|
|
|
// amount: an asset amount to spend
|
|
|
|
// return values
|
|
|
|
// inputs: UTXO's for the preparing transaction
|
|
|
|
// total: summarized asset amount from all the `inputs`
|
|
|
|
// error: error would be considered in the caller function
|
2019-09-03 15:11:13 +00:00
|
|
|
CalculateInputs(address string, assetID util.Uint256, amount util.Fixed8) (inputs []transaction.Input, total util.Fixed8, err error)
|
2018-12-21 09:32:18 +00:00
|
|
|
}
|
|
|
|
)
|