neo-go/pkg/core/transaction/claim.go
Anthony De Meulemeester 1a1a19da7d
Smartcontract (#39)
* deleted transfer_output added asset type and transaction result to core

* removed writing 0x00 when buffer length is 0

* Refactored emit into VM package + moved tx to own package.

* implemented transaction along with claimTransaction.

* refactored naming of transaction + added decode address for uint160 types

* removed unnecessary folder and files.

* transaction/smartcontract logic

* bumped version 0.24.0
2018-03-04 14:56:49 +01:00

38 lines
805 B
Go

package transaction
import (
"io"
"github.com/CityOfZion/neo-go/pkg/util"
)
// ClaimTX represents a claim transaction.
type ClaimTX struct {
Claims []*Input
}
// DecodeBinary implements the Payload interface.
func (tx *ClaimTX) DecodeBinary(r io.Reader) error {
lenClaims := util.ReadVarUint(r)
tx.Claims = make([]*Input, lenClaims)
for i := 0; i < int(lenClaims); i++ {
tx.Claims[i] = &Input{}
if err := tx.Claims[i].DecodeBinary(r); err != nil {
return err
}
}
return nil
}
// EncodeBinary implements the Payload interface.
func (tx *ClaimTX) EncodeBinary(w io.Writer) error {
if err := util.WriteVarUint(w, uint64(len(tx.Claims))); err != nil {
return err
}
for _, claim := range tx.Claims {
if err := claim.EncodeBinary(w); err != nil {
return err
}
}
return nil
}