neoneo-go/pkg/core/transaction/witness.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

36 lines
1,020 B
Go

package transaction
import (
"encoding/binary"
"io"
"github.com/CityOfZion/neo-go/pkg/util"
)
// Witness contains 2 scripts.
type Witness struct {
InvocationScript []byte
VerificationScript []byte
}
// DecodeBinary implements the payload interface.
func (wit *Witness) DecodeBinary(r io.Reader) error {
lenb := util.ReadVarUint(r)
wit.InvocationScript = make([]byte, lenb)
if err := binary.Read(r, binary.LittleEndian, wit.InvocationScript); err != nil {
return err
}
lenb = util.ReadVarUint(r)
wit.VerificationScript = make([]byte, lenb)
return binary.Read(r, binary.LittleEndian, wit.VerificationScript)
}
// EncodeBinary implements the payload interface.
func (wit *Witness) EncodeBinary(w io.Writer) error {
util.WriteVarUint(w, uint64(len(wit.InvocationScript)))
if err := binary.Write(w, binary.LittleEndian, wit.InvocationScript); err != nil {
return err
}
util.WriteVarUint(w, uint64(len(wit.VerificationScript)))
return binary.Write(w, binary.LittleEndian, wit.VerificationScript)
}