Search in sources :

Example 1 with Deadline

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

the class ListenerBase method toStatus.

private TransactionStatusError toStatus(Object message, String channelParams) {
    UnresolvedAddress unresolvedAddress = getUnresolvedAddress(channelParams);
    String hash = jsonHelper.getString(message, "hash");
    String code = jsonHelper.getString(message, "code");
    Deadline deadline = new Deadline(new BigInteger(jsonHelper.getString(message, "deadline")));
    return (new TransactionStatusError(unresolvedAddress, hash, code, deadline));
}
Also used : TransactionStatusError(io.nem.symbol.sdk.model.transaction.TransactionStatusError) UnresolvedAddress(io.nem.symbol.sdk.model.account.UnresolvedAddress) Deadline(io.nem.symbol.sdk.model.transaction.Deadline) BigInteger(java.math.BigInteger)

Example 2 with Deadline

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

the class BinarySerializationImpl method toTransaction.

/**
 * It converts a {@link EmbeddedTransactionBuilder} to a {@link Transaction}
 *
 * @param builder the builder
 * @return the {@link Transaction} model.
 */
private Transaction toTransaction(EmbeddedTransactionBuilder builder) {
    TransactionType transactionType = TransactionType.rawValueOf(SerializationUtils.shortToUnsignedInt(builder.getType().getValue()));
    NetworkType networkType = NetworkType.rawValueOf(SerializationUtils.byteToUnsignedInt(builder.getNetwork().getValue()));
    TransactionFactory<?> factory = resolveSerializer(transactionType, builder.getVersion()).fromBodyBuilder(networkType, new Deadline(BigInteger.ZERO), builder.getBody());
    factory.signer(SerializationUtils.toPublicAccount(builder.getSignerPublicKey(), networkType));
    factory.version(SerializationUtils.byteToUnsignedInt(builder.getVersion()));
    return factory.build();
}
Also used : TransactionType(io.nem.symbol.sdk.model.transaction.TransactionType) NetworkType(io.nem.symbol.sdk.model.network.NetworkType) Deadline(io.nem.symbol.sdk.model.transaction.Deadline)

Example 3 with Deadline

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

the class TestnetTester method sendMosaics.

private static void sendMosaics(RepositoryFactory repositoryFactory) throws Exception {
    NetworkType networkType = repositoryFactory.getNetworkType().blockingFirst();
    Account account = Account.createFromPrivateKey(PRIVATE_KEY, networkType);
    Account recipient = Account.generateNewAccount(networkType);
    Mosaic mosaic = repositoryFactory.getNetworkCurrency().blockingFirst().createAbsolute(1);
    System.out.println(account.getAddress().plain());
    Duration duration = repositoryFactory.getEpochAdjustment().blockingFirst();
    Deadline deadline = Deadline.create(duration);
    TransferTransaction transaction = TransferTransactionFactory.create(networkType, deadline, recipient.getAddress(), Collections.singletonList(mosaic)).maxFee(MAX_FEE).build();
    announceTransaction(repositoryFactory, account, transaction);
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) NetworkType(io.nem.symbol.sdk.model.network.NetworkType) Deadline(io.nem.symbol.sdk.model.transaction.Deadline) Duration(java.time.Duration) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) Mosaic(io.nem.symbol.sdk.model.mosaic.Mosaic)

Example 4 with Deadline

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

the class AggregateTransactionServiceTest method shouldReturnCorrectIsCompleteStatusForAggregatedCompleteTransaction2LevelsMultisigMultiinnerTransaction.

/*
   * MLMA - with multiple transaction Alice (account1): normal account Bob (multisig2) - Multisig
   * 2-1 (account1 && multisig1) Charles (multisig1) - Multisig 1-1 (account2 || account3) An
   * extra inner transaction to account4 (just to increase the complexity) Given signatories:
   * Account1 && Account4 Expecting incomplete as Bob needs 2 signatures (account1 && (account2 ||
   * account3))
   */
