2018-03-04 13:56:49 +00:00
|
|
|
package transaction
|
|
|
|
|
|
|
|
import (
|
2019-09-16 09:18:13 +00:00
|
|
|
"github.com/CityOfZion/neo-go/pkg/io"
|
2018-03-21 16:11:04 +00:00
|
|
|
"github.com/CityOfZion/neo-go/pkg/util"
|
2018-03-04 13:56:49 +00:00
|
|
|
)
|
|
|
|
|
2019-02-20 17:39:32 +00:00
|
|
|
// Input represents a Transaction input (CoinReference).
|
2018-03-04 13:56:49 +00:00
|
|
|
type Input struct {
|
|
|
|
// The hash of the previous transaction.
|
2019-02-20 17:39:32 +00:00
|
|
|
PrevHash util.Uint256 `json:"txid"`
|
2018-03-04 13:56:49 +00:00
|
|
|
|
|
|
|
// The index of the previous transaction.
|
2019-02-20 17:39:32 +00:00
|
|
|
PrevIndex uint16 `json:"vout"`
|
2018-03-04 13:56:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// DecodeBinary implements the Payload interface.
|
2019-09-16 09:18:13 +00:00
|
|
|
func (in *Input) DecodeBinary(br *io.BinReader) error {
|
2019-08-28 16:27:06 +00:00
|
|
|
br.ReadLE(&in.PrevHash)
|
|
|
|
br.ReadLE(&in.PrevIndex)
|
|
|
|
return br.Err
|
2018-03-04 13:56:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// EncodeBinary implements the Payload interface.
|
2019-09-16 09:18:13 +00:00
|
|
|
func (in *Input) EncodeBinary(bw *io.BinWriter) error {
|
2019-08-28 16:27:06 +00:00
|
|
|
bw.WriteLE(in.PrevHash)
|
|
|
|
bw.WriteLE(in.PrevIndex)
|
|
|
|
return bw.Err
|
2018-03-04 13:56:49 +00:00
|
|
|
}
|