OSDN Git Service

Hulk did something
[bytom/vapor.git] / protocol / bc / spend.go
1 package bc
2
3 import "io"
4
5 // Spend accesses the value in a prior Output for transfer
6 // elsewhere. It satisfies the Entry interface.
7 //
8 // (Not to be confused with the deprecated type SpendInput.)
9
10 func (Spend) typ() string { return "spend1" }
11 func (s *Spend) writeForHash(w io.Writer) {
12         mustWriteForHash(w, s.SpentOutputId)
13 }
14
15 // SetDestination will link the spend to the output
16 func (s *Spend) SetDestination(id *Hash, val *AssetAmount, pos uint64) {
17         s.WitnessDestination = &ValueDestination{
18                 Ref:      id,
19                 Value:    val,
20                 Position: pos,
21         }
22 }
23
24 // NewSpend creates a new Spend.
25 func NewSpend(spentOutputID *Hash, ordinal uint64) *Spend {
26         return &Spend{
27                 SpentOutputId: spentOutputID,
28                 Ordinal:       ordinal,
29         }
30 }