State and TIP-1034 precompile identity for an MPP payment channel.
Channel IDs match the Tempo TIP-20 Channel Reserve precompile:
keccak256(abi.encode(payer, payee, operator, token, salt,
authorizedSigner, expiringNonceHash,
escrowContract, chainId))Channel lifecycle is deliberately small: a new channel is :open, may be
activated once, and an active channel may be closed once.
Summary
Functions
Parse a session credential action JSON value into its Elixir atom.
Return the camelCase JSON value for a session credential action atom.
Move an open channel to the active state.
Deduct a per-request spend from the authorized voucher balance.
Increase the channel deposit by a positive additional amount.
Raise the accepted cumulative voucher amount. Equal amounts are idempotent.
Authorized-but-unspent voucher balance (cumulative_amount - spent).
Move an active channel to the closed state.
Compute the TIP-1034 channel ID from its complete identity descriptor.
Compute a channel ID, raising ArgumentError on invalid input.
Create validated channel state in the :open status.
Create validated channel state, raising ArgumentError on invalid input.
Normalize a 32-byte channel ID to lowercase, 0x-prefixed hex.
Unvouchered remainder of the on-channel deposit (deposit - cumulative_amount).
Types
@type action() :: :open | :top_up | :voucher | :close
@type status() :: :open | :active | :closed
@type t() :: %MPP.Session.Channel{ channel_id: String.t(), cumulative_amount: non_neg_integer(), deposit: non_neg_integer(), payer: String.t(), recipient: String.t(), spent: non_neg_integer(), status: status(), token: String.t(), units: non_neg_integer() }
Functions
Parse a session credential action JSON value into its Elixir atom.
Return the camelCase JSON value for a session credential action atom.
Move an open channel to the active state.
@spec apply_spend(t(), non_neg_integer()) :: {:ok, t()} | {:error, term()}
Deduct a per-request spend from the authorized voucher balance.
@spec apply_top_up(t(), pos_integer()) :: {:ok, t()} | {:error, term()}
Increase the channel deposit by a positive additional amount.
@spec apply_voucher(t(), non_neg_integer()) :: {:ok, t()} | {:error, term()}
Raise the accepted cumulative voucher amount. Equal amounts are idempotent.
@spec available_balance(t()) :: non_neg_integer()
Authorized-but-unspent voucher balance (cumulative_amount - spent).
Move an active channel to the closed state.
Compute the TIP-1034 channel ID from its complete identity descriptor.
Compute a channel ID, raising ArgumentError on invalid input.
Create validated channel state in the :open status.
Create validated channel state, raising ArgumentError on invalid input.
Normalize a 32-byte channel ID to lowercase, 0x-prefixed hex.
@spec remaining_deposit(t()) :: non_neg_integer()
Unvouchered remainder of the on-channel deposit (deposit - cumulative_amount).