Search in sources :

Example 1 with MultisigAccountModificationTransaction

use of io.nem.symbol.sdk.model.transaction.MultisigAccountModificationTransaction 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);
}
Also used : MultisigAccountModificationTransaction(io.nem.symbol.sdk.model.transaction.MultisigAccountModificationTransaction) HashLockTransaction(io.nem.symbol.sdk.model.transaction.HashLockTransaction) CosignatureTransaction(io.nem.symbol.sdk.model.transaction.CosignatureTransaction) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) MultisigAccountModificationTransaction(io.nem.symbol.sdk.model.transaction.MultisigAccountModificationTransaction) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) 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)

Example 2 with MultisigAccountModificationTransaction

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

the class AggregateTransactionServiceIntegrationTest method isMultisigAccountModificationTransactionAdditionComplete.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void isMultisigAccountModificationTransactionAdditionComplete(RepositoryType type) {
    Account multisigAccount = helper().getMultisigAccount(type).getKey();
    Account cosignatoryAccount = config().getCosignatoryAccount();
    Account cosignatory2Account = config().getCosignatory2Account();
    List<Account> accounts = Arrays.asList(cosignatoryAccount, cosignatory2Account);
    List<UnresolvedAddress> additions = accounts.stream().map(Account::getAddress).collect(Collectors.toList());
    MultisigAccountModificationTransaction multisigAccountModificationTransaction = MultisigAccountModificationTransactionFactory.create(getNetworkType(), getDeadline(), (byte) 1, (byte) 1, additions, Collections.emptyList()).maxFee(maxFee).build();
    AggregateTransaction aggregateTransaction = AggregateTransactionFactory.createComplete(getNetworkType(), getDeadline(), Collections.singletonList(multisigAccountModificationTransaction.toAggregate(multisigAccount.getPublicAccount()))).maxFee(maxFee).build();
    SignedTransaction signedAggregateTransaction = aggregateTransaction.signTransactionWithCosigners(multisigAccount, accounts, getGenerationHash());
    AggregateTransactionService aggregateTransactionService = new AggregateTransactionServiceImpl(getRepositoryFactory(type));
    Assertions.assertTrue(get(aggregateTransactionService.isComplete(signedAggregateTransaction)));
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) MultisigAccountModificationTransaction(io.nem.symbol.sdk.model.transaction.MultisigAccountModificationTransaction) UnresolvedAddress(io.nem.symbol.sdk.model.account.UnresolvedAddress) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) AggregateTransactionService(io.nem.symbol.sdk.api.AggregateTransactionService) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with MultisigAccountModificationTransaction

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

the class AggregateTransactionServiceIntegrationTest method isMultisigAccountModificationTransactionAdditionNotComplete.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void isMultisigAccountModificationTransactionAdditionNotComplete(RepositoryType type) {
    Account testAccount = helper().getTestAccount(type).getLeft();
    Account multisigAccount = helper().getMultisigAccount(type).getLeft();
    Account cosignatoryAccount = config().getCosignatoryAccount();
    Account cosignatory2Account = config().getCosignatory2Account();
    List<Account> accounts = Arrays.asList(cosignatoryAccount, cosignatory2Account);
    List<UnresolvedAddress> additions = accounts.stream().map(Account::getAddress).collect(Collectors.toList());
    MultisigAccountModificationTransaction multisigAccountModificationTransaction = MultisigAccountModificationTransactionFactory.create(getNetworkType(), getDeadline(), (byte) 1, (byte) 1, additions, Collections.emptyList()).maxFee(maxFee).build();
    AggregateTransaction aggregateTransaction = AggregateTransactionFactory.createComplete(getNetworkType(), getDeadline(), Collections.singletonList(multisigAccountModificationTransaction.toAggregate(multisigAccount.getPublicAccount()))).maxFee(maxFee).build();
    SignedTransaction signedAggregateTransaction = aggregateTransaction.signTransactionWithCosigners(multisigAccount, Collections.singletonList(testAccount), getGenerationHash());
    AggregateTransactionService aggregateTransactionService = new AggregateTransactionServiceImpl(getRepositoryFactory(type));
    Assertions.assertFalse(get(aggregateTransactionService.isComplete(signedAggregateTransaction)));
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) MultisigAccountModificationTransaction(io.nem.symbol.sdk.model.transaction.MultisigAccountModificationTransaction) UnresolvedAddress(io.nem.symbol.sdk.model.account.UnresolvedAddress) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) AggregateTransactionService(io.nem.symbol.sdk.api.AggregateTransactionService) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with MultisigAccountModificationTransaction

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

