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/crypto/keys"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
2018-03-21 16:11:04 +00:00
|
|
|
)
|
|
|
|
|
2019-09-03 14:51:37 +00:00
|
|
|
// EnrollmentTX transaction represents an enrollment form, which indicates
|
2018-03-21 16:11:04 +00:00
|
|
|
// 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 {
|
2019-10-22 14:56:03 +00:00
|
|
|
// PublicKey of the validator.
|
2019-12-09 15:33:04 +00:00
|
|
|
PublicKey keys.PublicKey
|
2018-03-21 16:11:04 +00:00
|
|
|
}
|
|
|
|
|
2020-04-10 10:41:49 +00:00
|
|
|
// NewEnrollmentTX creates Transaction of EnrollmentType type.
|
|
|
|
func NewEnrollmentTX(enrollment *EnrollmentTX) *Transaction {
|
|
|
|
return &Transaction{
|
|
|
|
Type: EnrollmentType,
|
|
|
|
Version: 0,
|
|
|
|
Nonce: rand.Uint32(),
|
|
|
|
Data: enrollment,
|
|
|
|
Attributes: []Attribute{},
|
|
|
|
Inputs: []Input{},
|
|
|
|
Outputs: []Output{},
|
|
|
|
Scripts: []Witness{},
|
|
|
|
Trimmed: false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-16 16:31:49 +00:00
|
|
|
// DecodeBinary implements Serializable interface.
|
|
|
|
func (tx *EnrollmentTX) DecodeBinary(r *io.BinReader) {
|
|
|
|
tx.PublicKey.DecodeBinary(r)
|
2018-03-21 16:11:04 +00:00
|
|
|
}
|
|
|
|
|
2019-09-16 16:31:49 +00:00
|
|
|
// EncodeBinary implements Serializable interface.
|
|
|
|
func (tx *EnrollmentTX) EncodeBinary(w *io.BinWriter) {
|
|
|
|
tx.PublicKey.EncodeBinary(w)
|
2018-03-21 16:11:04 +00:00
|
|
|
}
|