feat: route nofxos data API calls through claw402 x402 payment

When CLAW402_WALLET_KEY env var is set, all nofxos.ai data API calls
(AI500, OI rankings, NetFlow, price rankings) are automatically routed
through claw402.ai with x402 USDC micropayment.

- provider/nofxos/claw402.go: x402 GET request client for data APIs
- provider/nofxos/client.go: claw402 mode support in doRequest()
- kernel/engine.go: auto-detect CLAW402_WALLET_KEY and enable routing
- mcp/payment/x402.go: MakeClaw402SignFunc helper

Without CLAW402_WALLET_KEY, falls back to direct nofxos.ai (backward compat).
This commit is contained in:
shinchan-zhai
2026-03-25 09:58:24 +08:00
parent 9b14c5c84d
commit 2d68b48f52
4 changed files with 151 additions and 1 deletions
+7
View File
@@ -81,6 +81,13 @@ func X402DecodeHeader(b64 string) ([]byte, error) {
return decoded, nil
}
// MakeClaw402SignFunc creates an X402SignFunc from a private key for claw402 payments.
func MakeClaw402SignFunc(privateKey *ecdsa.PrivateKey) X402SignFunc {
return func(paymentHeaderB64 string) (string, error) {
return SignBasePaymentHeader(privateKey, paymentHeaderB64, "Claw402")
}
}
// SignBasePaymentHeader decodes a base64 x402 header, parses it, and signs with
// EIP-712 (USDC TransferWithAuthorization).
func SignBasePaymentHeader(privateKey *ecdsa.PrivateKey, paymentHeaderB64 string, providerName string) (string, error) {