Search in sources :

Example 36 with TransferTransaction

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

the class ListenerStatusIntegrationTest method statusListener.

@Test
void statusListener() throws ExecutionException, InterruptedException {
    RepositoryType type = DEFAULT_REPOSITORY_TYPE;
    Account account1 = Account.generateNewAccount(getNetworkType());
    Account account2 = Account.generateNewAccount(getNetworkType());
    Account account3 = Account.generateNewAccount(getNetworkType());
    createListener(type).status(account1.getAddress()).subscribe(a -> {
        System.out.println(">>>> account 1 " + a.getAddress() + " " + a.getHash() + " " + a.getStatus());
    });
    createListener(type).status(account2.getAddress()).subscribe(a -> {
        System.out.println(">>>> account 2 " + a.getAddress() + " " + a.getHash() + " " + a.getStatus());
    });
    createListener(type).status(account3.getAddress()).subscribe(a -> {
        System.out.println(">>>> account 3  " + a.getAddress() + " " + a.getHash() + " " + a.getStatus());
    });
    TransferTransaction transferTransaction = TransferTransactionFactory.create(getNetworkType(), getDeadline(), account2.getAddress(), Collections.singletonList(getNetworkCurrency().createAbsolute(BigInteger.valueOf(1)))).message(new PlainMessage("test-message")).maxFee(maxFee).build();
    announceAndValidate(type, account1, transferTransaction);
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) PlainMessage(io.nem.symbol.sdk.model.message.PlainMessage) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) Test(org.junit.jupiter.api.Test)

Example 37 with TransferTransaction

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

the class AggregateTransactionServiceIntegrationTest method isTransferFromMultisigComplete.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void isTransferFromMultisigComplete(RepositoryType type) {
    Account multisigAccount = helper().getMultisigAccount(type).getKey();
    Account cosignatoryAccount = config().getCosignatoryAccount();
    TransferTransaction transferTransaction = TransferTransactionFactory.create(getNetworkType(), getDeadline(), getRecipient(), Collections.emptyList()).message(new PlainMessage("")).maxFee(maxFee).build();
    AggregateTransaction aggregateTransaction = AggregateTransactionFactory.createComplete(getNetworkType(), getDeadline(), Collections.singletonList(transferTransaction.toAggregate(multisigAccount.getPublicAccount()))).maxFee(maxFee).build();
    SignedTransaction signedAggregateTransaction = aggregateTransaction.signTransactionWithCosigners(multisigAccount, Arrays.asList(cosignatoryAccount, config().getTestAccount()), getGenerationHash());
    AggregateTransactionService aggregateTransactionService = new AggregateTransactionServiceImpl(getRepositoryFactory(type));
    Assertions.assertTrue(get(aggregateTransactionService.isComplete(signedAggregateTransaction)));
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) PlainMessage(io.nem.symbol.sdk.model.message.PlainMessage) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) AggregateTransactionService(io.nem.symbol.sdk.api.AggregateTransactionService) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 38 with TransferTransaction

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

the class TransactionRepositoryVertxImplTest method getSignedTransaction.

private SignedTransaction getSignedTransaction() {
    String generationHash = "A94B1BE81F1D4C95D6D252AD7BA3FFFB1674991FD880B7A57DC3180AF8D69C32";
    Account account = Account.generateNewAccount(this.networkType);
    Address recipientAddress = Address.generateRandom(this.networkType);
    TransferTransaction transferTransaction = TransferTransactionFactory.create(NetworkType.MIJIN_TEST, new Deadline(BigInteger.ONE), recipientAddress, Collections.singletonList(createAbsolute(BigInteger.valueOf(1)))).message(new PlainMessage("E2ETest:standaloneTransferTransaction:message")).build();
    SignedTransaction signedTransaction = account.sign(transferTransaction, generationHash);
    String payload = signedTransaction.getPayload();
    assertEquals(444, payload.length());
    return signedTransaction;
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) PublicAccount(io.nem.symbol.sdk.model.account.PublicAccount) Address(io.nem.symbol.sdk.model.account.Address) PlainMessage(io.nem.symbol.sdk.model.message.PlainMessage) Deadline(io.nem.symbol.sdk.model.transaction.Deadline) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction)

Example 39 with TransferTransaction

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

the class VertxAggregateTransactionTest method createAAggregateTransactionViaStaticConstructor.

