factom: github.com/Factom-Asset-Tokens/factom Index | Files | Directories

package factom

import "github.com/Factom-Asset-Tokens/factom"

Package factom provides data types corresponding to some of the Factom blockchain's data structures, as well as methods on those types for querying the data from factomd and factom-walletd's APIs.

All of the Factom data structure types in this package have the Get and IsPopulated methods.

Methods that accept a *Client, like those that start with Get, may make calls to the factomd or factom-walletd API queries to populate the data in the variable on which it is called. The returned error can be checked to see if it is a jsonrpc2.Error type, indicating that the networking calls were successful, but that there is some error returned by the RPC method.

IsPopulated methods return whether the data in the variable has been populated by a successful call to Get.

The DBlock, EBlock and Entry types allow for exploring the Factom blockchain.

The Bytes and Bytes32 types are used by other types when JSON marshaling and unmarshaling to and from hex encoded data is required. Bytes32 is used for Chain IDs and KeyMRs.

The Address interfaces and types allow for working with the four Factom address types.

The IDKey interfaces and types allow for working with the id/sk key pairs for server identities.

Currently this package supports creating new chains and entries using both the factom-walletd "compose" methods, and by locally generating the commit and reveal data, if the private entry credit key is available locally. See Entry.Create and Entry.ComposeCreate.

This package does not yet support Factoid transactions, nor does it support the binary data structures for DBlocks or EBlocks. Additionally, working with Identity Chains is not yet supported beyond querying the ID1Key.

Index

Package Files

address.go bytes.go client.go dblock.go doc.go eblock.go entry.go gen.go heights.go identity.go idkey.go idkey_gen.go networkid.go payload.go pendingentries.go rcdprivatekey.go

Constants

const (
    // RCDType is the magic number identifying the currenctly accepted RCD.
    RCDType byte = 0x01
    // RCDSize is the size of the RCD.
    RCDSize = ed25519.PublicKeySize + 1
    // SignatureSize is the size of the ed25519 signatures.
    SignatureSize = ed25519.SignatureSize
)
const (
    FactomdDefault = "http://localhost:8088"
    WalletdDefault = "http://localhost:8089"
)

Defaults for the factomd and factom-walletd endpoints.

const (
    DBlockHeaderLen = 1 +
        4 +
        32 +
        32 +
        32 +
        4 +
        4 +
        4   // EBlock Count

    DBlockEBlockLen = 32 +
        32  // KeyMR

    DBlockMinBodyLen = DBlockEBlockLen +
        DBlockEBlockLen +
        DBlockEBlockLen // FCT Block
    DBlockMinTotalLen = DBlockHeaderLen + DBlockMinBodyLen

    DBlockMaxBodyLen  = math.MaxUint32 * DBlockEBlockLen
    DBlockMaxTotalLen = DBlockHeaderLen + DBlockMaxBodyLen
)
const (
    EBlockHeaderLen = 32 +
        32 +
        32 +
        32 +
        4 +
        4 +
        4   // [Entry Count (uint32 BE)]

    EBlockObjectLen = 32 // Entry hash or minute marker

    EBlockMinBodyLen  = EBlockObjectLen * 2 // one entry hash & one minute marker
    EBlockMinTotalLen = EBlockHeaderLen + EBlockMinBodyLen

    EBlockMaxBodyLen  = math.MaxUint32 * EBlockObjectLen
    EBlockMaxTotalLen = EBlockHeaderLen + EBlockMaxBodyLen
)
const (
    EntryHeaderLen = 1 +
        32 +
        2   // total len

    EntryMaxDataLen  = 10240
    EntryMaxTotalLen = EntryMaxDataLen + EntryHeaderLen
)
const NewChainCost = 10

NewChainCost is the fixed added cost of creating a new chain.

func EntryCost Uses

func EntryCost(size int) (int8, error)

EntryCost returns the required Entry Credit cost for an entry with encoded length equal to size. An error is returned if size exceeds 10275.

func ValidIdentityChainID Uses

func ValidIdentityChainID(chainID Bytes) bool

ValidIdentityChainID returns true if the chainID matches the pattern for an Identity Chain ID.

The Identity Chain specification can be found here: https://github.com/FactomProject/FactomDocs/blob/master/Identity.md#factom-identity-chain-creation

func ValidIdentityNameIDs Uses

func ValidIdentityNameIDs(nameIDs []Bytes) bool

ValidIdentityNameIDs returns true if the nameIDs match the pattern for a valid Identity Chain. The nameIDs for a chain are the ExtIDs of the first entry in the chain.

The Identity Chain specification can be found here: https://github.com/FactomProject/FactomDocs/blob/master/Identity.md#factom-identity-chain-creation

type Address Uses

type Address interface {
    // PrefixBytes returns the prefix bytes for the Address.
    PrefixBytes() []byte
    // PrefixString returns the encoded prefix string for the Address.
    PrefixString() string

    // String encodes the address to a base58check string with the
    // appropriate prefix.
    String() string
    // Payload returns the address as a byte array.
    Payload() [sha256.Size]byte

    // PublicAddress returns the corresponding public address in an Address
    // interface. Public addresses return themselves. Private addresses
    // compute the public address.
    PublicAddress() Address
    // GetPrivateAddress returns the corresponding private address in a
    // PrivateAddress interface. Public addresses query factom-walletd for
    // the private address. Private addresses return themselves.
    GetPrivateAddress(*Client) (PrivateAddress, error)

    // GetBalance returns the current balance for the address.
    GetBalance(*Client) (uint64, error)

    // Remove queries factom-walletd to remove the public and private
    // addresses from its database.
    // WARNING: DESTRUCTIVE ACTION! LOSS OF KEYS AND FUNDS MAY RESULT!
    Remove(*Client) error
}

Address is the interface implemented by the four address types: FAAddress, FsAddress, ECAddress, and EsAddress.

func NewAddress Uses

func NewAddress(adrStr string) (Address, error)

NewAddress parses adrStr and returns the correct address type as an Address interface. This is useful when the address type isn't known prior to parsing adrStr. If the address type is known ahead of time, it is generally better to just use the appropriate concrete type.

func NewPublicAddress Uses

func NewPublicAddress(adrStr string) (Address, error)

NewPublicAddress parses adrStr and returns the correct address type as an Address interface. If adrStr is not a public address then an "invalid prefix" error is returned. This is useful when the address type isn't known prior to parsing adrStr, but must be a public address. If the address type is known ahead of time, it is generally better to just use the appropriate concrete type.

type Bytes Uses

type Bytes []byte

Bytes implements json.Marshaler and json.Unmarshaler to encode and decode strings with hex encoded data, such as an Entry's External IDs or content.

func NewBytesFromString Uses

func NewBytesFromString(s string) Bytes

NewBytesFromString makes a new Bytes object with the hex encoded string data contained in s.

func (Bytes) MarshalJSON Uses

func (b Bytes) MarshalJSON() ([]byte, error)

MarshalJSON encodes b as a hex JSON string.

func (*Bytes) Set Uses

func (b *Bytes) Set(hexStr string) error

Set decodes a string with hex encoded data.

func (Bytes) String Uses

func (b Bytes) String() string

String encodes b as a hex string.

func (Bytes) Type Uses

func (b Bytes) Type() string

Type returns "Bytes". Satisfies pflag.Value interface.

func (*Bytes) UnmarshalJSON Uses

func (b *Bytes) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes a JSON string with hex encoded data.

type Bytes32 Uses

type Bytes32 [32]byte

Bytes32 implements json.Marshaler and json.Unmarshaler to encode and decode strings with exactly 32 bytes of hex encoded data, such as Chain IDs and KeyMRs.

func ChainID Uses

func ChainID(nameIDs []Bytes) Bytes32

ChainID returns the chain ID for a set of NameIDs.

func EntryHash Uses

