Skip to content

feat(marketplace): RLUSD withdrawal endpoint + SQLite balance persistence#194

Merged
Timwal78 merged 1 commit into
mainfrom
claude/beast-revenue-loop
Jun 19, 2026
Merged

feat(marketplace): RLUSD withdrawal endpoint + SQLite balance persistence#194
Timwal78 merged 1 commit into
mainfrom
claude/beast-revenue-loop

Conversation

@Timwal78

Copy link
Copy Markdown
Owner

Summary

  • SQLite persistence for seller balances on the existing /var/data/vapl disk — marketplace revenue now survives server redeploys
  • DID-signed withdrawal endpoint (POST /api/marketplace/withdraw) — agents sign a canonical JSON message with their Ed25519 private key; SqueezeOS verifies by extracting the pubkey from the did:key DID, with 5-minute replay protection via timestamp + nonce
  • XRPL RLUSD payout from operator treasury wallet (MARKETPLACE_XRPL_SEED) — verified sellers receive RLUSD on-chain when they call withdraw
  • render.yaml — added MARKETPLACE_XRPL_SEED and MARKETPLACE_XRPL_ADDRESS env vars (sync: false); consolidated the duplicate envVars block that was splitting VAPL_SOUL_FILE into a separate block (would have been overridden in YAML)

What changed

core/api/marketplace_bp.py

  • Added sqlite3, threading, base64, hashlib imports
  • _init_db() / _load_balances() / _persist_balance(wallet) — SQLite UPSERT on the VAPL disk at /var/data/vapl/marketplace.db; falls back to /tmp/marketplace.db if disk not mounted
  • _load_balances() called at module import — warms in-memory _seller_stats from disk on startup
  • _persist_balance(wallet) called in /read route after every sale — durable balance update
  • _verify_did_signature(agent_did, message, sig_b64) — extracts 34-byte multicodec from did:key z{base58btc}, verifies Ed25519
  • _send_rlusd_payout(amount_rlusd, destination) — XRPL IssuedCurrencyAmount RLUSD transfer from operator wallet
  • POST /api/marketplace/withdraw — full endpoint: validates wallet/did/timestamp/nonce/signature, checks balance ≥ 0.05 RLUSD, pays out, zeroes balance, persists

render.yaml

  • Merged duplicate envVars block (fixed YAML structure)
  • Added MARKETPLACE_XRPL_SEED and MARKETPLACE_XRPL_ADDRESS

Operator setup required

Add to Render SqueezeOS service environment (Dashboard → Environment → Add):

Key Value
MARKETPLACE_XRPL_SEED XRPL wallet seed for the treasury payout wallet
MARKETPLACE_XRPL_ADDRESS Matching XRPL address

The treasury wallet needs an RLUSD trust line and sufficient RLUSD balance to fund agent withdrawals. The wallet never holds user funds — it pays out seller earnings on demand.

Revenue loop architecture

IWM/GME/ORACLE/FTD agents → list signals (free) → sell reads (0.02 RLUSD each)
                           ↓ balance accumulates in SQLite
                           ↓ agent calls POST /api/marketplace/withdraw
                           ↓ DID signature verified server-side
ARBI agent                 → buys top peer signals → synthesizes composite → relists
                           ↓ earns from composite reads → withdraws
Operator treasury wallet   → funds payouts → replenished by marketplace platform cut

Test plan

  • Deploy to Render with MARKETPLACE_XRPL_SEED / MARKETPLACE_XRPL_ADDRESS set
  • Fund treasury wallet with RLUSD on XRPL mainnet, verify trust line
  • Run a Beast IWM agent cycle — confirm balance appears in /api/marketplace leaderboard
  • Call POST /api/marketplace/withdraw with a valid DID-signed request — confirm XRPL payment
  • Restart the Render service — confirm balances reload from SQLite (not zeroed)
  • Attempt withdraw with stale timestamp (>5 min) — confirm 401
  • Attempt withdraw with replayed nonce — confirm 401

🤖 Generated with Claude Code


Generated by Claude Code

… for seller balances

Closes the VAPL revenue loop for Beast Swarm agents:
- SQLite balance persistence on /var/data/vapl disk (survives redeploys)
- DID-signed withdraw endpoint (POST /api/marketplace/withdraw) with Ed25519
  signature verification, 5-min replay protection, and nonce enforcement
- XRPL payout from operator treasury wallet (MARKETPLACE_XRPL_SEED)
- render.yaml: add MARKETPLACE_XRPL_SEED/ADDRESS env vars + consolidate
  duplicate envVars block (VAPL_SOUL_FILE merged into primary block)

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
signal-auction-loom Ready Ready Preview, Comment Jun 19, 2026 3:35pm
squeeze-os Ready Ready Preview, Comment Jun 19, 2026 3:35pm

@Timwal78 Timwal78 marked this pull request as ready for review June 19, 2026 15:38
@Timwal78 Timwal78 merged commit 3c0601e into main Jun 19, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants