use of com.hedera.hashgraph.sdk.PublicKey in project hedera-mirror-node by hashgraph.
the class AccountCreateTransactionSupplierTest method createWithCustomData.
@Test
void createWithCustomData() {
PublicKey key = PrivateKey.generate().getPublicKey();
AccountCreateTransactionSupplier accountCreateTransactionSupplier = new AccountCreateTransactionSupplier();
accountCreateTransactionSupplier.setInitialBalance(1);
accountCreateTransactionSupplier.setMaxTransactionFee(1);
accountCreateTransactionSupplier.setReceiverSignatureRequired(true);
accountCreateTransactionSupplier.setPublicKey(key.toString());
AccountCreateTransaction actual = accountCreateTransactionSupplier.get();
assertThat(actual).returns(ONE_TINYBAR, AccountCreateTransaction::getInitialBalance).returns(key, AccountCreateTransaction::getKey).returns(ONE_TINYBAR, AccountCreateTransaction::getMaxTransactionFee).returns(true, AccountCreateTransaction::getReceiverSignatureRequired).extracting(AccountCreateTransaction::getAccountMemo, STRING).contains("Mirror node created test account");
}
use of com.hedera.hashgraph.sdk.PublicKey in project hedera-mirror-node by hashgraph.
the class ConsensusCreateTopicTransactionSupplierTest method createWithCustomData.
@Test
void createWithCustomData() {
PublicKey key = PrivateKey.generate().getPublicKey();
ConsensusCreateTopicTransactionSupplier consensusCreateTopicTransactionSupplier = new ConsensusCreateTopicTransactionSupplier();
consensusCreateTopicTransactionSupplier.setAdminKey(key.toString());
consensusCreateTopicTransactionSupplier.setAutoRenewAccountId(ACCOUNT_ID.toString());
consensusCreateTopicTransactionSupplier.setMaxTransactionFee(1);
TopicCreateTransaction actual = consensusCreateTopicTransactionSupplier.get();
assertThat(actual).returns(key, TopicCreateTransaction::getAdminKey).returns(ACCOUNT_ID, TopicCreateTransaction::getAutoRenewAccountId).returns(ONE_TINYBAR, TopicCreateTransaction::getMaxTransactionFee).returns(key, TopicCreateTransaction::getSubmitKey).extracting(TopicCreateTransaction::getTopicMemo, STRING).contains("Mirror node created test topic");
}
use of com.hedera.hashgraph.sdk.PublicKey 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.PublicKey in project hedera-mirror-node by hashgraph.
the class ConsensusUpdateTopicTransactionSupplierTest method createWithCustomData.
@Test
void createWithCustomData() {
PublicKey key = PrivateKey.generate().getPublicKey();
Duration autoRenewPeriod = Duration.ofSeconds(1);
ConsensusUpdateTopicTransactionSupplier consensusUpdateTopicTransactionSupplier = new ConsensusUpdateTopicTransactionSupplier();
consensusUpdateTopicTransactionSupplier.setAdminKey(key.toString());
consensusUpdateTopicTransactionSupplier.setAutoRenewAccountId("0.0.2");
consensusUpdateTopicTransactionSupplier.setAutoRenewPeriod(autoRenewPeriod);
consensusUpdateTopicTransactionSupplier.setMaxTransactionFee(1);
consensusUpdateTopicTransactionSupplier.setTopicId(TOPIC_ID.toString());
TopicUpdateTransaction actual = consensusUpdateTopicTransactionSupplier.get();
assertThat(actual).returns(key, TopicUpdateTransaction::getAdminKey).returns(AccountId.fromString("0.0.2"), TopicUpdateTransaction::getAutoRenewAccountId).returns(autoRenewPeriod, TopicUpdateTransaction::getAutoRenewPeriod).returns(ONE_TINYBAR, TopicUpdateTransaction::getMaxTransactionFee).returns(key, TopicUpdateTransaction::getSubmitKey).returns(TOPIC_ID, TopicUpdateTransaction::getTopicId).extracting(TopicUpdateTransaction::getTopicMemo, STRING).contains("Mirror node updated test topic");
}
use of com.hedera.hashgraph.sdk.PublicKey in project hedera-mirror-node by hashgraph.
the class TokenCreateTransactionSupplierTest method createWithCustomFungibleData.
@Test
void createWithCustomFungibleData() {
PublicKey key = PrivateKey.generate().getPublicKey();
TokenCreateTransactionSupplier tokenCreateTransactionSupplier = new TokenCreateTransactionSupplier();
tokenCreateTransactionSupplier.setAdminKey(key.toString());
tokenCreateTransactionSupplier.setDecimals(1);
tokenCreateTransactionSupplier.setFreezeDefault(true);
tokenCreateTransactionSupplier.setInitialSupply(1);
tokenCreateTransactionSupplier.setMaxSupply(1);
tokenCreateTransactionSupplier.setMaxTransactionFee(1);
tokenCreateTransactionSupplier.setSupplyType(TokenSupplyType.FINITE);
tokenCreateTransactionSupplier.setSymbol("TEST");
tokenCreateTransactionSupplier.setTreasuryAccountId(ACCOUNT_ID.toString());
tokenCreateTransactionSupplier.setType(TokenType.FUNGIBLE_COMMON);
TokenCreateTransaction actual = tokenCreateTransactionSupplier.get();
assertThat(actual).returns(key, TokenCreateTransaction::getAdminKey).returns(ACCOUNT_ID, TokenCreateTransaction::getAutoRenewAccountId).returns(1, TokenCreateTransaction::getDecimals).returns(key, TokenCreateTransaction::getFeeScheduleKey).returns(true, TokenCreateTransaction::getFreezeDefault).returns(key, TokenCreateTransaction::getFreezeKey).returns(1L, TokenCreateTransaction::getInitialSupply).returns(key, TokenCreateTransaction::getKycKey).returns(1L, TokenCreateTransaction::getMaxSupply).returns(ONE_TINYBAR, TokenCreateTransaction::getMaxTransactionFee).returns(key, TokenCreateTransaction::getSupplyKey).returns(TokenSupplyType.FINITE, TokenCreateTransaction::getSupplyType).returns(TokenType.FUNGIBLE_COMMON, TokenCreateTransaction::getTokenType).returns(ACCOUNT_ID, TokenCreateTransaction::getTreasuryAccountId).returns(key, TokenCreateTransaction::getWipeKey).extracting(TokenCreateTransaction::getTokenMemo, STRING).contains("Mirror node created test token");
}
Aggregations