ExPlasma.Output.Type.AbstractPayment (ExPlasma v0.2.0)
Abstract payment output type.
Link to this section Summary
Functions
Decode a map of the output data into the Abstract Payment format
Encode a map of the output data into an RLP list.
Validates the output data
Link to this section Types
Link to this type
address()
Specs
address() :: <<_::160>>
Link to this type
amount()
Specs
amount() :: non_neg_integer()
Link to this type
mapping_errors()
Specs
mapping_errors() :: :malformed_output_guard | :malformed_output_token | :malformed_output_amount
Link to this type
output_guard()
Specs
output_guard() :: address()
Link to this type
rlp()
Specs
rlp() :: [<<_::8>> | [output_guard() | [token() | binary()]]]
Specs
t() :: %{output_guard: output_guard(), token: token(), amount: amount()}
Link to this type
token()
Specs
token() :: address()
Link to this type
validation_error()
Specs
Link to this type
validation_responses()
Specs
validation_responses() :: {:ok, t()}
Link to this section Functions
Link to this function
to_map(arg1)
Specs
to_map(rlp()) :: {:ok, %{output_data: t(), output_type: non_neg_integer()}} | {:error, mapping_errors()}
Decode a map of the output data into the Abstract Payment format
Only validates that the RLP is structurally correct. Does not perform any other kind of validation, use validate/1 for that.
Example
iex> data = [<<1>>, [<<1::160>>, <<1::160>>, <<1>>]]
iex> ExPlasma.Output.Type.AbstractPayment.to_map(data)
{:ok, %{
output_type: 1,
output_data: %{output_guard: <<1::160>>, token: <<1::160>>, amount: 1}
}}
Link to this function
to_rlp(output)
Specs
to_rlp(ExPlasma.Output.t()) :: rlp()
Encode a map of the output data into an RLP list.
Example
iex> output = %{output_type: 1, output_data: %{output_guard: <<1::160>>, token: <<1::160>>, amount: 1}}
iex> ExPlasma.Output.Type.AbstractPayment.to_rlp(output)
[<<1>>, [<<1::160>>, <<1::160>>, <<1>>]]
Link to this function
validate(output)
Validates the output data
Example
iex> data = %{output_data: %{output_guard: <<1::160>>, token: <<0::160>>, amount: 1}}
iex> ExPlasma.Output.Type.AbstractPayment.validate(data)
:ok