func EntryHash(data []byte) Bytes32

EntryHash returns the Entry hash of data. Entry's are hashed via: sha256(sha512(data) + data).

func NewBytes32 Uses

func NewBytes32(s32 []byte) *Bytes32

NewBytes32 allocates a new Bytes32 object with the first 32 bytes of data contained in s32.

func NewBytes32FromString Uses

func NewBytes32FromString(s32 string) *Bytes32

NewBytes32FromString allocates a new Bytes32 object with the hex encoded string data contained in s32.

func (Bytes32) IsZero Uses

func (b Bytes32) IsZero() bool

func (Bytes32) MarshalJSON Uses

func (b Bytes32) MarshalJSON() ([]byte, error)

MarshalJSON encodes b as a hex JSON string.

func (*Bytes32) Scan Uses

func (b *Bytes32) Scan(v interface{}) error

Scan expects v to be a byte slice with exactly 32 bytes of data.

func (*Bytes32) Set Uses

func (b *Bytes32) Set(hexStr string) error

Set decodes a string with exactly 32 bytes of hex encoded data.

func (Bytes32) String Uses

func (b Bytes32) String() string

String encodes b as a hex string.

func (Bytes32) Type Uses

func (b Bytes32) Type() string

Type returns "Bytes32". Satisfies pflag.Value interface.

func (*Bytes32) UnmarshalJSON Uses

func (b *Bytes32) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes a JSON string with exactly 32 bytes of hex encoded data.

func (Bytes32) Value Uses

func (b Bytes32) Value() (driver.Value, error)

Value expects b to be a byte slice with exactly 32 bytes of data.

type Client Uses

type Client struct {
    Factomd       jrpc.Client
    FactomdServer string
    Walletd       jrpc.Client
    WalletdServer string
}

Client makes RPC requests to factomd's and factom-walletd's APIs. Client embeds two jsonrpc2.Clients, and thus also two http.Client, one for requests to factomd and one for requests to factom-walletd. Use jsonrpc2.Client's BasicAuth settings to set up BasicAuth and http.Client's transport settings to configure TLS.

func NewClient Uses

func NewClient() *Client

NewClient returns a pointer to a Client initialized with the default localhost endpoints for factomd and factom-walletd, and 15 second timeouts for each of the http.Clients.

func (*Client) Commit Uses

func (c *Client) Commit(commit []byte) error

Commit sends an entry or new chain commit to factomd.

func (*Client) FactomdRequest Uses

func (c *Client) FactomdRequest(method string, params, result interface{}) error

FactomdRequest makes a request to factomd's v2 API.

func (*Client) GetAddress Uses

func (c *Client) GetAddress(pubAdr Address, privAdr PrivateAddress) error

GetAddress queries factom-walletd for the privAdr corresponding to pubAdr. If the returned error is nil, then privAdr is now populated. Note that privAdr must be a pointer to a concrete type implementing PrivateAddress.

func (*Client) GetAddresses Uses

func (c *Client) GetAddresses() ([]Address, error)

GetAddresses queries factom-walletd for all public addresses.

func (*Client) GetECAddresses Uses

func (c *Client) GetECAddresses() ([]ECAddress, error)

GetECAddresses queries factom-walletd for all public Entry Credit addresses.

func (*Client) GetEsAddresses Uses

func (c *Client) GetEsAddresses() ([]EsAddress, error)

GetEsAddresses queries factom-walletd for all secret Entry Credit addresses.

func (*Client) GetFAAddresses Uses

func (c *Client) GetFAAddresses() ([]FAAddress, error)

GetFAAddresses queries factom-walletd for all public Factoid addresses.

func (*Client) GetFsAddresses Uses

func (c *Client) GetFsAddresses() ([]FsAddress, error)

GetFsAddresses queries factom-walletd for all secret Factoid addresses.

func (*Client) GetPrivateAddresses Uses

func (c *Client) GetPrivateAddresses() ([]PrivateAddress, error)

GetPrivateAddresses queries factom-walletd for all private addresses.

func (*Client) RemoveAddress Uses

func (c *Client) RemoveAddress(adr Address) error

RemoveAddress removes adr from factom-walletd. WARNING: THIS IS DESTRUCTIVE.

func (*Client) Reveal Uses

func (c *Client) Reveal(reveal []byte) error

Reveal reveals an entry or new chain entry to factomd.

func (*Client) SavePrivateAddresses Uses

func (c *Client) SavePrivateAddresses(adrs ...PrivateAddress) error

SavePrivateAddresses saves many adrs with factom-walletd.

func (*Client) WalletdRequest Uses

func (c *Client) WalletdRequest(method string, params, result interface{}) error

WalletdRequest makes a request to factom-walletd's v2 API.

type DBlock Uses

type DBlock struct {
    KeyMR *Bytes32 `json:"keymr"`

    FullHash *Bytes32 `json:"dbhash"`

    Header DBlockHeader `json:"header"`

    // DBlock.Get populates EBlocks with their ChainID and KeyMR.
    EBlocks []EBlock `json:"dbentries,omitempty"`
}

DBlock represents a Factom Directory Block.

func (DBlock) ComputeBodyMR Uses

func (db DBlock) ComputeBodyMR() (Bytes32, error)

func (DBlock) ComputeFullHash Uses

func (db DBlock) ComputeFullHash() (Bytes32, error)

func (DBlock) ComputeHeaderHash Uses

func (db DBlock) ComputeHeaderHash() (Bytes32, error)

func (DBlock) ComputeKeyMR Uses

func (db DBlock) ComputeKeyMR() (Bytes32, error)

func (DBlock) EBlock Uses

func (db DBlock) EBlock(chainID Bytes32) *EBlock

EBlock efficiently finds and returns the *EBlock in db.EBlocks for the given chainID, if it exists. Otherwise, EBlock returns nil.

func (*DBlock) Get Uses

func (db *DBlock) Get(c *Client) (err error)

Get queries factomd for the Directory Block at db.Header.Height. After a successful call, the EBlocks will all have their ChainID and KeyMR, but not their Entries. Call Get on the EBlocks individually to populate their Entries.

func (DBlock) IsPopulated Uses

func (db DBlock) IsPopulated() bool

IsPopulated returns true if db has already been successfully populated by a call to Get. IsPopulated returns false if db.EBlocks is nil.

func (*DBlock) MarshalBinary Uses

func (db *DBlock) MarshalBinary() ([]byte, error)

func (*DBlock) MarshalBinaryHeader Uses

func (db *DBlock) MarshalBinaryHeader() ([]byte, error)

func (*DBlock) MarshalBinaryLen Uses

func (db *DBlock) MarshalBinaryLen() int

func (*DBlock) UnmarshalBinary Uses

func (db *DBlock) UnmarshalBinary(data []byte) error

UnmarshalBinary unmarshals raw directory block data.

Header [Version byte (0x00)] + [NetworkID (4 bytes)] + [BodyMR (Bytes32)] + [PrevKeyMR (Bytes32)] + [PrevFullHash (Bytes32)] + [Timestamp (4 bytes)] + [DB Height (4 bytes)] + [EBlock Count (4 bytes)]

Body [Admin Block ChainID (Bytes32{31:0x0a})] + [Admin Block LookupHash (Bytes32)] + [EC Block ChainID (Bytes32{31:0x0c})] + [EC Block HeaderHash (Bytes32)] + [FCT Block ChainID (Bytes32{31:0x0f})] + [FCT Block KeyMR (Bytes32)] + [ChainID 0 (Bytes32)] + [KeyMR 0 (Bytes32)] + ... + [ChainID N (Bytes32)] + [KeyMR N (Bytes32)] +

https://github.com/FactomProject/FactomDocs/blob/master/factomDataStructureDetails.md#directory-block

type DBlockHeader Uses

