io.nuls.kernel.model.Address.getAddressBytes()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(110)

本文整理了Java中io.nuls.kernel.model.Address.getAddressBytes()方法的一些代码示例,展示了Address.getAddressBytes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Address.getAddressBytes()方法的具体详情如下:
包路径:io.nuls.kernel.model.Address
类名称:Address
方法名:getAddressBytes

Address.getAddressBytes介绍

暂无

代码示例

代码示例来源:origin: nuls-io/nuls

@Override
public boolean equals(Object obj) {
  if (obj == null) {
    return false;
  }
  if (obj instanceof Address) {
    Address other = (Address) obj;
    return ArraysTool.arrayEquals(this.addressBytes, other.getAddressBytes());
  }
  return false;
}

代码示例来源:origin: nuls-io/nuls

/**
 * 获取账户余额
 */
public Result<Balance> getBalance(Address address) {
  return getBalance(address.getAddressBytes());
}

代码示例来源:origin: nuls-io/nuls

public static List<byte[]> getLocalAddresses() {
  List<byte[]> result = new ArrayList<>();
  Collection<Account> localAccountList = accountService.getAccountList().getData();
  if (localAccountList == null || localAccountList.size() == 0) {
    return result;
  }
  List<byte[]> destAddresses = new ArrayList<>();
  for (Account account : localAccountList) {
    destAddresses.add(account.getAddress().getAddressBytes());
  }
  return destAddresses;
}

代码示例来源:origin: nuls-io/nuls

