use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.
the class BackupAccountProcessor method execute.
@Override
public CommandResult execute(String[] args) {
String address = args[1];
String path = args.length == 3 ? args[2] : "";
RpcClientResult res = CommandHelper.getPassword(address, restFul);
if (!res.isSuccess()) {
return CommandResult.getFailed(res);
}
String password = (String) res.getData();
Map<String, Object> parameters = new HashMap<>();
parameters.put("password", password);
parameters.put("path", path);
RpcClientResult result = restFul.post("/account/export/" + address, parameters);
if (result.isFailed()) {
return CommandResult.getFailed(result);
}
return CommandResult.getSuccess("The path to the backup file is " + (String) (CommandResult.dataTransformValue(result).getData()));
}
use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.
the class GetAccountProcessor method execute.
@Override
public CommandResult execute(String[] args) {
String address = args[1];
RpcClientResult result = restFul.get("/account/" + address, null);
if (result.isFailed()) {
return CommandResult.getFailed(result);
}
Map<String, Object> map = (Map) result.getData();
map.put("createTime", DateUtil.convertDate(new Date((Long) map.get("createTime"))));
result.setData(map);
return CommandResult.getResult(result);
}
use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.
the class GetAccountsProcessor method execute.
@Override
public CommandResult execute(String[] args) {
int pageNumber = Integer.parseInt(args[1]);
int pageSize = Integer.parseInt(args[2]);
Map<String, Object> parameters = new HashMap<>();
parameters.put("pageNumber", pageNumber);
parameters.put("pageSize", pageSize);
RpcClientResult result = restFul.get("/account", parameters);
if (result.isFailed()) {
return CommandResult.getFailed(result);
}
List<Map<String, Object>> list = (List<Map<String, Object>>) ((Map) result.getData()).get("list");
for (Map<String, Object> map : list) {
map.put("createTime", DateUtil.convertDate(new Date((Long) map.get("createTime"))));
}
result.setData(list);
return CommandResult.getResult(result);
}
use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.
the class GetBalanceProcessor method execute.
@Override
public CommandResult execute(String[] args) {
String address = args[1];
RpcClientResult result = restFul.get("/accountledger/balance/" + address, null);
if (result.isFailed()) {
return CommandResult.getFailed(result);
}
Map<String, Object> map = (Map) result.getData();
map.put("balance", CommandHelper.naToNuls(((Map) map.get("balance")).get("value")));
map.put("usable", CommandHelper.naToNuls(((Map) map.get("usable")).get("value")));
map.put("locked", CommandHelper.naToNuls(((Map) map.get("locked")).get("value")));
result.setData(map);
return CommandResult.getResult(result);
}
use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.
the class GetPrivateKeyProcessor method execute.
@Override
public CommandResult execute(String[] args) {
String address = args[1];
RpcClientResult res = CommandHelper.getPassword(address, restFul);
if (!res.isSuccess()) {
return CommandResult.getFailed(res);
}
String password = (String) res.getData();
Map<String, Object> parameters = new HashMap<>();
parameters.put("password", password);
RpcClientResult result = restFul.post("/account/prikey/" + address, parameters);
if (result.isFailed()) {
return CommandResult.getFailed(result);
}
return CommandResult.getResult(CommandResult.dataTransformValue(result));
}
Aggregations