type DBlockHeader struct {
    NetworkID NetworkID `json:"networkid"`

    BodyMR       *Bytes32 `json:"bodymr"`
    PrevKeyMR    *Bytes32 `json:"prevkeymr"`
    PrevFullHash *Bytes32 `json:"prevfullhash"`

    Height uint32 `json:"dbheight"`

    Timestamp time.Time `json:"-"`
}

func (*DBlockHeader) MarshalJSON Uses

func (dbh *DBlockHeader) MarshalJSON() ([]byte, error)

func (*DBlockHeader) UnmarshalJSON Uses

func (dbh *DBlockHeader) UnmarshalJSON(data []byte) error

type EBlock Uses

type EBlock struct {
    // DBlock.Get populates the ChainID, KeyMR, and Height.
    ChainID *Bytes32 `json:"chainid,omitempty"`
    KeyMR   *Bytes32 `json:"keymr,omitempty"`

    PrevKeyMR *Bytes32 `json:"-"`

    PrevFullHash *Bytes32 `json:"-"`
    BodyMR       *Bytes32 `json:"-"`

    Height      uint32 `json:"-"`
    Sequence    uint32 `json:"-"`
    ObjectCount uint32 `json:"-"`

    Timestamp time.Time `json:"-"`

    // EBlock.Get populates the EBlockHeader.PrevKeyMR and the Entries with
    // their Hash and Timestamp.
    Entries []Entry `json:"-"`
}

EBlock represents a Factom Entry Block.

func (*EBlock) ComputeBodyMR Uses

func (eb *EBlock) ComputeBodyMR() (Bytes32, error)

func (*EBlock) ComputeFullHash Uses

func (eb *EBlock) ComputeFullHash() (Bytes32, error)

func (*EBlock) ComputeHeaderHash Uses

func (eb *EBlock) ComputeHeaderHash() (Bytes32, error)

func (*EBlock) ComputeKeyMR Uses

func (eb *EBlock) ComputeKeyMR() (Bytes32, error)

func (EBlock) CountObjects Uses

func (eb EBlock) CountObjects() uint32

func (*EBlock) Get Uses

func (eb *EBlock) Get(c *Client) error

Get queries factomd for the Entry Block corresponding to eb.KeyMR, if not nil, and otherwise the Entry Block chain head for eb.ChainID. Either eb.KeyMR or eb.ChainID must be not nil or else Get will fail to populate the EBlock. After a successful call, EBlockHeader and Entries will be populated. Each Entry will be populated with its Hash, Timestamp, ChainID, and Height, but not its Content or ExtIDs. Call Get on the individual Entries to populate their Content and ExtIDs.

func (*EBlock) GetChainHead Uses

func (eb *EBlock) GetChainHead(c *Client) error

GetChainHead queries factomd for the latest eb.KeyMR for chain eb.ChainID.

func (*EBlock) GetEntries Uses

func (eb *EBlock) GetEntries(c *Client) error

GetEntries calls eb.Get and then calls Get on each Entry in eb.Entries.

func (*EBlock) GetFirst Uses

func (eb *EBlock) GetFirst(c *Client) error

GetFirst finds the first Entry Block in eb's chain, and populates eb as such.

GetFirst differs from GetPrevAll in that it does not allocate any additional EBlocks. GetFirst avoids allocating any new EBlocks by reusing eb to traverse up to the first entry block.

func (EBlock) GetPrevAll Uses

func (eb EBlock) GetPrevAll(c *Client) ([]EBlock, error)

GetPrevAll returns a slice of all preceding EBlocks, in order from eb to the first EBlock in the chain. So the 0th element of the returned slice is always equal to eb. If eb is the first EBlock in the chain, then it is the only element in the slice. Like Get, if eb does not have a KeyMR, the chain head KeyMR is queried first.

If you are only interested in obtaining the first entry block in eb's chain, and not all of the intermediary ones, then use GetFirst.

func (EBlock) GetPrevUpTo Uses

func (eb EBlock) GetPrevUpTo(c *Client, keyMR Bytes32) ([]EBlock, error)

GetPrevUpTo returns a slice of all preceding EBlocks, in order from eb up to, but not including, keyMR. So the 0th element of the returned slice is always equal to eb. If *eb.KeyMR == keyMR then nil, nil is returned. If *eb.PrevKeyMR == keyMR, then it is the only element in the slice. If the beginning of the chain is reached without finding keyMR, an error is returned with the fully populated []EBlock. Like Get, if eb does not have a KeyMR, the chain head KeyMR is queried first.

func (EBlock) IsFirst Uses

func (eb EBlock) IsFirst() bool

IsFirst returns true if this is the first EBlock in its chain, indicated by the PrevKeyMR being all zeroes. IsFirst returns false if eb is not populated or if the PrevKeyMR is not all zeroes.

func (EBlock) IsPopulated Uses

func (eb EBlock) IsPopulated() bool

func (*EBlock) MarshalBinary Uses

func (eb *EBlock) MarshalBinary() ([]byte, error)

func (*EBlock) MarshalBinaryHeader Uses

func (eb *EBlock) MarshalBinaryHeader() ([]byte, error)

func (*EBlock) MarshalBinaryLen Uses

func (eb *EBlock) MarshalBinaryLen() int

func (*EBlock) Objects Uses

func (eb *EBlock) Objects() ([]Bytes32, error)

func (EBlock) Prev Uses

func (eb EBlock) Prev() EBlock

Prev returns the an EBlock with its KeyMR initialized to eb.PrevKeyMR and ChainID initialized to eb.ChainID. If eb is the first Entry Block in the chain, then eb is returned.

func (*EBlock) SetTimestamp Uses

func (eb *EBlock) SetTimestamp(ts time.Time)

func (*EBlock) UnmarshalBinary Uses

func (eb *EBlock) UnmarshalBinary(data []byte) error

UnmarshalBinary unmarshals raw entry block data.

Header

[ChainID (Bytes32)] + [BodyMR (Bytes32)] + [PrevKeyMR (Bytes32)] + [PrevFullHash (Bytes32)] + [EB Sequence (uint32 BE)] + [DB Height (uint32 BE)] + [Object Count (uint32 BE)]

Body

[Object 0 (Bytes32)] // entry hash or minute marker + ... + [Object N (Bytes32)]

https://github.com/FactomProject/FactomDocs/blob/master/factomDataStructureDetails.md#entry-block

type ECAddress Uses

type ECAddress [sha256.Size]byte

ECAddress is a Public Entry Credit Address.

func NewECAddress Uses

func NewECAddress(adrStr string) (adr ECAddress, err error)

NewECAddress attempts to parse adrStr into a new ECAddress.

func (ECAddress) GetBalance Uses

func (adr ECAddress) GetBalance(c *Client) (uint64, error)

GetBalance queries factomd for the Entry Credit Balance for adr.

func (ECAddress) GetEsAddress Uses

func (adr ECAddress) GetEsAddress(c *Client) (EsAddress, error)

GetEsAddress queries factom-walletd for the EsAddress corresponding to adr.

func (ECAddress) GetPrivateAddress Uses

func (adr ECAddress) GetPrivateAddress(c *Client) (PrivateAddress, error)

GetPrivateAddress queries factom-walletd for the secret address corresponding to adr and returns it as a PrivateAddress.

func (ECAddress) MarshalJSON Uses

func (adr ECAddress) MarshalJSON() ([]byte, error)

MarshalJSON encodes adr as a JSON string using adr.String().

func (ECAddress) Payload Uses

func (adr ECAddress) Payload() [sha256.Size]byte

Payload returns adr as a byte array.

func (ECAddress) PrefixBytes Uses

func (ECAddress) PrefixBytes() []byte

PrefixBytes returns the two byte prefix for the address type as a byte array. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns []byte{0x59, 0x2a}.

func (ECAddress) PrefixString Uses

func (ECAddress) PrefixString() string

