State and identity for an MPP payment channel.
Tempo TIP-1034 channel IDs are keccak256 of the ABI-encoded identity
descriptor. XRPL PayChannel IDs are SHA-512Half of the 0x0078 space key,
source AccountID, destination AccountID and create Sequence (or TicketSequence),
per the PayChannel ledger-entry ID format. new/1 accepts EVM addresses or
XRPL classic addresses; token may be an EVM address or "XRP".
Channel lifecycle is deliberately small: a new channel is :open, may be
activated once, and an active channel may be closed once.
proof holds the highest accepted method-specific settlement material
(for XRPL: cumulative drops, claim signature, and ledger PublicKey). Tempo
leaves it nil.
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.
Compute an XRPL PayChannel ID from funder, destination and create sequence.
Create validated channel state in the :open status.
Create validated channel state, raising ArgumentError on invalid input.
Build the method-specific settlement proof retained for a claim.
Normalize a 32-byte channel ID to lowercase, 0x-prefixed hex.
Unvouchered remainder of the on-channel deposit (deposit - cumulative_amount).
Return the 64-character uppercase hex form used on the XRPL wire.
Types
@type action() :: :open | :top_up | :voucher | :close
@type proof() :: %{ amount: non_neg_integer(), signature: String.t(), public_key: String.t() }
@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(), proof: proof() | nil, 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(), proof() | nil) :: {: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.
@spec compute_xrpl_id(String.t(), String.t(), non_neg_integer()) :: {:ok, String.t()} | {:error, term()}
Compute an XRPL PayChannel ID from funder, destination and create sequence.
Create validated channel state in the :open status.
Create validated channel state, raising ArgumentError on invalid input.
@spec new_proof(non_neg_integer(), String.t(), String.t()) :: proof()
Build the method-specific settlement proof retained for a claim.
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).
Return the 64-character uppercase hex form used on the XRPL wire.