OSDN Git Service

03b1f7b0eb65654c22ac40a1436fd070745e9f91
[bytom/bytom.git] / protocol / bc / types / veto_input.go
1 package types
2
3 import (
4         "github.com/bytom/bytom/protocol/bc"
5 )
6
7 // VetoInput satisfies the TypedInput interface and represents a veto transaction.
8 type VetoInput struct {
9         VetoCommitmentSuffix []byte   // The unconsumed suffix of the output commitment
10         Arguments            [][]byte // Witness
11         Vote                 []byte   // voter xpub
12         SpendCommitment
13 }
14
15 // NewVetoInput create a new VetoInput struct.
16 func NewVetoInput(arguments [][]byte, sourceID bc.Hash, assetID bc.AssetID, amount, sourcePos uint64, controlProgram []byte, vote []byte, stateData []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                 StateData:      stateData,
27         }
28         return &TxInput{
29                 AssetVersion: 1,
30                 TypedInput: &VetoInput{
31                         SpendCommitment: sc,
32                         Arguments:       arguments,
33                         Vote:            vote,
34                 },
35         }
36 }
37
38 // InputType is the interface function for return the input type.
39 func (ui *VetoInput) InputType() uint8 { return VetoInputType }