Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(x402): advertise the Solana accept in self-pay mode without the sponsor secret

nrpo8ff464eab53d
diff --git a/api/_lib/x402-spec.js b/api/_lib/x402-spec.js
index 6f51bcf62..f5c4ff4da 100644
--- a/api/_lib/x402-spec.js
+++ b/api/_lib/x402-spec.js
@@ -335,6 +335,12 @@ export function baseSettleable() {
export function solanaSettleable() {
const route = resolveSolanaFacilitator();
if (!route.self) return true; // external facilitator co-signs with its own key
+ // SELF-PAY (X402_RING_SELF_PAY): the buyer signs its own 1-signature fee and the
+ // self-facilitator only BROADCASTS the already-signed tx — no sponsor key is
+ // used (settleRingPayment's `if (!selfPay)` branch skips loadFeePayerKeypair).
+ // So self-routing is settleable when self-pay is on, even with no sponsor
+ // secret. Sponsor mode still requires the co-signing secret.
+ if (String(process.env.X402_RING_SELF_PAY || '').toLowerCase() === 'true') return true;
return !!String(process.env.X402_FEE_PAYER_SECRET_BASE58 || '').trim();
}
diff --git a/api/_lib/x402/ring-config.js b/api/_lib/x402/ring-config.js
index 485ad98e5..47cd39b01 100644
--- a/api/_lib/x402/ring-config.js
+++ b/api/_lib/x402/ring-config.js
@@ -136,13 +136,13 @@ export function validateRingConfig() {
// set, so surface it here as an error the health board and /api/x402-status show.
// Only meaningful when we route to our own facilitator; an external facilitator
// co-signs with its own key.
- if (route.self && !String(process.env.X402_FEE_PAYER_SECRET_BASE58 || '').trim()) {
+ if (route.self && !ringSelfPayEnabled() && !String(process.env.X402_FEE_PAYER_SECRET_BASE58 || '').trim()) {
findings.push({
code: 'fee_payer_secret_missing',
severity: 'error',
message:
- 'X402_FEE_PAYER_SECRET_BASE58 is not set — the self-facilitator cannot co-sign sponsor-mode settlements, so the Solana accept is withheld and no Solana payment can settle in-house',
- fix: 'set X402_FEE_PAYER_SECRET_BASE58 to the sponsor secret from scripts/x402-ring-setup.mjs (must match X402_FEE_PAYER_SOLANA)',
+ 'X402_FEE_PAYER_SECRET_BASE58 is not set and self-pay is off — the self-facilitator cannot co-sign sponsor-mode settlements, so the Solana accept is withheld and no Solana payment can settle in-house',
+ fix: 'set X402_RING_SELF_PAY=true (buyer pays its own fee, no sponsor key needed) OR set X402_FEE_PAYER_SECRET_BASE58 to the sponsor secret (must match X402_FEE_PAYER_SOLANA)',
});
}
const priceAtomic = Number(priceFor('ring-settle', RING_SETTLE_DEFAULT_PRICE_ATOMICS));
diff --git a/tests/api/x402-ring-config.test.js b/tests/api/x402-ring-config.test.js
index ccb2c4c3a..0d161b120 100644
--- a/tests/api/x402-ring-config.test.js
+++ b/tests/api/x402-ring-config.test.js
@@ -157,14 +157,21 @@ describe('validateRingConfig finding matrix', () => {
expect(f.severity).toBe('error');
});
- it('flags fee_payer_secret_missing (error) when self-routing without the co-signing secret', () => {
+ it('flags fee_payer_secret_missing (error) when self-routing in SPONSOR mode without the co-signing secret', () => {
healthyRingEnv();
+ process.env.X402_RING_SELF_PAY = 'false'; // sponsor mode co-signs → needs the secret
delete process.env.X402_FEE_PAYER_SECRET_BASE58;
const f = validateRingConfig().find((x) => x.code === 'fee_payer_secret_missing');
expect(f).toBeTruthy();
expect(f.severity).toBe('error');
});
+ it('does NOT flag fee_payer_secret_missing in SELF-PAY mode (buyer pays its own 1-sig fee)', () => {
+ healthyRingEnv(); // self-pay is on
+ delete process.env.X402_FEE_PAYER_SECRET_BASE58;
+ expect(codes(validateRingConfig())).not.toContain('fee_payer_secret_missing');
+ });
+
it('does NOT flag fee_payer_secret_missing when settlement routes externally', () => {
healthyRingEnv();
delete process.env.X402_FEE_PAYER_SECRET_BASE58;