feat(marketplace): RLUSD withdrawal endpoint + SQLite balance persistence#194
Merged
Conversation
… 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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/var/data/vapldisk — marketplace revenue now survives server redeploysPOST /api/marketplace/withdraw) — agents sign a canonical JSON message with their Ed25519 private key; SqueezeOS verifies by extracting the pubkey from thedid:keyDID, with 5-minute replay protection via timestamp + nonceMARKETPLACE_XRPL_SEED) — verified sellers receive RLUSD on-chain when they call withdrawMARKETPLACE_XRPL_SEEDandMARKETPLACE_XRPL_ADDRESSenv vars (sync: false); consolidated the duplicateenvVarsblock that was splittingVAPL_SOUL_FILEinto a separate block (would have been overridden in YAML)What changed
core/api/marketplace_bp.pysqlite3,threading,base64,hashlibimports_init_db()/_load_balances()/_persist_balance(wallet)— SQLite UPSERT on the VAPL disk at/var/data/vapl/marketplace.db; falls back to/tmp/marketplace.dbif disk not mounted_load_balances()called at module import — warms in-memory_seller_statsfrom disk on startup_persist_balance(wallet)called in/readroute after every sale — durable balance update_verify_did_signature(agent_did, message, sig_b64)— extracts 34-byte multicodec fromdid:key z{base58btc}, verifies Ed25519_send_rlusd_payout(amount_rlusd, destination)— XRPLIssuedCurrencyAmountRLUSD transfer from operator walletPOST /api/marketplace/withdraw— full endpoint: validates wallet/did/timestamp/nonce/signature, checks balance ≥ 0.05 RLUSD, pays out, zeroes balance, persistsrender.yamlenvVarsblock (fixed YAML structure)MARKETPLACE_XRPL_SEEDandMARKETPLACE_XRPL_ADDRESSOperator setup required
Add to Render SqueezeOS service environment (Dashboard → Environment → Add):
MARKETPLACE_XRPL_SEEDMARKETPLACE_XRPL_ADDRESSThe 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
Test plan
MARKETPLACE_XRPL_SEED/MARKETPLACE_XRPL_ADDRESSset/api/marketplaceleaderboardPOST /api/marketplace/withdrawwith a valid DID-signed request — confirm XRPL payment🤖 Generated with Claude Code
Generated by Claude Code