PrefixString returns the two prefix bytes for the address type as an encoded string. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns "EC".

func (ECAddress) PublicAddress Uses

func (adr ECAddress) PublicAddress() Address

PublicAddress returns adr as an Address.

func (ECAddress) PublicKey Uses

func (adr ECAddress) PublicKey() ed25519.PublicKey

PublicKey returns the ed25519.PublicKey for adr.

func (ECAddress) Remove Uses

func (adr ECAddress) Remove(c *Client) error

Remove adr from factom-walletd. WARNING: THIS IS DESTRUCTIVE.

func (*ECAddress) Set Uses

func (adr *ECAddress) Set(adrStr string) error

Set attempts to parse adrStr into adr.

func (ECAddress) String Uses

func (adr ECAddress) String() string

String encodes adr into its human readable form: a base58check string with adr.PrefixBytes().

func (*ECAddress) UnmarshalJSON Uses

func (adr *ECAddress) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes a JSON string with a human readable public Entry Credit address into adr.

type Entry Uses

type Entry struct {
    // EBlock.Get populates the Hash, Timestamp, ChainID, and Height.
    Hash      *Bytes32  `json:"entryhash,omitempty"`
    Timestamp time.Time `json:"-"`
    ChainID   *Bytes32  `json:"chainid,omitempty"`

    // Entry.Get populates the Content and ExtIDs.
    ExtIDs  []Bytes `json:"extids"`
    Content Bytes   `json:"content"`
}

Entry represents a Factom Entry with some additional useful fields. Both Timestamp and Height are not included in the entry binary structure or hash. These fields will only be populated if this Entry was initially part of a populated EBlock, and can be manipulated in this type without affecting the Entry Hash.

func (*Entry) Compose Uses

func (e *Entry) Compose(es EsAddress) (commit []byte, reveal []byte, txID *Bytes32,
    err error)

Compose generates the commit and reveal data required to submit an entry to factomd. If e.ChainID is nil, then the ChainID is computed from the e.ExtIDs and a new chain commit is created.

func (*Entry) ComposeCreate Uses

func (e *Entry) ComposeCreate(c *Client, es EsAddress) (*Bytes32, error)

ComposeCreate Composes e locally and then Commit and Reveals it using factomd. This does not make any calls to factom-walletd. The Transaction ID is returned.

func (*Entry) ComputeHash Uses

func (e *Entry) ComputeHash() (Bytes32, error)

ComputeHash returns the Entry's hash as computed by hashing the binary representation of the Entry.

func (Entry) Cost Uses

func (e Entry) Cost() (int8, error)

func (*Entry) Create Uses

func (e *Entry) Create(c *Client, ec ECAddress) (*Bytes32, error)

Create queries factom-walletd to compose and factomd to commit and reveal a new Entry or new Chain, if e.ChainID is nil. ec must exist in factom-walletd's keystore.

func (*Entry) Get Uses

func (e *Entry) Get(c *Client) error

Get queries factomd for the entry corresponding to e.Hash, which must be not nil. After a successful call e.Content, e.ExtIDs, and e.Timestamp will be populated.

func (Entry) IsPopulated Uses

func (e Entry) IsPopulated() bool

IsPopulated returns true if e has already been successfully populated by a call to Get. IsPopulated returns false if e.ExtIDs, e.Content, or e.Hash are nil, or if e.Timestamp is zero.

func (*Entry) MarshalBinary Uses

func (e *Entry) MarshalBinary() ([]byte, error)

MarshalBinary marshals the entry to its binary representation. See UnmarshalBinary for encoding details. MarshalBinary populates e.ChainID if nil, and always overwrites e.Hash with the computed EntryHash. This is also the reveal data.

func (Entry) MarshalBinaryLen Uses

func (e Entry) MarshalBinaryLen() int

func (*Entry) UnmarshalBinary Uses

func (e *Entry) UnmarshalBinary(data []byte) error

UnmarshalBinary unmarshals raw entry data. It does not populate the Entry.Hash. Entries are encoded as follows:

[Version byte (0x00)] + [ChainID (Bytes32)] + [Total ExtID encoded length (uint16 BE)] + [ExtID 0 length (uint16)] + [ExtID 0 (Bytes)] + ... + [ExtID X length (uint16)] + [ExtID X (Bytes)] + [Content (Bytes)]

https://github.com/FactomProject/FactomDocs/blob/master/factomDataStructureDetails.md#entry

type EsAddress Uses

type EsAddress [sha256.Size]byte

EsAddress is the secret key to a ECAddress.

func GenerateEsAddress Uses

func GenerateEsAddress() (EsAddress, error)

GenerateEsAddress generates a secure random private Entry Credit address using crypto/rand.Random as the source of randomness.

func NewEsAddress Uses

func NewEsAddress(adrStr string) (adr EsAddress, err error)

NewEsAddress attempts to parse adrStr into a new EsAddress.

func (EsAddress) ECAddress Uses

func (adr EsAddress) ECAddress() (ec ECAddress)

ECAddress returns the ECAddress corresponding to adr.

func (EsAddress) GetBalance Uses

func (adr EsAddress) GetBalance(c *Client) (uint64, error)

GetBalance queries factomd for the Entry Credit Balance for adr.

func (EsAddress) GetPrivateAddress Uses

func (adr EsAddress) GetPrivateAddress(_ *Client) (PrivateAddress, error)

GetPrivateAddress returns adr as a PrivateAddress.

func (EsAddress) MarshalJSON Uses

func (adr EsAddress) MarshalJSON() ([]byte, error)

MarshalJSON encodes adr as a JSON string using adr.String().

func (EsAddress) Payload Uses

func (adr EsAddress) Payload() [sha256.Size]byte

Payload returns adr as a byte array.

func (EsAddress) PrefixBytes Uses

func (EsAddress) PrefixBytes() []byte

PrefixBytes returns the two byte prefix for the address type as a byte array. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns []byte{0x5d, 0xb6}.

func (EsAddress) PrefixString Uses

func (EsAddress) PrefixString() string

PrefixString returns the two prefix bytes for the address type as an encoded string. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns "Es".

func (EsAddress) PrivateKey Uses

func (adr EsAddress) PrivateKey() ed25519.PrivateKey

PrivateKey returns the ed25519.PrivateKey for adr.

func (EsAddress) PublicAddress Uses

func (adr EsAddress) PublicAddress() Address

PublicAddress returns the ECAddress corresponding to adr as an Address.

func (EsAddress) PublicKey Uses

func (adr EsAddress) PublicKey() ed25519.PublicKey

PublicKey computes the ed25519.PublicKey for adr.

func (EsAddress) Remove Uses

func (adr EsAddress) Remove(c *Client) error

Remove adr from factom-walletd. WARNING: THIS IS DESTRUCTIVE.

func (EsAddress) Save Uses

func (adr EsAddress) Save(c *Client) error

Save adr with factom-walletd.

func (*EsAddress) Set Uses

func (adr *EsAddress) Set(adrStr string) error

Set attempts to parse adrStr into adr.

func (EsAddress) String Uses

func (adr EsAddress) String() string

String encodes adr into its human readable form: a base58check string with adr.PrefixBytes().

func (*EsAddress) UnmarshalJSON Uses

func (adr *EsAddress) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes a JSON string with a human readable secret Entry Credit address into adr.

type FAAddress Uses

type FAAddress [sha256.Size]byte

FAAddress is a Public Factoid Address.

func NewFAAddress Uses

func NewFAAddress(adrStr string) (adr FAAddress, err error)

NewFAAddress attempts to parse adrStr into a new FAAddress.

func (FAAddress) GetBalance Uses

func (adr FAAddress) GetBalance(c *Client) (uint64, error)

GetBalance queries factomd for the Factoid Balance for adr.

func (FAAddress) GetFsAddress Uses

