factom

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

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

Constants

View Source
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
)
View Source
const (
	FactomdDefault = "http://localhost:8088"
	WalletdDefault = "http://localhost:8089"
)

Defaults for the factomd and factom-walletd endpoints.

View Source
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
)
View Source
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
)
View Source
const (
	EntryHeaderLen = 1 +
		32 +
		2 // total len

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

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

Variables

This section is empty.

Functions

func EntryCost added in v0.4.0

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 added in v0.4.0

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 added in v0.4.0

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

Types

type Address

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

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 added in v0.4.0

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

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 (Bytes) MarshalJSON

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

MarshalJSON encodes b as a hex JSON string.

func (*Bytes) Set

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

Set decodes a string with hex encoded data.

func (Bytes) String

func (b Bytes) String() string

String encodes b as a hex string.

func (Bytes) Type added in v0.5.0

func (b Bytes) Type() string

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

func (*Bytes) UnmarshalJSON

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

UnmarshalJSON decodes a JSON string with hex encoded data.

type Bytes32

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

func ChainID(nameIDs []Bytes) Bytes32

ChainID returns the chain ID for a set of NameIDs.

func EntryHash

func EntryHash(data []byte) Bytes32

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

func NewBytes32

func NewBytes32(s32 []byte) *Bytes32

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

func NewBytes32FromString added in v0.6.0

func NewBytes32FromString(s32 string) *Bytes32

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

func ZeroBytes32

func ZeroBytes32() Bytes32

ZeroBytes32 returns an all zero Byte32.

func (Bytes32) MarshalJSON

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

MarshalJSON encodes b as a hex JSON string.

func (*Bytes32) Scan

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

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

func (*Bytes32) Set added in v0.4.0

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

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

func (Bytes32) String

func (b Bytes32) String() string

String encodes b as a hex string.

func (Bytes32) Type added in v0.5.0

func (b Bytes32) Type() string

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

func (*Bytes32) UnmarshalJSON

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

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

func (Bytes32) Value

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

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

type Client added in v0.4.0

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 added in v0.4.0

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 added in v0.4.0

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

Commit sends an entry or new chain commit to factomd.

func (*Client) FactomdRequest added in v0.4.0

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

FactomdRequest makes a request to factomd's v2 API.

func (*Client) GetAddress added in v0.4.0

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 added in v0.4.0

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

GetAddresses queries factom-walletd for all public addresses.

func (*Client) GetECAddresses added in v0.4.0

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

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

func (*Client) GetEsAddresses added in v0.4.0

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

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

func (*Client) GetFAAddresses added in v0.4.0

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

GetFAAddresses queries factom-walletd for all public Factoid addresses.

func (*Client) GetFsAddresses added in v0.4.0

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

GetFsAddresses queries factom-walletd for all secret Factoid addresses.

func (*Client) GetPrivateAddresses added in v0.4.0

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

GetPrivateAddresses queries factom-walletd for all private addresses.

func (*Client) RemoveAddress added in v0.4.0

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

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

func (*Client) Reveal added in v0.4.0

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

Reveal reveals an entry or new chain entry to factomd.

func (*Client) SavePrivateAddresses added in v0.4.0

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

SavePrivateAddresses saves many adrs with factom-walletd.

func (*Client) WalletdRequest added in v0.4.0

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

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

type DBlock

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 added in v0.6.0

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

func (DBlock) ComputeFullHash added in v0.6.0

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

func (DBlock) ComputeHeaderHash added in v0.6.0

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

func (DBlock) ComputeKeyMR added in v0.6.0

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

func (DBlock) EBlock added in v0.6.0

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

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

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 added in v0.6.0

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

func (*DBlock) MarshalBinaryHeader added in v0.6.0

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

func (*DBlock) MarshalBinaryLen added in v0.6.0

func (db *DBlock) MarshalBinaryLen() int

func (*DBlock) UnmarshalBinary added in v0.6.0

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 added in v0.6.0

type DBlockHeader struct {
	NetworkID [4]byte `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 added in v0.6.0

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

func (*DBlockHeader) UnmarshalJSON added in v0.6.0

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

type EBlock

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 added in v0.6.0

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

func (EBlock) ComputeFullHash added in v0.6.0

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

func (EBlock) ComputeHeaderHash added in v0.6.0

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

func (EBlock) ComputeKeyMR added in v0.6.0

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

func (*EBlock) CountObjects added in v0.6.0

func (eb *EBlock) CountObjects() uint32

func (*EBlock) Get

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) GetAllPrev

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

GetAllPrev returns a slice of all preceding EBlocks in eb's chain, in order from earliest to latest, up to and including eb. So the last element of the returned slice is always equal to eb. If eb is the first entry block in its chain, then it is the only element in the slice.

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 to reduce network calls and memory usage.

func (*EBlock) GetChainHead

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

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

func (*EBlock) GetFirst

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 GetAllPrev 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) IsFirst

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

func (eb EBlock) IsPopulated() bool

func (*EBlock) MarshalBinary added in v0.6.0

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

func (*EBlock) MarshalBinaryHeader added in v0.6.0

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

func (*EBlock) MarshalBinaryLen added in v0.6.0

func (eb *EBlock) MarshalBinaryLen() int

func (*EBlock) Objects added in v0.6.0

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

func (EBlock) Prev

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) UnmarshalBinary added in v0.6.0

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 added in v0.4.0

type ECAddress [sha256.Size]byte

ECAddress is a Public Entry Credit Address.

func NewECAddress added in v0.4.0

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

NewECAddress attempts to parse adrStr into a new ECAddress.

func (ECAddress) GetBalance added in v0.4.0

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

GetBalance queries factomd for the Entry Credit Balance for adr.

func (ECAddress) GetEsAddress added in v0.4.0

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

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

func (ECAddress) GetPrivateAddress added in v0.4.0

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 added in v0.4.0

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

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

func (ECAddress) Payload added in v0.4.0

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

Payload returns adr as a byte array.

func (ECAddress) PrefixBytes added in v0.4.0

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 added in v0.4.0

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 added in v0.4.0

func (adr ECAddress) PublicAddress() Address

PublicAddress returns adr as an Address.

func (ECAddress) PublicKey added in v0.4.0

func (adr ECAddress) PublicKey() ed25519.PublicKey

PublicKey returns the ed25519.PublicKey for adr.

func (ECAddress) Remove added in v0.4.0

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

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

func (*ECAddress) Set added in v0.4.0

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

Set attempts to parse adrStr into adr.

func (ECAddress) String added in v0.4.0

func (adr ECAddress) String() string

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

func (*ECAddress) UnmarshalJSON added in v0.4.0

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

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

type Entry

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"`
	Height    uint32

	// 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 added in v0.4.0

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 added in v0.4.0

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

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 added in v0.4.0

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

func (*Entry) Create

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

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

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

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 added in v0.4.0

func (e Entry) MarshalBinaryLen() int

func (*Entry) UnmarshalBinary

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 added in v0.4.0

type EsAddress [sha256.Size]byte

EsAddress is the secret key to a ECAddress.

func GenerateEsAddress added in v0.4.0

func GenerateEsAddress() (EsAddress, error)

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

func NewEsAddress added in v0.4.0

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

NewEsAddress attempts to parse adrStr into a new EsAddress.

func (EsAddress) ECAddress added in v0.4.0

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

ECAddress returns the ECAddress corresponding to adr.

func (EsAddress) GetBalance added in v0.4.0

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

GetBalance queries factomd for the Entry Credit Balance for adr.

func (EsAddress) GetPrivateAddress added in v0.4.0

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

GetPrivateAddress returns adr as a PrivateAddress.

func (EsAddress) MarshalJSON added in v0.4.0

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

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

func (EsAddress) Payload added in v0.4.0

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

Payload returns adr as a byte array.

func (EsAddress) PrefixBytes added in v0.4.0

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 added in v0.4.0

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 added in v0.4.0

func (adr EsAddress) PrivateKey() ed25519.PrivateKey

PrivateKey returns the ed25519.PrivateKey for adr.

func (EsAddress) PublicAddress added in v0.4.0

func (adr EsAddress) PublicAddress() Address

PublicAddress returns the ECAddress corresponding to adr as an Address.

func (EsAddress) PublicKey added in v0.4.0

func (adr EsAddress) PublicKey() ed25519.PublicKey

PublicKey computes the ed25519.PublicKey for adr.

func (EsAddress) Remove added in v0.4.0

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

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

func (EsAddress) Save added in v0.4.0

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

Save adr with factom-walletd.

func (*EsAddress) Set added in v0.4.0

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

Set attempts to parse adrStr into adr.

func (EsAddress) String added in v0.4.0

func (adr EsAddress) String() string

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

func (*EsAddress) UnmarshalJSON added in v0.4.0

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

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

type FAAddress added in v0.4.0

type FAAddress [sha256.Size]byte

FAAddress is a Public Factoid Address.

func NewFAAddress added in v0.4.0

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

NewFAAddress attempts to parse adrStr into a new FAAddress.

func (FAAddress) GetBalance added in v0.4.0

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

GetBalance queries factomd for the Factoid Balance for adr.

func (FAAddress) GetFsAddress added in v0.4.0

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

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

func (FAAddress) GetPrivateAddress added in v0.4.0

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 added in v0.4.0

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

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

func (FAAddress) Payload added in v0.4.0

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

Payload returns adr as a byte array.

func (FAAddress) PrefixBytes added in v0.4.0

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 added in v0.4.0

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 added in v0.4.0

func (adr FAAddress) PublicAddress() Address

PublicAddress returns adr as an Address.

func (FAAddress) RCDHash added in v0.4.0

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

RCDHash returns the RCD hash encoded in adr.

func (FAAddress) Remove added in v0.4.0

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

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

func (*FAAddress) Scan added in v0.4.0

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 added in v0.4.0

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

Set attempts to parse adrStr into adr.

func (FAAddress) String added in v0.4.0

func (adr FAAddress) String() string

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

func (*FAAddress) UnmarshalJSON added in v0.4.0

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

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

func (FAAddress) Value added in v0.4.0

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

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

type FsAddress added in v0.4.0

type FsAddress [sha256.Size]byte

FsAddress is the secret key to a FAAddress.

func GenerateFsAddress added in v0.4.0

func GenerateFsAddress() (FsAddress, error)

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

func NewFsAddress added in v0.4.0

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

NewFsAddress attempts to parse adrStr into a new FsAddress.

func (FsAddress) FAAddress added in v0.4.0

func (adr FsAddress) FAAddress() FAAddress

FAAddress returns the FAAddress corresponding to adr.

func (FsAddress) GetBalance added in v0.4.0

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

GetBalance queries factomd for the Factoid Balance for adr.

func (FsAddress) GetPrivateAddress added in v0.4.0

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

GetPrivateAddress returns adr as a PrivateAddress.

func (FsAddress) MarshalJSON added in v0.4.0

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

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

func (FsAddress) Payload added in v0.4.0

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

Payload returns adr as a byte array.

func (FsAddress) PrefixBytes added in v0.4.0

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 added in v0.4.0

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 added in v0.4.0

func (adr FsAddress) PrivateKey() ed25519.PrivateKey

PrivateKey returns the ed25519.PrivateKey for adr.

func (FsAddress) PublicAddress added in v0.4.0

func (adr FsAddress) PublicAddress() Address

PublicAddress returns the FAAddress corresponding to adr as an Address.

func (FsAddress) PublicKey added in v0.4.0

func (adr FsAddress) PublicKey() ed25519.PublicKey

PublicKey computes the ed25519.PublicKey for adr.

func (FsAddress) RCD added in v0.4.0

func (adr FsAddress) RCD() []byte

RCD computes the RCD for adr.

func (FsAddress) RCDHash added in v0.4.0

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

RCDHash computes the RCD hash corresponding to adr.

func (FsAddress) Remove added in v0.4.0

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

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

func (FsAddress) Save added in v0.4.0

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

Save adr with factom-walletd.

func (*FsAddress) Set added in v0.4.0

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

Set attempts to parse adrStr into adr.

func (FsAddress) String added in v0.4.0

func (adr FsAddress) String() string

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

func (*FsAddress) UnmarshalJSON added in v0.4.0

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

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

type Heights added in v0.4.0

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 added in v0.4.0

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

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

type ID1Key added in v0.4.0

type ID1Key [sha256.Size]byte

ID1Key is the id1 public key for an identity.

func NewID1Key added in v0.4.0

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

NewID1Key attempts to parse keyStr into a new ID1Key.

func (ID1Key) IDKey added in v0.4.0

func (key ID1Key) IDKey() IDKey

IDKey returns key as an IDKey.

func (ID1Key) MarshalJSON added in v0.4.0

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

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

func (ID1Key) Payload added in v0.4.0

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

Payload returns key as a byte array.

func (ID1Key) PrefixBytes added in v0.4.0

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 added in v0.4.0

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 added in v0.4.0

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

RCDHash returns the RCD hash encoded in key.

func (*ID1Key) Scan added in v0.4.0

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 added in v0.4.0

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

Set attempts to parse keyStr into key.

func (ID1Key) String added in v0.4.0

func (key ID1Key) String() string

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

func (ID1Key) Type added in v0.5.0

func (ID1Key) Type() string

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

func (*ID1Key) UnmarshalJSON added in v0.4.0

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

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

func (ID1Key) Value added in v0.4.0

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

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

type ID2Key added in v0.4.0

type ID2Key [sha256.Size]byte

ID2Key is the id2 public key for an identity.

func NewID2Key added in v0.4.0

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

NewID2Key attempts to parse keyStr into a new ID2Key.

func (ID2Key) IDKey added in v0.4.0

func (key ID2Key) IDKey() IDKey

IDKey returns key as an IDKey.

func (ID2Key) MarshalJSON added in v0.4.0

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

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

func (ID2Key) Payload added in v0.4.0

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

Payload returns key as a byte array.

func (ID2Key) PrefixBytes added in v0.4.0

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 added in v0.4.0

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 added in v0.4.0

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

RCDHash returns the RCD hash encoded in key.

func (*ID2Key) Scan added in v0.4.0

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 added in v0.4.0

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

Set attempts to parse keyStr into key.

func (ID2Key) String added in v0.4.0

func (key ID2Key) String() string

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

func (ID2Key) Type added in v0.5.0

func (ID2Key) Type() string

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

func (*ID2Key) UnmarshalJSON added in v0.4.0

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

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

func (ID2Key) Value added in v0.4.0

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

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

type ID3Key added in v0.4.0

type ID3Key [sha256.Size]byte

ID3Key is the id3 public key for an identity.

func NewID3Key added in v0.4.0

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

NewID3Key attempts to parse keyStr into a new ID3Key.

func (ID3Key) IDKey added in v0.4.0

func (key ID3Key) IDKey() IDKey

IDKey returns key as an IDKey.

func (ID3Key) MarshalJSON added in v0.4.0

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

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

func (ID3Key) Payload added in v0.4.0

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

Payload returns key as a byte array.

func (ID3Key) PrefixBytes added in v0.4.0

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 added in v0.4.0

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 added in v0.4.0

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

RCDHash returns the RCD hash encoded in key.

func (*ID3Key) Scan added in v0.4.0

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 added in v0.4.0

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

Set attempts to parse keyStr into key.

func (ID3Key) String added in v0.4.0

func (key ID3Key) String() string

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

func (ID3Key) Type added in v0.5.0

func (ID3Key) Type() string

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

func (*ID3Key) UnmarshalJSON added in v0.4.0

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

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

func (ID3Key) Value added in v0.4.0

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

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

type ID4Key added in v0.4.0

type ID4Key [sha256.Size]byte

ID4Key is the id4 public key for an identity.

func NewID4Key added in v0.4.0

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

NewID4Key attempts to parse keyStr into a new ID4Key.

func (ID4Key) IDKey added in v0.4.0

func (key ID4Key) IDKey() IDKey

IDKey returns key as an IDKey.

func (ID4Key) MarshalJSON added in v0.4.0

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

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

func (ID4Key) Payload added in v0.4.0

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

Payload returns key as a byte array.

func (ID4Key) PrefixBytes added in v0.4.0

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 added in v0.4.0

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 added in v0.4.0

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

RCDHash returns the RCD hash encoded in key.

func (*ID4Key) Scan added in v0.4.0

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 added in v0.4.0

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

Set attempts to parse keyStr into key.

func (ID4Key) String added in v0.4.0

func (key ID4Key) String() string

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

func (ID4Key) Type added in v0.5.0

func (ID4Key) Type() string

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

func (*ID4Key) UnmarshalJSON added in v0.4.0

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

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

func (ID4Key) Value added in v0.4.0

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

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

type IDKey added in v0.4.0

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 added in v0.4.0

type Identity struct {
	ID1 ID1Key
	Entry
}

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

func NewIdentity added in v0.4.0

func NewIdentity(chainID *Bytes32) (i Identity)

NewIdentity initializes an Identity with the given chainID.

func (*Identity) Get added in v0.4.0

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

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

func (Identity) IsPopulated added in v0.4.0

func (i Identity) IsPopulated() bool

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

type PendingEntries added in v0.6.0

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 added in v0.6.0

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 added in v0.6.0

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

Get returns all pending entries sorted by ChainID, and then order they were originally returned.

type PrivateAddress added in v0.4.0

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 added in v0.4.0

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 added in v0.4.0

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 added in v0.4.0

type SK1Key [sha256.Size]byte

SK1Key is the sk1 secret key for an identity.

func GenerateSK1Key added in v0.4.0

func GenerateSK1Key() (SK1Key, error)

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

func NewSK1Key added in v0.4.0

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

NewSK1Key attempts to parse keyStr into a new SK1Key.

func (SK1Key) ID1Key added in v0.4.0

func (key SK1Key) ID1Key() ID1Key

ID1Key computes the ID1Key corresponding to key.

func (SK1Key) IDKey added in v0.4.0

func (key SK1Key) IDKey() IDKey

IDKey returns the ID1Key corresponding to key as an IDKey.

func (SK1Key) MarshalJSON added in v0.4.0

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

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

func (SK1Key) Payload added in v0.4.0

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

Payload returns key as a byte array.

func (SK1Key) PrefixBytes added in v0.4.0

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 added in v0.4.0

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 added in v0.4.0

func (key SK1Key) PrivateKey() ed25519.PrivateKey

PrivateKey returns the ed25519.PrivateKey for key.

func (SK1Key) PublicKey added in v0.4.0

func (key SK1Key) PublicKey() ed25519.PublicKey

PublicKey computes the ed25519.PublicKey for key.

func (SK1Key) RCD added in v0.4.0

func (key SK1Key) RCD() []byte

RCD computes the RCD for key.

func (SK1Key) RCDHash added in v0.4.0

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

RCDHash computes the RCD hash corresponding to key.

func (SK1Key) SKKey added in v0.4.0

func (key SK1Key) SKKey() SKKey

SKKey returns key as an SKKey.

func (*SK1Key) Set added in v0.4.0

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

Set attempts to parse keyStr into key.

func (SK1Key) String added in v0.4.0

func (key SK1Key) String() string

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

func (SK1Key) Type added in v0.5.0

func (SK1Key) Type() string

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

func (*SK1Key) UnmarshalJSON added in v0.4.0

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

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

type SK2Key added in v0.4.0

type SK2Key [sha256.Size]byte

SK2Key is the sk2 secret key for an identity.

func GenerateSK2Key added in v0.4.0

func GenerateSK2Key() (SK2Key, error)

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

func NewSK2Key added in v0.4.0

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

NewSK2Key attempts to parse keyStr into a new SK2Key.

func (SK2Key) ID2Key added in v0.4.0

func (key SK2Key) ID2Key() ID2Key

ID2Key computes the ID2Key corresponding to key.

func (SK2Key) IDKey added in v0.4.0

func (key SK2Key) IDKey() IDKey

IDKey returns the ID2Key corresponding to key as an IDKey.

func (SK2Key) MarshalJSON added in v0.4.0

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

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

func (SK2Key) Payload added in v0.4.0

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

Payload returns key as a byte array.

func (SK2Key) PrefixBytes added in v0.4.0

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 added in v0.4.0

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 added in v0.4.0

func (key SK2Key) PrivateKey() ed25519.PrivateKey

PrivateKey returns the ed25519.PrivateKey for key.

func (SK2Key) PublicKey added in v0.4.0

func (key SK2Key) PublicKey() ed25519.PublicKey

PublicKey computes the ed25519.PublicKey for key.

func (SK2Key) RCD added in v0.4.0

func (key SK2Key) RCD() []byte

RCD computes the RCD for key.

func (SK2Key) RCDHash added in v0.4.0

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

RCDHash computes the RCD hash corresponding to key.

func (SK2Key) SKKey added in v0.4.0

func (key SK2Key) SKKey() SKKey

SKKey returns key as an SKKey.

func (*SK2Key) Set added in v0.4.0

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

Set attempts to parse keyStr into key.

func (SK2Key) String added in v0.4.0

func (key SK2Key) String() string

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

func (SK2Key) Type added in v0.5.0

func (SK2Key) Type() string

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

func (*SK2Key) UnmarshalJSON added in v0.4.0

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

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

type SK3Key added in v0.4.0

type SK3Key [sha256.Size]byte

SK3Key is the sk3 secret key for an identity.

func GenerateSK3Key added in v0.4.0

func GenerateSK3Key() (SK3Key, error)

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

func NewSK3Key added in v0.4.0

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

NewSK3Key attempts to parse keyStr into a new SK3Key.

func (SK3Key) ID3Key added in v0.4.0

func (key SK3Key) ID3Key() ID3Key

ID3Key computes the ID3Key corresponding to key.

func (SK3Key) IDKey added in v0.4.0

func (key SK3Key) IDKey() IDKey

IDKey returns the ID3Key corresponding to key as an IDKey.

func (SK3Key) MarshalJSON added in v0.4.0

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

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

func (SK3Key) Payload added in v0.4.0

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

Payload returns key as a byte array.

func (SK3Key) PrefixBytes added in v0.4.0

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 added in v0.4.0

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 added in v0.4.0

func (key SK3Key) PrivateKey() ed25519.PrivateKey

PrivateKey returns the ed25519.PrivateKey for key.

func (SK3Key) PublicKey added in v0.4.0

func (key SK3Key) PublicKey() ed25519.PublicKey

PublicKey computes the ed25519.PublicKey for key.

func (SK3Key) RCD added in v0.4.0

func (key SK3Key) RCD() []byte

RCD computes the RCD for key.

func (SK3Key) RCDHash added in v0.4.0

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

RCDHash computes the RCD hash corresponding to key.

func (SK3Key) SKKey added in v0.4.0

func (key SK3Key) SKKey() SKKey

SKKey returns key as an SKKey.

func (*SK3Key) Set added in v0.4.0

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

Set attempts to parse keyStr into key.

func (SK3Key) String added in v0.4.0

func (key SK3Key) String() string

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

func (SK3Key) Type added in v0.5.0

func (SK3Key) Type() string

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

func (*SK3Key) UnmarshalJSON added in v0.4.0

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

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

type SK4Key added in v0.4.0

type SK4Key [sha256.Size]byte

SK4Key is the sk4 secret key for an identity.

func GenerateSK4Key added in v0.4.0

func GenerateSK4Key() (SK4Key, error)

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

func NewSK4Key added in v0.4.0

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

NewSK4Key attempts to parse keyStr into a new SK4Key.

func (SK4Key) ID4Key added in v0.4.0

func (key SK4Key) ID4Key() ID4Key

ID4Key computes the ID4Key corresponding to key.

func (SK4Key) IDKey added in v0.4.0

func (key SK4Key) IDKey() IDKey

IDKey returns the ID4Key corresponding to key as an IDKey.

func (SK4Key) MarshalJSON added in v0.4.0

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

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

func (SK4Key) Payload added in v0.4.0

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

Payload returns key as a byte array.

func (SK4Key) PrefixBytes added in v0.4.0

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 added in v0.4.0

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 added in v0.4.0

func (key SK4Key) PrivateKey() ed25519.PrivateKey

PrivateKey returns the ed25519.PrivateKey for key.

func (SK4Key) PublicKey added in v0.4.0

func (key SK4Key) PublicKey() ed25519.PublicKey

PublicKey computes the ed25519.PublicKey for key.

func (SK4Key) RCD added in v0.4.0

func (key SK4Key) RCD() []byte

RCD computes the RCD for key.

func (SK4Key) RCDHash added in v0.4.0

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

RCDHash computes the RCD hash corresponding to key.

func (SK4Key) SKKey added in v0.4.0

func (key SK4Key) SKKey() SKKey

SKKey returns key as an SKKey.

func (*SK4Key) Set added in v0.4.0

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

Set attempts to parse keyStr into key.

func (SK4Key) String added in v0.4.0

func (key SK4Key) String() string

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

func (SK4Key) Type added in v0.5.0

func (SK4Key) Type() string

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

func (*SK4Key) UnmarshalJSON added in v0.4.0

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

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

type SKKey added in v0.4.0

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

Path Synopsis
Package varintf implements Factom's varInt_F specification.
Package varintf implements Factom's varInt_F specification.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL