Search in sources :

Example 16 with TransferTransaction

use of com.hedera.hashgraph.sdk.TransferTransaction in project hedera-mirror-node by hashgraph.

the class AccountClient method sendCryptoTransfer.

public NetworkTransactionResponse sendCryptoTransfer(AccountId recipient, Hbar hbarAmount) {
    log.debug("Send CryptoTransfer of {} tℏ from {} to {}", hbarAmount.toTinybars(), sdkClient.getExpandedOperatorAccountId().getAccountId(), recipient);
    TransferTransaction cryptoTransferTransaction = getCryptoTransferTransaction(sdkClient.getExpandedOperatorAccountId().getAccountId(), recipient, hbarAmount);
    NetworkTransactionResponse networkTransactionResponse = executeTransactionAndRetrieveReceipt(cryptoTransferTransaction);
    log.debug("Sent CryptoTransfer");
    return networkTransactionResponse;
}
Also used : NetworkTransactionResponse(com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse) TransferTransaction(com.hedera.hashgraph.sdk.TransferTransaction)

Example 17 with TransferTransaction

use of com.hedera.hashgraph.sdk.TransferTransaction in project hedera-mirror-node by hashgraph.

the class CryptoTransferTransactionSupplierTest method createWithCustomNftTransfer.

@Test
void createWithCustomNftTransfer() {
    CryptoTransferTransactionSupplier cryptoTransferTransactionSupplier = new CryptoTransferTransactionSupplier();
    cryptoTransferTransactionSupplier.setAmount(2);
    cryptoTransferTransactionSupplier.setMaxTransactionFee(1);
    cryptoTransferTransactionSupplier.setNftTokenId(TOKEN_ID.toString());
    cryptoTransferTransactionSupplier.setRecipientAccountId(ACCOUNT_ID_2.toString());
    cryptoTransferTransactionSupplier.setSenderAccountId(ACCOUNT_ID.toString());
    cryptoTransferTransactionSupplier.setSerialNumber(new AtomicLong(10));
    cryptoTransferTransactionSupplier.setTransferTypes(Set.of(NFT));
    TransferTransaction actual = cryptoTransferTransactionSupplier.get();
    assertThat(actual).returns(Collections.emptyMap(), TransferTransaction::getHbarTransfers).returns(ONE_TINYBAR, TransferTransaction::getMaxTransactionFee).returns(Collections.emptyMap(), TransferTransaction::getTokenTransfers).extracting(TransferTransaction::getTokenNftTransfers, MAP).hasSize(1).extractingByKey(TOKEN_ID, LIST).hasSize(2).extracting("serial", "sender", "receiver").containsExactlyInAnyOrder(tuple(10L, ACCOUNT_ID, ACCOUNT_ID_2), tuple(11L, ACCOUNT_ID, ACCOUNT_ID_2));
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) TransferTransaction(com.hedera.hashgraph.sdk.TransferTransaction) Test(org.junit.jupiter.api.Test) AbstractTransactionSupplierTest(com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)

Example 18 with TransferTransaction

use of com.hedera.hashgraph.sdk.TransferTransaction in project hedera-mirror-node by hashgraph.

the class CryptoTransferTransactionSupplierTest method createWithCustomCryptoTransfer.

@Test
void createWithCustomCryptoTransfer() {
    CryptoTransferTransactionSupplier cryptoTransferTransactionSupplier = new CryptoTransferTransactionSupplier();
    cryptoTransferTransactionSupplier.setAmount(10);
    cryptoTransferTransactionSupplier.setMaxTransactionFee(1);
    cryptoTransferTransactionSupplier.setRecipientAccountId(ACCOUNT_ID_2.toString());
    cryptoTransferTransactionSupplier.setSenderAccountId(ACCOUNT_ID.toString());
    cryptoTransferTransactionSupplier.setTransferTypes(Set.of(CRYPTO));
    TransferTransaction actual = cryptoTransferTransactionSupplier.get();
    Hbar transferAmount = Hbar.fromTinybars(10);
    assertThat(actual).returns(ONE_TINYBAR, TransferTransaction::getMaxTransactionFee).returns(Collections.emptyMap(), TransferTransaction::getTokenNftTransfers).returns(Collections.emptyMap(), TransferTransaction::getTokenTransfers).extracting(TransferTransaction::getHbarTransfers, MAP).hasSize(2).containsEntry(ACCOUNT_ID, transferAmount.negated()).containsEntry(ACCOUNT_ID_2, transferAmount);
}
Also used : Hbar(com.hedera.hashgraph.sdk.Hbar) TransferTransaction(com.hedera.hashgraph.sdk.TransferTransaction) Test(org.junit.jupiter.api.Test) AbstractTransactionSupplierTest(com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)

Example 19 with TransferTransaction

use of com.hedera.hashgraph.sdk.TransferTransaction in project hedera-mirror-node by hashgraph.

the class ScheduleCreateTransactionSupplier method get.

@Override
public ScheduleCreateTransaction get() {
    Hbar maxTransactionFee = Hbar.fromTinybars(getMaxTransactionFee());
    TransferTransaction innerTransaction = new TransferTransaction().setMaxTransactionFee(maxTransactionFee).addHbarTransfer(getOperatorId(), Hbar.fromTinybars(1L).negated()).addHbarTransfer(getPayerAccountId(), Hbar.fromTinybars(1L));
    ScheduleCreateTransaction scheduleCreateTransaction = new ScheduleCreateTransaction().setAdminKey(getAdminPublicKey()).setMaxTransactionFee(maxTransactionFee).setPayerAccountId(getPayerAccountId()).setScheduleMemo(Utility.getMemo("Mirror node created test schedule")).setScheduledTransaction(innerTransaction);
    return scheduleCreateTransaction;
}
Also used : Hbar(com.hedera.hashgraph.sdk.Hbar) TransferTransaction(com.hedera.hashgraph.sdk.TransferTransaction) ScheduleCreateTransaction(com.hedera.hashgraph.sdk.ScheduleCreateTransaction)

