use of com.hedera.hashgraph.sdk.AccountId in project hedera-mirror-node by hashgraph.
the class AccountClient method createCryptoAccount.
public ExpandedAccountId createCryptoAccount(Hbar initialBalance, boolean receiverSigRequired, KeyList keyList, String memo) {
// 1. Generate a Ed25519 private, public key pair
PrivateKey privateKey = PrivateKey.generate();
PublicKey publicKey = privateKey.getPublicKey();
log.trace("Private key = {}", privateKey);
log.trace("Public key = {}", publicKey);
KeyList publicKeyList = KeyList.of(privateKey.getPublicKey());
if (keyList != null) {
publicKeyList.addAll(keyList);
}
AccountCreateTransaction accountCreateTransaction = getAccountCreateTransaction(initialBalance, publicKeyList, receiverSigRequired, memo == null ? "" : memo);
NetworkTransactionResponse networkTransactionResponse = executeTransactionAndRetrieveReceipt(accountCreateTransaction, receiverSigRequired ? KeyList.of(privateKey) : null);
TransactionReceipt receipt = networkTransactionResponse.getReceipt();
AccountId newAccountId = receipt.accountId;
// verify accountId
if (receipt.accountId == null) {
throw new NetworkException(String.format("Receipt for %s returned no accountId, receipt: %s", networkTransactionResponse.getTransactionId(), receipt));
}
log.debug("Created new account {}, receiverSigRequired: {}", newAccountId, receiverSigRequired);
return new ExpandedAccountId(newAccountId, privateKey, privateKey.getPublicKey());
}
use of com.hedera.hashgraph.sdk.AccountId in project hedera-mirror-node by hashgraph.
the class TokenUpdateTransactionSupplier method get.
@Override
public TokenUpdateTransaction get() {
TokenUpdateTransaction tokenUpdateTransaction = new TokenUpdateTransaction().setMaxTransactionFee(Hbar.fromTinybars(maxTransactionFee)).setTokenMemo(Utility.getMemo("Mirror node updated test token")).setTokenName(symbol + "_name").setTokenSymbol(symbol).setTokenId(TokenId.fromString(tokenId));
if (adminKey != null) {
PublicKey key = PublicKey.fromString(adminKey);
tokenUpdateTransaction.setAdminKey(key).setFeeScheduleKey(key).setFreezeKey(key).setKycKey(key).setSupplyKey(key).setWipeKey(key);
}
if (treasuryAccountId != null) {
AccountId treastury = AccountId.fromString(treasuryAccountId);
tokenUpdateTransaction.setAutoRenewAccountId(treastury).setTreasuryAccountId(treastury);
}
if (expirationTime != null) {
tokenUpdateTransaction.setExpirationTime(expirationTime);
} else {
tokenUpdateTransaction.setAutoRenewPeriod(autoRenewPeriod);
}
return tokenUpdateTransaction;
}
use of com.hedera.hashgraph.sdk.AccountId in project hedera-mirror-node by hashgraph.
the class TokenCreateTransactionSupplier method get.
@Override
public TokenCreateTransaction get() {
AccountId treasuryAccount = AccountId.fromString(treasuryAccountId);
TokenCreateTransaction tokenCreateTransaction = new TokenCreateTransaction().setAutoRenewAccountId(treasuryAccount).setFreezeDefault(freezeDefault).setMaxTransactionFee(Hbar.fromTinybars(maxTransactionFee)).setSupplyType(supplyType).setTokenMemo(Utility.getMemo("Mirror node created test token")).setTokenName(symbol + "_name").setTokenSymbol(symbol).setTokenType(type).setTreasuryAccountId(treasuryAccount);
if (adminKey != null) {
PublicKey key = PublicKey.fromString(adminKey);
tokenCreateTransaction.setAdminKey(key).setFeeScheduleKey(key).setFreezeKey(key).setKycKey(key).setSupplyKey(key).setWipeKey(key);
}
if (type == TokenType.FUNGIBLE_COMMON) {
tokenCreateTransaction.setDecimals(decimals).setInitialSupply(initialSupply);
}
if (supplyType == TokenSupplyType.FINITE) {
tokenCreateTransaction.setMaxSupply(maxSupply);
}
return tokenCreateTransaction;
}
use of com.hedera.hashgraph.sdk.AccountId in project hedera-mirror-node by hashgraph.
the class AccountFeature method sendHbars.
@When("I send {int} ℏ to account {int}")
public void sendHbars(int amount, int accountNum) {
senderAccountId = new ExpandedAccountId(new AccountId(accountNum));
startingBalance = accountClient.getBalance(senderAccountId);
networkTransactionResponse = accountClient.sendCryptoTransfer(senderAccountId.getAccountId(), Hbar.from(amount));
assertNotNull(networkTransactionResponse.getTransactionId());
assertNotNull(networkTransactionResponse.getReceipt());
}
use of com.hedera.hashgraph.sdk.AccountId in project hedera-mirror-node by hashgraph.
the class TransactionPublisher method toClient.
private Client toClient(Map<String, AccountId> nodes) {
AccountId operatorId = AccountId.fromString(monitorProperties.getOperator().getAccountId());
PrivateKey operatorPrivateKey = PrivateKey.fromString(monitorProperties.getOperator().getPrivateKey());
Client client = Client.forNetwork(nodes);
client.setNodeMaxBackoff(publishProperties.getNodeMaxBackoff());
client.setOperator(operatorId, operatorPrivateKey);
return client;
}
Aggregations