func (adr FAAddress) GetFsAddress(c *Client) (FsAddress, error)

GetFsAddress queries factom-walletd for the FsAddress corresponding to adr.

func (FAAddress) GetPrivateAddress Uses

func (adr FAAddress) GetPrivateAddress(c *Client) (PrivateAddress, error)

GetPrivateAddress queries factom-walletd for the secret address corresponding to adr and returns it as a PrivateAddress.

func (FAAddress) MarshalJSON Uses

func (adr FAAddress) MarshalJSON() ([]byte, error)

MarshalJSON encodes adr as a JSON string using adr.String().

func (FAAddress) Payload Uses

func (adr FAAddress) Payload() [sha256.Size]byte

Payload returns adr as a byte array.

func (FAAddress) PrefixBytes Uses

func (FAAddress) PrefixBytes() []byte

PrefixBytes returns the two byte prefix for the address type as a byte array. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns []byte{0x5f, 0xb1}.

func (FAAddress) PrefixString Uses

func (FAAddress) PrefixString() string

PrefixString returns the two prefix bytes for the address type as an encoded string. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns "FA".

func (FAAddress) PublicAddress Uses

func (adr FAAddress) PublicAddress() Address

PublicAddress returns adr as an Address.

func (FAAddress) RCDHash Uses

func (adr FAAddress) RCDHash() [sha256.Size]byte

RCDHash returns the RCD hash encoded in adr.

func (FAAddress) Remove Uses

func (adr FAAddress) Remove(c *Client) error

Remove adr from factom-walletd. WARNING: THIS IS DESTRUCTIVE.

func (*FAAddress) Scan Uses

func (adr *FAAddress) Scan(v interface{}) error

Scan implements sql.Scanner for adr using Bytes32.Scan. The FAAddress type is not encoded and is assumed.

func (*FAAddress) Set Uses

func (adr *FAAddress) Set(adrStr string) error

Set attempts to parse adrStr into adr.

func (FAAddress) String Uses

func (adr FAAddress) String() string

String encodes adr into its human readable form: a base58check string with adr.PrefixBytes().

func (*FAAddress) UnmarshalJSON Uses

func (adr *FAAddress) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes a JSON string with a human readable public Factoid address into adr.

func (FAAddress) Value Uses

func (adr FAAddress) Value() (driver.Value, error)

Value implements driver.Valuer for adr using Bytes32.Value. The FAAddress type is not encoded.

type FsAddress Uses

type FsAddress [sha256.Size]byte

FsAddress is the secret key to a FAAddress.

func GenerateFsAddress Uses

func GenerateFsAddress() (FsAddress, error)

GenerateFsAddress generates a secure random private Factoid address using crypto/rand.Random as the source of randomness.

func NewFsAddress Uses

func NewFsAddress(adrStr string) (adr FsAddress, err error)

NewFsAddress attempts to parse adrStr into a new FsAddress.

func (FsAddress) FAAddress Uses

func (adr FsAddress) FAAddress() FAAddress

FAAddress returns the FAAddress corresponding to adr.

func (FsAddress) GetBalance Uses

func (adr FsAddress) GetBalance(c *Client) (uint64, error)

GetBalance queries factomd for the Factoid Balance for adr.

func (FsAddress) GetPrivateAddress Uses

func (adr FsAddress) GetPrivateAddress(_ *Client) (PrivateAddress, error)

GetPrivateAddress returns adr as a PrivateAddress.

func (FsAddress) MarshalJSON Uses

func (adr FsAddress) MarshalJSON() ([]byte, error)

MarshalJSON encodes adr as a JSON string using adr.String().

func (FsAddress) Payload Uses

func (adr FsAddress) Payload() [sha256.Size]byte

Payload returns adr as a byte array.

func (FsAddress) PrefixBytes Uses

func (FsAddress) PrefixBytes() []byte

PrefixBytes returns the two byte prefix for the address type as a byte array. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns []byte{0x64, 0x78}.

func (FsAddress) PrefixString Uses

func (FsAddress) PrefixString() string

PrefixString returns the two prefix bytes for the address type as an encoded string. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns "Fs".

func (FsAddress) PrivateKey Uses

func (adr FsAddress) PrivateKey() ed25519.PrivateKey

PrivateKey returns the ed25519.PrivateKey for adr.

func (FsAddress) PublicAddress Uses

func (adr FsAddress) PublicAddress() Address

PublicAddress returns the FAAddress corresponding to adr as an Address.

func (FsAddress) PublicKey Uses

func (adr FsAddress) PublicKey() ed25519.PublicKey

PublicKey computes the ed25519.PublicKey for adr.

func (FsAddress) RCD Uses

func (adr FsAddress) RCD() []byte

RCD computes the RCD for adr.

func (FsAddress) RCDHash Uses

func (adr FsAddress) RCDHash() [sha256.Size]byte

RCDHash computes the RCD hash corresponding to adr.

func (FsAddress) Remove Uses

func (adr FsAddress) Remove(c *Client) error

Remove adr from factom-walletd. WARNING: THIS IS DESTRUCTIVE.

func (FsAddress) Save Uses

func (adr FsAddress) Save(c *Client) error

Save adr with factom-walletd.

func (*FsAddress) Set Uses

func (adr *FsAddress) Set(adrStr string) error

Set attempts to parse adrStr into adr.

func (FsAddress) String Uses

func (adr FsAddress) String() string

String encodes adr into its human readable form: a base58check string with adr.PrefixBytes().

func (*FsAddress) UnmarshalJSON Uses

func (adr *FsAddress) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes a JSON string with a human readable secret Factoid address into adr.

type Heights Uses

type Heights struct {
    // The current directory block height of the local factomd node.
    DirectoryBlock uint32 `json:"directoryblockheight"`

    // The current block being worked on by the leaders in the network.
    // This block is not yet complete, but all transactions submitted will
    // go into this block (depending on network conditions, the transaction
    // may be delayed into the next block)
    Leader uint32 `json:"leaderheight"`

    // The height at which the factomd node has all the entry blocks.
    // Directory blocks are obtained first, entry blocks could be lagging
    // behind the directory block when syncing.
    EntryBlock uint32 `json:"entryblockheight"`

    // The height at which the local factomd node has all the entries. If
    // you added entries at a block height above this, they will not be
    // able to be retrieved by the local factomd until it syncs further.
    Entry uint32 `json:"entryheight"`
}

Heights contains all of the distinct heights for a factomd node and the Factom network.

func (*Heights) Get Uses

func (h *Heights) Get(c *Client) error

Get uses c to call the "heights" RPC method and populates h with the result.

type ID1Key Uses

type ID1Key [sha256.Size]byte

ID1Key is the id1 public key for an identity.

func NewID1Key Uses

func NewID1Key(keyStr string) (key ID1Key, err error)

NewID1Key attempts to parse keyStr into a new ID1Key.

func (ID1Key) IDKey Uses

func (key ID1Key) IDKey() IDKey

IDKey returns key as an IDKey.

func (ID1Key) MarshalJSON Uses

func (key ID1Key) MarshalJSON() ([]byte, error)

MarshalJSON encodes key as a JSON string using key.String().

func (ID1Key) Payload Uses

func (key ID1Key) Payload() [sha256.Size]byte

Payload returns key as a byte array.

func (ID1Key) PrefixBytes Uses

func (ID1Key) PrefixBytes() []byte

PrefixBytes returns the two byte prefix for the address type as a byte array. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns []byte{0x3f, 0xbe, 0xba}.

func (ID1Key) PrefixString Uses

func (ID1Key) PrefixString() string

PrefixString returns the two prefix bytes for the address type as an encoded string. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns "id1".

func (ID1Key) RCDHash Uses

func (key ID1Key) RCDHash() [sha256.Size]byte

RCDHash returns the RCD hash encoded in key.

