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;
}
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));
}
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);
}
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;
}
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);
}
Aggregations