OnFlow.Credentials (on_flow v0.5.0) View Source

Defines a struct that contains an address, a public key, and a private key.

:address might be nil, but the key will be present in the struct.

Do not initialize this directly. Instead, call Credentials.new/1 or Credentials.new!/1.

Link to this section Summary

Functions

Returns a %Credentials{} struct with the keypairs generated.

Initializes a %Credentials{} struct. Returns {:ok, credentials} on success. The params must contain a :private_key and :public_key, or {:error, :missing_keys} will be returned.

Initializes a %Credentials{} struct. Raises on error. See the documentation for new/1.

Link to this section Types

Specs

keys_with_address() :: %{
  optional(:address) => nil | String.t(),
  :public_key => String.t(),
  :private_key => String.t()
}

Specs

t() :: %OnFlow.Credentials{
  address: nil | hex_string(),
  private_key: hex_string(),
  public_key: hex_string()
}

Link to this section Functions

Specs

generate_keys() :: t()

Returns a %Credentials{} struct with the keypairs generated.

Specs

new(keys_with_address()) :: {:ok, t()} | {:error, :missing_keys}

Initializes a %Credentials{} struct. Returns {:ok, credentials} on success. The params must contain a :private_key and :public_key, or {:error, :missing_keys} will be returned.

:public_key and :private_key must be hex-encoded strings.

Specs

new!(map()) :: t() | none()

Initializes a %Credentials{} struct. Raises on error. See the documentation for new/1.