View Source Dpos.Tx behaviour (DPoS v0.4.0)

Define behaviour and implement functions to work with transactions.

Summary

Functions

Builds a new transaction.

Ensure transaction has a correct timestamp value.

Signs the transaction with the sender private key.

Types

@type t() :: %Dpos.Tx{
  address_suffix_length: term(),
  amount: term(),
  asset: term(),
  fee: term(),
  id: term(),
  public_key: term(),
  recipient: term(),
  second_signature: term(),
  signature: term(),
  timestamp: term(),
  type: term()
}
@type wallet_or_secret() ::
  %Dpos.Wallet{
    address: term(),
    priv_key: term(),
    pub_key: term(),
    suffix_length: term()
  }
  | {String.t(), String.t()}

Callbacks

Link to this callback

get_child_bytes(%Dpos.Tx{})

View Source
@callback get_child_bytes(%Dpos.Tx{
  address_suffix_length: term(),
  amount: term(),
  asset: term(),
  fee: term(),
  id: term(),
  public_key: term(),
  recipient: term(),
  second_signature: term(),
  signature: term(),
  timestamp: term(),
  type: term()
}) :: binary()
@callback type_id() :: integer()

Functions

@spec build(module(), map()) :: t()

Builds a new transaction.

@spec ensure_timestamp(map()) :: map()

Ensure transaction has a correct timestamp value.

Check if timestamp is present and not negative, otherwise it will be set to Dpos.Time.now/0.

@spec normalize(t()) :: Dpos.Tx.Normalized.t()
Link to this function

sign(tx, wallet_or_secret, second_priv_key \\ nil)

View Source
@spec sign(t(), wallet_or_secret(), binary() | nil) :: t()

Signs the transaction with the sender private key.

It accepts either a Dpos.Wallet or a {"secret", "L"} tuple as second argument where the first element is the secret and the second element is the address suffix (i.e. "L" for Lisk).

A secondary private_key can also be provided as third argument.