public static boolean isLocalAccount(byte[] address) {
  Collection<Account> localAccountList = accountService.getAccountList().getData();
  if (localAccountList == null || localAccountList.size() == 0) {
    return false;
  }
  for (Account account : localAccountList) {
    if (Arrays.equals(account.getAddress().getAddressBytes(), address)) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: nuls-io/nuls

@Override
protected void serializeToStream(NulsOutputStreamBuffer stream) throws IOException {
  stream.write(address.getAddressBytes());
  stream.writeUint32(m);
  stream.writeUint32(pubKeyList.size());
  for (int i = 0; i < pubKeyList.size(); i++) {
    stream.writeBytesWithLength(pubKeyList.get(i));
  }
}

代码示例来源:origin: nuls-io/nuls

public static List<byte[]> getRelatedAddresses(Transaction tx) {
  List<byte[]> result = new ArrayList<>();
  if (tx == null) {
    return result;
  }
  Collection<Account> localAccountList = accountService.getAccountList().getData();
  if (localAccountList == null || localAccountList.size() == 0) {
    return result;
  }
  List<byte[]> destAddresses = new ArrayList<>();
  for (Account account : localAccountList) {
    destAddresses.add(account.getAddress().getAddressBytes());
  }
  return getRelatedAddresses(tx, destAddresses);
}

代码示例来源:origin: nuls-io/nuls

public void calcLocalPacker(Collection<Account> accountList) {
  for (Account account : accountList) {
    if(account.isEncrypted()) {
      continue;
    }
    MeetingMember member = getMember(account.getAddress().getAddressBytes());
    if (null != member) {
      this.localPacker = account;
      myMember = member;
      return;
    }
  }
}

代码示例来源:origin: nuls-io/nuls

public static byte[] getAddress(byte[] publicKey) {
  if (publicKey == null) {
    return null;
  }
  byte[] hash160 = SerializeUtils.sha256hash160(publicKey);
  Address address = new Address(NulsContext.getInstance().getDefaultChainId(), NulsContext.DEFAULT_ADDRESS_TYPE, hash160);
  return address.getAddressBytes();
}

代码示例来源:origin: nuls-io/nuls

private void initGengsisTxs(Map<String, Object> jsonMap) throws Exception {
  List<Map<String, Object>> list = (List<Map<String, Object>>) jsonMap.get(CONFIG_FILED_TXS);
  if (null == list || list.isEmpty()) {
    throw new NulsRuntimeException(KernelErrorCode.CONFIG_ERROR);
  }
  CoinData coinData = new CoinData();
  for (Map<String, Object> map : list) {
    String address = (String) map.get(CONFIG_FILED_ADDRESS);
    AssertUtil.canNotEmpty(address, KernelErrorCode.NULL_PARAMETER.getMsg());
    Double amount = Double.valueOf("" + map.get(CONFIG_FILED_AMOUNT));
    AssertUtil.canNotEmpty(amount, KernelErrorCode.NULL_PARAMETER.getMsg());
    Long lockTime = Long.valueOf("" + map.get(CONFIG_FILED_LOCK_TIME));
    Address ads = Address.fromHashs(address);
    Coin coin = new Coin(ads.getAddressBytes(), Na.parseNuls(amount), lockTime == null ? 0 : lockTime.longValue());
    coinData.addTo(coin);
  }
  CoinBaseTransaction tx = new CoinBaseTransaction();
  tx.setTime(this.blockTime);
  tx.setCoinData(coinData);
  String remark = (String) jsonMap.get(CONFIG_FILED_REMARK);
  if (StringUtils.isNotBlank(remark)) {
    tx.setRemark(Hex.decode(remark));
  }
  tx.setHash(NulsDigestData.calcDigestData(tx.serializeForHash()));
  List<Transaction> txlist = new ArrayList<>();
  txlist.add(tx);
  setTxs(txlist);
}

代码示例来源:origin: nuls-io/nuls

/**
 * Creates a scriptPubKey for the given redeem script.
 * 根据赎回脚本创建P2SH的锁定脚本
 */
public static Script createP2SHOutputScript(Script redeemScript) {
  Address address = new Address(NulsContext.getInstance().getDefaultChainId(), NulsContext.P2SH_ADDRESS_TYPE, SerializeUtils.sha256hash160(redeemScript.getProgram()));
  //byte[] hash = Utils.sha256hash160(redeemScript.getProgram());
  byte[] hash = address.getAddressBytes();
  return ScriptBuilder.createP2SHOutputScript(hash);
}

代码示例来源:origin: nuls-io/nuls

/**
 * 初始化缓存本地所有账户的余额信息
 */
public void initAccountBalance() {
  balanceMap.clear();
  Collection<Account> accounts = accountService.getAccountList().getData();
  if (accounts == null) {
    return;
  }
  for (Account account : accounts) {
    try {
      calBalanceByAddress(account.getAddress().getAddressBytes());
    } catch (NulsException e) {
      Log.info("getbalance of address[" + account.getAddress().getBase58() + "] error");
    }
  }
}

代码示例来源:origin: nuls-io/nuls

if (Arrays.equals(aliasPo.getAddress(), multiSigAccount.getAddress().getAddressBytes())) {
  multiSigAccount.setAlias(aliasPo.getAlias());
  break;

代码示例来源:origin: nuls-io/nuls

/**
 * 根据地址获取本地存储的多签账户的详细信息
 * Get the details of the locally stored multi-sign account based on the address
 *
 * @param address 多签地址
 * @return 多签账户的详细信息
 */
@Override
public Result<MultiSigAccount> getMultiSigAccount(String address) throws Exception {
  byte[] bytes = this.multiSigAccountStorageService.getAccount(Address.fromHashs(address)).getData();
  if (null == bytes) {
    return Result.getFailed(KernelErrorCode.DATA_NOT_FOUND);
  }
  MultiSigAccount account = new MultiSigAccount();
  account.parse(new NulsByteBuffer(bytes, 0));
  List<AliasPo> list = aliasStorageService.getAliasList().getData();
  for (AliasPo aliasPo : list) {
    if (aliasPo.getAddress()[2] != NulsContext.P2SH_ADDRESS_TYPE) {
      continue;
    }
    if (Arrays.equals(aliasPo.getAddress(), account.getAddress().getAddressBytes())) {
      account.setAlias(aliasPo.getAlias());
      break;
    }
  }
  return Result.getSuccess().setData(account);
}

代码示例来源:origin: nuls-io/nuls

@Override
public Result removeAccount(String address, String password) {
  if (!AddressTool.validAddress(address)) {
    return Result.getFailed(AccountErrorCode.ADDRESS_ERROR);
  }
  Account account = getAccountByAddress(address);
  if (account == null) {
    return Result.getFailed(AccountErrorCode.ACCOUNT_NOT_EXIST);
  }
  //加过密(有密码)并且没有解锁, 就验证密码 Already encrypted(Added password) and did not unlock, verify password
  if (account.isEncrypted() && account.isLocked()) {
    if (!account.validatePassword(password)) {
      return Result.getFailed(AccountErrorCode.PASSWORD_IS_WRONG);
    }
  }
  Result result = accountStorageService.removeAccount(account.getAddress());
  if (result.isFailed()) {
    return result;
  }
  accountLedgerService.deleteUnconfirmedTx(account.getAddress().getAddressBytes());
  accountCacheService.localAccountMaps.remove(account.getAddress().getBase58());
  return Result.getSuccess().setData(true);
}

代码示例来源:origin: nuls-io/nuls

@Override
public Result<Balance> getBalance() throws NulsException {
  List<Account> list = new ArrayList<>();
  Balance balance = new Balance();
  Result<List<AccountPo>> result = accountStorageService.getAccountList();
  if (result.isFailed()) {
    return Result.getFailed().setData(balance);
  }
  List<AccountPo> poList = result.getData();
  if (null == poList || poList.isEmpty()) {
    return Result.getFailed(AccountErrorCode.ACCOUNT_NOT_EXIST);
  }
  for (AccountPo po : poList) {
    Account account = po.toAccount();
    list.add(account);
  }
  for (Account account : list) {
    Result<Balance> resultBalance = accountLedgerService.getBalance(account.getAddress().getAddressBytes());
    if (resultBalance.isSuccess()) {
      Balance temp = resultBalance.getData();
      if (null == temp) {
        continue;
      }
      balance.setBalance(balance.getBalance().add(temp.getBalance()));
      balance.setLocked(balance.getLocked().add(temp.getLocked()));
      balance.setUsable(balance.getUsable().add(temp.getUsable()));
    }
  }
  return Result.getSuccess().setData(balance);
}

代码示例来源:origin: nuls-io/nuls

continue;
if (Arrays.equals(a.getAgentAddress(), account.getAddress().getAddressBytes())) {
  agent = a;
  break;

代码示例来源:origin: nuls-io/nuls

List<TransactionInfo> list = accountLedgerService.getTxInfoList(account.getAddress().getAddressBytes()).getData();
if (list == null || list.isEmpty()) {
  continue;

代码示例来源:origin: nuls-io/nuls

Script redeemScript = ScriptBuilder.createNulsRedeemScript(m, pubkeys);
Address address = new Address(NulsContext.getInstance().getDefaultChainId(), NulsContext.P2SH_ADDRESS_TYPE, SerializeUtils.sha256hash160(redeemScript.getProgram()));
if (!AddressTool.getStringAddressByBytes(address.getAddressBytes()).equals(addressStr)) {
  return Result.getFailed(AccountErrorCode.ADDRESS_ERROR);

代码示例来源:origin: nuls-io/nuls

if (KernelErrorCode.DATA_SIZE_ERROR.getCode().equals(saveResult.getErrorCode().getCode())) {
  Result rs = accountLedgerService.getMaxAmountOfOnce(account.getAddress().getAddressBytes(), tx,
      TransactionFeeCalculator.OTHER_PRICE_PRE_1024_BYTES);
  if (rs.isSuccess()) {

代码示例来源:origin: nuls-io/nuls

return Result.getFailed(AccountErrorCode.ACCOUNT_NOT_EXIST);
byte[] addressBytes = account.getAddress().getAddressBytes();
try {

相关文章