mirror of
https://github.com/laoxong/nofx.git
synced 2026-06-04 01:48:22 +08:00
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:
+1
-1
@@ -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))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user