Search in sources :

Example 76 with RpcClientResult

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

Example 77 with RpcClientResult

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

Example 78 with RpcClientResult

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

Example 79 with RpcClientResult

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

Example 80 with RpcClientResult

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));
}
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