the class AggregateTransactionServiceIntegrationTest method isMultisigAccountModificationTransactionDeletionNotComplete.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void isMultisigAccountModificationTransactionDeletionNotComplete(RepositoryType type) {
    Account multisigAccount = helper().getMultisigAccount(type).getLeft();
    Account cosignatoryAccount = config().getCosignatoryAccount();
    Account cosignatory2Account = config().getCosignatory2Account();
    List<Account> accounts = Arrays.asList(cosignatoryAccount, cosignatory2Account);
    MultisigAccountModificationTransaction multisigAccountModificationTransaction = MultisigAccountModificationTransactionFactory.create(getNetworkType(), getDeadline(), (byte) 1, (byte) 1, Collections.emptyList(), Collections.singletonList(accounts.get(0).getAddress())).maxFee(maxFee).build();
    AggregateTransaction aggregateTransaction = AggregateTransactionFactory.createComplete(getNetworkType(), getDeadline(), Collections.singletonList(multisigAccountModificationTransaction.toAggregate(multisigAccount.getPublicAccount()))).maxFee(maxFee).build();
    SignedTransaction signedAggregateTransaction = aggregateTransaction.signTransactionWithCosigners(multisigAccount, // Random
    Collections.singletonList(config().getTestAccount()), // account
    getGenerationHash());
    AggregateTransactionService aggregateTransactionService = new AggregateTransactionServiceImpl(getRepositoryFactory(type));
    Assertions.assertFalse(get(aggregateTransactionService.isComplete(signedAggregateTransaction)));
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) MultisigAccountModificationTransaction(io.nem.symbol.sdk.model.transaction.MultisigAccountModificationTransaction) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) AggregateTransactionService(io.nem.symbol.sdk.api.AggregateTransactionService) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with MultisigAccountModificationTransaction

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

the class AggregateTransactionServiceIntegrationTest method isMultisigAccountModificationTransactionDeletionComplete.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void isMultisigAccountModificationTransactionDeletionComplete(RepositoryType type) {
    Account multisigAccount = helper().getMultisigAccount(type).getLeft();
    Account cosignatoryAccount = config().getCosignatoryAccount();
    Account cosignatory2Account = config().getCosignatory2Account();
    List<Account> accounts = Arrays.asList(cosignatoryAccount, cosignatory2Account);
    MultisigAccountModificationTransaction multisigAccountModificationTransaction = MultisigAccountModificationTransactionFactory.create(getNetworkType(), getDeadline(), (byte) 1, (byte) 1, Collections.emptyList(), Collections.singletonList(accounts.get(0).getAddress())).maxFee(maxFee).build();
    AggregateTransaction aggregateTransaction = AggregateTransactionFactory.createComplete(getNetworkType(), getDeadline(), Collections.singletonList(multisigAccountModificationTransaction.toAggregate(multisigAccount.getPublicAccount()))).maxFee(maxFee).build();
    SignedTransaction signedAggregateTransaction = aggregateTransaction.signTransactionWithCosigners(multisigAccount, Collections.singletonList(accounts.get(1)), getGenerationHash());
    AggregateTransactionService aggregateTransactionService = new AggregateTransactionServiceImpl(getRepositoryFactory(type));
    Assertions.assertTrue(get(aggregateTransactionService.isComplete(signedAggregateTransaction)));
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) MultisigAccountModificationTransaction(io.nem.symbol.sdk.model.transaction.MultisigAccountModificationTransaction) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) AggregateTransactionService(io.nem.symbol.sdk.api.AggregateTransactionService) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

AggregateTransaction (io.nem.symbol.sdk.model.transaction.AggregateTransaction)8 MultisigAccountModificationTransaction (io.nem.symbol.sdk.model.transaction.MultisigAccountModificationTransaction)8 SignedTransaction (io.nem.symbol.sdk.model.transaction.SignedTransaction)8 Account (io.nem.symbol.sdk.model.account.Account)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 EnumSource (org.junit.jupiter.params.provider.EnumSource)5 AggregateTransactionService (io.nem.symbol.sdk.api.AggregateTransactionService)4 UnresolvedAddress (io.nem.symbol.sdk.model.account.UnresolvedAddress)4 HashLockTransaction (io.nem.symbol.sdk.model.transaction.HashLockTransaction)3 Transaction (io.nem.symbol.sdk.model.transaction.Transaction)3 TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)3 AccountRepository (io.nem.symbol.sdk.api.AccountRepository)2 MultisigRepository (io.nem.symbol.sdk.api.MultisigRepository)2 RepositoryCallException (io.nem.symbol.sdk.api.RepositoryCallException)2 AccountInfo (io.nem.symbol.sdk.model.account.AccountInfo)2 MultisigAccountInfo (io.nem.symbol.sdk.model.account.MultisigAccountInfo)2 AddressAliasTransaction (io.nem.symbol.sdk.model.transaction.AddressAliasTransaction)2 Deadline (io.nem.symbol.sdk.model.transaction.Deadline)2 MosaicAliasTransaction (io.nem.symbol.sdk.model.transaction.MosaicAliasTransaction)2 MosaicDefinitionTransaction (io.nem.symbol.sdk.model.transaction.MosaicDefinitionTransaction)2