OSDN Git Service

Merge branch 'master' into dev
[bytom/bytom.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         mustWriteForHash(w, s.Data)
14         mustWriteForHash(w, s.ExtHash)
15 }
16
17 func (s *Spend) SetDestination(id *Hash, val *AssetAmount, pos uint64) {
18         s.WitnessDestination = &ValueDestination{
19                 Ref:      id,
20                 Value:    val,
21                 Position: pos,
22         }
23 }
24
25 // NewSpend creates a new Spend.
26 func NewSpend(spentOutputID *Hash, data *Hash, ordinal uint64) *Spend {
27         return &Spend{
28                 SpentOutputId: spentOutputID,
29                 Data:          data,
30                 Ordinal:       ordinal,
31         }
32 }
33
34 func (s *Spend) SetAnchored(id *Hash) {
35         s.WitnessAnchoredId = id
36 }