View Source Radixir.Util (radixir v0.0.3)

Utility functions that do various things.

Link to this section Summary

Functions

Converts atto, the smallest unit of value, into xrd.

Base16 decodes encoded_data.

Decodes a message.

Decrypts encrypted_message with private_key and address.

Base16 encodes data.

Encodes message by

Encrypts message with private_key and address.

Stitches together stitch plans which results in a map.

Verifies double hash of unsigned_transaction matches payload_to_sign.

Converts xrd to atto, smallest unit of value.

Link to this section Types

Specs

address() :: String.t()

Specs

atto() :: String.t()

Specs

data() :: String.t()

Specs

encoded_data() :: String.t()

Specs

encoded_message() :: String.t()

Specs

encrypted_message() :: String.t()

Specs

error_message() :: String.t()

Specs

error_note() :: String.t()

Specs

keys_values() :: [keyword()]

Specs

message() :: String.t()

Specs

payload_to_sign() :: String.t()

Specs

private_key() :: String.t()

Specs

public_key() :: String.t()
Link to this type

unsigned_transaction()

View Source

Specs

unsigned_transaction() :: String.t()

Specs

xrd() :: String.t()

Link to this section Functions

Specs

atto_to_xrd(atto()) :: {:ok, xrd()} | {:error, error_message()}

Converts atto, the smallest unit of value, into xrd.

Parameters

  • atto: Amount of XRD, in atto units.

Examples

iex> Radixir.Util.atto_to_xrd("1500000000000000000")
{:ok, "1.5"}
Link to this function

decode16(encoded_data, error_note)

View Source

Specs

decode16(encoded_data(), error_note()) ::
  {:ok, data()} | {:error, error_message()}

Base16 decodes encoded_data.

Link to this function

decode_message(encoded_message)

View Source

Specs

decode_message(encoded_message()) ::
  {:ok, message()} | {:error, error_message()}

Decodes a message.

Link to this function

decrypt_message(encrypted_message, private_key, address)

View Source

Specs

decrypt_message(encrypted_message(), private_key(), address()) ::
  {:ok, message()} | {:error, error_message()}

Decrypts encrypted_message with private_key and address.

Parameters

  • encrypted_message: Encrypted message to be decrypted.
  • private_key: Hex encoded private key.
  • address: Radix address.

Specs

encode16(data()) :: encoded_data()

Base16 encodes data.

Specs

encode_message(message()) :: encoded_message()

Encodes message by:

  • Base16 encoding the message
  • Prefixing "0000" to the front

Parameter

  • message: Plain text.
Link to this function

encrypt_message(message, private_key, address)

View Source

Specs

encrypt_message(message(), private_key(), address()) ::
  {:ok, encrypted_message()} | {:error, error_message()}

Encrypts message with private_key and address.

Parameters

  • message: Plain text message to be encrypted.
  • private_key: Hex encoded private key.
  • address: Radix address.

Specs

stitch(keys_values()) :: map()

Stitches together stitch plans which results in a map.

Parameters

  • keys_values: List of keyword lists.

Examples

iex> Radixir.Util.stitch([[keys: [:a, :b, :c], value: 4],[keys: [:z, :y, :x], value: 90]])
%{a: %{b: %{c: 4}}, z: %{y: %{x: 90}}}
Link to this function

verify_hash(unsigned_transaction, payload_to_sign)

View Source

Specs

verify_hash(unsigned_transaction(), payload_to_sign()) ::
  :ok | {:error, error_message()}

Verifies double hash of unsigned_transaction matches payload_to_sign.

Specs

xrd_to_atto(xrd()) :: {:ok, atto()} | {:error, error_message()}

Converts xrd to atto, smallest unit of value.

Parameters

  • xrd: Amount of XRD.

Examples

iex> Radixir.Util.xrd_to_atto("1.5")
{:ok, "1500000000000000000"}