use of io.nem.symbol.sdk.api.TransactionService in project nem2-sdk-java by nemtech.
the class TestHelper method announceAggregateAndValidate.
<T extends Transaction> Pair<T, AggregateTransaction> announceAggregateAndValidate(RepositoryType type, T transaction, Account signer, Account... cosigners) {
System.out.println("Announcing Aggregate Transaction: " + transaction.getType() + " signer " + signer.getAddress().plain() + " cosigners: " + Arrays.stream(cosigners).map(s -> s.getAddress().plain()).collect(Collectors.joining(", ")));
AggregateTransaction aggregateTransaction = AggregateTransactionFactory.createComplete(getNetworkType(), getDeadline(), Collections.singletonList(transaction.toAggregate(signer.getPublicAccount()))).maxFee(maxFee).build();
SignedTransaction signedTransaction = signer.signTransactionWithCosignatories(aggregateTransaction, Arrays.asList(cosigners), getGenerationHash());
if (transaction.getType() != TransactionType.AGGREGATE_COMPLETE) {
System.out.println("Announcing Transaction Transaction: " + transaction.getType() + " Address: " + signer.getAddress().plain() + " Public Key: " + signer.getPublicAccount().getPublicKey().toHex() + " hash " + signedTransaction.getHash());
}
TransactionService transactionService = new TransactionServiceImpl(getRepositoryFactory(type));
AggregateTransaction announcedAggregateTransaction = (AggregateTransaction) getTransactionOrFail(transactionService.announce(getListener(type), signedTransaction), transaction);
T announcedCorrectly = (T) announcedAggregateTransaction.getInnerTransactions().get(0);
System.out.println("Transaction completed, Transaction hash " + announcedAggregateTransaction.getTransactionInfo().get().getHash().get());
return Pair.of(announcedCorrectly, announcedAggregateTransaction);
}
use of io.nem.symbol.sdk.api.TransactionService in project nem2-sdk-java by nemtech.
the class TestHelper method announceAndValidate.
<T extends Transaction> T announceAndValidate(RepositoryType type, Account testAccount, T transaction) {
SignedTransaction signedTransaction = testAccount.sign(transaction, getGenerationHash());
System.out.println("Announcing Transaction Transaction: " + transaction.getType() + " Address: " + testAccount.getAddress().plain() + " Public Key: " + testAccount.getPublicAccount().getPublicKey().toHex() + " hash " + signedTransaction.getHash());
TransactionService transactionService = new TransactionServiceImpl(getRepositoryFactory(type));
Transaction announceCorrectly = getTransactionOrFail(transactionService.announce(getListener(type), signedTransaction), transaction);
Assertions.assertEquals(signedTransaction.getHash(), announceCorrectly.getTransactionInfo().get().getHash().get());
Assertions.assertEquals(announceCorrectly.getType(), transaction.getType());
System.out.println("Transaction completed, Transaction hash " + signedTransaction.getHash());
return (T) announceCorrectly;
}
Aggregations