Raxol.Payments.Router (Raxol Payments v0.2.0)

Copy Markdown View Source

Selects the optimal payment protocol based on transfer requirements.

Routing Logic

Same-chain + HTTP 402 detected -> x402 or MPP (auto-pay plugin)
Cross-chain transfer          -> Xochi (agent-facing, cash-positive)
Explicit privacy request      -> Xochi with stealth/shielded settlement
Direct solver access          -> Riddler (internal, not default)

When a trust score is provided, the router also determines the settlement target (public/stealth/shielded) via PrivacyTier.

Xochi is the default for cross-chain because it's the revenue-positive path with tier-based fees. Riddler Commerce is B2B (Coinbase/Shopify) and not intended for agent use.

Summary

Functions

Select the best protocol for a payment.

Determine the settlement target for a payment.

Compute effective trust score from options.

Types

privacy()

@type privacy() :: :public | :stealth | :shielded | :auto

Functions

select(opts \\ [])

@spec select(keyword()) :: atom()

Select the best protocol for a payment.

Returns a protocol atom: :x402, :mpp, :xochi, or :riddler.

Options

  • :cross_chain -- true if source and dest chains differ (default: false)
  • :privacy -- :public, :stealth, :shielded, or :auto (default: :auto)
  • :protocol -- force a specific protocol (overrides routing)
  • :trust_score -- trust score for privacy tier resolution (used by settlement_for/1)
  • :attestations -- list of verified ZKSAR proofs (computes trust score if :trust_score absent)

settlement_for(opts \\ [])

@spec settlement_for(keyword()) :: Raxol.Payments.PrivacyTier.settlement()

Determine the settlement target for a payment.

Uses trust score when available, falls back to explicit privacy option.

Options

  • :trust_score -- non-negative integer trust score
  • :privacy -- explicit privacy level (overrides trust score derivation)
  • :tier_override -- passed through to PrivacyTier.from_trust_score/2
  • :attestations -- list of verified ZKSAR proofs (computes trust score if absent)

trust_score_for(opts \\ [])

@spec trust_score_for(keyword()) :: non_neg_integer()

Compute effective trust score from options.

Returns the explicit :trust_score if present, otherwise aggregates from :attestations. Returns 0 if neither is provided.