use of com.hedera.hashgraph.sdk.TransactionReceipt 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());
}
use of com.hedera.hashgraph.sdk.TransactionReceipt in project hedera-mirror-node by hashgraph.
the class PublishMetricsTest method onErrorReceiptStatusException.
@Test
void onErrorReceiptStatusException() throws Exception {
TransactionId transactionId = TransactionId.withValidStart(AccountId.fromString("0.0.3"), Instant.now());
TransactionReceipt transactionReceipt = receipt(ResponseCodeEnum.SUCCESS);
Constructor<ReceiptStatusException> constructor = getDeclaredConstructor(ReceiptStatusException.class);
constructor.setAccessible(true);
ReceiptStatusException receiptStatusException = constructor.newInstance(transactionId, transactionReceipt);
onError(receiptStatusException, ResponseCodeEnum.SUCCESS.toString());
}
use of com.hedera.hashgraph.sdk.TransactionReceipt in project hedera-mirror-node by hashgraph.
the class ScheduleFeature method verifyNetworkScheduleStatus.
@Retryable(value = { AssertionError.class }, backoff = @Backoff(delayExpression = "#{@acceptanceTestProperties.backOffPeriod.toMillis()}"), maxAttemptsExpression = "#{@acceptanceTestProperties.maxRetries}")
public void verifyNetworkScheduleStatus(ScheduleStatus scheduleStatus) {
scheduleInfo = scheduleClient.getScheduleInfo(scheduleId);
// verify executed from 3 min record, set scheduled=true on scheduleCreateTransactionId and get receipt
validateScheduleInfo(scheduleInfo);
switch(scheduleStatus) {
case NON_EXECUTED:
assertThat(scheduleInfo.executedAt).isNull();
assertThat(scheduleInfo.deletedAt).isNull();
break;
case EXECUTED:
assertThat(scheduleInfo.deletedAt).isNull();
assertThat(scheduleInfo.executedAt).isNotNull();
TransactionReceipt transactionReceipt = scheduleClient.getTransactionReceipt(scheduledTransactionId);
assertNotNull(transactionReceipt);
log.debug("Executed transaction {} was confirmed", scheduledTransactionId);
break;
case DELETED:
assertThat(scheduleInfo.deletedAt).isNotNull();
assertThat(scheduleInfo.executedAt).isNull();
break;
default:
break;
}
log.info("Schedule {} status was confirmed by network state", scheduleId);
}
use of com.hedera.hashgraph.sdk.TransactionReceipt in project hedera-mirror-node by hashgraph.
the class TopicClient method publishMessageToTopicAndVerify.
public TransactionReceipt publishMessageToTopicAndVerify(TopicId topicId, byte[] message, KeyList submitKeys) {
TransactionId transactionId = publishMessageToTopic(topicId, message, submitKeys);
TransactionReceipt transactionReceipt = null;
try {
transactionReceipt = getTransactionReceipt(transactionId);
// note time stamp
recordPublishInstants.put(transactionReceipt.topicSequenceNumber, getTransactionRecord(transactionId).consensusTimestamp);
} catch (Exception e) {
log.error("Error retrieving transaction receipt", e);
}
log.trace("Verified message published : '{}' to topicId : {} with sequence number : {}", message, topicId, transactionReceipt.topicSequenceNumber);
return transactionReceipt;
}
use of com.hedera.hashgraph.sdk.TransactionReceipt in project hedera-mirror-node by hashgraph.
the class TokenFeature method mintNftToken.
@Given("I mint a serial number from the token")
public void mintNftToken() {
TokenId tokenId = tokenIds.get(0);
networkTransactionResponse = tokenClient.mint(tokenId, RandomUtils.nextBytes(4));
assertNotNull(networkTransactionResponse.getTransactionId());
TransactionReceipt receipt = networkTransactionResponse.getReceipt();
assertNotNull(receipt);
assertThat(receipt.serials.size()).isEqualTo(1);
long serialNumber = receipt.serials.get(0);
assertThat(serialNumber).isPositive();
tokenSerialNumbers.get(tokenId).add(serialNumber);
}
Aggregations