func (*ID1Key) Scan Uses

func (key *ID1Key) Scan(v interface{}) error

Scan implements sql.Scanner for key using Bytes32.Scan. The ID1Key type is not encoded and is assumed.

func (*ID1Key) Set Uses

func (key *ID1Key) Set(keyStr string) error

Set attempts to parse keyStr into key.

func (ID1Key) String Uses

func (key ID1Key) String() string

String encodes key into its human readable form: a base58check string with key.PrefixBytes().

func (ID1Key) Type Uses

func (ID1Key) Type() string

Type returns PrefixString() satisfies the pflag.Value interface.

func (*ID1Key) UnmarshalJSON Uses

func (key *ID1Key) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes a JSON string with a human readable id1 key into key.

func (ID1Key) Value Uses

func (key ID1Key) Value() (driver.Value, error)

Value implements driver.Valuer for key using Bytes32.Value. The ID1Key type is not encoded.

type ID2Key Uses

type ID2Key [sha256.Size]byte

ID2Key is the id2 public key for an identity.

func NewID2Key Uses

func NewID2Key(keyStr string) (key ID2Key, err error)

NewID2Key attempts to parse keyStr into a new ID2Key.

func (ID2Key) IDKey Uses

func (key ID2Key) IDKey() IDKey

IDKey returns key as an IDKey.

func (ID2Key) MarshalJSON Uses

func (key ID2Key) MarshalJSON() ([]byte, error)

MarshalJSON encodes key as a JSON string using key.String().

func (ID2Key) Payload Uses

func (key ID2Key) Payload() [sha256.Size]byte

Payload returns key as a byte array.

func (ID2Key) PrefixBytes Uses

func (ID2Key) PrefixBytes() []byte

PrefixBytes returns the two byte prefix for the address type as a byte array. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns []byte{0x3f, 0xbe, 0xd8}.

func (ID2Key) PrefixString Uses

func (ID2Key) PrefixString() string

PrefixString returns the two prefix bytes for the address type as an encoded string. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns "id2".

func (ID2Key) RCDHash Uses

func (key ID2Key) RCDHash() [sha256.Size]byte

RCDHash returns the RCD hash encoded in key.

func (*ID2Key) Scan Uses

func (key *ID2Key) Scan(v interface{}) error

Scan implements sql.Scanner for key using Bytes32.Scan. The ID2Key type is not encoded and is assumed.

func (*ID2Key) Set Uses

func (key *ID2Key) Set(keyStr string) error

Set attempts to parse keyStr into key.

func (ID2Key) String Uses

func (key ID2Key) String() string

String encodes key into its human readable form: a base58check string with key.PrefixBytes().

func (ID2Key) Type Uses

func (ID2Key) Type() string

Type returns PrefixString() satisfies the pflag.Value interface.

func (*ID2Key) UnmarshalJSON Uses

func (key *ID2Key) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes a JSON string with a human readable id2 key into key.

func (ID2Key) Value Uses

func (key ID2Key) Value() (driver.Value, error)

Value implements driver.Valuer for key using Bytes32.Value. The ID2Key type is not encoded.

type ID3Key Uses

type ID3Key [sha256.Size]byte

ID3Key is the id3 public key for an identity.

func NewID3Key Uses

func NewID3Key(keyStr string) (key ID3Key, err error)

NewID3Key attempts to parse keyStr into a new ID3Key.

func (ID3Key) IDKey Uses

func (key ID3Key) IDKey() IDKey

IDKey returns key as an IDKey.

func (ID3Key) MarshalJSON Uses

func (key ID3Key) MarshalJSON() ([]byte, error)

MarshalJSON encodes key as a JSON string using key.String().

func (ID3Key) Payload Uses

func (key ID3Key) Payload() [sha256.Size]byte

Payload returns key as a byte array.

func (ID3Key) PrefixBytes Uses

func (ID3Key) PrefixBytes() []byte

PrefixBytes returns the two byte prefix for the address type as a byte array. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns []byte{0x3f, 0xbe, 0xf6}.

func (ID3Key) PrefixString Uses

func (ID3Key) PrefixString() string

PrefixString returns the two prefix bytes for the address type as an encoded string. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns "id3".

func (ID3Key) RCDHash Uses

func (key ID3Key) RCDHash() [sha256.Size]byte

RCDHash returns the RCD hash encoded in key.

func (*ID3Key) Scan Uses

func (key *ID3Key) Scan(v interface{}) error

Scan implements sql.Scanner for key using Bytes32.Scan. The ID3Key type is not encoded and is assumed.

func (*ID3Key) Set Uses

func (key *ID3Key) Set(keyStr string) error

Set attempts to parse keyStr into key.

func (ID3Key) String Uses

func (key ID3Key) String() string

String encodes key into its human readable form: a base58check string with key.PrefixBytes().

func (ID3Key) Type Uses

func (ID3Key) Type() string

Type returns PrefixString() satisfies the pflag.Value interface.

func (*ID3Key) UnmarshalJSON Uses

func (key *ID3Key) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes a JSON string with a human readable id3 key into key.

func (ID3Key) Value Uses

func (key ID3Key) Value() (driver.Value, error)

Value implements driver.Valuer for key using Bytes32.Value. The ID3Key type is not encoded.

type ID4Key Uses

type ID4Key [sha256.Size]byte

ID4Key is the id4 public key for an identity.

func NewID4Key Uses

func NewID4Key(keyStr string) (key ID4Key, err error)

NewID4Key attempts to parse keyStr into a new ID4Key.

func (ID4Key) IDKey Uses

func (key ID4Key) IDKey() IDKey

IDKey returns key as an IDKey.

func (ID4Key) MarshalJSON Uses

func (key ID4Key) MarshalJSON() ([]byte, error)

MarshalJSON encodes key as a JSON string using key.String().

func (ID4Key) Payload Uses

func (key ID4Key) Payload() [sha256.Size]byte

Payload returns key as a byte array.

func (ID4Key) PrefixBytes Uses

func (ID4Key) PrefixBytes() []byte

PrefixBytes returns the two byte prefix for the address type as a byte array. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns []byte{0x3f, 0xbf, 0x14}.

func (ID4Key) PrefixString Uses

func (ID4Key) PrefixString() string

PrefixString returns the two prefix bytes for the address type as an encoded string. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns "id4".

func (ID4Key) RCDHash Uses

func (key ID4Key) RCDHash() [sha256.Size]byte

RCDHash returns the RCD hash encoded in key.

func (*ID4Key) Scan Uses

func (key *ID4Key) Scan(v interface{}) error

Scan implements sql.Scanner for key using Bytes32.Scan. The ID4Key type is not encoded and is assumed.

func (*ID4Key) Set Uses

func (key *ID4Key) Set(keyStr string) error

Set attempts to parse keyStr into key.

func (ID4Key) String Uses

func (key ID4Key) String() string

String encodes key into its human readable form: a base58check string with key.PrefixBytes().

func (ID4Key) Type Uses

func (ID4Key) Type() string

Type returns PrefixString() satisfies the pflag.Value interface.

func (*ID4Key) UnmarshalJSON Uses

func (key *ID4Key) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes a JSON string with a human readable id4 key into key.

func (ID4Key) Value Uses

func (key ID4Key) Value() (driver.Value, error)

Value implements driver.Valuer for key using Bytes32.Value. The ID4Key type is not encoded.

type IDKey Uses

type IDKey interface {
    // PrefixBytes returns the prefix bytes for the key.
    PrefixBytes() []byte
    // PrefixString returns the encoded prefix string for the key.
    PrefixString() string

    // String encodes the key to a base58check string with the appropriate
    // prefix.
    String() string
    // Payload returns the key as a byte array.
    Payload() [sha256.Size]byte
    // RCDHash returns the RCDHash as a byte array. For IDxKeys, this is
    // identical to Payload. For SKxKeys the RCDHash is computed.
    RCDHash() [sha256.Size]byte

    // IDKey returns the corresponding IDxKey in an IDKey interface.
    // IDxKeys return themselves.  Private SKxKeys compute the
    // corresponding IDxKey.
    IDKey() IDKey
}

