Paid, hosted product at menivor.com, now retired as a company project. Fresh squashed history of the cleaned working tree (secret-scanned, no .env, no customer data, no outreach logs). Built on MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
5.5 KiB
apps/mint — AITP-402 AI-Token (AIT) settlement layer
This is the real Mint: the AITP-402 double-entry ledger and mint-server
HTTP binary that backs Menivor's wallet AI-Token (AIT) rail — receive, transfer,
and hold-based (reserve → capture / release) settlement, plus provider-confirmed
mint/redeem supply changes and streaming ticks. Every amount is a bare
integer microdollar (µ$); ReelForge micros are Mint micros, no conversion.
Provenance / attribution
The crate graph is reused verbatim from the canonical Mint in the sibling
Railyard repo (railyard/apps/mint), not rebuilt from scratch. It is the same
AITP-402 implementation (121 Rust files across 11 crates). See NOTICE for the
attribution and LICENSE (MIT). Keep the two copies in sync when the protocol
changes; the Python wallet client in
apps/api/app/domains/wallet/mint_client.py speaks this server's exact /v1
API.
Crates
| crate | role |
|---|---|
mint-core |
typed ids/amounts (AccountId, Micros, Address), op_hash |
mint-store |
LedgerStore trait + in-memory reference store |
mint-store-postgres |
production PgStore (runtime sqlx, no compile-time DATABASE_URL) |
mint-ledger |
transfer + hold (reserve/capture/release) facade |
mint-receipts |
hash-linked, signed §6 receipt chain |
mint-protocol |
AITP-402 intents, signatures, flat AITP-Receipt wire codec |
mint-stream |
metered streaming settlement (open/tick/close) |
mint-reserve |
supply reserve, ramp + KYC seams (mint/redeem) |
mint-payments |
provider on-ramp webhook verification (Stripe/Creem/…) |
mint-sdk |
typed Rust client |
mint-server |
axum HTTP binary exposing the /v1 money routes |
Build
This is its own standalone cargo workspace (not a member of the repo-root GPUI/Metal desktop workspace), so build from here:
cd apps/mint
cargo check # or: cargo build --release -p mint-server
Run the server
export MINT_BIND_ADDR=0.0.0.0:8080
export DATABASE_URL=postgres://user:pass@host:5432/mint # → PgStore (production)
export MINT_API_KEY=$(openssl rand -hex 32) # required X-API-Key
export MINT_SIGNING_KEY=$(openssl rand -hex 32) # receipt-signing seed
cargo run --release -p mint-server
DATABASE_URL is the production signal: when set the server runs migrations and
uses PgStore. For local dev without Postgres use MINT_ALLOW_INMEMORY=1
(dev-only, refuses to co-exist with a money-moving Postgres deployment).
Wiring the Menivor wallet to this server
The wallet client is config-gated (apps/api/app/config/config.py → config.mint,
env wins). Set all three of these on the apps/api process and the wallet AIT
endpoints flip live automatically (see apps/api/app/domains/wallet/mint_stage.py
— current_stage() defaults to on once fully configured):
export MINT_SERVER_URL=http://mint:8080 # base URL of this server
export MINT_API_KEY=<same key the server requires>
export MINT_TREASURY_ACCOUNT=acct_... # capture destination (Treasury acct)
# optional staged rollout instead of full-on:
export MINT_STAGE=canary # local | canary | on
export MINT_ROLLOUT_PERCENT=10 # canary bucket %
When any of MINT_SERVER_URL / MINT_API_KEY / MINT_TREASURY_ACCOUNT is
missing the wallet fails closed to the local microdollar ledger (a clean
503 on AIT-only endpoints), never a partial/unauthenticated call to Mint.
MINT_STAGE=local is the kill-switch: instantly falls back without unsetting the
URL/keys.
Seller discounts (served)
Menivor's channel coupons (apps/api/app/domains/ott_commerce/processor.py,
MintDiscounts) call two seller routes that Railyard Mint serves since main
6200c2e. Mint forwards each body unchanged to the seller's connected Dodo
account with the seller's own key; Menivor authenticates with its seller
product key (x-api-key). The create answer includes the discount_id.
| Method and path | Body (Dodo shape) | Answer |
|---|---|---|
POST /mint/v1/sellers/{seller}/discounts |
Dodo POST /discounts: code, type (percentage or flat), amount (basis points, or smallest currency unit for flat), expires_at (ISO 8601 UTC), name, flat only currency_options ([{currency, max_amount_possible, is_default}]), optional restricted_to |
201 {"discount": {"discount_id": "dsc_...", "code": "SAVE20", ...}} |
PATCH /mint/v1/sellers/{seller}/discounts/{discount_id} |
Partial Dodo PATCH /discounts/{discount_id}: any of amount, type, code, currency_options, expires_at, name |
200 {"discount": {"discount_id": "dsc_...", "code": ...}} |
- Stopping a coupon is
PATCHwith only{"expires_at": <now>}, so it can be switched back on later. Re-enabling isPATCHwith the newtype,amount,currency_options,expires_atandnameon the samediscount_id(Dodo refuses a second discount with the same code). - Menivor never asks for Dodo's
DELETE /discounts/{id}(a soft delete that cannot be undone). - Errors use the seller error shape (
{"error": {"code", "message"}}):404 unknown_discount: an unknown or another seller'sdiscount_id. Menivor answers404 unknown_discount(the coupon is gone), not "unavailable".409 discounts_unsupported: a Stripe seller (Dodo only). Menivor answers409 discounts_unsupported.- An older Mint without these routes answers 404 with code
unknown,not_foundor none; Menivor maps that to503 discounts_unavailable.