Search in sources :

Example 86 with RpcClientResult

use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.

the class GetWalletBalanceProcessor method execute.

@Override
public CommandResult execute(String[] args) {
    RpcClientResult result = restFul.get("/account/balance", 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 87 with RpcClientResult

use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.

the class ImportByPrivateKeyProcessor method execute.

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

Example 88 with RpcClientResult

use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.

the class SignMessageProcessor method execute.

@Override
public CommandResult execute(String[] args) {
    String address = args[1];
    String message = 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("address", address);
    parameters.put("password", password);
    parameters.put("message", message);
    RpcClientResult rs = restFul.post("/account/signMessage", parameters);
    if (!rs.isSuccess()) {
        return CommandResult.getFailed(rs);
    }
    return CommandResult.getResult(rs);
}
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