2018-03-21 16:11:04 +00:00
|
|
|
package transaction
|
|
|
|
|
|
|
|
import (
|
2019-09-16 09:18:13 +00:00
|
|
|
"github.com/CityOfZion/neo-go/pkg/io"
|
2018-03-21 16:11:04 +00:00
|
|
|
"github.com/CityOfZion/neo-go/pkg/smartcontract"
|
|
|
|
)
|
|
|
|
|
|
|
|
// 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
|
2019-08-27 16:58:50 +00:00
|
|
|
Version uint8 // Version of the parent struct Transaction. Used in reading NeedStorage flag.
|
2018-03-21 16:11:04 +00:00
|
|
|
}
|
|
|
|
|
2019-09-16 16:31:49 +00:00
|
|
|
// DecodeBinary implements Serializable interface.
|
|
|
|
func (tx *PublishTX) DecodeBinary(br *io.BinReader) {
|
2019-12-06 15:37:37 +00:00
|
|
|
tx.Script = br.ReadVarBytes()
|
2018-03-25 10:45:54 +00:00
|
|
|
|
2019-08-28 16:27:06 +00:00
|
|
|
lenParams := br.ReadVarUint()
|
2018-03-25 10:45:54 +00:00
|
|
|
tx.ParamList = make([]smartcontract.ParamType, lenParams)
|
|
|
|
for i := 0; i < int(lenParams); i++ {
|
2019-12-12 17:17:50 +00:00
|
|
|
tx.ParamList[i] = smartcontract.ParamType(br.ReadB())
|
2018-03-25 10:45:54 +00:00
|
|
|
}
|
|
|
|
|
2019-12-12 17:17:50 +00:00
|
|
|
tx.ReturnType = smartcontract.ParamType(br.ReadB())
|
2018-03-25 10:45:54 +00:00
|
|
|
|
2019-08-27 16:58:50 +00:00
|
|
|
if tx.Version >= 1 {
|
2019-12-12 15:52:23 +00:00
|
|
|
tx.NeedStorage = br.ReadBool()
|
2019-08-27 16:58:50 +00:00
|
|
|
} else {
|
|
|
|
tx.NeedStorage = false
|
|
|
|
}
|
2018-03-25 10:45:54 +00:00
|
|
|
|
2019-08-28 16:27:06 +00:00
|
|
|
tx.Name = br.ReadString()
|
|
|
|
tx.CodeVersion = br.ReadString()
|
|
|
|
tx.Author = br.ReadString()
|
|
|
|
tx.Email = br.ReadString()
|
|
|
|
tx.Description = br.ReadString()
|
2018-03-21 16:11:04 +00:00
|
|
|
}
|
|
|
|
|
2019-09-16 16:31:49 +00:00
|
|
|
// EncodeBinary implements Serializable interface.
|
|
|
|
func (tx *PublishTX) EncodeBinary(bw *io.BinWriter) {
|
2019-11-22 10:34:06 +00:00
|
|
|
bw.WriteVarBytes(tx.Script)
|
2019-08-30 16:19:43 +00:00
|
|
|
bw.WriteVarUint(uint64(len(tx.ParamList)))
|
|
|
|
for _, param := range tx.ParamList {
|
2019-12-12 17:17:50 +00:00
|
|
|
bw.WriteB(byte(param))
|
2019-08-30 16:19:43 +00:00
|
|
|
}
|
2019-12-12 17:17:50 +00:00
|
|
|
bw.WriteB(byte(tx.ReturnType))
|
2019-08-30 16:19:43 +00:00
|
|
|
if tx.Version >= 1 {
|
2019-12-12 15:52:23 +00:00
|
|
|
bw.WriteBool(tx.NeedStorage)
|
2019-08-30 16:19:43 +00:00
|
|
|
}
|
|
|
|
bw.WriteString(tx.Name)
|
|
|
|
bw.WriteString(tx.CodeVersion)
|
|
|
|
bw.WriteString(tx.Author)
|
|
|
|
bw.WriteString(tx.Email)
|
|
|
|
bw.WriteString(tx.Description)
|
2018-03-21 16:11:04 +00:00
|
|
|
}
|