Search in sources :

Example 56 with Account

use of io.nuls.account.model.Account in project nuls by nuls-io.

the class AccountServiceTest method removeAccount.

@Test
public void removeAccount() {
    List<Account> accounts = this.accountService.createAccount(2, "nuls123456").getData();
    Result result0 = accountService.removeAccount(accounts.get(0).getAddress().toString(), "nuls123456");
    assertTrue(result0.isSuccess());
    Result result1 = accountService.removeAccount(accounts.get(1).getAddress().toString(), "123456");
    assertTrue(result1.isFailed());
}
Also used : Account(io.nuls.account.model.Account) Result(io.nuls.kernel.model.Result) Test(org.junit.Test)

Example 57 with Account

use of io.nuls.account.model.Account 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());
}
Also used : Account(io.nuls.account.model.Account) AccountKeyStore(io.nuls.account.model.AccountKeyStore) Test(org.junit.Test)

Example 58 with Account

use of io.nuls.account.model.Account in project nuls by nuls-io.

the class AccountServiceTest method isEncypted.

@Test
public void isEncypted() {
    List<Account> accounts = this.accountService.createAccount(1, "nuls123456").getData();
    Account account = accounts.get(0);
    assertTrue(accountService.isEncrypted(account.getAddress().toString()).isSuccess());
    List<Account> accounts2 = this.accountService.createAccount(1, "").getData();
    Account account2 = accounts2.get(0);
    assertTrue(accountService.isEncrypted(account2.getAddress().toString()).isFailed());
}
Also used : Account(io.nuls.account.model.Account) Test(org.junit.Test)

Example 59 with Account

use of io.nuls.account.model.Account 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()));
}
Also used : Account(io.nuls.account.model.Account) AccountKeyStore(io.nuls.account.model.AccountKeyStore) Test(org.junit.Test)

Example 60 with Account

use of io.nuls.account.model.Account in project nuls by nuls-io.

the class AliasServiceTest method saveAlias.

@Test
public void saveAlias() {
    List<Account> accounts = accountService.createAccount(1, "nuls123456").getData();
    Account account = accounts.get(0);
    Alias alias = new Alias(account.getAddress().getAddressBytes(), "lichao");
    try {
        assertTrue(aliasService.saveAlias(new AliasPo(alias)).isSuccess());
    } catch (NulsException e) {
        e.printStackTrace();
    }
}
Also used : Account(io.nuls.account.model.Account) Alias(io.nuls.account.model.Alias) NulsException(io.nuls.kernel.exception.NulsException) AliasPo(io.nuls.account.storage.po.AliasPo) Test(org.junit.Test)

Aggregations

Account (io.nuls.account.model.Account)65 NulsException (io.nuls.kernel.exception.NulsException)38 MultiSigAccount (io.nuls.account.model.MultiSigAccount)30 CoinDataResult (io.nuls.account.ledger.model.CoinDataResult)28 IOException (java.io.IOException)28 NulsRuntimeException (io.nuls.kernel.exception.NulsRuntimeException)16 UnsupportedEncodingException (java.io.UnsupportedEncodingException)13 ECKey (io.nuls.core.tools.crypto.ECKey)12 ContractResult (io.nuls.contract.dto.ContractResult)11 Test (org.junit.Test)11 TransferTransaction (io.nuls.protocol.model.tx.TransferTransaction)9 TransactionDataResult (io.nuls.account.ledger.model.TransactionDataResult)7 ValidateResult (io.nuls.kernel.validate.ValidateResult)7 Agent (io.nuls.consensus.poc.protocol.entity.Agent)6 CancelDeposit (io.nuls.consensus.poc.protocol.entity.CancelDeposit)6 StopAgent (io.nuls.consensus.poc.protocol.entity.StopAgent)6 CancelDepositTransaction (io.nuls.consensus.poc.protocol.tx.CancelDepositTransaction)6 DepositTransaction (io.nuls.consensus.poc.protocol.tx.DepositTransaction)6 Result (io.nuls.kernel.model.Result)6 ArrayList (java.util.ArrayList)6