use of io.nem.symbol.sdk.model.transaction.Transaction in project nem2-sdk-java by nemtech.
the class MultisignIntegrationTest method shouldReturnCosignatureAddedViaListener2.
@Disabled
@ParameterizedTest
@EnumSource(RepositoryType.class)
void shouldReturnCosignatureAddedViaListener2(RepositoryType type) {
Listener listener = getListener(type);
RepositoryFactory repositoryFactory = getRepositoryFactory(type);
TransactionRepository transactionRepository = repositoryFactory.createTransactionRepository();
SignedTransaction signedAggregatedTx = createSignedAggregatedBondTransaction(multisigAccount, cosignAccount1, account2.getAddress());
Object finalObject = get(createHashLockTransactionAndAnnounce(type, signedAggregatedTx, cosignAccount1).flatMap(t -> {
System.out.println("hash lock finished");
TransactionServiceImpl transactionService = new TransactionServiceImpl(getRepositoryFactory(type));
return transactionService.announceAggregateBonded(listener, signedAggregatedTx).flatMap(a -> {
System.out.println("Aggregate bonded finished");
return repositoryFactory.createTransactionRepository().search(new TransactionSearchCriteria(TransactionGroup.PARTIAL).signerPublicKey(cosignAccount1.getPublicAccount().getPublicKey())).flatMap((page) -> {
List<Transaction> transactions = page.getData();
System.out.println("partialTransactions " + transactions.size());
AggregateTransaction transactionToCosign = (AggregateTransaction) transactions.get(0);
CosignatureTransaction cosignatureTransaction = CosignatureTransaction.create(transactionToCosign);
CosignatureSignedTransaction cosignatureSignedTransaction = cosignAccount2.signCosignatureTransaction(cosignatureTransaction);
return transactionRepository.announceAggregateBondedCosignature(cosignatureSignedTransaction).flatMap(r -> {
System.out.println("announceAggregateBondedCosignature " + r);
return listener.cosignatureAdded(cosignAccount1.getAddress());
});
});
});
}));
System.out.println(finalObject.getClass());
Assertions.assertNull(finalObject);
}
use of io.nem.symbol.sdk.model.transaction.Transaction in project nem2-sdk-java by nemtech.
the class MultisignIntegrationTest method createMultisigAccount.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void createMultisigAccount(RepositoryType type) {
boolean multisigAccountExist = get(getRepositoryFactory(type).createMultisigRepository().getMultisigAccountInfo(multisigAccount.getAddress()).map(s -> true).onErrorReturnItem(false));
if (multisigAccountExist) {
System.out.println("Multisign account " + multisigAccount.getAddress().plain() + " already exist");
return;
}
MultisigAccountModificationTransaction modifyMultisigAccountTransaction = MultisigAccountModificationTransactionFactory.create(getNetworkType(), getDeadline(), (byte) 2, (byte) 1, Arrays.asList(cosignAccount1.getAddress(), cosignAccount2.getAddress(), cosignAccount3.getAddress()), Collections.emptyList()).maxFee(maxFee).build();
AggregateTransaction aggregateTransaction = AggregateTransactionFactory.createComplete(getNetworkType(), getDeadline(), Collections.singletonList(modifyMultisigAccountTransaction.toAggregate(multisigAccount.getPublicAccount()))).maxFee(maxFee).build();
SignedTransaction signedTransaction = aggregateTransaction.signTransactionWithCosigners(multisigAccount, Arrays.asList(cosignAccount1, cosignAccount2, cosignAccount3), getGenerationHash());
Transaction transaction = get(getTransactionService(type).announce(getListener(type), signedTransaction));
Assertions.assertNotNull(transaction);
}
use of io.nem.symbol.sdk.model.transaction.Transaction in project nem2-sdk-java by nemtech.
the class TestnetTester method announceTransaction.
private static void announceTransaction(RepositoryFactory repositoryFactory, Account account, Transaction transaction) throws Exception {
TransactionService transactionService = new TransactionServiceImpl(repositoryFactory);
String generationHash = repositoryFactory.getGenerationHash().toFuture().get();
try (Listener listener = repositoryFactory.createListener()) {
listener.open().get();
SignedTransaction signedTransaction = account.sign(transaction, generationHash);
System.out.println(signedTransaction.getHash());
Transaction completedTransaction = transactionService.announce(listener, signedTransaction).toFuture().get();
System.out.println(completedTransaction.getTransactionInfo().get().getHash().get());
}
}
use of io.nem.symbol.sdk.model.transaction.Transaction in project nem2-sdk-java by nemtech.
the class TestnetTester method readTransactions.
private static void readTransactions(RepositoryFactory repositoryFactory) throws Exception {
String generationHash = repositoryFactory.getGenerationHash().toFuture().get();
NetworkType networkType = repositoryFactory.getNetworkType().toFuture().get();
List<Transaction> transactions = repositoryFactory.createTransactionRepository().streamer().search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED).order(OrderBy.DESC).transactionTypes(Arrays.asList(TransactionType.VOTING_KEY_LINK))).take(50).toList().blockingGet();
transactions.forEach(t -> {
System.out.println(t.getVersion());
System.out.println(t.getTransactionInfo().get().getHash().get());
System.out.println(t.createTransactionHash(ConvertUtils.toHex(t.serialize()), ConvertUtils.fromHexToBytes(generationHash)));
});
}
use of io.nem.symbol.sdk.model.transaction.Transaction in project nem2-sdk-java by nemtech.
the class TransactionSearchRepositoryIntegrationTest method searchBySignerPublicKeyInvalid.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchBySignerPublicKeyInvalid(RepositoryType type) {
TransactionRepository transactionRepository = getTransactionRepository(type);
TransactionPaginationStreamer streamer = new TransactionPaginationStreamer(transactionRepository);
TransactionSearchCriteria criteria = new TransactionSearchCriteria(TransactionGroup.CONFIRMED);
PublicKey expectedSignerPublicKey = Account.generateNewAccount(getNetworkType()).getPublicAccount().getPublicKey();
criteria.setSignerPublicKey(expectedSignerPublicKey);
List<Transaction> transactions = get(streamer.search(criteria).toList().toObservable());
Assertions.assertTrue(transactions.isEmpty());
helper.assertById(transactionRepository, TransactionGroup.CONFIRMED, transactions);
}
Aggregations