Search in sources :

Example 1 with CosignatureTransaction

use of io.nem.symbol.sdk.model.transaction.CosignatureTransaction in project nem2-sdk-java by nemtech.

the class VertxCosignatureTransactionTest method createACosignatureTransactionViaConstructor.

@Test
void createACosignatureTransactionViaConstructor() {
    TransactionInfoDTO transactionInfoDTO = TestHelperVertx.loadTransactionInfoDTO("cosignatureTransactionViaConstructor.json");
    AggregateTransaction aggregateTransaction = (AggregateTransaction) new GeneralTransactionMapper(jsonHelper).mapFromDto(transactionInfoDTO);
    CosignatureTransaction cosignatureTransaction = CosignatureTransaction.create(aggregateTransaction);
    CosignatureSignedTransaction cosignatureSignedTransaction = account.signCosignatureTransaction(cosignatureTransaction);
    assertTrue(aggregateTransaction.getTransactionInfo().get().getHash().isPresent());
    assertEquals(aggregateTransaction.getTransactionInfo().get().getHash().get(), cosignatureSignedTransaction.getParentHash());
    assertEquals("5EA75D1A2C8AD25DA4F400C1BD2DA84449FAF583AFD813E1179E72AF0CDF5AC1C0F7404AF6FC7268EE416204240DD3D5B11420D80215F19AA314FC86D6E03E0D", cosignatureSignedTransaction.getSignature());
    assertEquals("671653C94E2254F2A23EFEDB15D67C38332AED1FBD24B063C0A8E675582B6A96", cosignatureTransaction.getTransactionToCosign().getTransactionInfo().get().getHash().get());
}
Also used : CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction) GeneralTransactionMapper(io.nem.symbol.sdk.infrastructure.vertx.mappers.GeneralTransactionMapper) TransactionInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.TransactionInfoDTO) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) CosignatureTransaction(io.nem.symbol.sdk.model.transaction.CosignatureTransaction) Test(org.junit.jupiter.api.Test)

Example 2 with CosignatureTransaction

use of io.nem.symbol.sdk.model.transaction.CosignatureTransaction 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);
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) Arrays(java.util.Arrays) HashLockTransaction(io.nem.symbol.sdk.model.transaction.HashLockTransaction) HashLockTransactionFactory(io.nem.symbol.sdk.model.transaction.HashLockTransactionFactory) Account(io.nem.symbol.sdk.model.account.Account) EnumSource(org.junit.jupiter.params.provider.EnumSource) Disabled(org.junit.jupiter.api.Disabled) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) CosignatureTransaction(io.nem.symbol.sdk.model.transaction.CosignatureTransaction) TestInstance(org.junit.jupiter.api.TestInstance) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) Observable(io.reactivex.Observable) BigInteger(java.math.BigInteger) Listener(io.nem.symbol.sdk.api.Listener) MultisigAccountModificationTransaction(io.nem.symbol.sdk.model.transaction.MultisigAccountModificationTransaction) MultisigAccountModificationTransactionFactory(io.nem.symbol.sdk.model.transaction.MultisigAccountModificationTransactionFactory) PlainMessage(io.nem.symbol.sdk.model.message.PlainMessage) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) TransactionGroup(io.nem.symbol.sdk.model.transaction.TransactionGroup) List(java.util.List) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) TransferTransactionFactory(io.nem.symbol.sdk.model.transaction.TransferTransactionFactory) Assertions(org.junit.jupiter.api.Assertions) AggregateTransactionFactory(io.nem.symbol.sdk.model.transaction.AggregateTransactionFactory) Address(io.nem.symbol.sdk.model.account.Address) Collections(java.util.Collections) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction) CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction) Listener(io.nem.symbol.sdk.api.Listener) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) List(java.util.List) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) CosignatureTransaction(io.nem.symbol.sdk.model.transaction.CosignatureTransaction) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Disabled(org.junit.jupiter.api.Disabled)

Example 3 with CosignatureTransaction

use of io.nem.symbol.sdk.model.transaction.CosignatureTransaction in project nem2-sdk-java by nemtech.

the class OkHttpCosignatureTransactionTest method createACosignatureTransactionViaConstructor.

