Documentation ¶
Index ¶
- Constants
- Variables
- func Checksum(ingest []byte) []byte
- func IDFromAddress(addr Address) (uint64, error)
- func NewForTestGetter() func() Address
- func ValidateChecksum(ingest, expect []byte) bool
- type Address
- func NewActorAddress(data []byte) (Address, error)
- func NewBLSAddress(pubkey []byte) (Address, error)
- func NewFromBytes(addr []byte) (Address, error)
- func NewFromString(addr string) (Address, error)
- func NewIDAddress(id uint64) (Address, error)
- func NewSecp256k1Address(pubkey []byte) (Address, error)
- func (a Address) Bytes() []byte
- func (a Address) Empty() bool
- func (a Address) Marshal() ([]byte, error)
- func (a Address) MarshalBinary() ([]byte, error)
- func (a *Address) MarshalCBOR(w io.Writer) error
- func (a Address) MarshalJSON() ([]byte, error)
- func (a Address) Payload() []byte
- func (a Address) Protocol() Protocol
- func (a *Address) Scan(value interface{}) error
- func (a Address) String() string
- func (a Address) Unmarshal(b []byte) error
- func (a *Address) UnmarshalBinary(b []byte) error
- func (a *Address) UnmarshalCBOR(r io.Reader) error
- func (a *Address) UnmarshalJSON(b []byte) error
- type Network
- type Protocol
Constants ¶
const BlsPrivateKeyBytes = 32
BlsPrivateKeyBytes is the length of a BLS private key
const BlsPublicKeyBytes = 48
BlsPublicKeyBytes is the length of a BLS public key
const ChecksumHashLength = 4
ChecksumHashLength defines the hash length used for calculating address checksums.
const MainnetPrefix = "m"
MainnetPrefix is the main network prefix.
const MaxAddressStringLength = 2 + 84
MaxAddressStringLength is the max length of an address encoded as a string it include the network prefx, protocol, and bls publickey
const PayloadHashLength = 20
PayloadHashLength defines the hash length taken over addresses using the Actor and SECP256K1 protocols.
const TestnetPrefix = "l"
TestnetPrefix is the test network prefix.
Variables ¶
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") )
var AddressEncoding = base32.NewEncoding(encodeStd)
AddressEncoding defines the base32 config used for address encoding and decoding.
var CurrentNetwork = Testnet
CurrentNetwork specifies which network the address belongs to
var Undef = Address{}
Undef is the type that represents an undefined address.
var UndefAddressString = "<empty>"
UndefAddressString is the string used to represent an empty address when encoded to a string.
Functions ¶
func IDFromAddress ¶
func NewForTestGetter ¶
func NewForTestGetter() func() Address
NewForTestGetter returns a closure that returns an address unique to that invocation. The address is unique wrt the closure returned, not globally.
func ValidateChecksum ¶
ValidateChecksum returns true if the checksum of `ingest` is equal to `expected`>
Types ¶
type Address ¶
type Address struct {
// contains filtered or unexported fields
}
Address is the go type that represents an address in the filecoin network.
func NewActorAddress ¶
NewActorAddress returns an address using the Actor protocol.
func NewBLSAddress ¶
NewBLSAddress returns an address using the BLS protocol.
func NewFromBytes ¶
NewFromBytes return the address represented by the bytes `addr`.
func NewFromString ¶
NewFromString returns the address represented by the string `addr`.
func NewIDAddress ¶
NewIDAddress returns an address using the ID protocol.
func NewSecp256k1Address ¶
NewSecp256k1Address returns an address using the SECP256K1 protocol.
func (Address) MarshalBinary ¶
func (Address) MarshalJSON ¶
MarshalJSON implements the json marshal interface.
func (*Address) UnmarshalBinary ¶
func (*Address) UnmarshalJSON ¶
UnmarshalJSON implements the json unmarshal interface.