@Test
void createAAggregateTransactionViaStaticConstructor() {
    Duration epochAdjustment = Duration.ofSeconds(100);
    Address recipient = Address.generateRandom(networkType);
    Deadline deadline = Deadline.create(epochAdjustment);
    TransferTransaction transferTx = TransferTransactionFactory.create(networkType, deadline, recipient, Collections.emptyList()).message(new PlainMessage("")).build();
    AggregateTransaction aggregateTx = AggregateTransactionFactory.createComplete(networkType, deadline, Collections.singletonList(transferTx.toAggregate(new PublicAccount("9A49366406ACA952B88BADF5F1E9BE6CE4968141035A60BE503273EA65456B24", networkType)))).build();
    assertEquals(networkType, aggregateTx.getNetworkType());
    assertEquals(1, (int) aggregateTx.getVersion());
    assertTrue(LocalDateTime.now().isBefore(aggregateTx.getDeadline().getLocalDateTime(epochAdjustment)));
    assertEquals(BigInteger.valueOf(0), aggregateTx.getMaxFee());
    assertEquals(1, aggregateTx.getInnerTransactions().size());
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) PlainMessage(io.nem.symbol.sdk.model.message.PlainMessage) Deadline(io.nem.symbol.sdk.model.transaction.Deadline) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) PublicAccount(io.nem.symbol.sdk.model.account.PublicAccount) Duration(java.time.Duration) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) Test(org.junit.jupiter.api.Test)

Example 40 with TransferTransaction

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

the class TransactionMapperVertxTest method shouldCreateStandaloneTransferTransaction.

@Test
void shouldCreateStandaloneTransferTransaction() {
    TransactionInfoDTO transferTransactionDTO = TestHelperVertx.loadTransactionInfoDTO("standaloneTransferTransaction.json");
    Transaction transferTransaction = map(transferTransactionDTO);
    validateStandaloneTransaction(transferTransaction, transferTransactionDTO);
}
Also used : SecretProofTransaction(io.nem.symbol.sdk.model.transaction.SecretProofTransaction) HashLockTransaction(io.nem.symbol.sdk.model.transaction.HashLockTransaction) AccountOperationRestrictionTransaction(io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionTransaction) AccountAddressRestrictionTransaction(io.nem.symbol.sdk.model.transaction.AccountAddressRestrictionTransaction) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) NamespaceRegistrationTransaction(io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) MosaicDefinitionTransaction(io.nem.symbol.sdk.model.transaction.MosaicDefinitionTransaction) MultisigAccountModificationTransaction(io.nem.symbol.sdk.model.transaction.MultisigAccountModificationTransaction) AccountMosaicRestrictionTransaction(io.nem.symbol.sdk.model.transaction.AccountMosaicRestrictionTransaction) MosaicMetadataTransaction(io.nem.symbol.sdk.model.transaction.MosaicMetadataTransaction) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) AccountKeyLinkTransaction(io.nem.symbol.sdk.model.transaction.AccountKeyLinkTransaction) NamespaceMetadataTransaction(io.nem.symbol.sdk.model.transaction.NamespaceMetadataTransaction) AccountMetadataTransaction(io.nem.symbol.sdk.model.transaction.AccountMetadataTransaction) AddressAliasTransaction(io.nem.symbol.sdk.model.transaction.AddressAliasTransaction) MosaicAliasTransaction(io.nem.symbol.sdk.model.transaction.MosaicAliasTransaction) MosaicSupplyChangeTransaction(io.nem.symbol.sdk.model.transaction.MosaicSupplyChangeTransaction) SecretLockTransaction(io.nem.symbol.sdk.model.transaction.SecretLockTransaction) TransactionInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.TransactionInfoDTO) Test(org.junit.jupiter.api.Test)

Aggregations

TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)63 PlainMessage (io.nem.symbol.sdk.model.message.PlainMessage)48 Test (org.junit.jupiter.api.Test)37 AggregateTransaction (io.nem.symbol.sdk.model.transaction.AggregateTransaction)35 SignedTransaction (io.nem.symbol.sdk.model.transaction.SignedTransaction)31 Deadline (io.nem.symbol.sdk.model.transaction.Deadline)28 Account (io.nem.symbol.sdk.model.account.Account)18 Mosaic (io.nem.symbol.sdk.model.mosaic.Mosaic)17 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)14 EnumSource (org.junit.jupiter.params.provider.EnumSource)14 Address (io.nem.symbol.sdk.model.account.Address)13 Transaction (io.nem.symbol.sdk.model.transaction.Transaction)13 PublicAccount (io.nem.symbol.sdk.model.account.PublicAccount)10 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)8 BigInteger (java.math.BigInteger)8 ArrayList (java.util.ArrayList)8 UnresolvedAddress (io.nem.symbol.sdk.model.account.UnresolvedAddress)7 HashLockTransaction (io.nem.symbol.sdk.model.transaction.HashLockTransaction)7 TransactionRepository (io.nem.symbol.sdk.api.TransactionRepository)5 TransactionSearchCriteria (io.nem.symbol.sdk.api.TransactionSearchCriteria)5