OSDN Git Service

Add issue for claim
[bytom/vapor.git] / protocol / bc / types / claim_pegin.go
1 package types
2
3 import (
4         "github.com/vapor/protocol/bc"
5 )
6
7 // ClaimInput satisfies the TypedInput interface and represents a spend transaction.
8 type ClaimInput struct {
9         SpendCommitmentSuffix []byte   // The unconsumed suffix of the output commitment
10         Arguments             [][]byte // Witness
11         AssetDefinition       []byte
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, assetDefinition []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                         AssetDefinition: assetDefinition,
35                 },
36         }
37 }
38
39 // InputType is the interface function for return the input type.
40 func (si *ClaimInput) InputType() uint8 { return ClainPeginInputType }