OSDN Git Service

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