Search in sources :

Example 36 with RpcClientResult

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");
}
Also used : HashMap(java.util.HashMap) RpcClientResult(io.nuls.kernel.model.RpcClientResult)

Example 37 with RpcClientResult

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");
}
Also used : HashMap(java.util.HashMap) RpcClientResult(io.nuls.kernel.model.RpcClientResult)

Example 38 with RpcClientResult

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);
}
Also used : HashMap(java.util.HashMap) RpcClientResult(io.nuls.kernel.model.RpcClientResult) List(java.util.List)

Example 39 with RpcClientResult

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);
}
Also used : HashMap(java.util.HashMap) RpcClientResult(io.nuls.kernel.model.RpcClientResult)

Example 40 with RpcClientResult

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));
}
Also used : HashMap(java.util.HashMap) RpcClientResult(io.nuls.kernel.model.RpcClientResult)

Aggregations

RpcClientResult (io.nuls.kernel.model.RpcClientResult)88 HashMap (java.util.HashMap)49 Map (java.util.Map)24 Date (java.util.Date)14 List (java.util.List)14 Result (io.nuls.kernel.model.Result)7 InputDto (io.nuls.accout.ledger.rpc.dto.InputDto)5 GET (javax.ws.rs.GET)5 Path (javax.ws.rs.Path)5 Produces (javax.ws.rs.Produces)5 ApiOperation (io.swagger.annotations.ApiOperation)4 ApiResponses (io.swagger.annotations.ApiResponses)4 NulsException (io.nuls.kernel.exception.NulsException)3 Na (io.nuls.kernel.model.Na)3 Node (io.nuls.network.model.Node)3 Test (org.junit.Test)3 RandomSeedDTO (io.nuls.consensus.poc.rpc.model.RandomSeedDTO)2 Coin (io.nuls.kernel.model.Coin)2 IOException (java.io.IOException)2 AccountKeyStoreDto (io.nuls.account.rpc.model.AccountKeyStoreDto)1