@Test
void shouldReturnCorrectIsCompleteStatusForAggregatedCompleteTransaction2LevelsMultisigMultiinnerTransaction() throws ExecutionException, InterruptedException {
    TransferTransaction transferTransaction = TransferTransactionFactory.create(networkType, new Deadline(BigInteger.ONE), Address.generateRandom(networkType), Collections.emptyList()).message(new PlainMessage("test-message")).build();
    TransferTransaction transferTransaction2 = TransferTransactionFactory.create(networkType, new Deadline(BigInteger.ONE), account2.getAddress(), Collections.emptyList()).message(new PlainMessage("test-message")).build();
    AggregateTransaction aggregateTransaction = AggregateTransactionFactory.createComplete(networkType, new Deadline(BigInteger.ONE), Arrays.asList(transferTransaction.toAggregate(multisig2.getPublicAccount()), transferTransaction2.toAggregate(account4.getPublicAccount()))).build();
    SignedTransaction signedTransaction = account1.signTransactionWithCosignatories(aggregateTransaction, Collections.singletonList(account4), generationHash);
    Assertions.assertFalse(service.isComplete(signedTransaction).toFuture().get());
}
Also used : PlainMessage(io.nem.symbol.sdk.model.message.PlainMessage) Deadline(io.nem.symbol.sdk.model.transaction.Deadline) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) Test(org.junit.jupiter.api.Test)

Example 5 with Deadline

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

the class AggregateTransactionServiceTest method shouldReturnCorrectIsCompleteStatusForAggregatedCompleteTransaction2LevelsMultisigMmultiInnerTransaction.

/*
   * MLMA - with multiple transaction Alice (account1): normal account Bob (multisig2) - Multisig
   * 2-1 (account1 && multisig1) Charles (multisig1) - Multisig 1-1 (account2 || account3) An
   * extra inner transaction to account4 (just to increase the complexity) Given signatories:
   * Account1 && Account4 && Account2 Expecting complete
   */
@Test
void shouldReturnCorrectIsCompleteStatusForAggregatedCompleteTransaction2LevelsMultisigMmultiInnerTransaction() throws ExecutionException, InterruptedException {
    TransferTransaction transferTransaction = TransferTransactionFactory.create(networkType, new Deadline(BigInteger.ONE), account2.getAddress(), Collections.emptyList()).message(new PlainMessage("test-message")).build();
    TransferTransaction transferTransaction2 = TransferTransactionFactory.create(networkType, new Deadline(BigInteger.ONE), account2.getAddress(), Collections.emptyList()).message(new PlainMessage("test-message")).build();
    AggregateTransaction aggregateTransaction = AggregateTransactionFactory.createComplete(networkType, new Deadline(BigInteger.ONE), Arrays.asList(transferTransaction.toAggregate(multisig2.getPublicAccount()), transferTransaction2.toAggregate(account4.getPublicAccount()))).build();
    SignedTransaction signedTransaction = account1.signTransactionWithCosignatories(aggregateTransaction, Arrays.asList(account4, account2), generationHash);
    Assertions.assertTrue(service.isComplete(signedTransaction).toFuture().get());
}
Also used : PlainMessage(io.nem.symbol.sdk.model.message.PlainMessage) Deadline(io.nem.symbol.sdk.model.transaction.Deadline) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) Test(org.junit.jupiter.api.Test)

Aggregations

Deadline (io.nem.symbol.sdk.model.transaction.Deadline)49 Test (org.junit.jupiter.api.Test)38 TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)28 PlainMessage (io.nem.symbol.sdk.model.message.PlainMessage)23 AggregateTransaction (io.nem.symbol.sdk.model.transaction.AggregateTransaction)22 SignedTransaction (io.nem.symbol.sdk.model.transaction.SignedTransaction)19 Mosaic (io.nem.symbol.sdk.model.mosaic.Mosaic)14 UnresolvedAddress (io.nem.symbol.sdk.model.account.UnresolvedAddress)9 NetworkType (io.nem.symbol.sdk.model.network.NetworkType)9 BigInteger (java.math.BigInteger)8 ArrayList (java.util.ArrayList)6 Address (io.nem.symbol.sdk.model.account.Address)5 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)5 Account (io.nem.symbol.sdk.model.account.Account)4 PublicAccount (io.nem.symbol.sdk.model.account.PublicAccount)4 TransactionType (io.nem.symbol.sdk.model.transaction.TransactionType)4 Duration (java.time.Duration)4 HashLockTransaction (io.nem.symbol.sdk.model.transaction.HashLockTransaction)3 TransactionAnnounceResponse (io.nem.symbol.sdk.model.transaction.TransactionAnnounceResponse)3 BinarySerialization (io.nem.symbol.sdk.api.BinarySerialization)2