-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathconstants.go
73 lines (55 loc) · 2.38 KB
/
constants.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package address
import (
"encoding/base32"
"errors"
)
func init() {
var err error
TestAddress, err = NewActorAddress([]byte("satoshi"))
if err != nil {
panic(err)
}
TestAddress2, err = NewActorAddress([]byte("nakamoto"))
if err != nil {
panic(err)
}
}
var (
// TestAddress is an account with some initial funds in it.
TestAddress Address
// TestAddress2 is an account with some initial funds in it.
TestAddress2 Address
)
var (
// ErrUnknownNetwork is returned when encountering an unknown network in an address.
ErrUnknownNetwork = errors.New("unknown address network")
// ErrUnknownProtocol is returned when encountering an unknown protocol in an address.
ErrUnknownProtocol = errors.New("unknown address protocol")
// ErrInvalidPayload is returned when encountering an invalid address payload.
ErrInvalidPayload = errors.New("invalid address payload")
// ErrInvalidLength is returned when encountering an address of invalid length.
ErrInvalidLength = errors.New("invalid address length")
// ErrInvalidChecksum is returned when encountering an invalid address checksum.
ErrInvalidChecksum = errors.New("invalid address checksum")
// ErrInvalidEncoding is returned when encountering a non-standard encoding of an address.
ErrInvalidEncoding = errors.New("invalid encoding")
)
// UndefAddressString is the string used to represent an empty address when encoded to a string.
var UndefAddressString = "<empty>"
// MaxInt64StringLength defines the maximum length of `int64` as a string.
const MaxInt64StringLength = 19
// PayloadHashLength defines the hash length taken over addresses using the Actor and SECP256K1 protocols.
const PayloadHashLength = 20
// ChecksumHashLength defines the hash length used for calculating address checksums.
const ChecksumHashLength = 4
// MaxAddressStringLength is the max length of an address encoded as a string (115).
const MaxAddressStringLength = 2 + MaxInt64StringLength + 1 + 93
// BlsPublicKeyBytes is the length of a BLS public key
const BlsPublicKeyBytes = 48
// BlsPrivateKeyBytes is the length of a BLS private key
const BlsPrivateKeyBytes = 32
// MaxSubaddressLen is the maximum length of a delegated address's sub-address.
const MaxSubaddressLen = 54
const encodeStd = "abcdefghijklmnopqrstuvwxyz234567"
// AddressEncoding defines the base32 config used for address encoding and decoding.
var AddressEncoding = base32.NewEncoding(encodeStd)