2019-02-25 22:44:14 +00:00
|
|
|
package transaction
|
|
|
|
|
|
|
|
import "github.com/CityOfZion/neo-go/pkg/wire/util"
|
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
2019-03-17 18:26:35 +00:00
|
|
|
//NewInput returns a transaction input object
|
2019-02-25 22:44:14 +00:00
|
|
|
func NewInput(prevHash util.Uint256, prevIndex uint16) *Input {
|
|
|
|
return &Input{
|
|
|
|
prevHash,
|
|
|
|
prevIndex,
|
|
|
|
}
|
|
|
|
}
|
2019-03-17 18:26:35 +00:00
|
|
|
|
|
|
|
// Encode encodes the given input into a binary writer
|
2019-02-25 22:44:14 +00:00
|
|
|
func (i *Input) Encode(bw *util.BinWriter) {
|
|
|
|
bw.Write(i.PrevHash)
|
|
|
|
bw.Write(i.PrevIndex)
|
|
|
|
}
|
|
|
|
|
2019-03-17 18:26:35 +00:00
|
|
|
// Decode decodes a binary reader into an input object
|
2019-02-25 22:44:14 +00:00
|
|
|
func (i *Input) Decode(br *util.BinReader) {
|
|
|
|
br.Read(&i.PrevHash)
|
|
|
|
br.Read(&i.PrevIndex)
|
|
|
|
}
|