OSDN Git Service

810a8f39fc3f9a906fa37e5824e77dec689a0f69
[bytom/vapor.git] / protocol / bc / types / unvote.go
1 package types
2
3 import (
4         "github.com/vapor/protocol/bc"
5 )
6
7 // UnvoteInput satisfies the TypedInput interface and represents a unvote transaction.
8 type UnvoteInput struct {
9         UnvoteCommitmentSuffix []byte   // The unconsumed suffix of the output commitment
10         Arguments              [][]byte // Witness
11         Vote                   []byte   // voter xpub
12         SpendCommitment
13 }
14
15 // NewUnvoteInput create a new UnvoteInput struct.
16 func NewUnvoteInput(arguments [][]byte, sourceID bc.Hash, assetID bc.AssetID, amount, sourcePos uint64, controlProgram []byte, vote []byte) *TxInput {
17         sc := SpendCommitment{
18                 AssetAmount: bc.AssetAmount{
19                         AssetId: &assetID,
20                         Amount:  amount,
21                 },
22                 SourceID:       sourceID,
23                 SourcePosition: sourcePos,
24                 VMVersion:      1,
25                 ControlProgram: controlProgram,
26         }
27         return &TxInput{
28                 AssetVersion: 1,
29                 TypedInput: &UnvoteInput{
30                         SpendCommitment: sc,
31                         Arguments:       arguments,
32                         Vote:            vote,
33                 },
34         }
35 }
36
37 // InputType is the interface function for return the input type.
38 func (ui *UnvoteInput) InputType() uint8 { return SpendInputType }