use of io.nem.sdk.model.account.Address in project nem2-sdk-java by nemtech.
the class TransferTransactionTest method serialization.
@Test
@DisplayName("Serialization")
void serialization() {
// Generated at nem2-library-js/test/transactions/TransferTransaction.spec.js
byte[] expected = new byte[] { (byte) 165, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, (byte) 144, 84, 65, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, (byte) 144, (byte) 232, (byte) 254, (byte) 189, (byte) 103, (byte) 29, (byte) 212, (byte) 27, (byte) 238, (byte) 148, (byte) 236, (byte) 59, (byte) 165, (byte) 131, (byte) 28, (byte) 182, (byte) 8, (byte) 163, (byte) 18, (byte) 194, (byte) 242, (byte) 3, (byte) 186, (byte) 132, (byte) 172, 1, 0, 1, 0, 103, 43, 0, 0, (byte) 206, 86, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0 };
TransferTransaction transferTransaction = TransferTransaction.create(new FakeDeadline(), new Address("SDUP5PLHDXKBX3UU5Q52LAY4WYEKGEWC6IB3VBFM", NetworkType.MIJIN_TEST), Arrays.asList(new Mosaic(new MosaicId(new BigInteger("95442763262823")), BigInteger.valueOf(100))), PlainMessage.Empty, NetworkType.MIJIN_TEST);
byte[] actual = transferTransaction.generateBytes();
assertArrayEquals(expected, actual);
}
use of io.nem.sdk.model.account.Address in project nem2-sdk-java by nemtech.
the class E2ETest method CosignatureTransaction.
@Test
void CosignatureTransaction() throws ExecutionException, InterruptedException {
TransferTransaction transferTransaction = TransferTransaction.create(new Deadline(2, HOURS), new Address("SDRDGFTDLLCB67D4HPGIMIHPNSRYRJRT7DOBGWZY", NetworkType.MIJIN_TEST), Collections.singletonList(XEM.createAbsolute(BigInteger.valueOf(1))), PlainMessage.create("test-message"), NetworkType.MIJIN_TEST);
AggregateTransaction aggregateTransaction = AggregateTransaction.createComplete(new Deadline(2, HOURS), Collections.singletonList(transferTransaction.toAggregate(this.multisigAccount.getPublicAccount())), NetworkType.MIJIN_TEST);
SignedTransaction signedTransaction = this.cosignatoryAccount.sign(aggregateTransaction);
LockFundsTransaction lockFundsTransaction = LockFundsTransaction.create(new Deadline(2, HOURS), XEM.createRelative(BigInteger.valueOf(10)), BigInteger.valueOf(100), signedTransaction, NetworkType.MIJIN_TEST);
SignedTransaction lockFundsSignedTransaction = this.cosignatoryAccount.sign(lockFundsTransaction);
transactionHttp.announce(lockFundsSignedTransaction).toFuture().get();
listener.confirmed(this.cosignatoryAccount.getAddress()).take(1).toFuture().get();
transactionHttp.announceAggregateBonded(signedTransaction).toFuture().get();
this.validateAggregateBondedTransactionAnnounceCorrectly(this.cosignatoryAccount.getAddress(), signedTransaction.getHash());
CosignatureTransaction cosignatureTransaction = CosignatureTransaction.create(aggregateTransaction);
CosignatureSignedTransaction cosignatureSignedTransaction = this.cosignatoryAccount2.signCosignatureTransaction(cosignatureTransaction);
transactionHttp.announceAggregateBondedCosignature(cosignatureSignedTransaction).toFuture().get();
this.validateAggregateBondedCosignatureTransactionAnnounceCorrectly(this.cosignatoryAccount.getAddress(), cosignatureSignedTransaction.getParentHash());
}
use of io.nem.sdk.model.account.Address in project nem2-sdk-java by nemtech.
the class ListenerTest method announceStandaloneTransferTransactionWithInsufficientBalance.
private SignedTransaction announceStandaloneTransferTransactionWithInsufficientBalance() throws ExecutionException, InterruptedException {
TransferTransaction transferTransaction = TransferTransaction.create(new Deadline(2, HOURS), new Address("SBILTA367K2LX2FEXG5TFWAS7GEFYAGY7QLFBYKC", NetworkType.MIJIN_TEST), Arrays.asList(XEM.createRelative(new BigInteger("100000000000"))), PlainMessage.create("test-message"), NetworkType.MIJIN_TEST);
SignedTransaction signedTransaction = this.account.sign(transferTransaction);
transactionHttp.announce(signedTransaction).toFuture().get();
return signedTransaction;
}
use of io.nem.sdk.model.account.Address in project nem2-sdk-java by nemtech.
the class NamespaceHttp method getNamespacesFromAccounts.
private Observable<List<NamespaceInfo>> getNamespacesFromAccounts(List<Address> addresses, Optional<QueryParams> queryParams) {
JsonObject requestBody = new JsonObject();
requestBody.put("addresses", addresses.stream().map((address -> address.plain())).collect(Collectors.toList()));
Observable<NetworkType> networkTypeResolve = getNetworkTypeObservable();
return networkTypeResolve.flatMap(networkType -> this.client.postAbs(this.url + "/account/namespaces" + (queryParams.isPresent() ? queryParams.get().toUrl() : "")).as(BodyCodec.jsonArray()).rxSendJson(requestBody).toObservable().map(HttpResponse::body).map(json -> objectMapper.<List<NamespaceInfoDTO>>readValue(json.toString(), new TypeReference<List<NamespaceInfoDTO>>() {
})).flatMapIterable(item -> item).map(namespaceInfoDTO -> new NamespaceInfo(namespaceInfoDTO.getMeta().isActive(), namespaceInfoDTO.getMeta().getIndex(), namespaceInfoDTO.getMeta().getId(), NamespaceType.rawValueOf(namespaceInfoDTO.getNamespace().getType()), namespaceInfoDTO.getNamespace().getDepth(), extractLevels(namespaceInfoDTO), new NamespaceId(namespaceInfoDTO.getNamespace().getParentId().extractIntArray()), new PublicAccount(namespaceInfoDTO.getNamespace().getOwner(), networkType), namespaceInfoDTO.getNamespace().getStartHeight().extractIntArray(), namespaceInfoDTO.getNamespace().getEndHeight().extractIntArray())).toList().toObservable());
}
Aggregations