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));
}
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();
}
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);
}
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());
}
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());
}
Aggregations