ExPlasma.Transaction.Signed (ExPlasma v0.3.0)

Holds functions related to transactions containing signatures.

Link to this section Summary

Functions

Decodes a binary expecting it to represent a signed transactions with the signatures being the first element of the decoded RLP list.

Recovers the witnesses for non-empty signatures, in the order they appear in transaction's signatures.

Validate a signed transaction.

Link to this section Types

Link to this type

decoding_error()

Specs

decoding_error() :: :malformed_rlp | :malformed_witnesses

Specs

sigs() :: [ExPlasma.Crypto.sig_t()] | []

Specs

tx_bytes() :: binary()
Link to this type

validation_error()

Specs

validation_error() :: {:witnesses, :malformed_witnesses}

Link to this section Functions

Link to this function

compute_signatures(transaction, keys)

Specs

compute_signatures(ExPlasma.Transaction.t(), [String.t()]) ::
  {:ok, sigs()} | {:error, :not_signable}
Link to this function

decode(signed_tx_bytes)

Specs

decode(tx_bytes()) :: {:ok, list()} | {:error, decoding_error()}

Decodes a binary expecting it to represent a signed transactions with the signatures being the first element of the decoded RLP list.

Returns {:ok, signed_tx_rlp_items} if the encoded RLP can be decoded, or {:error, atom} otherwise.

Only validates that the RLP is structurally correct. Does not perform any other kind of validation, use validate/1 for that.

Link to this function

get_witnesses(transaction)

Specs

Recovers the witnesses for non-empty signatures, in the order they appear in transaction's signatures.

Returns {:ok, witness_list} if witnesses are recoverable, or {:error, :corrupted_witness} otherwise.

Link to this function

validate(transaction)

Specs

validate(ExPlasma.Transaction.t()) :: :ok | {:error, validation_error()}

Validate a signed transaction.

Returns :ok if valid or {:error, {:witnesses, :malformed_witnesses}} otherwise.