-
Notifications
You must be signed in to change notification settings - Fork 0
/
spend.go
36 lines (30 loc) · 837 Bytes
/
spend.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package bc
import "io"
// Spend accesses the value in a prior Output for transfer
// elsewhere. It satisfies the Entry interface.
//
// (Not to be confused with the deprecated type SpendInput.)
func (Spend) typ() string { return "spend1" }
func (s *Spend) writeForHash(w io.Writer) {
mustWriteForHash(w, s.SpentOutputId)
mustWriteForHash(w, s.Data)
mustWriteForHash(w, s.ExtHash)
}
func (s *Spend) SetDestination(id *Hash, val *AssetAmount, pos uint64) {
s.WitnessDestination = &ValueDestination{
Ref: id,
Value: val,
Position: pos,
}
}
// NewSpend creates a new Spend.
func NewSpend(spentOutputID *Hash, data *Hash, ordinal uint64) *Spend {
return &Spend{
SpentOutputId: spentOutputID,
Data: data,
Ordinal: ordinal,
}
}
func (s *Spend) SetAnchored(id *Hash) {
s.WitnessAnchoredId = id
}