neoneo-go/pkg/core/transaction/enrollment.go
Roman Khimov 5bf00db2c9 io: move BinReader/BinWriter there, redo Serializable with it
The logic here is that we'll have all binary encoding/decoding done via our io
package, which simplifies error handling. This functionality doesn't belong to
util, so it's moved.

This also expands BufBinWriter with Reset() method to fit the needs of core
package.
2019-09-16 23:39:51 +03:00

32 lines
1 KiB
Go

package transaction
import (
"github.com/CityOfZion/neo-go/pkg/crypto/keys"
"github.com/CityOfZion/neo-go/pkg/io"
)
// EnrollmentTX transaction represents an enrollment form, which indicates
// that the sponsor of the transaction would like to sign up as a validator.
// The way to sign up is: To construct an EnrollmentTransaction type of transaction,
// and send a deposit to the address of the PublicKey.
// The way to cancel the registration is: Spend the deposit on the address of the PublicKey.
type EnrollmentTX struct {
// PublicKey of the validator
PublicKey *keys.PublicKey
}
// DecodeBinary implements the Payload interface.
func (tx *EnrollmentTX) DecodeBinary(r *io.BinReader) error {
tx.PublicKey = &keys.PublicKey{}
return tx.PublicKey.DecodeBinary(r)
}
// EncodeBinary implements the Payload interface.
func (tx *EnrollmentTX) EncodeBinary(w *io.BinWriter) error {
return tx.PublicKey.EncodeBinary(w)
}
// Size returns serialized binary size for this transaction.
func (tx *EnrollmentTX) Size() int {
return len(tx.PublicKey.Bytes())
}