@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(); } }
public Result saveAlias(AliasPo aliaspo) throws NulsException { try { Result result = aliasStorageService.saveAlias(aliaspo); if (result.isFailed()) { this.rollbackAlias(aliaspo); } AccountPo po = accountStorageService.getAccount(aliaspo.getAddress()).getData(); if (null != po) { po.setAlias(aliaspo.getAlias()); Result resultAcc = accountStorageService.updateAccount(po); if (resultAcc.isFailed()) { this.rollbackAlias(aliaspo); } Account account = po.toAccount(); accountCacheService.localAccountMaps.put(account.getAddress().getBase58(), account); } } catch (Exception e) { this.rollbackAlias(aliaspo); Log.error(e); return Result.getFailed(AccountErrorCode.FAILED); } return Result.getSuccess().setData(true); }
AliasService { public Result saveAlias(AliasPo aliaspo) throws NulsException { try { Result result = aliasStorageService.saveAlias(aliaspo); if (result.isFailed()) { this.rollbackAlias(aliaspo); } AccountPo po = accountStorageService.getAccount(aliaspo.getAddress()).getData(); if (null != po) { po.setAlias(aliaspo.getAlias()); Result resultAcc = accountStorageService.updateAccount(po); if (resultAcc.isFailed()) { this.rollbackAlias(aliaspo); } Account account = po.toAccount(); accountCacheService.localAccountMaps.put(account.getAddress().getBase58(), account); } } catch (Exception e) { this.rollbackAlias(aliaspo); Log.error(e); return Result.getFailed(AccountErrorCode.FAILED); } return Result.getSuccess().setData(true); } }
AliasService { public Result saveAlias(AliasPo aliaspo) throws NulsException { try { Result result = aliasStorageService.saveAlias(aliaspo); if (result.isFailed()) { this.rollbackAlias(aliaspo); } AccountPo po = accountStorageService.getAccount(aliaspo.getAddress()).getData(); if (null != po) { po.setAlias(aliaspo.getAlias()); Result resultAcc = accountStorageService.updateAccount(po); if (resultAcc.isFailed()) { this.rollbackAlias(aliaspo); } Account account = po.toAccount(); accountCacheService.localAccountMaps.put(account.getAddress().getBase58(), account); } } catch (Exception e) { this.rollbackAlias(aliaspo); Log.error(e); return Result.getFailed(AccountErrorCode.FAILED); } return Result.getSuccess().setData(true); }  }
AliasService { public Result saveAlias(AliasPo aliaspo) throws NulsException { try { Result result = aliasStorageService.saveAlias(aliaspo); if (result.isFailed()) { this.rollbackAlias(aliaspo); } AccountPo po = accountStorageService.getAccount(aliaspo.getAddress()).getData(); if (null != po) { po.setAlias(aliaspo.getAlias()); Result resultAcc = accountStorageService.updateAccount(po); if (resultAcc.isFailed()) { this.rollbackAlias(aliaspo); } Account account = po.toAccount(); accountCacheService.localAccountMaps.put(account.getAddress().getBase58(), account); } } catch (Exception e) { this.rollbackAlias(aliaspo); Log.error(e); return Result.getFailed(AccountErrorCode.FAILED); } return Result.getSuccess().setData(true); }  Result<String> setAlias(String addr, String aliasName, String password); Result saveAlias(AliasPo aliaspo); Alias getAlias(String alias); boolean isAliasUsable(String alias); Result rollbackAlias(AliasPo aliasPo); Result<Na> getAliasFee(String address, String aliasName); Result<Na> getMultiAliasFee(String address, String aliasName); Result<String> setMutilAlias(String addr, String signAddr, String aliasName, String password, List<String> pubKeys, int m, String txdata); Result<String> setMutilAlias(String addr, String signAddr, String aliasName, String password); Result signMultiAliasTransaction(String signAddr, String password, String txdata); boolean isMutilAliasUsable(byte[] address, String aliasName); Result<String> txMutilProcessing(Transaction tx, List<P2PHKSignature> p2PHKSignatures, List<Script> scripts, TransactionSignature transactionSignature, byte[] fromAddr); List<AliasPo> getAllAlias(); }
AliasService { public Result saveAlias(AliasPo aliaspo) throws NulsException { try { Result result = aliasStorageService.saveAlias(aliaspo); if (result.isFailed()) { this.rollbackAlias(aliaspo); } AccountPo po = accountStorageService.getAccount(aliaspo.getAddress()).getData(); if (null != po) { po.setAlias(aliaspo.getAlias()); Result resultAcc = accountStorageService.updateAccount(po); if (resultAcc.isFailed()) { this.rollbackAlias(aliaspo); } Account account = po.toAccount(); accountCacheService.localAccountMaps.put(account.getAddress().getBase58(), account); } } catch (Exception e) { this.rollbackAlias(aliaspo); Log.error(e); return Result.getFailed(AccountErrorCode.FAILED); } return Result.getSuccess().setData(true); }  Result<String> setAlias(String addr, String aliasName, String password); Result saveAlias(AliasPo aliaspo); Alias getAlias(String alias); boolean isAliasUsable(String alias); Result rollbackAlias(AliasPo aliasPo); Result<Na> getAliasFee(String address, String aliasName); Result<Na> getMultiAliasFee(String address, String aliasName); Result<String> setMutilAlias(String addr, String signAddr, String aliasName, String password, List<String> pubKeys, int m, String txdata); Result<String> setMutilAlias(String addr, String signAddr, String aliasName, String password); Result signMultiAliasTransaction(String signAddr, String password, String txdata); boolean isMutilAliasUsable(byte[] address, String aliasName); Result<String> txMutilProcessing(Transaction tx, List<P2PHKSignature> p2PHKSignatures, List<Script> scripts, TransactionSignature transactionSignature, byte[] fromAddr); List<AliasPo> getAllAlias();  }