2018-03-04 14:56:49 +01:00
|
|
|
package transaction
|
|
|
|
|
|
|
|
import (
|
2019-09-16 12:18:13 +03:00
|
|
|
"github.com/CityOfZion/neo-go/pkg/io"
|
2018-03-21 17:11:04 +01:00
|
|
|
"github.com/CityOfZion/neo-go/pkg/util"
|
2018-03-04 14:56:49 +01:00
|
|
|
)
|
|
|
|
|
2019-02-20 18:39:32 +01:00
|
|
|
// Input represents a Transaction input (CoinReference).
|
2018-03-04 14:56:49 +01:00
|
|
|
type Input struct {
|
|
|
|
// The hash of the previous transaction.
|
2019-02-20 18:39:32 +01:00
|
|
|
PrevHash util.Uint256 `json:"txid"`
|
2018-03-04 14:56:49 +01:00
|
|
|
|
|
|
|
// The index of the previous transaction.
|
2019-02-20 18:39:32 +01:00
|
|
|
PrevIndex uint16 `json:"vout"`
|
2018-03-04 14:56:49 +01:00
|
|
|
}
|
|
|
|
|
2019-09-16 19:31:49 +03:00
|
|
|
// DecodeBinary implements Serializable interface.
|
|
|
|
func (in *Input) DecodeBinary(br *io.BinReader) {
|
2019-12-06 18:37:46 +03:00
|
|
|
br.ReadBytes(in.PrevHash[:])
|
2019-12-12 18:52:23 +03:00
|
|
|
in.PrevIndex = br.ReadU16LE()
|
2018-03-04 14:56:49 +01:00
|
|
|
}
|
|
|
|
|
2019-09-16 19:31:49 +03:00
|
|
|
// EncodeBinary implements Serializable interface.
|
|
|
|
func (in *Input) EncodeBinary(bw *io.BinWriter) {
|
2019-12-06 18:22:21 +03:00
|
|
|
bw.WriteBytes(in.PrevHash[:])
|
2019-12-12 18:52:23 +03:00
|
|
|
bw.WriteU16LE(in.PrevIndex)
|
2018-03-04 14:56:49 +01:00
|
|
|
}
|