go-address: github.com/filecoin-project/go-address Index | Files

package address

import "github.com/filecoin-project/go-address"

Index

Package Files

address.go constants.go testing.go

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 = "f"

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 = "t"

TestnetPrefix is the main 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 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.

func Checksum Uses

func Checksum(ingest []byte) []byte

Checksum returns the checksum of `ingest`.

func IDFromAddress Uses

func IDFromAddress(addr Address) (uint64, error)

func NewForTestGetter Uses

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 Uses

func ValidateChecksum(ingest, expect []byte) bool

ValidateChecksum returns true if the checksum of `ingest` is equal to `expected`>

type Address Uses

type Address struct {
    // contains filtered or unexported fields
}

Address is the go type that represents an address in the filecoin network.

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
)

func NewActorAddress Uses

func NewActorAddress(data []byte) (Address, error)

NewActorAddress returns an address using the Actor protocol.

func NewBLSAddress Uses

func NewBLSAddress(pubkey []byte) (Address, error)

NewBLSAddress returns an address using the BLS protocol.

func NewFromBytes Uses

func NewFromBytes(addr []byte) (Address, error)

NewFromBytes return the address represented by the bytes `addr`.

func NewFromString Uses

func NewFromString(addr string) (Address, error)

NewFromString returns the address represented by the string `addr`.

func NewIDAddress Uses

func NewIDAddress(id uint64) (Address, error)

NewIDAddress returns an address using the ID protocol.

func NewSecp256k1Address Uses

func NewSecp256k1Address(pubkey []byte) (Address, error)

NewSecp256k1Address returns an address using the SECP256K1 protocol.

func (Address) Bytes Uses

func (a Address) Bytes() []byte

Bytes returns the address as bytes.

func (Address) Empty Uses

func (a Address) Empty() bool

Empty returns true if the address is empty, false otherwise.

func (Address) Marshal Uses

func (a Address) Marshal() ([]byte, error)

Marshal marshals the address to cbor.

func (Address) MarshalBinary Uses

func (a Address) MarshalBinary() ([]byte, error)

func (*Address) MarshalCBOR Uses

func (a *Address) MarshalCBOR(w io.Writer) error

func (Address) MarshalJSON Uses

func (a Address) MarshalJSON() ([]byte, error)

MarshalJSON implements the json marshal interface.

func (Address) Payload Uses

func (a Address) Payload() []byte

Payload returns the payload of the address.

func (Address) Protocol Uses

func (a Address) Protocol() Protocol

Protocol returns the protocol used by the address.

func (*Address) Scan Uses

func (a *Address) Scan(value interface{}) error

func (Address) String Uses

func (a Address) String() string

String returns an address encoded as a string.

func (Address) Unmarshal Uses

func (a Address) Unmarshal(b []byte) error

Unmarshal unmarshals the cbor bytes into the address.

func (*Address) UnmarshalBinary Uses

func (a *Address) UnmarshalBinary(b []byte) error

func (*Address) UnmarshalCBOR Uses

func (a *Address) UnmarshalCBOR(r io.Reader) error

func (*Address) UnmarshalJSON Uses

func (a *Address) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json unmarshal interface.

type Network Uses

type Network = byte

Network represents which network an address belongs to.

const (
    // Mainnet is the main network.
    Mainnet Network = iota
    // Testnet is the test network.
    Testnet
)

type Protocol Uses

type Protocol = byte

Protocol represents which protocol an address uses.

const (
    // ID represents the address ID protocol.
    ID  Protocol = iota
    // SECP256K1 represents the address SECP256K1 protocol.
    SECP256K1
    // Actor represents the address Actor protocol.
    Actor
    // BLS represents the address BLS protocol.
    BLS

    Unknown = Protocol(255)
)

Package address imports 14 packages (graph) and is imported by 174 packages. Updated 2020-09-22. Refresh now. Tools for package owners.