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

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

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

Address.<init>介绍

暂无

代码示例

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

public static Address fromHashs(byte[] hashs) {
  if (hashs == null || hashs.length != ADDRESS_LENGTH) {
    throw new NulsRuntimeException(KernelErrorCode.DATA_ERROR);
  }
  short chainId = SerializeUtils.bytes2Short(hashs);
  byte addressType = hashs[2];
  byte[] content = new byte[LENGTH];
  System.arraycopy(hashs, 3, content, 0, LENGTH);
  Address address = new Address(chainId, addressType, content);
  return address;
}

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

public static Address newAddress(byte[] publicKey) throws NulsException {
  return new Address(NulsContext.getInstance().getDefaultChainId(), NulsContext.DEFAULT_ADDRESS_TYPE, SerializeUtils.sha256hash160(publicKey));
}

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

/**
 * 获取脚本中的公钥生成地址
 */
public static String getScriptAddress(List<ScriptChunk> chunks) {
  if (chunks.get(0).opcode == ScriptOpCodes.OP_0) {
    byte[] redeemByte = chunks.get(chunks.size() - 1).data;
    Script redeemScript = new Script(redeemByte);
    Address address = new Address(NulsContext.getInstance().getDefaultChainId(), NulsContext.P2SH_ADDRESS_TYPE, SerializeUtils.sha256hash160(redeemScript.getProgram()));
    return address.toString();
  } else {
    return AddressTool.getStringAddressByBytes(AddressTool.getAddress(chunks.get(1).data));
  }
}

代码示例来源: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

public static Address createContractAddress() throws NulsException {
  ECKey key = new ECKey();
  return new Address(NulsContext.getInstance().getDefaultChainId(), NulsContext.CONTRACT_ADDRESS_TYPE, SerializeUtils.sha256hash160(key.getPubKey()));
}

代码示例来源: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

return Result.getFailed(AccountErrorCode.ADDRESS_ERROR).toRpcClientResult();
Address addr = new Address(address);
Result<Balance> balanceResult = accountLedgerService.getBalance(addr.getAddressBytes());
if (balanceResult.isFailed()) {

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

@Override
public Result<Address> createMultiAccount(List<String> pubkeys, int m) {
  locker.lock();
  try {
    Script redeemScript = ScriptBuilder.createNulsRedeemScript(m, pubkeys);
    Address address = new Address(NulsContext.getInstance().getDefaultChainId(), NulsContext.P2SH_ADDRESS_TYPE, SerializeUtils.sha256hash160(redeemScript.getProgram()));
    MultiSigAccount account = new MultiSigAccount();
    account.setAddress(address);
    account.setM(m);
    account.addPubkeys(pubkeys);
    Result result = this.multiSigAccountStorageService.saveAccount(account.getAddress(), account.serialize());
    if (result.isFailed()) {
      return result;
    }
    return result.setData(account);
  } catch (Exception e) {
    Log.error(e);
    throw new NulsRuntimeException(KernelErrorCode.FAILED);
  } finally {
    locker.unlock();
  }
}

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

return Result.getFailed(AccountErrorCode.PARAMETER_ERROR).toRpcClientResult();
Address address = new Address(NulsContext.getInstance().getDefaultChainId(), NulsContext.DEFAULT_ADDRESS_TYPE, SerializeUtils.sha256hash160(key.getPubKey()));
Account account = accountService.getAccount(address).getData();
if (null != account) {

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

public static Account createAccount(String prikey) throws NulsException {
  ECKey key = null;
  if (StringUtils.isBlank(prikey)) {
    key = new ECKey();
  } else {
    try {
      key = ECKey.fromPrivate(new BigInteger(1, Hex.decode(prikey)));
    } catch (Exception e) {
      throw new NulsException(AccountErrorCode.PRIVATE_KEY_WRONG, e);
    }
  }
  Address address = new Address(NulsContext.getInstance().getDefaultChainId(), NulsContext.DEFAULT_ADDRESS_TYPE, SerializeUtils.sha256hash160(key.getPubKey()));
  Account account = new Account();
  account.setEncryptedPriKey(new byte[0]);
  account.setAddress(address);
  account.setPubKey(key.getPubKey());
  account.setEcKey(key);
  account.setPriKey(key.getPrivKeyBytes());
  account.setCreateTime(TimeService.currentTimeMillis());
  return account;
}

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

public Result<Boolean> saveMultiSigAccount(String addressStr, List<String> pubkeys, int m) {
  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

for (Script scriptSig : transactionSignature.getScripts()) {
  Script redeemScript = new Script(scriptSig.getChunks().get(scriptSig.getChunks().size() - 1).data);
  Address address = new Address(NulsContext.getInstance().getDefaultChainId(), NulsContext.P2SH_ADDRESS_TYPE, SerializeUtils.sha256hash160(redeemScript.getProgram()));
  Script publicScript = SignatureUtil.createOutputScript(address.getAddressBytes());
  signtureValidFlag = scriptSig.correctlyNulsSpends(transaction, 0, publicScript);

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

return Result.getFailed(AccountErrorCode.FAILED);
account.setAddress(new Address(keyStore.getAddress()));

相关文章