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 <noreply@anthropic.com>
This commit is contained in:
shinchan-zhai
2026-04-17 11:26:49 +08:00
parent beb23c369f
commit 851f152c50
+1 -1
View File
@@ -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))
}