2018-03-21 16:11:04 +00:00
|
|
|
package transaction
|
|
|
|
|
|
|
|
import (
|
2020-04-10 10:41:49 +00:00
|
|
|
"math/rand"
|
|
|
|
|
2020-03-03 14:21:42 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
2018-03-21 16:11:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// StateTX represents a state transaction.
|
|
|
|
type StateTX struct {
|
|
|
|
Descriptors []*StateDescriptor
|
|
|
|
}
|
|
|
|
|
2020-04-10 10:41:49 +00:00
|
|
|
// NewStateTX creates Transaction of StateType type.
|
|
|
|
func NewStateTX(state *StateTX) *Transaction {
|
|
|
|
return &Transaction{
|
|
|
|
Type: StateType,
|
|
|
|
Version: 0,
|
|
|
|
Nonce: rand.Uint32(),
|
|
|
|
Data: state,
|
|
|
|
Attributes: []Attribute{},
|
|
|
|
Inputs: []Input{},
|
|
|
|
Outputs: []Output{},
|
|
|
|
Scripts: []Witness{},
|
|
|
|
Trimmed: false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-16 16:31:49 +00:00
|
|
|
// DecodeBinary implements Serializable interface.
|
|
|
|
func (tx *StateTX) DecodeBinary(r *io.BinReader) {
|
2019-11-14 07:50:03 +00:00
|
|
|
r.ReadArray(&tx.Descriptors)
|
2018-03-21 16:11:04 +00:00
|
|
|
}
|
|
|
|
|
2019-09-16 16:31:49 +00:00
|
|
|
// EncodeBinary implements Serializable interface.
|
|
|
|
func (tx *StateTX) EncodeBinary(w *io.BinWriter) {
|
2019-11-13 07:36:29 +00:00
|
|
|
w.WriteArray(tx.Descriptors)
|
2018-03-21 16:11:04 +00:00
|
|
|
}
|