neoneo-go/pkg/core/transaction/register.go
Anthony De Meulemeester 94672cb9cc
Persistance (#53)
* added publish TX for backwards compat.

* lowered the prototick for faster block syncing

* print useragent on startup

* added createMultiRedeemScript for genesis block generation.

* building genesis block from scratch.

* implemented merkle tree.

* starting blockhain with generated genesis hash

* Fixed bug in unspent coin state.

* fixed broken tests after genesis block.

* removed log line.

* bumped version -> 0.34.0
2018-03-25 12:45:54 +02:00

79 lines
1.7 KiB
Go

package transaction
import (
"encoding/binary"
"io"
"github.com/CityOfZion/neo-go/pkg/crypto"
"github.com/CityOfZion/neo-go/pkg/util"
)
// RegisterTX represents a register transaction.
// NOTE: This is deprecated.
type RegisterTX struct {
// The type of the asset being registered.
AssetType AssetType
// Name of the asset being registered.
Name string
// Amount registered
// Unlimited mode -0.00000001
Amount util.Fixed8
// Decimals
Precision uint8
// Public key of the owner
Owner *crypto.PublicKey
Admin util.Uint160
}
// DecodeBinary implements the Payload interface.
func (tx *RegisterTX) DecodeBinary(r io.Reader) error {
if err := binary.Read(r, binary.LittleEndian, &tx.AssetType); err != nil {
return err
}
var err error
tx.Name, err = util.ReadVarString(r)
if err != nil {
return err
}
if err := binary.Read(r, binary.LittleEndian, &tx.Amount); err != nil {
return err
}
if err := binary.Read(r, binary.LittleEndian, &tx.Precision); err != nil {
return err
}
tx.Owner = &crypto.PublicKey{}
if err := tx.Owner.DecodeBinary(r); err != nil {
return err
}
return binary.Read(r, binary.LittleEndian, &tx.Admin)
}
// EncodeBinary implements the Payload interface.
func (tx *RegisterTX) EncodeBinary(w io.Writer) error {
if err := binary.Write(w, binary.LittleEndian, tx.AssetType); err != nil {
return err
}
if err := util.WriteVarString(w, tx.Name); err != nil {
return err
}
if err := binary.Write(w, binary.LittleEndian, tx.Amount); err != nil {
return err
}
if err := binary.Write(w, binary.LittleEndian, tx.Precision); err != nil {
return err
}
if err := binary.Write(w, binary.LittleEndian, tx.Owner.Bytes()); err != nil {
return err
}
return binary.Write(w, binary.LittleEndian, tx.Admin)
}