2018-03-21 16:11:04 +00:00
|
|
|
package transaction
|
|
|
|
|
|
|
|
import (
|
2018-03-25 10:45:54 +00:00
|
|
|
"encoding/binary"
|
2018-03-21 16:11:04 +00:00
|
|
|
"io"
|
|
|
|
|
|
|
|
"github.com/CityOfZion/neo-go/pkg/smartcontract"
|
2018-03-25 10:45:54 +00:00
|
|
|
"github.com/CityOfZion/neo-go/pkg/util"
|
2018-03-21 16:11:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// PublishTX represents a publish transaction.
|
2018-03-25 10:45:54 +00:00
|
|
|
// NOTE: This is deprecated and should no longer be used.
|
2018-03-21 16:11:04 +00:00
|
|
|
type PublishTX struct {
|
|
|
|
Script []byte
|
|
|
|
ParamList []smartcontract.ParamType
|
|
|
|
ReturnType smartcontract.ParamType
|
|
|
|
NeedStorage bool
|
|
|
|
Name string
|
2018-03-25 10:45:54 +00:00
|
|
|
CodeVersion string
|
2018-03-21 16:11:04 +00:00
|
|
|
Author string
|
|
|
|
Email string
|
|
|
|
Description string
|
|
|
|
}
|
|
|
|
|
|
|
|
// DecodeBinary implements the Payload interface.
|
|
|
|
func (tx *PublishTX) DecodeBinary(r io.Reader) error {
|
2018-03-25 10:45:54 +00:00
|
|
|
var err error
|
|
|
|
|
|
|
|
tx.Script, err = util.ReadVarBytes(r)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
lenParams := util.ReadVarUint(r)
|
|
|
|
tx.ParamList = make([]smartcontract.ParamType, lenParams)
|
|
|
|
for i := 0; i < int(lenParams); i++ {
|
|
|
|
var ptype uint8
|
|
|
|
if err := binary.Read(r, binary.LittleEndian, &ptype); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
tx.ParamList[i] = smartcontract.ParamType(ptype)
|
|
|
|
}
|
|
|
|
|
|
|
|
var rtype uint8
|
|
|
|
if err := binary.Read(r, binary.LittleEndian, &rtype); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
tx.ReturnType = smartcontract.ParamType(rtype)
|
|
|
|
|
|
|
|
if err := binary.Read(r, binary.LittleEndian, &tx.NeedStorage); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
tx.Name, err = util.ReadVarString(r)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
tx.CodeVersion, err = util.ReadVarString(r)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
tx.Author, err = util.ReadVarString(r)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
tx.Email, err = util.ReadVarString(r)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
tx.Description, err = util.ReadVarString(r)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-03-21 16:11:04 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// EncodeBinary implements the Payload interface.
|
|
|
|
func (tx *PublishTX) EncodeBinary(w io.Writer) error {
|
|
|
|
return nil
|
|
|
|
}
|