OSDN Git Service

versoin1.1.9 (#594)
[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.AssetDefinition)
13 }
14
15 // SetDestination will link the CrossChainInput to the output
16 func (cci *CrossChainInput) SetDestination(id *Hash, val *AssetAmount, pos uint64) {
17         cci.WitnessDestination = &ValueDestination{
18                 Ref:      id,
19                 Value:    val,
20                 Position: pos,
21         }
22 }
23
24 // NewCrossChainInput creates a new CrossChainInput.
25 func NewCrossChainInput(mainchainOutputID *Hash, prog *Program, ordinal uint64, assetDef *AssetDefinition, rawDefinitionByte []byte) *CrossChainInput {
26         return &CrossChainInput{
27                 MainchainOutputId: mainchainOutputID,
28                 Ordinal:           ordinal,
29                 ControlProgram:    prog,
30                 AssetDefinition:   assetDef,
31                 RawDefinitionByte: rawDefinitionByte,
32         }
33 }