6 "github.com/bytom/bytom/encoding/blockchain"
7 "github.com/bytom/bytom/errors"
8 "github.com/bytom/bytom/protocol/bc"
11 // VoteOutput satisfies the TypedOutput interface and represents a vote transaction.
12 type VoteOutput struct {
16 // NewVoteOutput create a new output struct
17 func NewVoteOutput(assetID bc.AssetID, amount uint64, controlProgram []byte, vote []byte, state []byte) *TxOutput {
20 OutputCommitment: OutputCommitment{
21 AssetAmount: bc.AssetAmount{
26 ControlProgram: controlProgram,
29 TypedOutput: &VoteOutput{Vote: vote},
33 func (v *VoteOutput) readFrom(r *blockchain.Reader) error {
35 if v.Vote, err = blockchain.ReadVarstr31(r); err != nil {
36 return errors.Wrap(err, "reading vote output vote")
41 func (v *VoteOutput) writeTo(w io.Writer) error {
42 _, err := blockchain.WriteVarstr31(w, v.Vote)
46 // OutputType implement the txout interface
47 func (v *VoteOutput) OutputType() uint8 { return VoteOutputType }