Search in sources :

Example 81 with RpcClientResult

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

the class ImportByKeyStoreProcessor method execute.

@Override
public CommandResult execute(String[] args) {
    String path = args[1];
    String password = CommandHelper.getPwdOptional();
    Result rs = getAccountKeystoreDto(path);
    if (rs.isFailed()) {
        return CommandResult.getFailed(rs.getMsg());
    }
    AccountKeyStoreDto accountKeyStoreDto = (AccountKeyStoreDto) rs.getData();
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("accountKeyStoreDto", accountKeyStoreDto);
    parameters.put("password", password);
    parameters.put("overwrite", false);
    RpcClientResult result = restFul.post("/account/import", parameters);
    if (result.isFailed()) {
        return CommandResult.getFailed(result);
    }
    return CommandResult.getResult(CommandResult.dataTransformValue(result));
}
Also used : HashMap(java.util.HashMap) AccountKeyStoreDto(io.nuls.account.rpc.model.AccountKeyStoreDto) RpcClientResult(io.nuls.kernel.model.RpcClientResult) CommandResult(io.nuls.kernel.model.CommandResult) RpcClientResult(io.nuls.kernel.model.RpcClientResult) Result(io.nuls.kernel.model.Result)

Example 82 with RpcClientResult

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

the class ImportForcedByPrivateKeyProcessor 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", true);
    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 83 with RpcClientResult

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

the class CreateMultiAliasProcess method execute.

@Override
public CommandResult execute(String[] args) {
    String signAddress = args[3];
    RpcClientResult res = CommandHelper.getPassword(signAddress, restFul);
    if (!res.isSuccess()) {
        return CommandResult.getFailed(res);
    }
    String password = (String) res.getData();
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("address", args[1]);
    parameters.put("alias", args[2]);
    parameters.put("signAddress", args[3]);
    parameters.put("password", password);
    RpcClientResult result = restFul.post("/account/multiAccount/mutilAlias", parameters);
    if (result.isFailed()) {
        return CommandResult.getFailed(result);
    }
    return CommandResult.getResult(CommandResult.dataMultiTransformValue(result));
}
Also used : HashMap(java.util.HashMap) RpcClientResult(io.nuls.kernel.model.RpcClientResult)

Example 84 with RpcClientResult

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

the class VerifyMessageSignatureProcessor method execute.

@Override
public CommandResult execute(String[] args) {
    String address = args[1];
    String message = args[2];
    String signatureBase64 = args[3];
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("address", address);
    parameters.put("message", message);
    parameters.put("signatureBase64", signatureBase64);
    RpcClientResult rs = restFul.post("/account/verifyMessageSignature", parameters);
    if (!rs.isSuccess()) {
        return CommandResult.getFailed(rs);
    }
    return CommandResult.getResult(rs);
}
Also used : HashMap(java.util.HashMap) RpcClientResult(io.nuls.kernel.model.RpcClientResult)

Example 85 with RpcClientResult

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

the class GetAssetProcessor method execute.

@Override
public CommandResult execute(String[] args) {
    String address = args[1];
    RpcClientResult result = restFul.get("/account/assets/" + address, null);
    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("balance", CommandHelper.naToNuls(map.get("balance")));
        map.put("usable", CommandHelper.naToNuls(map.get("usable")));
        map.put("locked", CommandHelper.naToNuls(map.get("locked")));
    }
    result.setData(list);
    return CommandResult.getResult(result);
}
Also used : RpcClientResult(io.nuls.kernel.model.RpcClientResult) List(java.util.List) Map(java.util.Map)

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