IDKey is the interface implemented by the four ID and SK Key types.

type Identity Uses

type Identity struct {
    ID1    ID1Key
    Height uint32
    Entry
}

Identity represents the Token Issuer's Identity Chain and the public ID1Key.

func NewIdentity Uses

func NewIdentity(chainID *Bytes32) (i Identity)

NewIdentity initializes an Identity with the given chainID.

func (*Identity) Get Uses

func (i *Identity) Get(c *Client) error

Get validates i.ChainID as an Identity Chain and parses out the ID1Key.

func (Identity) IsPopulated Uses

func (i Identity) IsPopulated() bool

IsPopulated returns true if the Identity has been populated with an ID1Key.

func (*Identity) UnmarshalBinary Uses

func (i *Identity) UnmarshalBinary(data []byte) error

type NetworkID Uses

type NetworkID [4]byte

func LocalnetID Uses

func LocalnetID() NetworkID

func MainnetID Uses

func MainnetID() NetworkID

func TestnetID Uses

func TestnetID() NetworkID

func (NetworkID) IsCustom Uses

func (n NetworkID) IsCustom() bool

func (NetworkID) IsLocalnet Uses

func (n NetworkID) IsLocalnet() bool

func (NetworkID) IsMainnet Uses

func (n NetworkID) IsMainnet() bool

func (NetworkID) IsTestnet Uses

func (n NetworkID) IsTestnet() bool

func (*NetworkID) Set Uses

func (n *NetworkID) Set(netIDStr string) error

func (NetworkID) String Uses

func (n NetworkID) String() string

type PendingEntries Uses

type PendingEntries []Entry

PendingEntries is a list of pending entries which may or may not be revealed. If the entry's ChainID is not nil, then its data has been revealed and can be queried from factomd.

func (PendingEntries) Entries Uses

func (pe PendingEntries) Entries(chainID *Bytes32) []Entry

Entries efficiently finds and returns all entries in pe for the given chainID, if any exist. Otherwise, Entries returns nil.

func (*PendingEntries) Get Uses

func (pe *PendingEntries) Get(c *Client) error

Get returns all pending entries sorted by descending ChainID, and then order they were originally returned. Pending Entries that are committed but not revealed have a nil ChainID and are at the end of the pe slice.

type PrivateAddress Uses

type PrivateAddress interface {
    Address

    // PrivateKey returns the ed25519.PrivateKey which can be used for
    // signing data.
    PrivateKey() ed25519.PrivateKey
    // PublicKey returns the ed25519.PublicKey which can be used for
    // verifying signatures.
    PublicKey() ed25519.PublicKey
}

PrivateAddress is the interface implemented by the two private address types: FsAddress, and EsAddress.

func NewPrivateAddress Uses

func NewPrivateAddress(adrStr string) (PrivateAddress, error)

NewPrivateAddress parses adrStr and returns the correct address type as a PrivateAddress interface. If adrStr is not a private address then an "invalid prefix" error is returned. This is useful when the address type isn't known prior to parsing adrStr, but must be a private address. If the address type is known ahead of time, it is generally better to just use the appropriate concrete type.

type RCDPrivateKey Uses

type RCDPrivateKey interface {
    // RCD returns the RCD corresponding to the private key.
    RCD() []byte

    // PrivateKey returns the ed25519.PrivateKey which can be used for
    // signing data.
    PrivateKey() ed25519.PrivateKey
    // PublicKey returns the ed25519.PublicKey which can be used for
    // verifying signatures.
    PublicKey() ed25519.PublicKey
}

RCDPrivateKey is the interface implemented by the four SK Key types and the Fs Address type.

type SK1Key Uses

type SK1Key [sha256.Size]byte

SK1Key is the sk1 secret key for an identity.

func GenerateSK1Key Uses

func GenerateSK1Key() (SK1Key, error)

GenerateSK1Key generates a secure random private Entry Credit address using crypto/rand.Random as the source of randomness.

func NewSK1Key Uses

func NewSK1Key(keyStr string) (key SK1Key, err error)

NewSK1Key attempts to parse keyStr into a new SK1Key.

func (SK1Key) ID1Key Uses

func (key SK1Key) ID1Key() ID1Key

ID1Key computes the ID1Key corresponding to key.

func (SK1Key) IDKey Uses

func (key SK1Key) IDKey() IDKey

IDKey returns the ID1Key corresponding to key as an IDKey.

func (SK1Key) MarshalJSON Uses

func (key SK1Key) MarshalJSON() ([]byte, error)

MarshalJSON encodes key as a JSON string using key.String().

func (SK1Key) Payload Uses

func (key SK1Key) Payload() [sha256.Size]byte

Payload returns key as a byte array.

func (SK1Key) PrefixBytes Uses

func (SK1Key) PrefixBytes() []byte

PrefixBytes returns the two byte prefix for the address type as a byte array. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns []byte{0x4d, 0xb6, 0xc9}.

func (SK1Key) PrefixString Uses

func (SK1Key) PrefixString() string

PrefixString returns the two prefix bytes for the address type as an encoded string. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns "sk1".

func (SK1Key) PrivateKey Uses

func (key SK1Key) PrivateKey() ed25519.PrivateKey

PrivateKey returns the ed25519.PrivateKey for key.

func (SK1Key) PublicKey Uses

func (key SK1Key) PublicKey() ed25519.PublicKey

PublicKey computes the ed25519.PublicKey for key.

func (SK1Key) RCD Uses

func (key SK1Key) RCD() []byte

RCD computes the RCD for key.

func (SK1Key) RCDHash Uses

func (key SK1Key) RCDHash() [sha256.Size]byte

RCDHash computes the RCD hash corresponding to key.

func (SK1Key) SKKey Uses

func (key SK1Key) SKKey() SKKey

SKKey returns key as an SKKey.

func (*SK1Key) Set Uses

func (key *SK1Key) Set(keyStr string) error

Set attempts to parse keyStr into key.

func (SK1Key) String Uses

func (key SK1Key) String() string

String encodes key into its human readable form: a base58check string with key.PrefixBytes().

func (SK1Key) Type Uses

func (SK1Key) Type() string

Type returns PrefixString() satisfies the pflag.Value interface.

func (*SK1Key) UnmarshalJSON Uses

func (key *SK1Key) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes a JSON string with a human readable sk1 key into key.

type SK2Key Uses

type SK2Key [sha256.Size]byte

SK2Key is the sk2 secret key for an identity.

func GenerateSK2Key Uses

func GenerateSK2Key() (SK2Key, error)

GenerateSK2Key generates a secure random private Entry Credit address using crypto/rand.Random as the source of randomness.

func NewSK2Key Uses

func NewSK2Key(keyStr string) (key SK2Key, err error)

NewSK2Key attempts to parse keyStr into a new SK2Key.

func (SK2Key) ID2Key Uses

func (key SK2Key) ID2Key() ID2Key

ID2Key computes the ID2Key corresponding to key.

func (SK2Key) IDKey Uses

func (key SK2Key) IDKey() IDKey

IDKey returns the ID2Key corresponding to key as an IDKey.

func (SK2Key) MarshalJSON Uses

func (key SK2Key) MarshalJSON() ([]byte, error)

MarshalJSON encodes key as a JSON string using key.String().

func (SK2Key) Payload Uses

func (key SK2Key) Payload() [sha256.Size]byte

Payload returns key as a byte array.

func (SK2Key) PrefixBytes Uses

func (SK2Key) PrefixBytes() []byte

