use of com.hedera.hashgraph.sdk.AccountCreateTransaction in project hedera-sdk-java by hashgraph.
the class ReceiptQueryIntegrationTest method getCostBigMaxTransactionRecord.
@Test
@DisplayName("Can get Record cost with big max set")
@SuppressWarnings("UnusedVariable")
void getCostBigMaxTransactionRecord() throws Exception {
var testEnv = new IntegrationTestEnv(1);
var key = PrivateKey.generateED25519();
var response = new AccountCreateTransaction().setKey(key).execute(testEnv.client);
new TransactionReceiptQuery().setTransactionId(response.transactionId).execute(testEnv.client);
var recordQuery = new TransactionRecordQuery().setTransactionId(response.transactionId).setMaxQueryPayment(new Hbar(1000));
var cost = recordQuery.getCost(testEnv.client);
var record = recordQuery.execute(testEnv.client);
testEnv.close(record.receipt.accountId, key);
}
use of com.hedera.hashgraph.sdk.AccountCreateTransaction in project hedera-sdk-java by hashgraph.
the class ReceiptQueryIntegrationTest method getCostInsufficientTxFeeTransactionRecord.
@Test
@DisplayName("Insufficient transaction fee error for transaction record query")
void getCostInsufficientTxFeeTransactionRecord() throws Exception {
var testEnv = new IntegrationTestEnv(1);
var key = PrivateKey.generateED25519();
var response = new AccountCreateTransaction().setKey(key).execute(testEnv.client);
var receipt = new TransactionReceiptQuery().setTransactionId(response.transactionId).execute(testEnv.client);
var recordQuery = new TransactionRecordQuery().setTransactionId(response.transactionId);
assertThatExceptionOfType(PrecheckStatusException.class).isThrownBy(() -> {
recordQuery.setQueryPayment(Hbar.fromTinybars(1)).execute(testEnv.client);
}).satisfies(error -> assertThat(error.status.toString()).isEqualTo("INSUFFICIENT_TX_FEE"));
testEnv.close(receipt.accountId, key);
}
use of com.hedera.hashgraph.sdk.AccountCreateTransaction 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.AccountCreateTransaction in project hedera-mirror-node by hashgraph.
the class AccountCreateTransactionSupplierTest method createWithMinimumData.
@Test
void createWithMinimumData() {
AccountCreateTransactionSupplier accountCreateTransactionSupplier = new AccountCreateTransactionSupplier();
AccountCreateTransaction actual = accountCreateTransactionSupplier.get();
assertThat(actual).returns(Hbar.fromTinybars(10_000_000), AccountCreateTransaction::getInitialBalance).returns(MAX_TRANSACTION_FEE_HBAR, AccountCreateTransaction::getMaxTransactionFee).returns(false, AccountCreateTransaction::getReceiverSignatureRequired).satisfies(a -> assertThat(a.getKey()).isNotNull()).extracting(AccountCreateTransaction::getAccountMemo, STRING).contains("Mirror node created test account");
}
use of com.hedera.hashgraph.sdk.AccountCreateTransaction 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());
}
Aggregations