From 851f152c501caf0e7de708f4c5709a8e9021844b Mon Sep 17 00:00:00 2001 From: shinchan-zhai Date: Fri, 17 Apr 2026 11:26:49 +0800 Subject: [PATCH] fix(wallet): handle JSON-RPC null error field in balance query 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 --- wallet/usdc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wallet/usdc.go b/wallet/usdc.go index e8643daf..c40f696b 100644 --- a/wallet/usdc.go +++ b/wallet/usdc.go @@ -78,7 +78,7 @@ func queryUSDCBalanceRPC(address string) (float64, error) { if err := json.Unmarshal(respBody, &rpcResp); err != nil { return 0, fmt.Errorf("decode rpc response: %w", err) } - if len(rpcResp.Error) > 0 { + if len(rpcResp.Error) > 0 && string(rpcResp.Error) != "null" { return 0, fmt.Errorf("rpc error: %s", string(rpcResp.Error)) }