PrefixBytes returns the two byte prefix for the address type as a byte array. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns []byte{0x4d, 0xb6, 0xe7}.

func (SK2Key) PrefixString Uses

func (SK2Key) PrefixString() string

PrefixString returns the two prefix bytes for the address type as an encoded string. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns "sk2".

func (SK2Key) PrivateKey Uses

func (key SK2Key) PrivateKey() ed25519.PrivateKey

PrivateKey returns the ed25519.PrivateKey for key.

func (SK2Key) PublicKey Uses

func (key SK2Key) PublicKey() ed25519.PublicKey

PublicKey computes the ed25519.PublicKey for key.

func (SK2Key) RCD Uses

func (key SK2Key) RCD() []byte

RCD computes the RCD for key.

func (SK2Key) RCDHash Uses

func (key SK2Key) RCDHash() [sha256.Size]byte

RCDHash computes the RCD hash corresponding to key.

func (SK2Key) SKKey Uses

func (key SK2Key) SKKey() SKKey

SKKey returns key as an SKKey.

func (*SK2Key) Set Uses

func (key *SK2Key) Set(keyStr string) error

Set attempts to parse keyStr into key.

func (SK2Key) String Uses

func (key SK2Key) String() string

String encodes key into its human readable form: a base58check string with key.PrefixBytes().

func (SK2Key) Type Uses

func (SK2Key) Type() string

Type returns PrefixString() satisfies the pflag.Value interface.

func (*SK2Key) UnmarshalJSON Uses

func (key *SK2Key) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes a JSON string with a human readable sk2 key into key.

type SK3Key Uses

type SK3Key [sha256.Size]byte

SK3Key is the sk3 secret key for an identity.

func GenerateSK3Key Uses

func GenerateSK3Key() (SK3Key, error)

GenerateSK3Key generates a secure random private Entry Credit address using crypto/rand.Random as the source of randomness.

func NewSK3Key Uses

func NewSK3Key(keyStr string) (key SK3Key, err error)

NewSK3Key attempts to parse keyStr into a new SK3Key.

func (SK3Key) ID3Key Uses

func (key SK3Key) ID3Key() ID3Key

ID3Key computes the ID3Key corresponding to key.

func (SK3Key) IDKey Uses

func (key SK3Key) IDKey() IDKey

IDKey returns the ID3Key corresponding to key as an IDKey.

func (SK3Key) MarshalJSON Uses

func (key SK3Key) MarshalJSON() ([]byte, error)

MarshalJSON encodes key as a JSON string using key.String().

func (SK3Key) Payload Uses

func (key SK3Key) Payload() [sha256.Size]byte

Payload returns key as a byte array.

func (SK3Key) PrefixBytes Uses

func (SK3Key) PrefixBytes() []byte

PrefixBytes returns the two byte prefix for the address type as a byte array. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns []byte{0x4d, 0xb7, 0x05}.

func (SK3Key) PrefixString Uses

func (SK3Key) PrefixString() string

PrefixString returns the two prefix bytes for the address type as an encoded string. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns "sk3".

func (SK3Key) PrivateKey Uses

func (key SK3Key) PrivateKey() ed25519.PrivateKey

PrivateKey returns the ed25519.PrivateKey for key.

func (SK3Key) PublicKey Uses

func (key SK3Key) PublicKey() ed25519.PublicKey

PublicKey computes the ed25519.PublicKey for key.

func (SK3Key) RCD Uses

func (key SK3Key) RCD() []byte

RCD computes the RCD for key.

func (SK3Key) RCDHash Uses

func (key SK3Key) RCDHash() [sha256.Size]byte

RCDHash computes the RCD hash corresponding to key.

func (SK3Key) SKKey Uses

func (key SK3Key) SKKey() SKKey

SKKey returns key as an SKKey.

func (*SK3Key) Set Uses

func (key *SK3Key) Set(keyStr string) error

Set attempts to parse keyStr into key.

func (SK3Key) String Uses

func (key SK3Key) String() string

String encodes key into its human readable form: a base58check string with key.PrefixBytes().

func (SK3Key) Type Uses

func (SK3Key) Type() string

Type returns PrefixString() satisfies the pflag.Value interface.

func (*SK3Key) UnmarshalJSON Uses

func (key *SK3Key) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes a JSON string with a human readable sk3 key into key.

type SK4Key Uses

type SK4Key [sha256.Size]byte

SK4Key is the sk4 secret key for an identity.

func GenerateSK4Key Uses

func GenerateSK4Key() (SK4Key, error)

GenerateSK4Key generates a secure random private Entry Credit address using crypto/rand.Random as the source of randomness.

func NewSK4Key Uses

func NewSK4Key(keyStr string) (key SK4Key, err error)

NewSK4Key attempts to parse keyStr into a new SK4Key.

func (SK4Key) ID4Key Uses

func (key SK4Key) ID4Key() ID4Key

ID4Key computes the ID4Key corresponding to key.

func (SK4Key) IDKey Uses

func (key SK4Key) IDKey() IDKey

IDKey returns the ID4Key corresponding to key as an IDKey.

func (SK4Key) MarshalJSON Uses

func (key SK4Key) MarshalJSON() ([]byte, error)

MarshalJSON encodes key as a JSON string using key.String().

func (SK4Key) Payload Uses

func (key SK4Key) Payload() [sha256.Size]byte

Payload returns key as a byte array.

func (SK4Key) PrefixBytes Uses

func (SK4Key) PrefixBytes() []byte

PrefixBytes returns the two byte prefix for the address type as a byte array. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns []byte{0x4d, 0xb7, 0x23}.

func (SK4Key) PrefixString Uses

func (SK4Key) PrefixString() string

PrefixString returns the two prefix bytes for the address type as an encoded string. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns "sk4".

func (SK4Key) PrivateKey Uses

func (key SK4Key) PrivateKey() ed25519.PrivateKey

PrivateKey returns the ed25519.PrivateKey for key.

func (SK4Key) PublicKey Uses

func (key SK4Key) PublicKey() ed25519.PublicKey

PublicKey computes the ed25519.PublicKey for key.

func (SK4Key) RCD Uses

func (key SK4Key) RCD() []byte

RCD computes the RCD for key.

func (SK4Key) RCDHash Uses

func (key SK4Key) RCDHash() [sha256.Size]byte

RCDHash computes the RCD hash corresponding to key.

func (SK4Key) SKKey Uses

func (key SK4Key) SKKey() SKKey

SKKey returns key as an SKKey.

func (*SK4Key) Set Uses

func (key *SK4Key) Set(keyStr string) error

Set attempts to parse keyStr into key.

func (SK4Key) String Uses

func (key SK4Key) String() string

String encodes key into its human readable form: a base58check string with key.PrefixBytes().

func (SK4Key) Type Uses

func (SK4Key) Type() string

Type returns PrefixString() satisfies the pflag.Value interface.

func (*SK4Key) UnmarshalJSON Uses

func (key *SK4Key) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes a JSON string with a human readable sk4 key into key.

type SKKey Uses

type SKKey interface {
    IDKey

    // SKKey returns the SKKey interface. IDxKeys return themselves.
    // Private SKxKeys compute the corresponding IDxKey.
    SKKey() SKKey

    // RCD returns the RCD corresponding to the private key.
    RCD() []byte

    // PrivateKey returns the ed25519.PrivateKey which can be used for
    // signing data.
    PrivateKey() ed25519.PrivateKey
    // PublicKey returns the ed25519.PublicKey which can be used for
    // verifying signatures.
    PublicKey() ed25519.PublicKey
}

SKKey is the interface implemented by the four SK Key types.

Directories

PathSynopsis
varintfPackage varintf implements Factom's varInt_F specification.

Package factom imports 19 packages (graph) and is imported by 1 packages. Updated 2019-09-16. Refresh now. Tools for package owners.