OSDN Git Service

feature: add cross-chain input (#61)
[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 }
13
14 // SetDestination will link the CrossChainInput to the output
15 func (cci *CrossChainInput) SetDestination(id *Hash, val *AssetAmount, pos uint64) {
16         cci.WitnessDestination = &ValueDestination{
17                 Ref:      id,
18                 Value:    val,
19                 Position: pos,
20         }
21 }
22
23 // NewCrossChainInput creates a new CrossChainInput.
24 func NewCrossChainInput(mainchainOutputID *Hash, value *AssetAmount, ordinal uint64) *CrossChainInput {
25         return &CrossChainInput{
26                 MainchainOutputId: mainchainOutputID,
27                 Value:             value,
28                 Ordinal:           ordinal,
29         }
30 }