@Test
void createACosignatureTransactionViaConstructor() {
    TransactionInfoDTO transactionInfoDTO = TestHelperOkHttp.loadTransactionInfoDTO("cosignatureTransactionViaConstructor.json");
    AggregateTransaction aggregateTransaction = (AggregateTransaction) new GeneralTransactionMapper(jsonHelper).mapFromDto(transactionInfoDTO);
    CosignatureTransaction cosignatureTransaction = CosignatureTransaction.create(aggregateTransaction);
    CosignatureSignedTransaction cosignatureSignedTransaction = account.signCosignatureTransaction(cosignatureTransaction);
    assertTrue(aggregateTransaction.getTransactionInfo().get().getHash().isPresent());
    assertEquals(aggregateTransaction.getTransactionInfo().get().getHash().get(), cosignatureSignedTransaction.getParentHash());
    assertEquals("5EA75D1A2C8AD25DA4F400C1BD2DA84449FAF583AFD813E1179E72AF0CDF5AC1C0F7404AF6FC7268EE416204240DD3D5B11420D80215F19AA314FC86D6E03E0D", cosignatureSignedTransaction.getSignature());
    assertEquals("671653C94E2254F2A23EFEDB15D67C38332AED1FBD24B063C0A8E675582B6A96", cosignatureTransaction.getTransactionToCosign().getTransactionInfo().get().getHash().get());
}
Also used : CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction) GeneralTransactionMapper(io.nem.symbol.sdk.infrastructure.okhttp.mappers.GeneralTransactionMapper) TransactionInfoDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.TransactionInfoDTO) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) CosignatureTransaction(io.nem.symbol.sdk.model.transaction.CosignatureTransaction) Test(org.junit.jupiter.api.Test)

Example 4 with CosignatureTransaction

use of io.nem.symbol.sdk.model.transaction.CosignatureTransaction in project nem2-sdk-java by nemtech.

the class ListenerIntegrationTest method announceCosignatureTransaction.

private CosignatureSignedTransaction announceCosignatureTransaction(AggregateTransaction transactionToCosign, RepositoryType type) {
    CosignatureTransaction cosignatureTransaction = new CosignatureTransaction(transactionToCosign);
    CosignatureSignedTransaction cosignatureSignedTransaction = this.cosignatoryAccount2.signCosignatureTransaction(cosignatureTransaction);
    get(getRepositoryFactory(type).createTransactionRepository().announceAggregateBondedCosignature(cosignatureSignedTransaction));
    return cosignatureSignedTransaction;
}
Also used : CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction) CosignatureTransaction(io.nem.symbol.sdk.model.transaction.CosignatureTransaction)

Aggregations

CosignatureSignedTransaction (io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction)4 CosignatureTransaction (io.nem.symbol.sdk.model.transaction.CosignatureTransaction)4 AggregateTransaction (io.nem.symbol.sdk.model.transaction.AggregateTransaction)3 Test (org.junit.jupiter.api.Test)2 Listener (io.nem.symbol.sdk.api.Listener)1 RepositoryFactory (io.nem.symbol.sdk.api.RepositoryFactory)1 TransactionRepository (io.nem.symbol.sdk.api.TransactionRepository)1 TransactionSearchCriteria (io.nem.symbol.sdk.api.TransactionSearchCriteria)1 GeneralTransactionMapper (io.nem.symbol.sdk.infrastructure.okhttp.mappers.GeneralTransactionMapper)1 GeneralTransactionMapper (io.nem.symbol.sdk.infrastructure.vertx.mappers.GeneralTransactionMapper)1 Account (io.nem.symbol.sdk.model.account.Account)1 Address (io.nem.symbol.sdk.model.account.Address)1 PlainMessage (io.nem.symbol.sdk.model.message.PlainMessage)1 AggregateTransactionFactory (io.nem.symbol.sdk.model.transaction.AggregateTransactionFactory)1 HashLockTransaction (io.nem.symbol.sdk.model.transaction.HashLockTransaction)1 HashLockTransactionFactory (io.nem.symbol.sdk.model.transaction.HashLockTransactionFactory)1 MultisigAccountModificationTransaction (io.nem.symbol.sdk.model.transaction.MultisigAccountModificationTransaction)1 MultisigAccountModificationTransactionFactory (io.nem.symbol.sdk.model.transaction.MultisigAccountModificationTransactionFactory)1 SignedTransaction (io.nem.symbol.sdk.model.transaction.SignedTransaction)1 Transaction (io.nem.symbol.sdk.model.transaction.Transaction)1