-
Notifications
You must be signed in to change notification settings - Fork 672
/
stakeable_lock.go
52 lines (43 loc) · 1.22 KB
/
stakeable_lock.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// (c) 2019-2021, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package platformvm
import (
"errors"
"github.com/ava-labs/avalanchego/vms/components/avax"
)
var (
errInvalidLocktime = errors.New("invalid locktime")
errNestedStakeableLocks = errors.New("shouldn't nest stakeable locks")
)
type StakeableLockOut struct {
Locktime uint64 `serialize:"true" json:"locktime"`
avax.TransferableOut `serialize:"true"`
}
func (s *StakeableLockOut) Addresses() [][]byte {
if addressable, ok := s.TransferableOut.(avax.Addressable); ok {
return addressable.Addresses()
}
return nil
}
func (s *StakeableLockOut) Verify() error {
if s.Locktime == 0 {
return errInvalidLocktime
}
if _, nested := s.TransferableOut.(*StakeableLockOut); nested {
return errNestedStakeableLocks
}
return s.TransferableOut.Verify()
}
type StakeableLockIn struct {
Locktime uint64 `serialize:"true" json:"locktime"`
avax.TransferableIn `serialize:"true"`
}
func (s *StakeableLockIn) Verify() error {
if s.Locktime == 0 {
return errInvalidLocktime
}
if _, nested := s.TransferableIn.(*StakeableLockIn); nested {
return errNestedStakeableLocks
}
return s.TransferableIn.Verify()
}