2018-03-04 13:56:49 +00:00
|
|
|
package transaction
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/binary"
|
|
|
|
"io"
|
|
|
|
|
2018-03-21 16:11:04 +00:00
|
|
|
"github.com/CityOfZion/neo-go/pkg/util"
|
2018-03-04 13:56:49 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Input represents a Transaction input.
|
|
|
|
type Input struct {
|
|
|
|
// The hash of the previous transaction.
|
|
|
|
PrevHash util.Uint256
|
|
|
|
|
|
|
|
// The index of the previous transaction.
|
|
|
|
PrevIndex uint16
|
|
|
|
}
|
|
|
|
|
|
|
|
// DecodeBinary implements the Payload interface.
|
|
|
|
func (in *Input) DecodeBinary(r io.Reader) error {
|
|
|
|
if err := binary.Read(r, binary.LittleEndian, &in.PrevHash); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return binary.Read(r, binary.LittleEndian, &in.PrevIndex)
|
|
|
|
}
|
|
|
|
|
|
|
|
// EncodeBinary implements the Payload interface.
|
|
|
|
func (in *Input) EncodeBinary(w io.Writer) error {
|
|
|
|
if err := binary.Write(w, binary.LittleEndian, in.PrevHash); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := binary.Write(w, binary.LittleEndian, in.PrevIndex); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|