use of io.nuls.account.model.AccountKeyStore in project nuls by nuls-io.
the class AccountKeyStoreDto method toAccountKeyStore.
public AccountKeyStore toAccountKeyStore() {
AccountKeyStore accountKeyStore = new AccountKeyStore();
accountKeyStore.setAddress(this.address);
accountKeyStore.setAlias(this.alias);
accountKeyStore.setEncryptedPrivateKey(this.encryptedPrivateKey);
if (null == this.prikey || "null".toUpperCase().equals(this.prikey.trim().toUpperCase()) || "".equals(prikey.trim())) {
accountKeyStore.setPrikey(null);
} else {
try {
accountKeyStore.setPrikey(Hex.decode(this.prikey.trim()));
} catch (Exception e) {
accountKeyStore.setPrikey(null);
}
}
accountKeyStore.setPubKey(Hex.decode(this.pubKey));
return accountKeyStore;
}
use of io.nuls.account.model.AccountKeyStore in project nuls by nuls-io.
the class AccountServiceTest method exportAccountToKeyStore.
@Test
public void exportAccountToKeyStore() {
List<Account> accounts = this.accountService.createAccount(1, "nuls123456").getData();
Account account = accounts.get(0);
Result<AccountKeyStore> result = accountService.exportAccountToKeyStore(account.getAddress().toString(), "nuls123456");
try {
System.out.println(JSONUtils.obj2PrettyJson(result.getData()));
} catch (Exception e) {
e.printStackTrace();
}
assertNotNull(result.getData());
}
use of io.nuls.account.model.AccountKeyStore in project nuls by nuls-io.
the class AccountServiceTest method importAccount.
@Test
public void importAccount() {
AccountKeyStore accountKeyStore = new AccountKeyStore();
accountKeyStore.setAddress("Ns5fRyLX5Z6aNrxSGijUcR9SwjnVivi");
accountKeyStore.setAlias(null);
accountKeyStore.setEncryptedPrivateKey("8fd44822ecf4589c02722f2b8f8e8636cd3106c8b85f0fbc87c78bdef64512f7c604e42e3d829fdbe981fb135ed46dc8");
accountKeyStore.setPrikey(null);
accountKeyStore.setPubKey(Hex.decode("025e11c5bba00490c15ff9f0c5e24c7141204282fec3ef9b179cc77d947161c4cc"));
Result<Account> result = accountService.importAccountFormKeyStore(accountKeyStore, "nuls123456");
assertTrue(result.isSuccess());
assertNotNull(accountService.getAccount(result.getData().getAddress()));
}
Aggregations