Search in sources :

Example 16 with AccountId

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());
}
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 17 with AccountId

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;
}
Also used : AccountId(com.hedera.hashgraph.sdk.AccountId) PublicKey(com.hedera.hashgraph.sdk.PublicKey) TokenUpdateTransaction(com.hedera.hashgraph.sdk.TokenUpdateTransaction)

Example 18 with AccountId

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;
}
Also used : AccountId(com.hedera.hashgraph.sdk.AccountId) PublicKey(com.hedera.hashgraph.sdk.PublicKey) TokenCreateTransaction(com.hedera.hashgraph.sdk.TokenCreateTransaction)

Example 19 with AccountId

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());
}
Also used : AccountId(com.hedera.hashgraph.sdk.AccountId) ExpandedAccountId(com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId) ExpandedAccountId(com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId) When(io.cucumber.java.en.When)

Example 20 with AccountId

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;
}
Also used : AccountId(com.hedera.hashgraph.sdk.AccountId) PrivateKey(com.hedera.hashgraph.sdk.PrivateKey) Client(com.hedera.hashgraph.sdk.Client)

Aggregations

AccountId (com.hedera.hashgraph.sdk.AccountId)35 Client (com.hedera.hashgraph.sdk.Client)20 PrivateKey (com.hedera.hashgraph.sdk.PrivateKey)17 Hbar (com.hedera.hashgraph.sdk.Hbar)16 TransferTransaction (com.hedera.hashgraph.sdk.TransferTransaction)16 AccountCreateTransaction (com.hedera.hashgraph.sdk.AccountCreateTransaction)15 TransactionResponse (com.hedera.hashgraph.sdk.TransactionResponse)14 TransactionReceipt (com.hedera.hashgraph.sdk.TransactionReceipt)11 AccountBalanceQuery (com.hedera.hashgraph.sdk.AccountBalanceQuery)10 KeyList (com.hedera.hashgraph.sdk.KeyList)9 PublicKey (com.hedera.hashgraph.sdk.PublicKey)9 Var (com.google.errorprone.annotations.Var)8 ExpandedAccountId (com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId)7 AccountDeleteTransaction (com.hedera.hashgraph.sdk.AccountDeleteTransaction)6 ScheduleId (com.hedera.hashgraph.sdk.ScheduleId)5 ScheduleInfoQuery (com.hedera.hashgraph.sdk.ScheduleInfoQuery)5 ScheduleSignTransaction (com.hedera.hashgraph.sdk.ScheduleSignTransaction)5 TimeoutException (java.util.concurrent.TimeoutException)5 AccountBalance (com.hedera.hashgraph.sdk.AccountBalance)4 ScheduleCreateTransaction (com.hedera.hashgraph.sdk.ScheduleCreateTransaction)4