Skip to content

fix(api): filter x402 discovery rails - #123

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-management-7a96
Draft

fix(api): filter x402 discovery rails#123
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-management-7a96

Conversation

@cursor

@cursor cursor Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Bug and impact

/.well-known/x402 advertised wallet-configured rails such as Ethereum, Arbitrum, Optimism, Avalanche, native assets, and other non-CDP networks even though the real x402 payment challenge filters settlement to CDP-supported rails. Agents/crawlers using the machine-readable discovery endpoint could select a rail that Arch Tools would not actually settle, causing payment attempts that fail to unlock service.

Root cause

The discovery route duplicated its own rail list and exposed it directly, while buildPaymentRequired applied an in-function CDP support filter before returning real 402 accepts entries.

Fix

  • Export the CDP-supported accept filter from api/src/middleware/x402.ts.
  • Reuse it in both the runtime 402 builder and /.well-known/x402 discovery.
  • Derive payment.x402.networks and token summary from the filtered rails.
  • Align discovery USDT behavior with runtime by using the main EVM wallet.
  • Add tests/x402-discovery-rails.test.mjs and include it in the API test script.

Validation

Ran from api/:

npm run build && node tests/x402-discovery-rails.test.mjs && node tests/x402-sell-copy.test.mjs && node tests/intent-funnel.test.mjs && node tests/credit-email-buylinks.test.mjs && node tests/outreach-active-devs.test.mjs && node tests/reactivation-render.test.mjs

All checks passed, including x402-discovery-rails: ALL PASS.

Open in Web View Automation 

Co-authored-by: Deesmo <Deesmo@users.noreply.github.com>
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.

1 participant