Search in sources :

Example 6 with PublicKey

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");
}
Also used : PublicKey(com.hedera.hashgraph.sdk.PublicKey) AccountCreateTransaction(com.hedera.hashgraph.sdk.AccountCreateTransaction) Test(org.junit.jupiter.api.Test) AbstractTransactionSupplierTest(com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)

Example 7 with PublicKey

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");
}
Also used : TopicCreateTransaction(com.hedera.hashgraph.sdk.TopicCreateTransaction) PublicKey(com.hedera.hashgraph.sdk.PublicKey) Test(org.junit.jupiter.api.Test) AbstractTransactionSupplierTest(com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)

Example 8 with PublicKey

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());
}
Also used : PrivateKey(com.hedera.hashgraph.sdk.PrivateKey) NetworkTransactionResponse(com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse) AccountId(com.hedera.hashgraph.sdk.AccountId) ExpandedAccountId(com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId) PublicKey(com.hedera.hashgraph.sdk.PublicKey) KeyList(com.hedera.hashgraph.sdk.KeyList) ExpandedAccountId(com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId) TransactionReceipt(com.hedera.hashgraph.sdk.TransactionReceipt) AccountCreateTransaction(com.hedera.hashgraph.sdk.AccountCreateTransaction)

Example 9 with PublicKey

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");
}
Also used : TopicUpdateTransaction(com.hedera.hashgraph.sdk.TopicUpdateTransaction) PublicKey(com.hedera.hashgraph.sdk.PublicKey) Duration(java.time.Duration) Test(org.junit.jupiter.api.Test) AbstractTransactionSupplierTest(com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)

Example 10 with PublicKey

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");
}
Also used : PublicKey(com.hedera.hashgraph.sdk.PublicKey) TokenCreateTransaction(com.hedera.hashgraph.sdk.TokenCreateTransaction) Test(org.junit.jupiter.api.Test) AbstractTransactionSupplierTest(com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)

Aggregations

PublicKey (com.hedera.hashgraph.sdk.PublicKey)25 AccountId (com.hedera.hashgraph.sdk.AccountId)9 PrivateKey (com.hedera.hashgraph.sdk.PrivateKey)9 AbstractTransactionSupplierTest (com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)8 Test (org.junit.jupiter.api.Test)8 AccountCreateTransaction (com.hedera.hashgraph.sdk.AccountCreateTransaction)7 Client (com.hedera.hashgraph.sdk.Client)6 TransactionReceipt (com.hedera.hashgraph.sdk.TransactionReceipt)6 TransactionResponse (com.hedera.hashgraph.sdk.TransactionResponse)6 Hbar (com.hedera.hashgraph.sdk.Hbar)4 KeyList (com.hedera.hashgraph.sdk.KeyList)4 TokenCreateTransaction (com.hedera.hashgraph.sdk.TokenCreateTransaction)4 TransferTransaction (com.hedera.hashgraph.sdk.TransferTransaction)4 AccountBalanceQuery (com.hedera.hashgraph.sdk.AccountBalanceQuery)3 TokenUpdateTransaction (com.hedera.hashgraph.sdk.TokenUpdateTransaction)3 TopicCreateTransaction (com.hedera.hashgraph.sdk.TopicCreateTransaction)3 NetworkTransactionResponse (com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse)3 AccountBalance (com.hedera.hashgraph.sdk.AccountBalance)2 AccountDeleteTransaction (com.hedera.hashgraph.sdk.AccountDeleteTransaction)2 ScheduleCreateTransaction (com.hedera.hashgraph.sdk.ScheduleCreateTransaction)2