-
Notifications
You must be signed in to change notification settings - Fork 659
/
stakeable_lock.go
52 lines (43 loc) · 1.19 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
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package stakeable
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 LockOut struct {
Locktime uint64 `serialize:"true" json:"locktime"`
avax.TransferableOut `serialize:"true" json:"output"`
}
func (s *LockOut) Addresses() [][]byte {
if addressable, ok := s.TransferableOut.(avax.Addressable); ok {
return addressable.Addresses()
}
return nil
}
func (s *LockOut) Verify() error {
if s.Locktime == 0 {
return errInvalidLocktime
}
if _, nested := s.TransferableOut.(*LockOut); nested {
return errNestedStakeableLocks
}
return s.TransferableOut.Verify()
}
type LockIn struct {
Locktime uint64 `serialize:"true" json:"locktime"`
avax.TransferableIn `serialize:"true" json:"input"`
}
func (s *LockIn) Verify() error {
if s.Locktime == 0 {
return errInvalidLocktime
}
if _, nested := s.TransferableIn.(*LockIn); nested {
return errNestedStakeableLocks
}
return s.TransferableIn.Verify()
}