use of io.nem.symbol.sdk.model.transaction.SignedTransaction in project nem2-sdk-java by nemtech.
the class TransactionRepositoryOkHttpImplTest method getSignedTransaction.
private SignedTransaction getSignedTransaction() {
String generationHash = "A94B1BE81F1D4C95D6D252AD7BA3FFFB1674991FD880B7A57DC3180AF8D69C32";
Account account = Account.createFromPrivateKey("063F36659A8BB01D5685826C19E2C2CA9D281465B642BD5E43CB69510408ECF7", networkType);
Address address = Address.generateRandom(networkType);
TransferTransaction transferTransaction = TransferTransactionFactory.create(NetworkType.MIJIN_TEST, deadline, address, 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;
}
use of io.nem.symbol.sdk.model.transaction.SignedTransaction in project nem2-sdk-java by nemtech.
the class TransactionRepositoryOkHttpImplTest method shouldAnnounce.
@Test
public void shouldAnnounce() throws Exception {
SignedTransaction signedTransaction = getSignedTransaction();
AnnounceTransactionInfoDTO announceTransactionInfoDTO = new AnnounceTransactionInfoDTO();
announceTransactionInfoDTO.setMessage("SomeMessage");
mockRemoteCall(announceTransactionInfoDTO);
TransactionAnnounceResponse response = repository.announce(signedTransaction).toFuture().get();
Assertions.assertNotNull(response);
Assertions.assertEquals(announceTransactionInfoDTO.getMessage(), announceTransactionInfoDTO.getMessage());
}
use of io.nem.symbol.sdk.model.transaction.SignedTransaction in project nem2-sdk-java by nemtech.
the class ListenerIntegrationTest method shouldReturnUnconfirmedRemovedTransactionViaListener.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void shouldReturnUnconfirmedRemovedTransactionViaListener(RepositoryType type) {
Listener listener = getListener(type);
SignedTransaction signedTransaction = this.announceStandaloneTransferTransaction(type, this.getRecipient());
String transactionHash = get(listener.unconfirmedRemoved(this.account.getAddress()).take(1));
assertEquals(signedTransaction.getHash(), transactionHash);
}
use of io.nem.symbol.sdk.model.transaction.SignedTransaction in project nem2-sdk-java by nemtech.
the class ListenerIntegrationTest method announceStandaloneTransferTransaction.
private SignedTransaction announceStandaloneTransferTransaction(RepositoryType type, Address recipient) {
TransferTransaction transferTransaction = TransferTransactionFactory.create(getNetworkType(), getDeadline(), recipient, Collections.singletonList(getNetworkCurrency().createAbsolute(BigInteger.valueOf(10000L)))).message(new PlainMessage("test-message")).maxFee(maxFee).build();
SignedTransaction signedTransaction = this.account.sign(transferTransaction, getGenerationHash());
System.out.println("Announcing transaction " + signedTransaction.getHash());
get(getTransactionRepository(type).announce(signedTransaction));
System.out.println("Transaction " + signedTransaction.getHash() + " Announced");
return signedTransaction;
}
use of io.nem.symbol.sdk.model.transaction.SignedTransaction in project nem2-sdk-java by nemtech.
the class CreatingAnEscrowContractWithAggregateBondedTransactionIntegrationTest method executeTransfer.
@Test
@Disabled
void executeTransfer() {
Account ticketDistributorAccount = this.config().getTestAccount();
Account aliceAccount = this.config().getTestAccount2();
RepositoryType type = DEFAULT_REPOSITORY_TYPE;
MosaicId mosaicId = createMosaic(ticketDistributorAccount, type, BigInteger.ZERO, null);
TransferTransaction aliceToTicketDistributorTx = TransferTransactionFactory.create(getNetworkType(), getDeadline(), ticketDistributorAccount.getAddress(), Collections.singletonList(getNetworkCurrency().createRelative(BigInteger.valueOf(100)))).message(new PlainMessage("send 100 cat.currency to distributor")).maxFee(maxFee).build();
TransferTransaction ticketDistributorToAliceTx = TransferTransactionFactory.create(getNetworkType(), getDeadline(), aliceAccount.getAddress(), Collections.singletonList(new Mosaic(mosaicId, BigInteger.ONE))).message(new PlainMessage("send 1 museum ticket to alice")).maxFee(maxFee).build();
/* end block 01 */
/* start block 02 */
AggregateTransaction aggregateTransaction = AggregateTransactionFactory.createBonded(getNetworkType(), getDeadline(), Arrays.asList(aliceToTicketDistributorTx.toAggregate(aliceAccount.getPublicAccount()), ticketDistributorToAliceTx.toAggregate(ticketDistributorAccount.getPublicAccount()))).maxFee(maxFee).build();
String networkGenerationHash = getGenerationHash();
SignedTransaction signedTransaction = aliceAccount.sign(aggregateTransaction, networkGenerationHash);
System.out.println("Aggregate Transaction Hash: " + signedTransaction.getHash());
/* end block 02 */
/* start block 03 */
HashLockTransaction hashLockTransaction = HashLockTransactionFactory.create(getNetworkType(), getDeadline(), getNetworkCurrency().createRelative(BigInteger.TEN), BigInteger.valueOf(480), signedTransaction).maxFee(maxFee).build();
SignedTransaction signedHashLockTransaction = aliceAccount.sign(hashLockTransaction, networkGenerationHash);
System.out.println("Hash Transaction Hash: " + hashLockTransaction.getHash());
TransactionService transactionService = getTransactionService(type);
Transaction transaction = get(transactionService.announceHashLockAggregateBonded(getListener(type), signedHashLockTransaction, signedTransaction));
Assertions.assertNotNull(transaction);
}
Aggregations