use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.
the class ResetPasswordProcessor method execute.
@Override
public CommandResult execute(String[] args) {
String address = args[1];
RpcClientResult res = CommandHelper.getPassword(address, restFul, "Enter your old password:");
if (!res.isSuccess()) {
return CommandResult.getFailed(res);
}
if (res.isSuccess() && null == res.getData()) {
return CommandResult.getFailed("No password has been set up yet");
}
String password = (String) res.getData();
String newPassword = CommandHelper.getNewPwd();
CommandHelper.confirmPwd(newPassword);
Map<String, Object> parameters = new HashMap<>();
parameters.put("password", password);
parameters.put("newPassword", newPassword);
RpcClientResult result = restFul.put("/account/password/" + address, parameters);
if (result.isFailed()) {
return CommandResult.getFailed(result);
}
return CommandResult.getSuccess("Success");
}
use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.
the class SetPasswordProcessor method execute.
@Override
public CommandResult execute(String[] args) {
String address = args[1];
RpcClientResult rs = restFul.get("/account/encrypted/" + address, null);
if (!rs.isSuccess()) {
return CommandResult.getFailed(rs);
}
if (rs.isSuccess() && rs.dataToBooleanValue()) {
return CommandResult.getFailed("This account already has a password.");
}
String password = CommandHelper.getNewPwd();
CommandHelper.confirmPwd(password);
Map<String, Object> parameters = new HashMap<>();
parameters.put("password", password);
RpcClientResult result = restFul.post("/account/password/" + address, parameters);
if (result.isFailed()) {
return CommandResult.getFailed(result);
}
return CommandResult.getSuccess("Success");
}
use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.
the class GetMultiSigAccountCountProcessor method execute.
@Override
public CommandResult execute(String[] args) {
RpcClientResult result = restFul.get("/account/multiAccounts", null);
if (result.isFailed()) {
return CommandResult.getFailed(result);
}
List list = (List) result.getData();
Map<String, Integer> map = new HashMap<>();
map.put("count", list.size());
result.setData(map);
return CommandResult.getResult(result);
}
use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.
the class ImportMultiSigAccountProcessor method execute.
@Override
public CommandResult execute(String[] args) {
Map<String, Object> parameters = new HashMap<>();
String pubkeysStr = args[2];
parameters.put("address", args[1]);
parameters.put("pubkeys", pubkeysStr.split(","));
parameters.put("m", args[3]);
RpcClientResult result = restFul.post("/account/importMultiAccount", parameters);
if (result.isFailed()) {
return CommandResult.getFailed(result);
}
return CommandResult.getResult(result);
}
use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.
the class SetAliasProcessor 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("alias", args[2]);
parameters.put("password", password);
RpcClientResult result = restFul.post("/account/alias/" + address, parameters);
if (result.isFailed()) {
return CommandResult.getFailed(result);
}
return CommandResult.getResult(CommandResult.dataTransformValue(result));
}
Aggregations