Example 20 with TransferTransaction

use of com.hedera.hashgraph.sdk.TransferTransaction in project hedera-mirror-node by hashgraph.

the class CryptoTransferTransactionSupplierTest method createWithCustomAllTransfer.

@Test
void createWithCustomAllTransfer() {
    TokenId nftTokenId = TokenId.fromString("0.0.21");
    Hbar transferAmount = Hbar.fromTinybars(2);
    CryptoTransferTransactionSupplier cryptoTransferTransactionSupplier = new CryptoTransferTransactionSupplier();
    cryptoTransferTransactionSupplier.setAmount(2);
    cryptoTransferTransactionSupplier.setMaxTransactionFee(1);
    cryptoTransferTransactionSupplier.setNftTokenId(nftTokenId.toString());
    cryptoTransferTransactionSupplier.setRecipientAccountId(ACCOUNT_ID_2.toString());
    cryptoTransferTransactionSupplier.setSenderAccountId(ACCOUNT_ID.toString());
    cryptoTransferTransactionSupplier.setSerialNumber(new AtomicLong(10));
    cryptoTransferTransactionSupplier.setTokenId(TOKEN_ID.toString());
    cryptoTransferTransactionSupplier.setTransferTypes(Set.of(CRYPTO, NFT, TOKEN));
    TransferTransaction actual = cryptoTransferTransactionSupplier.get();
    assertThat(actual).returns(ONE_TINYBAR, TransferTransaction::getMaxTransactionFee).satisfies(a -> assertThat(a.getHbarTransfers()).containsEntry(ACCOUNT_ID, transferAmount.negated()).containsEntry(ACCOUNT_ID_2, transferAmount)).satisfies(a -> assertThat(a).extracting(TransferTransaction::getTokenNftTransfers, MAP).hasSize(1).extractingByKey(nftTokenId, LIST).extracting("serial", "sender", "receiver").containsExactlyInAnyOrder(tuple(10L, ACCOUNT_ID, ACCOUNT_ID_2), tuple(11L, ACCOUNT_ID, ACCOUNT_ID_2))).extracting(TransferTransaction::getHbarTransfers, MAP).hasSize(2).containsEntry(ACCOUNT_ID, transferAmount.negated()).containsEntry(ACCOUNT_ID_2, transferAmount);
}
Also used : TokenId(com.hedera.hashgraph.sdk.TokenId) Assertions.tuple(org.assertj.core.api.Assertions.tuple) TransferTransaction(com.hedera.hashgraph.sdk.TransferTransaction) MAP(org.assertj.core.api.InstanceOfAssertFactories.MAP) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) TOKEN(com.hedera.mirror.monitor.publish.transaction.account.CryptoTransferTransactionSupplier.TransferType.TOKEN) Set(java.util.Set) CRYPTO(com.hedera.mirror.monitor.publish.transaction.account.CryptoTransferTransactionSupplier.TransferType.CRYPTO) NFT(com.hedera.mirror.monitor.publish.transaction.account.CryptoTransferTransactionSupplier.TransferType.NFT) Test(org.junit.jupiter.api.Test) AtomicLong(java.util.concurrent.atomic.AtomicLong) LIST(org.assertj.core.api.InstanceOfAssertFactories.LIST) Hbar(com.hedera.hashgraph.sdk.Hbar) Collections(java.util.Collections) AbstractTransactionSupplierTest(com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest) AtomicLong(java.util.concurrent.atomic.AtomicLong) Hbar(com.hedera.hashgraph.sdk.Hbar) TokenId(com.hedera.hashgraph.sdk.TokenId) TransferTransaction(com.hedera.hashgraph.sdk.TransferTransaction) Test(org.junit.jupiter.api.Test) AbstractTransactionSupplierTest(com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)

Aggregations

TransferTransaction (com.hedera.hashgraph.sdk.TransferTransaction)42 Hbar (com.hedera.hashgraph.sdk.Hbar)31 AccountCreateTransaction (com.hedera.hashgraph.sdk.AccountCreateTransaction)26 Test (org.junit.jupiter.api.Test)23 DisplayName (org.junit.jupiter.api.DisplayName)18 AccountId (com.hedera.hashgraph.sdk.AccountId)15 TokenCreateTransaction (com.hedera.hashgraph.sdk.TokenCreateTransaction)14 PrivateKey (com.hedera.hashgraph.sdk.PrivateKey)13 TokenAssociateTransaction (com.hedera.hashgraph.sdk.TokenAssociateTransaction)13 TransactionResponse (com.hedera.hashgraph.sdk.TransactionResponse)13 Client (com.hedera.hashgraph.sdk.Client)12 Var (com.google.errorprone.annotations.Var)10 AccountBalanceQuery (com.hedera.hashgraph.sdk.AccountBalanceQuery)10 TokenGrantKycTransaction (com.hedera.hashgraph.sdk.TokenGrantKycTransaction)8 TransactionReceipt (com.hedera.hashgraph.sdk.TransactionReceipt)8 KeyList (com.hedera.hashgraph.sdk.KeyList)7 TokenWipeTransaction (com.hedera.hashgraph.sdk.TokenWipeTransaction)7 AccountDeleteTransaction (com.hedera.hashgraph.sdk.AccountDeleteTransaction)6 ScheduleInfoQuery (com.hedera.hashgraph.sdk.ScheduleInfoQuery)6 ScheduleSignTransaction (com.hedera.hashgraph.sdk.ScheduleSignTransaction)6