Some RPC implementations return explicit "error": null on success.
json.RawMessage deserializes this as the 4-byte literal "null", so
len() > 0 was true, causing every balance query to fail with
"rpc error: null". Skip the null literal to avoid false positives.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* chore: ignore nofx-server build artifact
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(claw402): preflight USDC balance before AI calls
Short-circuit claw402 Call/CallWithRequestFull when the wallet balance
can't cover the estimated cost of the call, surfacing ErrInsufficientFunds
instead of letting x402 fail mid-flight after the sign step.
- wallet: cached balance lookup (30s TTL, per-address mutex) to avoid
hammering the Base RPC; separate error-returning and display-only APIs
so callers can distinguish zero balance from an unreachable RPC.
- claw402: 1.5× safety multiplier on the flat per-call estimate, 4.0×
for reasoner models whose chain-of-thought cost can blow past the
flat rate. Fail-open on RPC errors — x402 still gates actually-empty
wallets, and we prefer availability over extra strictness.
- shortAddr redacts the wallet in error strings to avoid leaking the
full address into telemetry bundles.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>