OSDN Git Service

123ce25341a060141cdcd8d552610c45e1ce0a9b
[bytom/vapor.git] / protocol / bc / crosschain_input.go
1 package bc
2
3 import "io"
4
5 // crosschaininput is the result of a transfer of value. The value it contains
6 // comes from the main chain. It satisfies the Entry interface.
7
8 func (CrossChainInput) typ() string { return "crosschaininput1" }
9
10 func (cci *CrossChainInput) writeForHash(w io.Writer) {
11         mustWriteForHash(w, cci.MainchainOutputId)
12         mustWriteForHash(w, cci.Value)
13         mustWriteForHash(w, cci.AssetDefinition)
14 }
15
16 // SetDestination will link the CrossChainInput to the output
17 func (cci *CrossChainInput) SetDestination(id *Hash, val *AssetAmount, pos uint64) {
18         cci.WitnessDestination = &ValueDestination{
19                 Ref:      id,
20                 Value:    val,
21                 Position: pos,
22         }
23 }
24
25 // NewCrossChainInput creates a new CrossChainInput.
26 func NewCrossChainInput(mainchainOutputID *Hash, value *AssetAmount, prog *Program, ordinal uint64, assetDef *AssetDefinition) *CrossChainInput {
27         return &CrossChainInput{
28                 MainchainOutputId: mainchainOutputID,
29                 Value:             value,
30                 Ordinal:           ordinal,
31                 ControlProgram:    prog,
32                 AssetDefinition:   assetDef,
33         }
34 }