Return 0 for balance queries for non-existant (new) accounts
This commit is contained in:
@@ -68,7 +68,17 @@ public final class NodeClient {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, Object> account(String accountId) throws Exception {
|
||||
return (Map<String, Object>) request("/v3/accounts/" + accountId, "GET", null);
|
||||
try {
|
||||
return (Map<String, Object>) request("/v3/accounts/" + accountId, "GET", null);
|
||||
} catch (Exception e) {
|
||||
if (e.getMessage() != null && e.getMessage().contains("Account not found")) {
|
||||
Map<String, Object> res = new HashMap<>();
|
||||
res.put("id", accountId);
|
||||
res.put("balance", 0);
|
||||
return res;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
Reference in New Issue
Block a user