@Override public CommandResult execute(String[] args) { String prikey = args[1]; String password = CommandHelper.getPwdOptional(); if(StringUtils.isNotBlank(password)){ CommandHelper.confirmPwd(password); } Map<String, Object> parameters = new HashMap<>(); parameters.put("priKey", prikey); parameters.put("password", password); parameters.put("overwrite", false); RpcClientResult result = restFul.post("/account/import/pri", parameters); if (result.isFailed()) { return CommandResult.getFailed(result); } return CommandResult.getResult(CommandResult.dataTransformValue(result)); } }
@Override public CommandResult execute(String[] args) { String prikey = args[1]; String password = CommandHelper.getPwdOptional(); if(StringUtils.isNotBlank(password)){ CommandHelper.confirmPwd(password); } Map<String, Object> parameters = new HashMap<>(); parameters.put("priKey", prikey); parameters.put("password", password); parameters.put("overwrite", true); RpcClientResult result = restFul.post("/account/import/pri", parameters); if (result.isFailed()) { return CommandResult.getFailed(result); } return CommandResult.getResult(CommandResult.dataTransformValue(result)); }
@Override public CommandResult execute(String[] args) { String password = CommandHelper.getPwdOptional(); if(StringUtils.isNotBlank(password)){ CommandHelper.confirmPwd(password); } int count = 1; if(args.length == 2){ count = Integer.parseInt(args[1]); } Map<String, Object> parameters = new HashMap<>(); parameters.put("password", password); parameters.put("count", count); RpcClientResult result = restFul.post("/account", parameters); if(result.isFailed()){ return CommandResult.getFailed(result); } return CommandResult.getResult(CommandResult.dataTransformList(result)); } }
@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"); } }
@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"); } }