diff --git a/.gitignore b/.gitignore index 21282d23..61a0eba3 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,30 @@ .gradle .idea/ .tags -build +.project +/build/ out/ +bin/ +.settings +.classpath + +# Ignore Gradle GUI config +gradle-app.setting + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar + +# Cache of project +.gradletasknamecache + +gen/ +idea-gitignore.jar +resources/templates.list +resources/gitignore/* +build/ +build.properties +junit*.properties +IgnoreLexer.java~ +.DS_Store + +/verification diff --git a/CHANGELOG.md b/CHANGELOG.md index 6993f28e..0fb273d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## Unreleased +## 1.0.0 - 2020-02-11 + +### Changed +- Upgrade Dependencies + +### Added +- Add Support for new Core v2.6 Transaction Types + ## 0.1.6 - 2019-10-15 ### Changed diff --git a/build.gradle b/build.gradle index f4ec520c..07c4974a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,9 @@ +buildscript { + dependencies { + classpath "com.diffplug.spotless:spotless-plugin-gradle:3.27.1" + } +} + plugins { id 'java' id 'maven' @@ -9,12 +15,26 @@ plugins { apply plugin:'java' apply plugin:'maven' apply plugin:'maven-publish' +apply plugin: com.diffplug.gradle.spotless.SpotlessPlugin repositories { jcenter() mavenCentral() } +task fatJar(type: Jar) { + manifest.from jar.manifest + classifier = 'standalone' + from { + configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } + } { + exclude "META-INF/*.SF" + exclude "META-INF/*.DSA" + exclude "META-INF/*.RSA" + } + with jar +} + task javadocJar(type: Jar) { classifier = 'javadoc' from javadoc @@ -34,11 +54,11 @@ uploadArchives { mavenDeployer { beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - repository(url: "file://${buildDir}/repo") {} + repository(url: "file://${buildDir}/repo") {} //repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2") { - // authentication(userName: '', password: '') - // } + // authentication(userName: '', password: '') + // } // snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { // authentication(userName: ossrhUsername, password: ossrhPassword) @@ -46,7 +66,7 @@ uploadArchives { pom.project { groupId = 'org.arkecosystem' - version = '0.1.6' + version = '1.0.0' artifactId = 'crypto' name = 'java-crypto' @@ -80,12 +100,18 @@ uploadArchives { organization = 'Ark Ecosystem' organizationUrl = 'https://ark.io' } + developer { + name = 'Zan Kovac' + email = 'zan@ark.io' + organization = 'Ark Ecosystem' + organizationUrl = 'https://ark.io' + } } scm { connection = 'scm:git:git://github.com/ArkEcosystem/java-crypto.git' developerConnection = 'scm:git:ssh://github.com:ArkEcosystem/java-crypto.git' - url = 'https://github.com/ArkEcosystem/java-crypto/tree/0.1.6' + url = 'https://github.com/ArkEcosystem/java-crypto/tree/1.0.0' } } } @@ -124,5 +150,20 @@ jacocoTestReport { } wrapper { - gradleVersion = '4.9' + gradleVersion = '5.6.2' } + spotless { + java { + target fileTree(projectDir) { + include 'src/main/**/*.java' + include 'src/test/**/*.java' + exclude '**/build/**' + } + googleJavaFormat('1.1').aosp() + } + } + + +task formatCode(dependsOn: ['spotlessApply']) + +build.dependsOn 'spotlessApply' diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 1948b907..5c2d1cf0 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradlew b/gradlew index cccdd3d5..83f2acfd 100755 --- a/gradlew +++ b/gradlew @@ -1,5 +1,21 @@ #!/usr/bin/env sh +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + ############################################################################## ## ## Gradle start up script for UN*X @@ -28,7 +44,7 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" @@ -109,8 +125,8 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` diff --git a/gradlew.bat b/gradlew.bat index e95643d6..24467a14 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome diff --git a/src/main/java/org/arkecosystem/crypto/configuration/Fee.java b/src/main/java/org/arkecosystem/crypto/configuration/Fee.java index 12d36a5a..a7ce7720 100644 --- a/src/main/java/org/arkecosystem/crypto/configuration/Fee.java +++ b/src/main/java/org/arkecosystem/crypto/configuration/Fee.java @@ -1,31 +1,53 @@ package org.arkecosystem.crypto.configuration; -import org.arkecosystem.crypto.enums.Fees; -import org.arkecosystem.crypto.enums.Types; - import java.util.HashMap; import java.util.Map; +import org.arkecosystem.crypto.enums.CoreTransactionTypes; +import org.arkecosystem.crypto.enums.Fees; +import org.arkecosystem.crypto.enums.TransactionTypeGroup; public class Fee { - private static Map fees = new HashMap<>(); + private static Map> internalTransactionTypes = new HashMap<>(); static { - fees.put(Types.TRANSFER, Fees.TRANSFER.getValue()); - fees.put(Types.SECOND_SIGNATURE_REGISTRATION, Fees.SECOND_SIGNATURE_REGISTRATION.getValue()); - fees.put(Types.DELEGATE_REGISTRATION, Fees.DELEGATE_REGISTRATION.getValue()); - fees.put(Types.VOTE, Fees.VOTE.getValue()); - fees.put(Types.MULTI_SIGNATURE_REGISTRATION, Fees.MULTI_SIGNATURE_REGISTRATION.getValue()); - fees.put(Types.IPFS, Fees.IPFS.getValue()); - fees.put(Types.TIMELOCK_TRANSFER, Fees.TIMELOCK_TRANSFER.getValue()); - fees.put(Types.MULTI_PAYMENT, Fees.MULTI_PAYMENT.getValue()); - fees.put(Types.DELEGATE_RESIGNATION, Fees.DELEGATE_RESIGNATION.getValue()); + Map coreFees = new HashMap<>(); + + coreFees.put(CoreTransactionTypes.TRANSFER.getValue(), Fees.TRANSFER.getValue()); + coreFees.put( + CoreTransactionTypes.SECOND_SIGNATURE_REGISTRATION.getValue(), + Fees.SECOND_SIGNATURE_REGISTRATION.getValue()); + coreFees.put( + CoreTransactionTypes.DELEGATE_REGISTRATION.getValue(), + Fees.DELEGATE_REGISTRATION.getValue()); + coreFees.put(CoreTransactionTypes.VOTE.getValue(), Fees.VOTE.getValue()); + coreFees.put( + CoreTransactionTypes.MULTI_SIGNATURE_REGISTRATION.getValue(), + Fees.MULTI_SIGNATURE_REGISTRATION.getValue()); + coreFees.put(CoreTransactionTypes.IPFS.getValue(), Fees.IPFS.getValue()); + coreFees.put(CoreTransactionTypes.MULTI_PAYMENT.getValue(), Fees.MULTI_PAYMENT.getValue()); + coreFees.put( + CoreTransactionTypes.DELEGATE_RESIGNATION.getValue(), + Fees.DELEGATE_RESIGNATION.getValue()); + coreFees.put(CoreTransactionTypes.HTLC_LOCK.getValue(), Fees.HTLC_LOCK.getValue()); + coreFees.put(CoreTransactionTypes.HTLC_CLAIM.getValue(), Fees.HTLC_CLAIM.getValue()); + coreFees.put(CoreTransactionTypes.HTLC_REFUND.getValue(), Fees.HTLC_REFUND.getValue()); + + internalTransactionTypes.put(TransactionTypeGroup.CORE.getValue(), coreFees); + } + + public static long getFee(int transactionTypeGroup, int type) { + return internalTransactionTypes.get(transactionTypeGroup).get(type); } - public static long get(Types type) { - return fees.get(type); + public static long getCoreFee(int type) { + return internalTransactionTypes.get(TransactionTypeGroup.CORE.getValue()).get(type); } - public static void set(Types type, long fee) { - fees.put(type, fee); + public static void set(int transactionTypeGroup, Map transactionTypes) { + if (transactionTypeGroup < TransactionTypeGroup.RESERVED.getValue()) { + throw new IllegalArgumentException( + "Cannot add TransactionTypeGroup with value less then 1000"); + } + internalTransactionTypes.put(transactionTypeGroup, transactionTypes); } } diff --git a/src/main/java/org/arkecosystem/crypto/encoding/Base58.java b/src/main/java/org/arkecosystem/crypto/encoding/Base58.java index b9eb0451..9dc31a81 100644 --- a/src/main/java/org/arkecosystem/crypto/encoding/Base58.java +++ b/src/main/java/org/arkecosystem/crypto/encoding/Base58.java @@ -14,4 +14,11 @@ public static byte[] decodeChecked(String value) { return org.bitcoinj.core.Base58.decodeChecked(value); } + public static byte[] decode(String value) { + return org.bitcoinj.core.Base58.decode(value); + } + + public static String encode(byte[] value) { + return org.bitcoinj.core.Base58.encode(value); + } } diff --git a/src/main/java/org/arkecosystem/crypto/encoding/Hex.java b/src/main/java/org/arkecosystem/crypto/encoding/Hex.java index a06b0ca1..060df4c2 100644 --- a/src/main/java/org/arkecosystem/crypto/encoding/Hex.java +++ b/src/main/java/org/arkecosystem/crypto/encoding/Hex.java @@ -10,5 +10,4 @@ public static String encode(byte[] value) { public static byte[] decode(String value) { return BaseEncoding.base16().lowerCase().decode(value); } - } diff --git a/src/main/java/org/arkecosystem/crypto/enums/Types.java b/src/main/java/org/arkecosystem/crypto/enums/CoreTransactionTypes.java similarity index 63% rename from src/main/java/org/arkecosystem/crypto/enums/Types.java rename to src/main/java/org/arkecosystem/crypto/enums/CoreTransactionTypes.java index c7b09e98..59ef82da 100644 --- a/src/main/java/org/arkecosystem/crypto/enums/Types.java +++ b/src/main/java/org/arkecosystem/crypto/enums/CoreTransactionTypes.java @@ -1,19 +1,21 @@ package org.arkecosystem.crypto.enums; -public enum Types { +public enum CoreTransactionTypes { TRANSFER(0), SECOND_SIGNATURE_REGISTRATION(1), DELEGATE_REGISTRATION(2), VOTE(3), MULTI_SIGNATURE_REGISTRATION(4), IPFS(5), - TIMELOCK_TRANSFER(6), - MULTI_PAYMENT(7), - DELEGATE_RESIGNATION(8); + MULTI_PAYMENT(6), + DELEGATE_RESIGNATION(7), + HTLC_LOCK(8), + HTLC_CLAIM(9), + HTLC_REFUND(10); private final int value; - Types(int value) { + CoreTransactionTypes(int value) { this.value = value; } diff --git a/src/main/java/org/arkecosystem/crypto/enums/Fees.java b/src/main/java/org/arkecosystem/crypto/enums/Fees.java index 1a4b38fe..ea2a3103 100644 --- a/src/main/java/org/arkecosystem/crypto/enums/Fees.java +++ b/src/main/java/org/arkecosystem/crypto/enums/Fees.java @@ -6,10 +6,12 @@ public enum Fees { DELEGATE_REGISTRATION(2_500_000_000L), VOTE(100_000_000L), MULTI_SIGNATURE_REGISTRATION(500_000_000L), - IPFS(0L), - TIMELOCK_TRANSFER(0L), - MULTI_PAYMENT(0L), - DELEGATE_RESIGNATION(0L); + IPFS(500_000_000L), + MULTI_PAYMENT(10_000_000L), + DELEGATE_RESIGNATION(2_500_000_000L), + HTLC_LOCK(10_000_000L), + HTLC_CLAIM(0L), + HTLC_REFUND(0L); private final Long value; diff --git a/src/main/java/org/arkecosystem/crypto/enums/HtlcLockExpirationType.java b/src/main/java/org/arkecosystem/crypto/enums/HtlcLockExpirationType.java new file mode 100644 index 00000000..5d10b8e9 --- /dev/null +++ b/src/main/java/org/arkecosystem/crypto/enums/HtlcLockExpirationType.java @@ -0,0 +1,16 @@ +package org.arkecosystem.crypto.enums; + +public enum HtlcLockExpirationType { + EPOCH_TIMESTAMP(1), + BLOCK_HEIGHT(2); + + private final int value; + + HtlcLockExpirationType(int value) { + this.value = value; + } + + public int getValue() { + return value; + } +} diff --git a/src/main/java/org/arkecosystem/crypto/enums/TransactionTypeGroup.java b/src/main/java/org/arkecosystem/crypto/enums/TransactionTypeGroup.java new file mode 100644 index 00000000..b61b8c38 --- /dev/null +++ b/src/main/java/org/arkecosystem/crypto/enums/TransactionTypeGroup.java @@ -0,0 +1,18 @@ +package org.arkecosystem.crypto.enums; + +public enum TransactionTypeGroup { + TEST(0), + CORE(1), + + RESERVED(1000); + + private final int value; + + TransactionTypeGroup(int value) { + this.value = value; + } + + public int getValue() { + return value; + } +} diff --git a/src/main/java/org/arkecosystem/crypto/identities/Address.java b/src/main/java/org/arkecosystem/crypto/identities/Address.java index adb2d3b6..d9d429eb 100644 --- a/src/main/java/org/arkecosystem/crypto/identities/Address.java +++ b/src/main/java/org/arkecosystem/crypto/identities/Address.java @@ -28,7 +28,7 @@ public static String fromPublicKey(String publicKey, Integer networkVersion) { networkVersion = Network.get().version(); } - byte[] bytes = Bytes.concat(new byte[]{networkVersion.byteValue()}, out); + byte[] bytes = Bytes.concat(new byte[] {networkVersion.byteValue()}, out); return Base58.encodeChecked(bytes); } @@ -49,12 +49,10 @@ public static Boolean validate(String address, Integer networkVersion) { networkVersion = Network.get().version(); } - return Base58.decodeChecked(address)[0] == networkVersion; } public static Boolean validate(String address) { return Address.validate(address, null); } - } diff --git a/src/main/java/org/arkecosystem/crypto/identities/PrivateKey.java b/src/main/java/org/arkecosystem/crypto/identities/PrivateKey.java index dea74cd3..9e4ea627 100644 --- a/src/main/java/org/arkecosystem/crypto/identities/PrivateKey.java +++ b/src/main/java/org/arkecosystem/crypto/identities/PrivateKey.java @@ -14,5 +14,4 @@ public static ECKey fromPassphrase(String passphrase) { public static ECKey fromHex(String privateKey) { return ECKey.fromPrivate(Hex.decode(privateKey), true); } - } diff --git a/src/main/java/org/arkecosystem/crypto/identities/PublicKey.java b/src/main/java/org/arkecosystem/crypto/identities/PublicKey.java index 9998e657..22c884d8 100644 --- a/src/main/java/org/arkecosystem/crypto/identities/PublicKey.java +++ b/src/main/java/org/arkecosystem/crypto/identities/PublicKey.java @@ -4,5 +4,4 @@ public class PublicKey { public static String fromPassphrase(String passphrase) { return PrivateKey.fromPassphrase(passphrase).getPublicKeyAsHex(); } - } diff --git a/src/main/java/org/arkecosystem/crypto/identities/WIF.java b/src/main/java/org/arkecosystem/crypto/identities/WIF.java index 44fa5c4d..3ddc4c63 100644 --- a/src/main/java/org/arkecosystem/crypto/identities/WIF.java +++ b/src/main/java/org/arkecosystem/crypto/identities/WIF.java @@ -1,12 +1,11 @@ package org.arkecosystem.crypto.identities; +import java.io.ByteArrayOutputStream; +import java.io.IOException; import org.arkecosystem.crypto.configuration.Network; import org.arkecosystem.crypto.encoding.Base58; import org.bitcoinj.core.Sha256Hash; -import java.io.ByteArrayOutputStream; -import java.io.IOException; - public class WIF { public static String fromPassphrase(String passphrase) throws IOException { byte[] secret = Sha256Hash.hash(passphrase.getBytes()); @@ -18,5 +17,4 @@ public static String fromPassphrase(String passphrase) throws IOException { return Base58.encodeChecked(outputStream.toByteArray()); } - } diff --git a/src/main/java/org/arkecosystem/crypto/networks/Devnet.java b/src/main/java/org/arkecosystem/crypto/networks/Devnet.java index 2a246684..ff89bd8a 100644 --- a/src/main/java/org/arkecosystem/crypto/networks/Devnet.java +++ b/src/main/java/org/arkecosystem/crypto/networks/Devnet.java @@ -13,5 +13,4 @@ public int wif() { public String epoch() { return "2017-03-21 13:00:00"; } - } diff --git a/src/main/java/org/arkecosystem/crypto/networks/INetwork.java b/src/main/java/org/arkecosystem/crypto/networks/INetwork.java index a5733347..cfc01482 100644 --- a/src/main/java/org/arkecosystem/crypto/networks/INetwork.java +++ b/src/main/java/org/arkecosystem/crypto/networks/INetwork.java @@ -7,5 +7,4 @@ public interface INetwork { int wif(); String epoch(); - } diff --git a/src/main/java/org/arkecosystem/crypto/networks/Mainnet.java b/src/main/java/org/arkecosystem/crypto/networks/Mainnet.java index e62a203f..2f3bbb59 100644 --- a/src/main/java/org/arkecosystem/crypto/networks/Mainnet.java +++ b/src/main/java/org/arkecosystem/crypto/networks/Mainnet.java @@ -13,5 +13,4 @@ public int wif() { public String epoch() { return "2017-03-21 13:00:00"; } - } diff --git a/src/main/java/org/arkecosystem/crypto/networks/Testnet.java b/src/main/java/org/arkecosystem/crypto/networks/Testnet.java index 65999b9b..0066e500 100644 --- a/src/main/java/org/arkecosystem/crypto/networks/Testnet.java +++ b/src/main/java/org/arkecosystem/crypto/networks/Testnet.java @@ -13,5 +13,4 @@ public int wif() { public String epoch() { return "2017-03-21 13:00:00"; } - } diff --git a/src/main/java/org/arkecosystem/crypto/transactions/Deserializer.java b/src/main/java/org/arkecosystem/crypto/transactions/Deserializer.java index fba41cfe..da7280f0 100644 --- a/src/main/java/org/arkecosystem/crypto/transactions/Deserializer.java +++ b/src/main/java/org/arkecosystem/crypto/transactions/Deserializer.java @@ -1,13 +1,13 @@ package org.arkecosystem.crypto.transactions; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; import org.arkecosystem.crypto.encoding.Hex; -import org.arkecosystem.crypto.enums.Types; +import org.arkecosystem.crypto.enums.CoreTransactionTypes; +import org.arkecosystem.crypto.enums.TransactionTypeGroup; import org.arkecosystem.crypto.identities.Address; import org.arkecosystem.crypto.transactions.deserializers.*; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - public class Deserializer { private String serialized; @@ -16,7 +16,6 @@ public class Deserializer { public Transaction deserialize(String serialized) { this.serialized = serialized; - this.buffer = ByteBuffer.wrap(Hex.decode(serialized)).slice(); this.buffer.order(ByteOrder.LITTLE_ENDIAN); this.buffer.get(); @@ -25,17 +24,23 @@ public Transaction deserialize(String serialized) { int assetOffset = deserializeHeader(); deserializeTypeSpecific(assetOffset); + deserializeVersionOne(); return this.transaction; } - public int deserializeHeader() { + private int deserializeHeader() { transaction.version = this.buffer.get(); transaction.network = this.buffer.get(); - transaction.type = Types.values()[this.buffer.get()]; - transaction.timestamp = this.buffer.getInt(); - + if (transaction.version == 1) { + transaction.type = CoreTransactionTypes.values()[this.buffer.get()].getValue(); + transaction.timestamp = this.buffer.getInt(); + } else { + transaction.typeGroup = TransactionTypeGroup.values()[this.buffer.getInt()].getValue(); + transaction.type = CoreTransactionTypes.values()[this.buffer.getShort()].getValue(); + transaction.nonce = this.buffer.getLong(); + } byte[] senderPublicKey = new byte[33]; this.buffer.get(senderPublicKey); transaction.senderPublicKey = Hex.encode(senderPublicKey); @@ -49,41 +54,77 @@ public int deserializeHeader() { transaction.vendorFieldHex = Hex.encode(vendorFieldHex); } - return (41 + 8 + 1) * 2 + vendorFieldLength * 2; + if (transaction.version == 1) { + return (41 + 8 + 1) * 2 + vendorFieldLength * 2; + } else { + return 59 * 2 + vendorFieldLength * 2; + } } - public void deserializeTypeSpecific(int assetOffset) { - switch (transaction.type) { + private void deserializeTypeSpecific(int assetOffset) { + CoreTransactionTypes transactionType = CoreTransactionTypes.values()[transaction.type]; + switch (transactionType) { case TRANSFER: - new Transfer(this.serialized, this.buffer, this.transaction).deserialize(assetOffset); + new Transfer(this.serialized, this.buffer, this.transaction) + .deserialize(assetOffset); break; case SECOND_SIGNATURE_REGISTRATION: - new SecondSignatureRegistration(this.serialized, this.buffer, this.transaction).deserialize(assetOffset); + new SecondSignatureRegistration(this.serialized, this.buffer, this.transaction) + .deserialize(assetOffset); break; case DELEGATE_REGISTRATION: - new DelegateRegistration(this.serialized, this.buffer, this.transaction).deserialize(assetOffset); + new DelegateRegistration(this.serialized, this.buffer, this.transaction) + .deserialize(assetOffset); break; case VOTE: new Vote(this.serialized, this.buffer, this.transaction).deserialize(assetOffset); break; case MULTI_SIGNATURE_REGISTRATION: - new MultiSignatureRegistration(this.serialized, this.buffer, this.transaction).deserialize(assetOffset); + new MultiSignatureRegistration(this.serialized, this.buffer, this.transaction) + .deserialize(assetOffset); + break; + case IPFS: + new Ipfs(this.serialized, this.buffer, this.transaction).deserialize(assetOffset); + break; + case MULTI_PAYMENT: + new MultiPayment(this.serialized, this.buffer, this.transaction) + .deserialize(assetOffset); + break; + case DELEGATE_RESIGNATION: + new DelegateResignation(this.serialized, this.buffer, this.transaction) + .deserialize(assetOffset); + break; + case HTLC_LOCK: + new HtlcLock(this.serialized, this.buffer, this.transaction) + .deserialize(assetOffset); break; + case HTLC_CLAIM: + new HtlcClaim(this.serialized, this.buffer, this.transaction) + .deserialize(assetOffset); + break; + case HTLC_REFUND: + new HtlcRefund(this.serialized, this.buffer, this.transaction) + .deserialize(assetOffset); + break; + default: + throw new UnsupportedOperationException(); } } - public void deserializeVersionOne() { + private void deserializeVersionOne() { if (transaction.secondSignature != null) { transaction.signSignature = transaction.secondSignature; } - if (transaction.type == Types.VOTE) { - transaction.recipientId = Address.fromPublicKey(transaction.senderPublicKey, transaction.network); + if (transaction.type == CoreTransactionTypes.VOTE.getValue()) { + transaction.recipientId = + Address.fromPublicKey(transaction.senderPublicKey, transaction.network); } - if (transaction.type == Types.MULTI_SIGNATURE_REGISTRATION) { + if (transaction.type == CoreTransactionTypes.MULTI_SIGNATURE_REGISTRATION.getValue()) { for (int i = 0; i < transaction.asset.multisignature.keysgroup.size(); i++) { - transaction.asset.multisignature.keysgroup.set(i, "+" + transaction.asset.multisignature.keysgroup.get(i)); + transaction.asset.multisignature.keysgroup.set( + i, "+" + transaction.asset.multisignature.keysgroup.get(i)); } } @@ -95,10 +136,11 @@ public void deserializeVersionOne() { transaction.id = transaction.computeId(); } - if (transaction.type == Types.SECOND_SIGNATURE_REGISTRATION || transaction.type == Types.MULTI_SIGNATURE_REGISTRATION) { - transaction.recipientId = Address.fromPublicKey(transaction.senderPublicKey, transaction.network); + if (transaction.type == CoreTransactionTypes.SECOND_SIGNATURE_REGISTRATION.getValue() + || transaction.type + == CoreTransactionTypes.MULTI_SIGNATURE_REGISTRATION.getValue()) { + transaction.recipientId = + Address.fromPublicKey(transaction.senderPublicKey, transaction.network); } - } - } diff --git a/src/main/java/org/arkecosystem/crypto/transactions/Serializer.java b/src/main/java/org/arkecosystem/crypto/transactions/Serializer.java index 0c29e209..1c894c71 100644 --- a/src/main/java/org/arkecosystem/crypto/transactions/Serializer.java +++ b/src/main/java/org/arkecosystem/crypto/transactions/Serializer.java @@ -1,26 +1,30 @@ package org.arkecosystem.crypto.transactions; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; import org.arkecosystem.crypto.configuration.Network; import org.arkecosystem.crypto.encoding.Hex; +import org.arkecosystem.crypto.enums.CoreTransactionTypes; import org.arkecosystem.crypto.transactions.serializers.*; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - public class Serializer { private ByteBuffer buffer; private Transaction transaction; - public byte[] serialize(Transaction transaction) { + public byte[] serialize( + Transaction transaction, boolean skipSignature, boolean skipSecondSignature) { this.transaction = transaction; this.buffer = ByteBuffer.allocate(512); this.buffer.order(ByteOrder.LITTLE_ENDIAN); serializeHeader(); + serializeVendorField(); + serializeTypeSpecific(); - serializeSignatures(); + + serializeSignatures(skipSignature, skipSecondSignature); byte[] result = new byte[this.buffer.position()]; this.buffer.rewind(); @@ -29,6 +33,10 @@ public byte[] serialize(Transaction transaction) { return result; } + public byte[] serialize(Transaction transaction) { + return this.serialize(transaction, false, false); + } + private void serializeHeader() { this.buffer.put((byte) 0xff); @@ -44,11 +52,20 @@ private void serializeHeader() { this.buffer.put((byte) Network.get().version()); } - this.buffer.put((byte) this.transaction.type.getValue()); - this.buffer.putInt(this.transaction.timestamp); + if (transaction.version == 1) { + this.buffer.put((byte) this.transaction.type); + this.buffer.putInt(this.transaction.timestamp); + } else { + this.buffer.putInt(this.transaction.typeGroup); + this.buffer.putShort((short) this.transaction.type); + this.buffer.putLong(this.transaction.nonce); + } + this.buffer.put(Hex.decode(this.transaction.senderPublicKey)); this.buffer.putLong(this.transaction.fee); + } + private void serializeVendorField() { if (this.transaction.vendorField != null) { int vendorFieldLength = this.transaction.vendorField.length(); @@ -62,11 +79,11 @@ private void serializeHeader() { } else { this.buffer.put((byte) 0x00); } - } private void serializeTypeSpecific() { - switch (transaction.type) { + CoreTransactionTypes transactionType = CoreTransactionTypes.values()[transaction.type]; + switch (transactionType) { case TRANSFER: new Transfer(this.buffer, this.transaction).serialize(); break; @@ -82,20 +99,36 @@ private void serializeTypeSpecific() { case MULTI_SIGNATURE_REGISTRATION: new MultiSignatureRegistration(this.buffer, this.transaction).serialize(); break; + case IPFS: + new Ipfs(this.buffer, this.transaction).serialize(); + break; + case MULTI_PAYMENT: + new MultiPayment(this.buffer, this.transaction).serialize(); + break; + case DELEGATE_RESIGNATION: + new DelegateResignation(this.buffer, this.transaction).serialize(); + break; + case HTLC_LOCK: + new HtlcLock(this.buffer, this.transaction).serialize(); + break; + case HTLC_CLAIM: + new HtlcClaim(this.buffer, this.transaction).serialize(); + break; + case HTLC_REFUND: + new HtlcRefund(this.buffer, this.transaction).serialize(); + break; default: throw new UnsupportedOperationException(); } } - private void serializeSignatures() { - if (this.transaction.signature != null) { + private void serializeSignatures(boolean skipSignature, boolean skipSecondSignature) { + if (!skipSignature) { buffer.put(Hex.decode(this.transaction.signature)); } - if (this.transaction.secondSignature != null) { + if (!skipSecondSignature && this.transaction.secondSignature != null) { buffer.put(Hex.decode(this.transaction.secondSignature)); - } else if (this.transaction.signSignature != null) { - buffer.put(Hex.decode(this.transaction.signSignature)); } if (this.transaction.signatures != null) { @@ -103,5 +136,4 @@ private void serializeSignatures() { buffer.put(Hex.decode(String.join("", this.transaction.signatures))); } } - } diff --git a/src/main/java/org/arkecosystem/crypto/transactions/Transaction.java b/src/main/java/org/arkecosystem/crypto/transactions/Transaction.java index ca80655c..589648ca 100644 --- a/src/main/java/org/arkecosystem/crypto/transactions/Transaction.java +++ b/src/main/java/org/arkecosystem/crypto/transactions/Transaction.java @@ -1,26 +1,25 @@ package org.arkecosystem.crypto.transactions; import com.google.gson.*; -import org.arkecosystem.crypto.encoding.Base58; -import org.arkecosystem.crypto.encoding.Hex; -import org.arkecosystem.crypto.enums.Types; -import org.arkecosystem.crypto.identities.PrivateKey; -import org.bitcoinj.core.ECKey; -import org.bitcoinj.core.Sha256Hash; -import org.bitcoinj.core.SignatureDecodeException; - import java.lang.reflect.Type; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import org.arkecosystem.crypto.encoding.Base58; +import org.arkecosystem.crypto.encoding.Hex; +import org.arkecosystem.crypto.enums.CoreTransactionTypes; +import org.arkecosystem.crypto.identities.PrivateKey; +import org.bitcoinj.core.ECKey; +import org.bitcoinj.core.Sha256Hash; +import org.bitcoinj.core.SignatureDecodeException; public class Transaction { public int expiration; public int network; public int timestamp; - public Types type; + public int type; public int version; public List signatures; public long amount = 0L; @@ -35,6 +34,8 @@ public class Transaction { public String vendorField; public String vendorFieldHex; + public long nonce; + public int typeGroup; public static Transaction deserialize(String serialized) { return new Deserializer().deserialize(serialized); @@ -48,7 +49,8 @@ public Transaction sign(String passphrase) { ECKey privateKey = PrivateKey.fromPassphrase(passphrase); this.senderPublicKey = privateKey.getPublicKeyAsHex(); - this.signature = Hex.encode(privateKey.sign(Sha256Hash.of(toBytes())).encodeToDER()); + this.signature = + Hex.encode(privateKey.sign(Sha256Hash.of(toBytes(true, true))).encodeToDER()); return this; } @@ -56,7 +58,8 @@ public Transaction sign(String passphrase) { public Transaction secondSign(String passphrase) { ECKey privateKey = PrivateKey.fromPassphrase(passphrase); - this.signSignature = Hex.encode(privateKey.sign(Sha256Hash.of(toBytes(false))).encodeToDER()); + this.signSignature = + Hex.encode(privateKey.sign(Sha256Hash.of(toBytes(false, true))).encodeToDER()); return this; } @@ -65,7 +68,7 @@ public boolean verify() { ECKey keys = ECKey.fromPublicOnly(Hex.decode(this.senderPublicKey)); byte[] signature = Hex.decode(this.signature); - byte[] bytes = toBytes(); + byte[] bytes = this.toBytes(true, true); try { return ECKey.verify(Sha256Hash.hash(bytes), signature, keys.getPubKey()); @@ -78,7 +81,7 @@ public boolean secondVerify(String secondPublicKey) { ECKey keys = ECKey.fromPublicOnly(Hex.decode(secondPublicKey)); byte[] signature = Hex.decode(this.signSignature); - byte[] bytes = toBytes(false); + byte[] bytes = toBytes(false, true); try { return ECKey.verify(Sha256Hash.hash(bytes), signature, keys.getPubKey()); @@ -87,9 +90,17 @@ public boolean secondVerify(String secondPublicKey) { } } + private byte[] toBytes(boolean skipSignature, boolean skipSecondSignature) { + if (this.version == 1) { + return this.toBytesV1(skipSignature, skipSecondSignature); + } else { + return new Serializer().serialize(this, skipSignature, skipSecondSignature); + } + } + + @Deprecated public Transaction parseSignatures(String serialized, int startOffset) { this.signature = serialized.substring(startOffset); - int multiSignatureOffset = 0; if (this.signature.length() == 0) { @@ -106,11 +117,12 @@ public Transaction parseSignatures(String serialized, int startOffset) { if ("ff".equals(this.secondSignature.substring(0, 2))) { this.secondSignature = null; } else { - int secondSignatureLength = Integer.parseInt(this.secondSignature.substring(2, 4), 16) + 2; - this.secondSignature = this.secondSignature.substring(0, secondSignatureLength * 2); + int secondSignatureLength = + Integer.parseInt(this.secondSignature.substring(2, 4), 16) + 2; + this.secondSignature = + this.secondSignature.substring(0, secondSignatureLength * 2); multiSignatureOffset += secondSignatureLength * 2; } - } String signatures = serialized.substring(startOffset + multiSignatureOffset); @@ -135,29 +147,29 @@ public Transaction parseSignatures(String serialized, int startOffset) { moreSignatures = false; } - signatures = signatures.substring(mLength * 2); if (signatures.length() == 0) { break; } - } - } return this; } - private byte[] toBytes(boolean skipSignature, boolean skipSecondSignature) { + private byte[] toBytesV1(boolean skipSignature, boolean skipSecondSignature) { ByteBuffer buffer = ByteBuffer.allocate(1000); buffer.order(ByteOrder.LITTLE_ENDIAN); - buffer.put((byte) type.getValue()); + buffer.put((byte) type); buffer.putInt(timestamp); buffer.put(Hex.decode(this.senderPublicKey)); - boolean skipRecipientId = this.type == Types.SECOND_SIGNATURE_REGISTRATION || this.type == Types.MULTI_SIGNATURE_REGISTRATION; + boolean skipRecipientId = + this.type == CoreTransactionTypes.SECOND_SIGNATURE_REGISTRATION.getValue() + || this.type + == CoreTransactionTypes.MULTI_SIGNATURE_REGISTRATION.getValue(); if (recipientId != null && !recipientId.isEmpty() && !skipRecipientId) { buffer.put(Base58.decodeChecked(this.recipientId)); } else { @@ -179,19 +191,19 @@ private byte[] toBytes(boolean skipSignature, boolean skipSecondSignature) { buffer.putLong(amount); buffer.putLong(fee); - if (this.type == Types.SECOND_SIGNATURE_REGISTRATION) { + if (this.type == CoreTransactionTypes.SECOND_SIGNATURE_REGISTRATION.getValue()) { buffer.put(Hex.decode(this.asset.signature.publicKey)); } - if (this.type == Types.DELEGATE_REGISTRATION) { + if (this.type == CoreTransactionTypes.DELEGATE_REGISTRATION.getValue()) { buffer.put(this.asset.delegate.username.getBytes()); } - if (this.type == Types.VOTE) { + if (this.type == CoreTransactionTypes.VOTE.getValue()) { buffer.put(String.join("", this.asset.votes).getBytes()); } - if (this.type == Types.MULTI_SIGNATURE_REGISTRATION) { + if (this.type == CoreTransactionTypes.MULTI_SIGNATURE_REGISTRATION.getValue()) { buffer.put(this.asset.multisignature.min); buffer.put(this.asset.multisignature.lifetime); buffer.put(String.join("", this.asset.multisignature.keysgroup).getBytes()); @@ -211,14 +223,6 @@ private byte[] toBytes(boolean skipSignature, boolean skipSecondSignature) { return result; } - private byte[] toBytes(boolean skipSignature) { - return toBytes(skipSignature, true); - } - - private byte[] toBytes() { - return toBytes(true, true); - } - public String serialize() { return Hex.encode(new Serializer().serialize(this)); } @@ -232,40 +236,60 @@ public HashMap toHashMap() { HashMap map = new HashMap(); map.put("network", this.network); map.put("id", this.id); - map.put("timestamp", this.timestamp); - map.put("expiration", this.expiration); - map.put("type", this.type.getValue()); - map.put("amount", this.amount); - map.put("fee", this.fee); + map.put("amount", String.valueOf(this.amount)); + map.put("fee", String.valueOf(this.fee)); map.put("recipientId", this.recipientId); map.put("signature", this.signature); map.put("senderPublicKey", this.senderPublicKey); + map.put("type", this.type); + map.put("version", this.version); + if (this.version == 1) { + map.put("timestamp", this.timestamp); + } else { + map.put("nonce", String.valueOf(this.nonce)); + map.put("typeGroup", this.typeGroup); + } if (this.vendorField != null && !this.vendorField.isEmpty()) { map.put("vendorField", this.vendorField); } - if (this.signSignature!= null && !this.signSignature.isEmpty()) { + if (this.signSignature != null && !this.signSignature.isEmpty()) { map.put("signSignature", this.signSignature); } - HashMap asset = new HashMap(); - if (this.type == Types.SECOND_SIGNATURE_REGISTRATION) { - HashMap publicKey = new HashMap(); + if (this.expiration > 0) { + map.put("expiration", this.expiration); + } + + HashMap asset = new HashMap<>(); + if (this.type == CoreTransactionTypes.SECOND_SIGNATURE_REGISTRATION.getValue()) { + HashMap publicKey = new HashMap<>(); publicKey.put("publicKey", this.asset.signature.publicKey); asset.put("signature", publicKey); - } else if (this.type == Types.VOTE) { + } else if (this.type == CoreTransactionTypes.VOTE.getValue()) { asset.put("votes", this.asset.votes); - } else if (this.type == Types.DELEGATE_REGISTRATION) { - HashMap delegate = new HashMap(); + } else if (this.type == CoreTransactionTypes.DELEGATE_REGISTRATION.getValue()) { + HashMap delegate = new HashMap<>(); delegate.put("username", this.asset.delegate.username); asset.put("delegate", delegate); - } else if (this.type == Types.MULTI_SIGNATURE_REGISTRATION) { - HashMap multisignature = new HashMap(); + } else if (this.type == CoreTransactionTypes.MULTI_SIGNATURE_REGISTRATION.getValue()) { + HashMap multisignature = new HashMap<>(); multisignature.put("min", this.asset.multisignature.min); multisignature.put("lifetime", this.asset.multisignature.lifetime); multisignature.put("keysgroup", this.asset.multisignature.keysgroup); asset.put("multisignature", multisignature); + } else if (this.type == CoreTransactionTypes.IPFS.getValue()) { + asset.put("ipfs", this.asset.ipfs); + } else if (this.type == CoreTransactionTypes.MULTI_PAYMENT.getValue()) { + ArrayList> payments = new ArrayList<>(); + for (TransactionAsset.Payment current : this.asset.multiPayment.payments) { + HashMap payment = new HashMap<>(); + payment.put("amount", String.valueOf(current.amount)); + payment.put("recipientId", current.recipientId); + payments.add(payment); + } + asset.put("payments", payments); } if (!asset.isEmpty()) { @@ -274,18 +298,20 @@ public HashMap toHashMap() { return map; } - private static class TransactionTypeDeserializer implements - JsonDeserializer { + private static class TransactionTypeDeserializer + implements JsonDeserializer { @Override - public Types deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { - return Types.values()[json.getAsInt()]; + public CoreTransactionTypes deserialize( + JsonElement json, Type typeOfT, JsonDeserializationContext context) + throws JsonParseException { + return CoreTransactionTypes.values()[json.getAsInt()]; } } - private static class TransactionTypeSerializer implements - JsonSerializer { + private static class TransactionTypeSerializer implements JsonSerializer { @Override - public JsonElement serialize(Types src, Type typeOfSrc, JsonSerializationContext context) { + public JsonElement serialize( + CoreTransactionTypes src, Type typeOfSrc, JsonSerializationContext context) { return new JsonPrimitive(src.getValue()); } } diff --git a/src/main/java/org/arkecosystem/crypto/transactions/TransactionAsset.java b/src/main/java/org/arkecosystem/crypto/transactions/TransactionAsset.java index 8d0f5d2e..7952a6a1 100644 --- a/src/main/java/org/arkecosystem/crypto/transactions/TransactionAsset.java +++ b/src/main/java/org/arkecosystem/crypto/transactions/TransactionAsset.java @@ -1,13 +1,18 @@ package org.arkecosystem.crypto.transactions; -import java.util.ArrayList; -import java.util.List; +import java.util.*; +import org.arkecosystem.crypto.enums.HtlcLockExpirationType; public class TransactionAsset { public Signature signature = new Signature(); public List votes = new ArrayList<>(); public Delegate delegate = new Delegate(); public MultiSignature multisignature = new MultiSignature(); + public MultiPayment multiPayment = new MultiPayment(); + public String ipfs; + public HtlcLockAsset htlcLockAsset = new HtlcLockAsset(); + public HtlcClaimAsset htlcClaimAsset = new HtlcClaimAsset(); + public HtlcRefundAsset htlcRefundAsset = new HtlcRefundAsset(); public class Signature { public String publicKey; @@ -22,4 +27,42 @@ public class MultiSignature { public byte lifetime; public List keysgroup = new ArrayList<>(); } + + public class MultiPayment { + public List payments = new ArrayList<>(); + } + + public static class Payment { + public long amount; + public String recipientId; + + public Payment(long amount, String recipientId) { + this.amount = amount; + this.recipientId = recipientId; + } + } + + public class HtlcLockAsset { + public String secretHash; + public Expiration expiration; + } + + public static class Expiration { + public HtlcLockExpirationType type; + public int value; + + public Expiration(HtlcLockExpirationType type, int value) { + this.type = type; + this.value = value; + } + } + + public class HtlcClaimAsset { + public String lockTransactionId; + public String unlockSecret; + } + + public class HtlcRefundAsset { + public String lockTransactionId; + } } diff --git a/src/main/java/org/arkecosystem/crypto/transactions/builder/AbstractTransaction.java b/src/main/java/org/arkecosystem/crypto/transactions/builder/AbstractTransaction.java deleted file mode 100644 index 93f7545b..00000000 --- a/src/main/java/org/arkecosystem/crypto/transactions/builder/AbstractTransaction.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.arkecosystem.crypto.transactions.builder; - -import org.arkecosystem.crypto.configuration.Fee; -import org.arkecosystem.crypto.configuration.Network; -import org.arkecosystem.crypto.enums.Types; -import org.arkecosystem.crypto.transactions.Transaction; -import org.arkecosystem.crypto.utils.Slot; - -public abstract class AbstractTransaction { - public Transaction transaction; - - public AbstractTransaction() { - this.transaction = new Transaction(); - this.transaction.type = this.getType(); - this.transaction.fee = Fee.get(this.getType()); - this.transaction.timestamp = Slot.time(); - this.transaction.version = 1; - this.transaction.network = Network.get().version(); - } - - public AbstractTransaction sign(String passphrase) { - this.transaction.sign(passphrase); - this.transaction.id = this.transaction.computeId(); - - return this; - } - - public AbstractTransaction secondSign(String passphrase) { - this.transaction.secondSign(passphrase); - this.transaction.id = this.transaction.computeId(); - - return this; - } - - abstract Types getType(); - -} diff --git a/src/main/java/org/arkecosystem/crypto/transactions/builder/AbstractTransactionBuilder.java b/src/main/java/org/arkecosystem/crypto/transactions/builder/AbstractTransactionBuilder.java new file mode 100644 index 00000000..67958c0e --- /dev/null +++ b/src/main/java/org/arkecosystem/crypto/transactions/builder/AbstractTransactionBuilder.java @@ -0,0 +1,81 @@ +package org.arkecosystem.crypto.transactions.builder; + +import org.arkecosystem.crypto.configuration.Fee; +import org.arkecosystem.crypto.configuration.Network; +import org.arkecosystem.crypto.enums.CoreTransactionTypes; +import org.arkecosystem.crypto.enums.TransactionTypeGroup; +import org.arkecosystem.crypto.transactions.Transaction; +import org.arkecosystem.crypto.utils.Slot; + +public abstract class AbstractTransactionBuilder< + TBuilder extends AbstractTransactionBuilder> { + public Transaction transaction; + + public AbstractTransactionBuilder() { + this.transaction = new Transaction(); + this.transaction.type = this.getType(); + this.transaction.fee = Fee.getCoreFee(this.getType()); + this.transaction.timestamp = Slot.time(); + this.transaction.version = 2; + this.transaction.network = Network.get().version(); + this.transaction.typeGroup = TransactionTypeGroup.CORE.getValue(); + this.transaction.nonce = 0; + } + + public TBuilder version(int version) { + this.transaction.version = version; + return this.instance(); + }; + + public TBuilder typeGroup(int typeGroup) { + if (typeGroup > Short.MAX_VALUE) { + throw new IllegalArgumentException( + "Type group should not be bigger then 2 bytes (bigger then 32767)"); + } + this.transaction.typeGroup = typeGroup; + return this.instance(); + } + + public TBuilder nonce(long nonce) { + this.transaction.nonce = nonce; + return this.instance(); + }; + + public TBuilder secondSign(String passphrase) { + this.transaction.secondSign(passphrase); + this.transaction.id = this.transaction.computeId(); + + return this.instance(); + } + + public TBuilder network(int network) { + this.transaction.network = network; + return this.instance(); + } + + public TBuilder fee(long fee) { + this.transaction.fee = fee; + return this.instance(); + } + + public TBuilder amount(long amount) { + this.transaction.amount = amount; + return this.instance(); + } + + public TBuilder sign(String passphrase) { + if (this.transaction.type == CoreTransactionTypes.MULTI_SIGNATURE_REGISTRATION.getValue() + && this.transaction.version == 2) { + throw new UnsupportedOperationException( + "Version 2 MultiSignatureRegistration is not supported in java sdk"); + } + this.transaction.sign(passphrase); + this.transaction.id = this.transaction.computeId(); + + return this.instance(); + } + + abstract int getType(); + + abstract TBuilder instance(); +} diff --git a/src/main/java/org/arkecosystem/crypto/transactions/builder/DelegateRegistration.java b/src/main/java/org/arkecosystem/crypto/transactions/builder/DelegateRegistration.java index a7c6e92e..f34caaa5 100644 --- a/src/main/java/org/arkecosystem/crypto/transactions/builder/DelegateRegistration.java +++ b/src/main/java/org/arkecosystem/crypto/transactions/builder/DelegateRegistration.java @@ -1,16 +1,21 @@ package org.arkecosystem.crypto.transactions.builder; -import org.arkecosystem.crypto.enums.Types; +import org.arkecosystem.crypto.enums.CoreTransactionTypes; -public class DelegateRegistration extends AbstractTransaction { +public class DelegateRegistration extends AbstractTransactionBuilder { public DelegateRegistration username(String username) { this.transaction.asset.delegate.username = username; return this; } - public Types getType() { - return Types.DELEGATE_REGISTRATION; + @Override + public int getType() { + return CoreTransactionTypes.DELEGATE_REGISTRATION.getValue(); } + @Override + public DelegateRegistration instance() { + return this; + } } diff --git a/src/main/java/org/arkecosystem/crypto/transactions/builder/DelegateResignation.java b/src/main/java/org/arkecosystem/crypto/transactions/builder/DelegateResignation.java new file mode 100644 index 00000000..a7cbe94e --- /dev/null +++ b/src/main/java/org/arkecosystem/crypto/transactions/builder/DelegateResignation.java @@ -0,0 +1,16 @@ +package org.arkecosystem.crypto.transactions.builder; + +import org.arkecosystem.crypto.enums.CoreTransactionTypes; + +public class DelegateResignation extends AbstractTransactionBuilder { + + @Override + public int getType() { + return CoreTransactionTypes.DELEGATE_RESIGNATION.getValue(); + } + + @Override + public DelegateResignation instance() { + return this; + } +} diff --git a/src/main/java/org/arkecosystem/crypto/transactions/builder/HtlcClaim.java b/src/main/java/org/arkecosystem/crypto/transactions/builder/HtlcClaim.java new file mode 100644 index 00000000..860a16bd --- /dev/null +++ b/src/main/java/org/arkecosystem/crypto/transactions/builder/HtlcClaim.java @@ -0,0 +1,22 @@ +package org.arkecosystem.crypto.transactions.builder; + +import org.arkecosystem.crypto.enums.CoreTransactionTypes; + +public class HtlcClaim extends AbstractTransactionBuilder { + + public HtlcClaim htlcClaimAsset(String lockTransactionId, String unlockSecret) { + this.transaction.asset.htlcClaimAsset.lockTransactionId = lockTransactionId; + this.transaction.asset.htlcClaimAsset.unlockSecret = unlockSecret; + return this; + } + + @Override + public int getType() { + return CoreTransactionTypes.HTLC_CLAIM.getValue(); + } + + @Override + public HtlcClaim instance() { + return this; + } +} diff --git a/src/main/java/org/arkecosystem/crypto/transactions/builder/HtlcLock.java b/src/main/java/org/arkecosystem/crypto/transactions/builder/HtlcLock.java new file mode 100644 index 00000000..ce27e118 --- /dev/null +++ b/src/main/java/org/arkecosystem/crypto/transactions/builder/HtlcLock.java @@ -0,0 +1,38 @@ +package org.arkecosystem.crypto.transactions.builder; + +import org.arkecosystem.crypto.enums.CoreTransactionTypes; +import org.arkecosystem.crypto.enums.HtlcLockExpirationType; +import org.arkecosystem.crypto.transactions.TransactionAsset; + +public class HtlcLock extends AbstractTransactionBuilder { + public HtlcLock recipientId(String recipientId) { + this.transaction.recipientId = recipientId; + return this; + } + + public HtlcLock secretHash(String secretHash) { + this.transaction.asset.htlcLockAsset.secretHash = secretHash; + return this; + } + + public HtlcLock expirationType(HtlcLockExpirationType expirationType, int expirationValue) { + this.transaction.asset.htlcLockAsset.expiration = + new TransactionAsset.Expiration(expirationType, expirationValue); + return this; + } + + public HtlcLock vendorField(String vendorField) { + this.transaction.vendorField = vendorField; + return this; + } + + @Override + public int getType() { + return CoreTransactionTypes.HTLC_LOCK.getValue(); + } + + @Override + public HtlcLock instance() { + return this; + } +} diff --git a/src/main/java/org/arkecosystem/crypto/transactions/builder/HtlcRefund.java b/src/main/java/org/arkecosystem/crypto/transactions/builder/HtlcRefund.java new file mode 100644 index 00000000..e9ef1732 --- /dev/null +++ b/src/main/java/org/arkecosystem/crypto/transactions/builder/HtlcRefund.java @@ -0,0 +1,21 @@ +package org.arkecosystem.crypto.transactions.builder; + +import org.arkecosystem.crypto.enums.CoreTransactionTypes; + +public class HtlcRefund extends AbstractTransactionBuilder { + + public HtlcRefund htlcRefundAsset(String lockTransactionId) { + this.transaction.asset.htlcRefundAsset.lockTransactionId = lockTransactionId; + return this; + } + + @Override + public int getType() { + return CoreTransactionTypes.HTLC_REFUND.getValue(); + } + + @Override + public HtlcRefund instance() { + return this; + } +} diff --git a/src/main/java/org/arkecosystem/crypto/transactions/builder/Ipfs.java b/src/main/java/org/arkecosystem/crypto/transactions/builder/Ipfs.java new file mode 100644 index 00000000..aa210ff7 --- /dev/null +++ b/src/main/java/org/arkecosystem/crypto/transactions/builder/Ipfs.java @@ -0,0 +1,21 @@ +package org.arkecosystem.crypto.transactions.builder; + +import org.arkecosystem.crypto.enums.CoreTransactionTypes; + +public class Ipfs extends AbstractTransactionBuilder { + + public AbstractTransactionBuilder ipfsAsset(String ipfsId) { + this.transaction.asset.ipfs = ipfsId; + return this; + } + + @Override + public int getType() { + return CoreTransactionTypes.IPFS.getValue(); + } + + @Override + public Ipfs instance() { + return this; + } +} diff --git a/src/main/java/org/arkecosystem/crypto/transactions/builder/MultiPayment.java b/src/main/java/org/arkecosystem/crypto/transactions/builder/MultiPayment.java new file mode 100644 index 00000000..aa42f325 --- /dev/null +++ b/src/main/java/org/arkecosystem/crypto/transactions/builder/MultiPayment.java @@ -0,0 +1,38 @@ +package org.arkecosystem.crypto.transactions.builder; + +import org.arkecosystem.crypto.enums.CoreTransactionTypes; +import org.arkecosystem.crypto.transactions.TransactionAsset; + +public class MultiPayment extends AbstractTransactionBuilder { + + public MultiPayment addPayment(String recipientId, long amount) { + if (this.transaction.asset.multiPayment.payments.size() >= 2258) { + throw new MaximumPaymentCountExceededError(); + } + this.transaction.asset.multiPayment.payments.add( + new TransactionAsset.Payment(amount, recipientId)); + return this; + } + + public MultiPayment vendorField(String vendorField) { + this.transaction.vendorField = vendorField; + + return this; + } + + @Override + public int getType() { + return CoreTransactionTypes.MULTI_PAYMENT.getValue(); + } + + @Override + public MultiPayment instance() { + return this; + } +} + +class MaximumPaymentCountExceededError extends RuntimeException { + MaximumPaymentCountExceededError() { + super("Expected a maximum of 2258 payments"); + } +} diff --git a/src/main/java/org/arkecosystem/crypto/transactions/builder/MultiSignatureRegistration.java b/src/main/java/org/arkecosystem/crypto/transactions/builder/MultiSignatureRegistration.java index 6b280264..7bfc61ca 100644 --- a/src/main/java/org/arkecosystem/crypto/transactions/builder/MultiSignatureRegistration.java +++ b/src/main/java/org/arkecosystem/crypto/transactions/builder/MultiSignatureRegistration.java @@ -1,11 +1,14 @@ package org.arkecosystem.crypto.transactions.builder; -import org.arkecosystem.crypto.enums.Types; - import java.util.List; +import org.arkecosystem.crypto.enums.CoreTransactionTypes; - -public class MultiSignatureRegistration extends AbstractTransaction { +public class MultiSignatureRegistration + extends AbstractTransactionBuilder { + public MultiSignatureRegistration() { + super(); + this.transaction.version = 1; + } public MultiSignatureRegistration min(int min) { return this.min((byte) min); @@ -35,8 +38,13 @@ public MultiSignatureRegistration keysgroup(List keysgroup) { return this; } - public Types getType() { - return Types.MULTI_SIGNATURE_REGISTRATION; + @Override + public int getType() { + return CoreTransactionTypes.MULTI_SIGNATURE_REGISTRATION.getValue(); } + @Override + public MultiSignatureRegistration instance() { + return this; + } } diff --git a/src/main/java/org/arkecosystem/crypto/transactions/builder/SecondSignatureRegistration.java b/src/main/java/org/arkecosystem/crypto/transactions/builder/SecondSignatureRegistration.java index 46ab9bb9..0c0b4777 100644 --- a/src/main/java/org/arkecosystem/crypto/transactions/builder/SecondSignatureRegistration.java +++ b/src/main/java/org/arkecosystem/crypto/transactions/builder/SecondSignatureRegistration.java @@ -1,19 +1,24 @@ package org.arkecosystem.crypto.transactions.builder; -import org.arkecosystem.crypto.encoding.Hex; -import org.arkecosystem.crypto.enums.Types; +import org.arkecosystem.crypto.enums.CoreTransactionTypes; import org.arkecosystem.crypto.identities.PublicKey; -public class SecondSignatureRegistration extends AbstractTransaction { +public class SecondSignatureRegistration + extends AbstractTransactionBuilder { public SecondSignatureRegistration signature(String signature) { - this.transaction.asset.signature.publicKey = Hex.encode(PublicKey.fromPassphrase(signature).getBytes()); + this.transaction.asset.signature.publicKey = PublicKey.fromPassphrase(signature); return this; } - public Types getType() { - return Types.SECOND_SIGNATURE_REGISTRATION; + @Override + public int getType() { + return CoreTransactionTypes.SECOND_SIGNATURE_REGISTRATION.getValue(); } + @Override + public SecondSignatureRegistration instance() { + return this; + } } diff --git a/src/main/java/org/arkecosystem/crypto/transactions/builder/Transfer.java b/src/main/java/org/arkecosystem/crypto/transactions/builder/Transfer.java index af1fcd67..5318b864 100644 --- a/src/main/java/org/arkecosystem/crypto/transactions/builder/Transfer.java +++ b/src/main/java/org/arkecosystem/crypto/transactions/builder/Transfer.java @@ -1,8 +1,8 @@ package org.arkecosystem.crypto.transactions.builder; -import org.arkecosystem.crypto.enums.Types; +import org.arkecosystem.crypto.enums.CoreTransactionTypes; -public class Transfer extends AbstractTransaction { +public class Transfer extends AbstractTransactionBuilder { public Transfer recipient(String recipientId) { this.transaction.recipientId = recipientId; @@ -10,10 +10,6 @@ public Transfer recipient(String recipientId) { return this; } - public Transfer amount(int amount) { - return this.amount((long) amount); - } - public Transfer amount(long amount) { this.transaction.amount = amount; @@ -26,8 +22,13 @@ public Transfer vendorField(String vendorField) { return this; } - public Types getType() { - return Types.TRANSFER; + @Override + public int getType() { + return CoreTransactionTypes.TRANSFER.getValue(); } + @Override + public Transfer instance() { + return this; + } } diff --git a/src/main/java/org/arkecosystem/crypto/transactions/builder/Vote.java b/src/main/java/org/arkecosystem/crypto/transactions/builder/Vote.java index 7b38a513..7a8582ae 100644 --- a/src/main/java/org/arkecosystem/crypto/transactions/builder/Vote.java +++ b/src/main/java/org/arkecosystem/crypto/transactions/builder/Vote.java @@ -1,11 +1,10 @@ package org.arkecosystem.crypto.transactions.builder; -import org.arkecosystem.crypto.enums.Types; -import org.arkecosystem.crypto.identities.Address; - import java.util.List; +import org.arkecosystem.crypto.enums.CoreTransactionTypes; +import org.arkecosystem.crypto.identities.Address; -public class Vote extends AbstractTransaction { +public class Vote extends AbstractTransactionBuilder { public Vote votes(List votes) { this.transaction.asset.votes = votes; @@ -20,8 +19,13 @@ public Vote sign(String passphrase) { return this; } - public Types getType() { - return Types.VOTE; + @Override + public int getType() { + return CoreTransactionTypes.VOTE.getValue(); } + @Override + public Vote instance() { + return this; + } } diff --git a/src/main/java/org/arkecosystem/crypto/transactions/deserializers/AbstractDeserializer.java b/src/main/java/org/arkecosystem/crypto/transactions/deserializers/AbstractDeserializer.java index f3fb322f..e2818983 100644 --- a/src/main/java/org/arkecosystem/crypto/transactions/deserializers/AbstractDeserializer.java +++ b/src/main/java/org/arkecosystem/crypto/transactions/deserializers/AbstractDeserializer.java @@ -1,8 +1,7 @@ package org.arkecosystem.crypto.transactions.deserializers; -import org.arkecosystem.crypto.transactions.Transaction; - import java.nio.ByteBuffer; +import org.arkecosystem.crypto.transactions.Transaction; public abstract class AbstractDeserializer { @@ -16,4 +15,5 @@ public AbstractDeserializer(String serialized, ByteBuffer buffer, Transaction tr this.transaction = transaction; } + public abstract void deserialize(int assetOffset); } diff --git a/src/main/java/org/arkecosystem/crypto/transactions/deserializers/DelegateRegistration.java b/src/main/java/org/arkecosystem/crypto/transactions/deserializers/DelegateRegistration.java index ab043e94..bbf04c44 100644 --- a/src/main/java/org/arkecosystem/crypto/transactions/deserializers/DelegateRegistration.java +++ b/src/main/java/org/arkecosystem/crypto/transactions/deserializers/DelegateRegistration.java @@ -1,14 +1,14 @@ package org.arkecosystem.crypto.transactions.deserializers; -import org.arkecosystem.crypto.transactions.Transaction; - import java.nio.ByteBuffer; +import org.arkecosystem.crypto.transactions.Transaction; public class DelegateRegistration extends AbstractDeserializer { public DelegateRegistration(String serialized, ByteBuffer buffer, Transaction transaction) { super(serialized, buffer, transaction); } + @Override public void deserialize(int assetOffset) { this.buffer.position(assetOffset / 2); @@ -21,5 +21,4 @@ public void deserialize(int assetOffset) { this.transaction.parseSignatures(this.serialized, assetOffset + (usernameLength + 1) * 2); } - } diff --git a/src/main/java/org/arkecosystem/crypto/transactions/deserializers/DelegateResignation.java b/src/main/java/org/arkecosystem/crypto/transactions/deserializers/DelegateResignation.java new file mode 100644 index 00000000..943e011d --- /dev/null +++ b/src/main/java/org/arkecosystem/crypto/transactions/deserializers/DelegateResignation.java @@ -0,0 +1,15 @@ +package org.arkecosystem.crypto.transactions.deserializers; + +import java.nio.ByteBuffer; +import org.arkecosystem.crypto.transactions.Transaction; + +public class DelegateResignation extends AbstractDeserializer { + public DelegateResignation(String serialized, ByteBuffer buffer, Transaction transaction) { + super(serialized, buffer, transaction); + } + + @Override + public void deserialize(int assetOffset) { + this.transaction.parseSignatures(this.serialized, assetOffset); + } +} diff --git a/src/main/java/org/arkecosystem/crypto/transactions/deserializers/HtlcClaim.java b/src/main/java/org/arkecosystem/crypto/transactions/deserializers/HtlcClaim.java new file mode 100644 index 00000000..2446091b --- /dev/null +++ b/src/main/java/org/arkecosystem/crypto/transactions/deserializers/HtlcClaim.java @@ -0,0 +1,27 @@ +package org.arkecosystem.crypto.transactions.deserializers; + +import java.nio.ByteBuffer; +import org.arkecosystem.crypto.encoding.Hex; +import org.arkecosystem.crypto.transactions.Transaction; + +public class HtlcClaim extends AbstractDeserializer { + public HtlcClaim(String serialized, ByteBuffer buffer, Transaction transaction) { + super(serialized, buffer, transaction); + } + + @Override + public void deserialize(int assetOffset) { + this.buffer.position(assetOffset / 2); + + byte[] lockTransactionIdBuf = new byte[32]; + this.buffer.get(lockTransactionIdBuf); + + byte[] unlockSecret = new byte[32]; + this.buffer.get(unlockSecret); + + this.transaction.asset.htlcClaimAsset.lockTransactionId = Hex.encode(lockTransactionIdBuf); + this.transaction.asset.htlcClaimAsset.unlockSecret = Hex.encode(unlockSecret); + + this.transaction.parseSignatures(this.serialized, assetOffset + 64 + 64); + } +} diff --git a/src/main/java/org/arkecosystem/crypto/transactions/deserializers/HtlcLock.java b/src/main/java/org/arkecosystem/crypto/transactions/deserializers/HtlcLock.java new file mode 100644 index 00000000..3b96d771 --- /dev/null +++ b/src/main/java/org/arkecosystem/crypto/transactions/deserializers/HtlcLock.java @@ -0,0 +1,33 @@ +package org.arkecosystem.crypto.transactions.deserializers; + +import java.nio.ByteBuffer; +import org.arkecosystem.crypto.encoding.Base58; +import org.arkecosystem.crypto.encoding.Hex; +import org.arkecosystem.crypto.enums.HtlcLockExpirationType; +import org.arkecosystem.crypto.transactions.Transaction; +import org.arkecosystem.crypto.transactions.TransactionAsset; + +public class HtlcLock extends AbstractDeserializer { + public HtlcLock(String serialized, ByteBuffer buffer, Transaction transaction) { + super(serialized, buffer, transaction); + } + + @Override + public void deserialize(int assetOffset) { + this.buffer.position(assetOffset / 2); + + this.transaction.amount = this.buffer.getLong(); + byte[] secretHash = new byte[32]; + this.buffer.get(secretHash); + this.transaction.asset.htlcLockAsset.secretHash = Hex.encode(secretHash); + this.transaction.asset.htlcLockAsset.expiration = + new TransactionAsset.Expiration( + HtlcLockExpirationType.values()[this.buffer.get() - 1], + this.buffer.getInt()); + byte[] recipientId = new byte[21]; + this.buffer.get(recipientId); + this.transaction.recipientId = Base58.encodeChecked(recipientId); + + this.transaction.parseSignatures(this.serialized, assetOffset + (8 + 32 + 1 + 4 + 21) * 2); + } +} diff --git a/src/main/java/org/arkecosystem/crypto/transactions/deserializers/HtlcRefund.java b/src/main/java/org/arkecosystem/crypto/transactions/deserializers/HtlcRefund.java new file mode 100644 index 00000000..a141855a --- /dev/null +++ b/src/main/java/org/arkecosystem/crypto/transactions/deserializers/HtlcRefund.java @@ -0,0 +1,22 @@ +package org.arkecosystem.crypto.transactions.deserializers; + +import java.nio.ByteBuffer; +import org.arkecosystem.crypto.encoding.Hex; +import org.arkecosystem.crypto.transactions.Transaction; + +public class HtlcRefund extends AbstractDeserializer { + public HtlcRefund(String serialized, ByteBuffer buffer, Transaction transaction) { + super(serialized, buffer, transaction); + } + + @Override + public void deserialize(int assetOffset) { + this.buffer.position(assetOffset / 2); + + byte[] buf = new byte[32]; + this.buffer.get(buf); + this.transaction.asset.htlcRefundAsset.lockTransactionId = Hex.encode(buf); + + this.transaction.parseSignatures(this.serialized, assetOffset + 64); + } +} diff --git a/src/main/java/org/arkecosystem/crypto/transactions/deserializers/Ipfs.java b/src/main/java/org/arkecosystem/crypto/transactions/deserializers/Ipfs.java new file mode 100644 index 00000000..88e086e2 --- /dev/null +++ b/src/main/java/org/arkecosystem/crypto/transactions/deserializers/Ipfs.java @@ -0,0 +1,31 @@ +package org.arkecosystem.crypto.transactions.deserializers; + +import java.nio.ByteBuffer; +import org.arkecosystem.crypto.encoding.Base58; +import org.arkecosystem.crypto.transactions.Transaction; + +public class Ipfs extends AbstractDeserializer { + public Ipfs(String serialized, ByteBuffer buffer, Transaction transaction) { + super(serialized, buffer, transaction); + } + + @Override + public void deserialize(int assetOffset) { + this.buffer.position(assetOffset / 2); + + byte hashFunction = this.buffer.get(); + byte ipfsHashLength = this.buffer.get(); + byte[] hashBuffer = new byte[ipfsHashLength]; + this.buffer.get(hashBuffer); + + byte[] ipfsBuffer = + ByteBuffer.allocate(ipfsHashLength + 2) + .put(hashFunction) + .put(ipfsHashLength) + .put(hashBuffer) + .array(); + this.transaction.asset.ipfs = Base58.encode(ipfsBuffer); + + this.transaction.parseSignatures(this.serialized, assetOffset + (ipfsHashLength + 2) * 2); + } +} diff --git a/src/main/java/org/arkecosystem/crypto/transactions/deserializers/MultiPayment.java b/src/main/java/org/arkecosystem/crypto/transactions/deserializers/MultiPayment.java new file mode 100644 index 00000000..e8980112 --- /dev/null +++ b/src/main/java/org/arkecosystem/crypto/transactions/deserializers/MultiPayment.java @@ -0,0 +1,29 @@ +package org.arkecosystem.crypto.transactions.deserializers; + +import java.nio.ByteBuffer; +import org.arkecosystem.crypto.encoding.Base58; +import org.arkecosystem.crypto.transactions.Transaction; +import org.arkecosystem.crypto.transactions.TransactionAsset; + +public class MultiPayment extends AbstractDeserializer { + public MultiPayment(String serialized, ByteBuffer buffer, Transaction transaction) { + super(serialized, buffer, transaction); + } + + @Override + public void deserialize(int assetOffset) { + this.buffer.position(assetOffset / 2); + + int paymentLength = this.buffer.getShort() & 0xff; + for (int i = 0; i < paymentLength; i++) { + byte[] recipientId = new byte[21]; + long amount = this.buffer.getLong(); + this.buffer.get(recipientId); + this.transaction.asset.multiPayment.payments.add( + new TransactionAsset.Payment(amount, Base58.encodeChecked(recipientId))); + } + + this.transaction.parseSignatures( + this.serialized, assetOffset + ((2 + paymentLength * 8 + paymentLength * 21) * 2)); + } +} diff --git a/src/main/java/org/arkecosystem/crypto/transactions/deserializers/MultiSignatureRegistration.java b/src/main/java/org/arkecosystem/crypto/transactions/deserializers/MultiSignatureRegistration.java index ced18cf5..fa112644 100644 --- a/src/main/java/org/arkecosystem/crypto/transactions/deserializers/MultiSignatureRegistration.java +++ b/src/main/java/org/arkecosystem/crypto/transactions/deserializers/MultiSignatureRegistration.java @@ -1,14 +1,15 @@ package org.arkecosystem.crypto.transactions.deserializers; -import org.arkecosystem.crypto.transactions.Transaction; - import java.nio.ByteBuffer; +import org.arkecosystem.crypto.transactions.Transaction; public class MultiSignatureRegistration extends AbstractDeserializer { - public MultiSignatureRegistration(String serialized, ByteBuffer buffer, Transaction transaction) { + public MultiSignatureRegistration( + String serialized, ByteBuffer buffer, Transaction transaction) { super(serialized, buffer, transaction); } + @Override public void deserialize(int assetOffset) { this.buffer.position(assetOffset / 2); @@ -18,11 +19,12 @@ public void deserialize(int assetOffset) { this.transaction.asset.multisignature.lifetime = (byte) (this.buffer.get() & 0xff); for (int i = 0; i < count; i++) { - String key = this.serialized.substring(assetOffset + 6 + i * 66, assetOffset + 6 + (i + 1) * 66); + String key = + this.serialized.substring( + assetOffset + 6 + i * 66, assetOffset + 6 + (i + 1) * 66); this.transaction.asset.multisignature.keysgroup.add(key); } this.transaction.parseSignatures(this.serialized, assetOffset + 6 + count * 66); } - } diff --git a/src/main/java/org/arkecosystem/crypto/transactions/deserializers/SecondSignatureRegistration.java b/src/main/java/org/arkecosystem/crypto/transactions/deserializers/SecondSignatureRegistration.java index 6eda7fed..83bbb87b 100644 --- a/src/main/java/org/arkecosystem/crypto/transactions/deserializers/SecondSignatureRegistration.java +++ b/src/main/java/org/arkecosystem/crypto/transactions/deserializers/SecondSignatureRegistration.java @@ -1,17 +1,19 @@ package org.arkecosystem.crypto.transactions.deserializers; -import org.arkecosystem.crypto.transactions.Transaction; - import java.nio.ByteBuffer; +import org.arkecosystem.crypto.transactions.Transaction; public class SecondSignatureRegistration extends AbstractDeserializer { - public SecondSignatureRegistration(String serialized, ByteBuffer buffer, Transaction transaction) { + public SecondSignatureRegistration( + String serialized, ByteBuffer buffer, Transaction transaction) { super(serialized, buffer, transaction); } + @Override public void deserialize(int assetOffset) { - this.transaction.asset.signature.publicKey = this.serialized.substring(assetOffset, assetOffset + 66); - this.transaction.parseSignatures(this.serialized, assetOffset + 66); - } + this.transaction.asset.signature.publicKey = + this.serialized.substring(assetOffset, assetOffset + 66); + this.transaction.signature = this.serialized.substring(assetOffset + 66); + } } diff --git a/src/main/java/org/arkecosystem/crypto/transactions/deserializers/Transfer.java b/src/main/java/org/arkecosystem/crypto/transactions/deserializers/Transfer.java index a5f3ea4f..96b2bf47 100644 --- a/src/main/java/org/arkecosystem/crypto/transactions/deserializers/Transfer.java +++ b/src/main/java/org/arkecosystem/crypto/transactions/deserializers/Transfer.java @@ -1,15 +1,15 @@ package org.arkecosystem.crypto.transactions.deserializers; +import java.nio.ByteBuffer; import org.arkecosystem.crypto.encoding.Base58; import org.arkecosystem.crypto.transactions.Transaction; -import java.nio.ByteBuffer; - public class Transfer extends AbstractDeserializer { public Transfer(String serialized, ByteBuffer buffer, Transaction transaction) { super(serialized, buffer, transaction); } + @Override public void deserialize(int assetOffset) { this.buffer.position(assetOffset / 2); @@ -22,5 +22,4 @@ public void deserialize(int assetOffset) { this.transaction.parseSignatures(this.serialized, assetOffset + (8 + 4 + 21) * 2); } - } diff --git a/src/main/java/org/arkecosystem/crypto/transactions/deserializers/Vote.java b/src/main/java/org/arkecosystem/crypto/transactions/deserializers/Vote.java index b177c772..f20e098c 100644 --- a/src/main/java/org/arkecosystem/crypto/transactions/deserializers/Vote.java +++ b/src/main/java/org/arkecosystem/crypto/transactions/deserializers/Vote.java @@ -1,25 +1,26 @@ package org.arkecosystem.crypto.transactions.deserializers; -import org.arkecosystem.crypto.transactions.Transaction; - import java.nio.ByteBuffer; +import org.arkecosystem.crypto.transactions.Transaction; public class Vote extends AbstractDeserializer { public Vote(String serialized, ByteBuffer buffer, Transaction transaction) { super(serialized, buffer, transaction); } + @Override public void deserialize(int assetOffset) { this.buffer.position(assetOffset / 2); int voteLength = this.buffer.get() & 0xff; for (int i = 0; i < voteLength; i++) { - String vote = this.serialized.substring(assetOffset + 2 + i * 2 * 34, assetOffset + 2 + (i + 1) * 2 * 34); + String vote = + this.serialized.substring( + assetOffset + 2 + i * 2 * 34, assetOffset + 2 + (i + 1) * 2 * 34); vote = (vote.startsWith("01") ? '+' : '-') + vote.substring(2); transaction.asset.votes.add(vote); } this.transaction.parseSignatures(this.serialized, assetOffset + 2 + voteLength * 34 * 2); } - } diff --git a/src/main/java/org/arkecosystem/crypto/transactions/serializers/AbstractSerializer.java b/src/main/java/org/arkecosystem/crypto/transactions/serializers/AbstractSerializer.java index 976b9e50..249a2990 100644 --- a/src/main/java/org/arkecosystem/crypto/transactions/serializers/AbstractSerializer.java +++ b/src/main/java/org/arkecosystem/crypto/transactions/serializers/AbstractSerializer.java @@ -1,8 +1,7 @@ package org.arkecosystem.crypto.transactions.serializers; -import org.arkecosystem.crypto.transactions.Transaction; - import java.nio.ByteBuffer; +import org.arkecosystem.crypto.transactions.Transaction; public abstract class AbstractSerializer { protected ByteBuffer buffer; @@ -13,4 +12,5 @@ public AbstractSerializer(ByteBuffer buffer, Transaction transaction) { this.transaction = transaction; } + abstract void serialize(); } diff --git a/src/main/java/org/arkecosystem/crypto/transactions/serializers/DelegateRegistration.java b/src/main/java/org/arkecosystem/crypto/transactions/serializers/DelegateRegistration.java index 44303366..5f8ad484 100644 --- a/src/main/java/org/arkecosystem/crypto/transactions/serializers/DelegateRegistration.java +++ b/src/main/java/org/arkecosystem/crypto/transactions/serializers/DelegateRegistration.java @@ -1,19 +1,18 @@ package org.arkecosystem.crypto.transactions.serializers; -import org.arkecosystem.crypto.transactions.Transaction; - import java.nio.ByteBuffer; +import org.arkecosystem.crypto.transactions.Transaction; public class DelegateRegistration extends AbstractSerializer { public DelegateRegistration(ByteBuffer buffer, Transaction transaction) { super(buffer, transaction); } + @Override public void serialize() { byte[] delegateBytes = this.transaction.asset.delegate.username.getBytes(); this.buffer.put((byte) delegateBytes.length); this.buffer.put(delegateBytes); } - } diff --git a/src/main/java/org/arkecosystem/crypto/transactions/serializers/DelegateResignation.java b/src/main/java/org/arkecosystem/crypto/transactions/serializers/DelegateResignation.java new file mode 100644 index 00000000..1798ad2e --- /dev/null +++ b/src/main/java/org/arkecosystem/crypto/transactions/serializers/DelegateResignation.java @@ -0,0 +1,13 @@ +package org.arkecosystem.crypto.transactions.serializers; + +import java.nio.ByteBuffer; +import org.arkecosystem.crypto.transactions.Transaction; + +public class DelegateResignation extends AbstractSerializer { + public DelegateResignation(ByteBuffer buffer, Transaction transaction) { + super(buffer, transaction); + } + + @Override + public void serialize() {} +} diff --git a/src/main/java/org/arkecosystem/crypto/transactions/serializers/HtlcClaim.java b/src/main/java/org/arkecosystem/crypto/transactions/serializers/HtlcClaim.java new file mode 100644 index 00000000..87315071 --- /dev/null +++ b/src/main/java/org/arkecosystem/crypto/transactions/serializers/HtlcClaim.java @@ -0,0 +1,17 @@ +package org.arkecosystem.crypto.transactions.serializers; + +import java.nio.ByteBuffer; +import org.arkecosystem.crypto.encoding.Hex; +import org.arkecosystem.crypto.transactions.Transaction; + +public class HtlcClaim extends AbstractSerializer { + public HtlcClaim(ByteBuffer buffer, Transaction transaction) { + super(buffer, transaction); + } + + @Override + public void serialize() { + this.buffer.put(Hex.decode(this.transaction.asset.htlcClaimAsset.lockTransactionId)); + this.buffer.put(Hex.decode(this.transaction.asset.htlcClaimAsset.unlockSecret)); + } +} diff --git a/src/main/java/org/arkecosystem/crypto/transactions/serializers/HtlcLock.java b/src/main/java/org/arkecosystem/crypto/transactions/serializers/HtlcLock.java new file mode 100644 index 00000000..ba7f6a86 --- /dev/null +++ b/src/main/java/org/arkecosystem/crypto/transactions/serializers/HtlcLock.java @@ -0,0 +1,21 @@ +package org.arkecosystem.crypto.transactions.serializers; + +import java.nio.ByteBuffer; +import org.arkecosystem.crypto.encoding.Base58; +import org.arkecosystem.crypto.encoding.Hex; +import org.arkecosystem.crypto.transactions.Transaction; + +public class HtlcLock extends AbstractSerializer { + public HtlcLock(ByteBuffer buffer, Transaction transaction) { + super(buffer, transaction); + } + + @Override + public void serialize() { + this.buffer.putLong(this.transaction.amount); + this.buffer.put(Hex.decode(this.transaction.asset.htlcLockAsset.secretHash)); + this.buffer.put((byte) this.transaction.asset.htlcLockAsset.expiration.type.getValue()); + this.buffer.putInt(this.transaction.asset.htlcLockAsset.expiration.value); + this.buffer.put(Base58.decodeChecked(this.transaction.recipientId)); + } +} diff --git a/src/main/java/org/arkecosystem/crypto/transactions/serializers/HtlcRefund.java b/src/main/java/org/arkecosystem/crypto/transactions/serializers/HtlcRefund.java new file mode 100644 index 00000000..a89d0edf --- /dev/null +++ b/src/main/java/org/arkecosystem/crypto/transactions/serializers/HtlcRefund.java @@ -0,0 +1,16 @@ +package org.arkecosystem.crypto.transactions.serializers; + +import java.nio.ByteBuffer; +import org.arkecosystem.crypto.encoding.Hex; +import org.arkecosystem.crypto.transactions.Transaction; + +public class HtlcRefund extends AbstractSerializer { + public HtlcRefund(ByteBuffer buffer, Transaction transaction) { + super(buffer, transaction); + } + + @Override + public void serialize() { + this.buffer.put(Hex.decode(this.transaction.asset.htlcRefundAsset.lockTransactionId)); + } +} diff --git a/src/main/java/org/arkecosystem/crypto/transactions/serializers/Ipfs.java b/src/main/java/org/arkecosystem/crypto/transactions/serializers/Ipfs.java new file mode 100644 index 00000000..e173ad8a --- /dev/null +++ b/src/main/java/org/arkecosystem/crypto/transactions/serializers/Ipfs.java @@ -0,0 +1,16 @@ +package org.arkecosystem.crypto.transactions.serializers; + +import java.nio.ByteBuffer; +import org.arkecosystem.crypto.encoding.Base58; +import org.arkecosystem.crypto.transactions.Transaction; + +public class Ipfs extends AbstractSerializer { + public Ipfs(ByteBuffer buffer, Transaction transaction) { + super(buffer, transaction); + } + + @Override + public void serialize() { + this.buffer.put(Base58.decode(this.transaction.asset.ipfs)); + } +} diff --git a/src/main/java/org/arkecosystem/crypto/transactions/serializers/MultiPayment.java b/src/main/java/org/arkecosystem/crypto/transactions/serializers/MultiPayment.java new file mode 100644 index 00000000..42a5314c --- /dev/null +++ b/src/main/java/org/arkecosystem/crypto/transactions/serializers/MultiPayment.java @@ -0,0 +1,21 @@ +package org.arkecosystem.crypto.transactions.serializers; + +import java.nio.ByteBuffer; +import org.arkecosystem.crypto.transactions.Transaction; +import org.arkecosystem.crypto.transactions.TransactionAsset; +import org.bitcoinj.core.Base58; + +public class MultiPayment extends AbstractSerializer { + public MultiPayment(ByteBuffer buffer, Transaction transaction) { + super(buffer, transaction); + } + + @Override + public void serialize() { + this.buffer.putShort((short) this.transaction.asset.multiPayment.payments.size()); + for (TransactionAsset.Payment current : this.transaction.asset.multiPayment.payments) { + this.buffer.putLong(current.amount); + this.buffer.put(Base58.decodeChecked(current.recipientId)); + } + } +} diff --git a/src/main/java/org/arkecosystem/crypto/transactions/serializers/MultiSignatureRegistration.java b/src/main/java/org/arkecosystem/crypto/transactions/serializers/MultiSignatureRegistration.java index 1d70d7f3..ae49af7c 100644 --- a/src/main/java/org/arkecosystem/crypto/transactions/serializers/MultiSignatureRegistration.java +++ b/src/main/java/org/arkecosystem/crypto/transactions/serializers/MultiSignatureRegistration.java @@ -1,21 +1,17 @@ package org.arkecosystem.crypto.transactions.serializers; +import java.nio.ByteBuffer; import org.arkecosystem.crypto.encoding.Hex; import org.arkecosystem.crypto.transactions.Transaction; import org.arkecosystem.crypto.transactions.TransactionAsset; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; - public class MultiSignatureRegistration extends AbstractSerializer { public MultiSignatureRegistration(ByteBuffer buffer, Transaction transaction) { super(buffer, transaction); } + @Override public void serialize() { - List keysgroup = new ArrayList(); - TransactionAsset.MultiSignature multiSignature = this.transaction.asset.multisignature; for (int i = 0; i < multiSignature.keysgroup.size(); i++) { @@ -31,5 +27,4 @@ public void serialize() { this.buffer.put(multiSignature.lifetime); this.buffer.put(Hex.decode(String.join("", multiSignature.keysgroup))); } - } diff --git a/src/main/java/org/arkecosystem/crypto/transactions/serializers/SecondSignatureRegistration.java b/src/main/java/org/arkecosystem/crypto/transactions/serializers/SecondSignatureRegistration.java index 53650af4..54657c6c 100644 --- a/src/main/java/org/arkecosystem/crypto/transactions/serializers/SecondSignatureRegistration.java +++ b/src/main/java/org/arkecosystem/crypto/transactions/serializers/SecondSignatureRegistration.java @@ -1,17 +1,16 @@ package org.arkecosystem.crypto.transactions.serializers; +import java.nio.ByteBuffer; import org.arkecosystem.crypto.encoding.Hex; import org.arkecosystem.crypto.transactions.Transaction; -import java.nio.ByteBuffer; - public class SecondSignatureRegistration extends AbstractSerializer { public SecondSignatureRegistration(ByteBuffer buffer, Transaction transaction) { super(buffer, transaction); } + @Override public void serialize() { this.buffer.put(Hex.decode(this.transaction.asset.signature.publicKey)); } - } diff --git a/src/main/java/org/arkecosystem/crypto/transactions/serializers/Transfer.java b/src/main/java/org/arkecosystem/crypto/transactions/serializers/Transfer.java index 96818620..4a9d6f18 100644 --- a/src/main/java/org/arkecosystem/crypto/transactions/serializers/Transfer.java +++ b/src/main/java/org/arkecosystem/crypto/transactions/serializers/Transfer.java @@ -1,19 +1,18 @@ package org.arkecosystem.crypto.transactions.serializers; +import java.nio.ByteBuffer; import org.arkecosystem.crypto.transactions.Transaction; import org.bitcoinj.core.Base58; -import java.nio.ByteBuffer; - public class Transfer extends AbstractSerializer { public Transfer(ByteBuffer buffer, Transaction transaction) { super(buffer, transaction); } + @Override public void serialize() { this.buffer.putLong(this.transaction.amount); this.buffer.putInt(this.transaction.expiration); this.buffer.put(Base58.decodeChecked(this.transaction.recipientId)); } - } diff --git a/src/main/java/org/arkecosystem/crypto/transactions/serializers/Vote.java b/src/main/java/org/arkecosystem/crypto/transactions/serializers/Vote.java index 66b2ebff..f2bc334f 100644 --- a/src/main/java/org/arkecosystem/crypto/transactions/serializers/Vote.java +++ b/src/main/java/org/arkecosystem/crypto/transactions/serializers/Vote.java @@ -1,25 +1,26 @@ package org.arkecosystem.crypto.transactions.serializers; -import org.arkecosystem.crypto.encoding.Hex; -import org.arkecosystem.crypto.transactions.Transaction; - import java.nio.ByteBuffer; +import java.util.ArrayList; import java.util.List; +import org.arkecosystem.crypto.encoding.Hex; +import org.arkecosystem.crypto.transactions.Transaction; public class Vote extends AbstractSerializer { public Vote(ByteBuffer buffer, Transaction transaction) { super(buffer, transaction); } + @Override public void serialize() { - List votes = transaction.asset.votes; + List votes = new ArrayList<>(transaction.asset.votes); for (int i = 0; i < votes.size(); i++) { - votes.set(i, (votes.get(i).startsWith("+") ? "01" : "00") + votes.get(i).substring(1)); + votes.set( + i, (votes.get(i).startsWith("+") ? "01" : "00") + (votes.get(i).substring(1))); } - this.buffer.put((byte) votes.size()); + this.buffer.put(Hex.decode(String.join("", votes))); } - } diff --git a/src/main/java/org/arkecosystem/crypto/utils/Message.java b/src/main/java/org/arkecosystem/crypto/utils/Message.java index bd638b4a..23687b96 100644 --- a/src/main/java/org/arkecosystem/crypto/utils/Message.java +++ b/src/main/java/org/arkecosystem/crypto/utils/Message.java @@ -1,21 +1,19 @@ package org.arkecosystem.crypto.utils; import com.google.gson.Gson; +import java.util.HashMap; +import java.util.Map; import org.arkecosystem.crypto.encoding.Hex; import org.arkecosystem.crypto.identities.PrivateKey; import org.bitcoinj.core.ECKey; import org.bitcoinj.core.Sha256Hash; import org.bitcoinj.core.SignatureDecodeException; -import java.util.HashMap; -import java.util.Map; - public class Message { private String publickey; private String signature; private String message; - public Message(String publickey, String signature, String message) { this.publickey = publickey; this.signature = signature; @@ -26,7 +24,10 @@ public static Message sign(String message, String passphrase) { ECKey privateKey = PrivateKey.fromPassphrase(passphrase); Sha256Hash messageBytes = Sha256Hash.of(message.getBytes()); - return new Message(privateKey.getPublicKeyAsHex(), Hex.encode(privateKey.sign(messageBytes).encodeToDER()), message); + return new Message( + privateKey.getPublicKeyAsHex(), + Hex.encode(privateKey.sign(messageBytes).encodeToDER()), + message); } public boolean verify() { @@ -65,5 +66,4 @@ public String getPublickey() { public String getSignature() { return signature; } - } diff --git a/src/main/java/org/arkecosystem/crypto/utils/Slot.java b/src/main/java/org/arkecosystem/crypto/utils/Slot.java index da29a5a8..bf164926 100644 --- a/src/main/java/org/arkecosystem/crypto/utils/Slot.java +++ b/src/main/java/org/arkecosystem/crypto/utils/Slot.java @@ -1,15 +1,14 @@ package org.arkecosystem.crypto.utils; -import org.arkecosystem.crypto.configuration.Network; - import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; +import org.arkecosystem.crypto.configuration.Network; public class Slot { public static int time() { - return (int)((new Date().getTime() - epoch()) / 1000); + return (int) ((new Date().getTime() - epoch()) / 1000); } public static long epoch() { diff --git a/src/test/java/org/arkecosystem/crypto/configuration/FeeTest.java b/src/test/java/org/arkecosystem/crypto/configuration/FeeTest.java index 6339df8e..1ecf537a 100644 --- a/src/test/java/org/arkecosystem/crypto/configuration/FeeTest.java +++ b/src/test/java/org/arkecosystem/crypto/configuration/FeeTest.java @@ -1,22 +1,26 @@ package org.arkecosystem.crypto.configuration; -import org.arkecosystem.crypto.enums.Types; -import org.junit.jupiter.api.Test; - import static org.junit.jupiter.api.Assertions.assertEquals; +import java.util.HashMap; +import java.util.Map; +import org.arkecosystem.crypto.enums.CoreTransactionTypes; +import org.junit.jupiter.api.Test; + class FeeTest { @Test void get() { - long fee = Fee.get(Types.TRANSFER); + long fee = Fee.getCoreFee(CoreTransactionTypes.TRANSFER.getValue()); assertEquals(10_000_000, fee); } @Test void set() { - Fee.set(Types.TRANSFER, 20_000_000L); - long fee = Fee.get(Types.TRANSFER); - assertEquals(20_000_000, fee); + Map fees = new HashMap<>(); + fees.put(500, 1L); + Fee.set(1001, fees); + long fee = Fee.getFee(1001, 500); + assertEquals(1L, fee); } } diff --git a/src/test/java/org/arkecosystem/crypto/configuration/NetworkTest.java b/src/test/java/org/arkecosystem/crypto/configuration/NetworkTest.java index c7a7c477..a18b111e 100644 --- a/src/test/java/org/arkecosystem/crypto/configuration/NetworkTest.java +++ b/src/test/java/org/arkecosystem/crypto/configuration/NetworkTest.java @@ -1,12 +1,12 @@ package org.arkecosystem.crypto.configuration; +import static org.junit.jupiter.api.Assertions.assertEquals; + import org.arkecosystem.crypto.networks.INetwork; import org.arkecosystem.crypto.networks.Mainnet; import org.arkecosystem.crypto.networks.Testnet; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; - class NetworkTest { @Test diff --git a/src/test/java/org/arkecosystem/crypto/identities/AddressTest.java b/src/test/java/org/arkecosystem/crypto/identities/AddressTest.java index 2c7afcec..33cde63c 100644 --- a/src/test/java/org/arkecosystem/crypto/identities/AddressTest.java +++ b/src/test/java/org/arkecosystem/crypto/identities/AddressTest.java @@ -1,13 +1,13 @@ package org.arkecosystem.crypto.identities; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.arkecosystem.crypto.configuration.Network; import org.arkecosystem.crypto.networks.Devnet; import org.bitcoinj.core.ECKey; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - public class AddressTest { @Test @@ -19,7 +19,9 @@ public void fromPassphrase() { @Test public void fromPublicKey() { - String actual = Address.fromPublicKey("034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192"); + String actual = + Address.fromPublicKey( + "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192"); assertEquals("D61mfSggzbvQgTUe6JhYKH2doHaqJ3Dyib", actual); } @@ -35,5 +37,4 @@ public void validate() { Network.set(new Devnet()); assertTrue(Address.validate("D61mfSggzbvQgTUe6JhYKH2doHaqJ3Dyib")); } - } diff --git a/src/test/java/org/arkecosystem/crypto/identities/PrivateKeyTest.java b/src/test/java/org/arkecosystem/crypto/identities/PrivateKeyTest.java index 768a6951..9363c423 100644 --- a/src/test/java/org/arkecosystem/crypto/identities/PrivateKeyTest.java +++ b/src/test/java/org/arkecosystem/crypto/identities/PrivateKeyTest.java @@ -1,21 +1,24 @@ package org.arkecosystem.crypto.identities; -import org.junit.jupiter.api.Test; - import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; + public class PrivateKeyTest { @Test public void fromPassphrase() { - String actual = PrivateKey.fromPassphrase("this is a top secret passphrase").getPrivateKeyAsHex(); + String actual = + PrivateKey.fromPassphrase("this is a top secret passphrase").getPrivateKeyAsHex(); assertEquals("d8839c2432bfd0a67ef10a804ba991eabba19f154a3d707917681d45822a5712", actual); } @Test public void fromHex() { - String actual = PrivateKey.fromHex("d8839c2432bfd0a67ef10a804ba991eabba19f154a3d707917681d45822a5712").getPrivateKeyAsHex(); + String actual = + PrivateKey.fromHex( + "d8839c2432bfd0a67ef10a804ba991eabba19f154a3d707917681d45822a5712") + .getPrivateKeyAsHex(); assertEquals("d8839c2432bfd0a67ef10a804ba991eabba19f154a3d707917681d45822a5712", actual); } - } diff --git a/src/test/java/org/arkecosystem/crypto/identities/PublicKeyTest.java b/src/test/java/org/arkecosystem/crypto/identities/PublicKeyTest.java index bdb54e27..274b48e3 100644 --- a/src/test/java/org/arkecosystem/crypto/identities/PublicKeyTest.java +++ b/src/test/java/org/arkecosystem/crypto/identities/PublicKeyTest.java @@ -7,13 +7,17 @@ public class PublicKeyTest { @Test public void fromPassphrase() { String actual = PublicKey.fromPassphrase("this is a top secret passphrase"); - Assertions.assertEquals("034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", actual); + Assertions.assertEquals( + "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", actual); } @Test public void fromHex() { - String actual = PrivateKey.fromHex("d8839c2432bfd0a67ef10a804ba991eabba19f154a3d707917681d45822a5712").getPrivateKeyAsHex(); - Assertions.assertEquals("d8839c2432bfd0a67ef10a804ba991eabba19f154a3d707917681d45822a5712", actual); + String actual = + PrivateKey.fromHex( + "d8839c2432bfd0a67ef10a804ba991eabba19f154a3d707917681d45822a5712") + .getPrivateKeyAsHex(); + Assertions.assertEquals( + "d8839c2432bfd0a67ef10a804ba991eabba19f154a3d707917681d45822a5712", actual); } - } diff --git a/src/test/java/org/arkecosystem/crypto/identities/WIFTest.java b/src/test/java/org/arkecosystem/crypto/identities/WIFTest.java index 4c4f9d2a..cfe4f4ee 100644 --- a/src/test/java/org/arkecosystem/crypto/identities/WIFTest.java +++ b/src/test/java/org/arkecosystem/crypto/identities/WIFTest.java @@ -1,10 +1,9 @@ package org.arkecosystem.crypto.identities; +import java.io.IOException; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import java.io.IOException; - public class WIFTest { @Test @@ -12,5 +11,4 @@ public void fromPassphrase() throws IOException { String actual = WIF.fromPassphrase("this is a top secret passphrase"); Assertions.assertEquals("SGq4xLgZKCGxs7bjmwnBrWcT4C1ADFEermj846KC97FSv1WFD1dA", actual); } - } diff --git a/src/test/java/org/arkecosystem/crypto/networks/DevnetTest.java b/src/test/java/org/arkecosystem/crypto/networks/DevnetTest.java index 2e654f14..81c490d3 100644 --- a/src/test/java/org/arkecosystem/crypto/networks/DevnetTest.java +++ b/src/test/java/org/arkecosystem/crypto/networks/DevnetTest.java @@ -1,9 +1,9 @@ package org.arkecosystem.crypto.networks; -import org.junit.jupiter.api.Test; - import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; + class DevnetTest { @Test diff --git a/src/test/java/org/arkecosystem/crypto/networks/MainnetTest.java b/src/test/java/org/arkecosystem/crypto/networks/MainnetTest.java index 2dddd3c1..5e1f3c9a 100644 --- a/src/test/java/org/arkecosystem/crypto/networks/MainnetTest.java +++ b/src/test/java/org/arkecosystem/crypto/networks/MainnetTest.java @@ -1,9 +1,9 @@ package org.arkecosystem.crypto.networks; -import org.junit.jupiter.api.Test; - import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; + class MainnetTest { @Test diff --git a/src/test/java/org/arkecosystem/crypto/networks/TestnetTest.java b/src/test/java/org/arkecosystem/crypto/networks/TestnetTest.java index c63b08b6..d31e0139 100644 --- a/src/test/java/org/arkecosystem/crypto/networks/TestnetTest.java +++ b/src/test/java/org/arkecosystem/crypto/networks/TestnetTest.java @@ -1,9 +1,9 @@ package org.arkecosystem.crypto.networks; -import org.junit.jupiter.api.Test; - import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; + class TestnetTest { @Test diff --git a/src/test/java/org/arkecosystem/crypto/transactions/FixtureLoader.java b/src/test/java/org/arkecosystem/crypto/transactions/FixtureLoader.java index 0251afd5..67258896 100644 --- a/src/test/java/org/arkecosystem/crypto/transactions/FixtureLoader.java +++ b/src/test/java/org/arkecosystem/crypto/transactions/FixtureLoader.java @@ -2,7 +2,6 @@ import com.google.gson.Gson; import com.google.gson.internal.LinkedTreeMap; - import java.io.IOException; import java.net.URL; import java.nio.charset.StandardCharsets; @@ -14,12 +13,14 @@ public class FixtureLoader { private static String readFile(String path) throws IOException { ClassLoader classLoader = Transaction.class.getClassLoader(); URL resource = classLoader.getResource(String.format("%s.json", path)); - return new String(Files.readAllBytes(Paths.get(resource.getPath())), StandardCharsets.UTF_8); + return new String( + Files.readAllBytes(Paths.get(resource.getPath())), StandardCharsets.UTF_8); } public static LinkedTreeMap load(String path) { try { - return new Gson().fromJson(readFile(path), new LinkedTreeMap().getClass()); + return new Gson() + .fromJson(readFile(path), new LinkedTreeMap().getClass()); } catch (IOException e) { e.printStackTrace(); return null; diff --git a/src/test/java/org/arkecosystem/crypto/transactions/builder/DelegateRegistrationTest.java b/src/test/java/org/arkecosystem/crypto/transactions/builder/DelegateRegistrationTest.java index b382e6af..f84bd51b 100644 --- a/src/test/java/org/arkecosystem/crypto/transactions/builder/DelegateRegistrationTest.java +++ b/src/test/java/org/arkecosystem/crypto/transactions/builder/DelegateRegistrationTest.java @@ -1,32 +1,60 @@ package org.arkecosystem.crypto.transactions.builder; +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.arkecosystem.crypto.transactions.Transaction; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertTrue; - public class DelegateRegistrationTest { @Test void build() { - Transaction actual = new DelegateRegistration() - .username("java") - .sign("this is a top secret passphrase") - .transaction; - - assertTrue(actual.verify()); + Transaction actualV1 = + new DelegateRegistration() + .username("java") + .version(1) + .sign("this is a top secret passphrase") + .transaction; + + assertTrue(actualV1.verify()); + + Transaction actualV2 = + new DelegateRegistration() + .username("java") + .version(2) + .nonce(3) + .sign("this is a top secret passphrase") + .transaction; + + assertTrue(actualV2.verify()); } @Test void buildSecondSignature() { - Transaction actual = new DelegateRegistration() - .username("java") - .sign("this is a top secret passphrase") - .secondSign("this is a top secret second passphrase") - .transaction; - - assertTrue(actual.verify()); - assertTrue(actual.secondVerify("03699e966b2525f9088a6941d8d94f7869964a000efe65783d78ac82e1199fe609")); + Transaction actualV1 = + new DelegateRegistration() + .username("java") + .sign("this is a top secret passphrase") + .secondSign("this is a top secret second passphrase") + .transaction; + + assertTrue(actualV1.verify()); + assertTrue( + actualV1.secondVerify( + "03699e966b2525f9088a6941d8d94f7869964a000efe65783d78ac82e1199fe609")); + + Transaction actualV2 = + new DelegateRegistration() + .username("java") + .version(2) + .nonce(3) + .sign("this is a top secret passphrase") + .secondSign("this is a top secret second passphrase") + .transaction; + + assertTrue(actualV2.verify()); + assertTrue( + actualV2.secondVerify( + "03699e966b2525f9088a6941d8d94f7869964a000efe65783d78ac82e1199fe609")); } - } diff --git a/src/test/java/org/arkecosystem/crypto/transactions/builder/DelegateResignationTest.java b/src/test/java/org/arkecosystem/crypto/transactions/builder/DelegateResignationTest.java new file mode 100644 index 00000000..03aa0651 --- /dev/null +++ b/src/test/java/org/arkecosystem/crypto/transactions/builder/DelegateResignationTest.java @@ -0,0 +1,37 @@ +package org.arkecosystem.crypto.transactions.builder; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.arkecosystem.crypto.transactions.Transaction; +import org.junit.jupiter.api.Test; + +public class DelegateResignationTest { + + @Test + void build() { + Transaction actual = + new DelegateResignation() + .version(2) + .nonce(3) + .sign("this is a top secret passphrase") + .transaction; + + assertTrue(actual.verify()); + } + + @Test + void buildSecondSignature() { + Transaction actual = + new DelegateResignation() + .version(2) + .nonce(3) + .sign("this is a top secret passphrase") + .secondSign("this is a top secret second passphrase") + .transaction; + + assertTrue(actual.verify()); + assertTrue( + actual.secondVerify( + "03699e966b2525f9088a6941d8d94f7869964a000efe65783d78ac82e1199fe609")); + } +} diff --git a/src/test/java/org/arkecosystem/crypto/transactions/builder/HtlcClaimTest.java b/src/test/java/org/arkecosystem/crypto/transactions/builder/HtlcClaimTest.java new file mode 100644 index 00000000..4760e8d8 --- /dev/null +++ b/src/test/java/org/arkecosystem/crypto/transactions/builder/HtlcClaimTest.java @@ -0,0 +1,40 @@ +package org.arkecosystem.crypto.transactions.builder; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.arkecosystem.crypto.transactions.Transaction; +import org.junit.jupiter.api.Test; + +public class HtlcClaimTest { + @Test + void build() { + Transaction actual = + new HtlcClaim() + .htlcClaimAsset( + "943c220691e711c39c79d437ce185748a0018940e1a4144293af9d05627d2eb4", + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") + .nonce(3) + .sign("this is a top secret passphrase") + .transaction; + + assertTrue(actual.verify()); + } + + @Test + void buildSecondSignature() { + Transaction actual = + new HtlcClaim() + .htlcClaimAsset( + "943c220691e711c39c79d437ce185748a0018940e1a4144293af9d05627d2eb4", + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") + .nonce(3) + .sign("this is a top secret passphrase") + .secondSign("this is a top secret second passphrase") + .transaction; + + assertTrue(actual.verify()); + assertTrue( + actual.secondVerify( + "03699e966b2525f9088a6941d8d94f7869964a000efe65783d78ac82e1199fe609")); + } +} diff --git a/src/test/java/org/arkecosystem/crypto/transactions/builder/HtlcLockTest.java b/src/test/java/org/arkecosystem/crypto/transactions/builder/HtlcLockTest.java new file mode 100644 index 00000000..e0fc9126 --- /dev/null +++ b/src/test/java/org/arkecosystem/crypto/transactions/builder/HtlcLockTest.java @@ -0,0 +1,45 @@ +package org.arkecosystem.crypto.transactions.builder; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.arkecosystem.crypto.enums.HtlcLockExpirationType; +import org.arkecosystem.crypto.transactions.Transaction; +import org.junit.jupiter.api.Test; + +public class HtlcLockTest { + @Test + void build() { + Transaction actual = + new HtlcLock() + .amount(1) + .recipientId("AXoXnFi4z1Z6aFvjEYkDVCtBGW2PaRiM25") + .secretHash( + "0f128d401958b1b30ad0d10406f47f9489321017b4614e6cb993fc63913c5454") + .expirationType(HtlcLockExpirationType.EPOCH_TIMESTAMP, 1) + .nonce(3) + .sign("this is a top secret passphrase") + .transaction; + + assertTrue(actual.verify()); + } + + @Test + void buildSecondSignature() { + Transaction actual = + new HtlcLock() + .amount(1) + .recipientId("AXoXnFi4z1Z6aFvjEYkDVCtBGW2PaRiM25") + .secretHash( + "0f128d401958b1b30ad0d10406f47f9489321017b4614e6cb993fc63913c5454") + .expirationType(HtlcLockExpirationType.EPOCH_TIMESTAMP, 1) + .nonce(3) + .sign("this is a top secret passphrase") + .secondSign("this is a top secret second passphrase") + .transaction; + + assertTrue(actual.verify()); + assertTrue( + actual.secondVerify( + "03699e966b2525f9088a6941d8d94f7869964a000efe65783d78ac82e1199fe609")); + } +} diff --git a/src/test/java/org/arkecosystem/crypto/transactions/builder/HtlcRefundTest.java b/src/test/java/org/arkecosystem/crypto/transactions/builder/HtlcRefundTest.java new file mode 100644 index 00000000..f9c603a8 --- /dev/null +++ b/src/test/java/org/arkecosystem/crypto/transactions/builder/HtlcRefundTest.java @@ -0,0 +1,38 @@ +package org.arkecosystem.crypto.transactions.builder; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.arkecosystem.crypto.transactions.Transaction; +import org.junit.jupiter.api.Test; + +public class HtlcRefundTest { + @Test + void build() { + Transaction actual = + new HtlcRefund() + .htlcRefundAsset( + "943c220691e711c39c79d437ce185748a0018940e1a4144293af9d05627d2eb4") + .nonce(3) + .sign("this is a top secret passphrase") + .transaction; + + assertTrue(actual.verify()); + } + + @Test + void buildSecondSignature() { + Transaction actual = + new HtlcRefund() + .htlcRefundAsset( + "943c220691e711c39c79d437ce185748a0018940e1a4144293af9d05627d2eb4") + .nonce(3) + .sign("this is a top secret passphrase") + .secondSign("this is a top secret second passphrase") + .transaction; + + assertTrue(actual.verify()); + assertTrue( + actual.secondVerify( + "03699e966b2525f9088a6941d8d94f7869964a000efe65783d78ac82e1199fe609")); + } +} diff --git a/src/test/java/org/arkecosystem/crypto/transactions/builder/IpfsTest.java b/src/test/java/org/arkecosystem/crypto/transactions/builder/IpfsTest.java new file mode 100644 index 00000000..0be28596 --- /dev/null +++ b/src/test/java/org/arkecosystem/crypto/transactions/builder/IpfsTest.java @@ -0,0 +1,39 @@ +package org.arkecosystem.crypto.transactions.builder; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.arkecosystem.crypto.transactions.Transaction; +import org.junit.jupiter.api.Test; + +public class IpfsTest { + + @Test + void build() { + Transaction actualV2 = + new Ipfs() + .ipfsAsset("QmR45FmbVVrixReBwJkhEKde2qwHYaQzGxu4ZoDeswuF9w") + .version(2) + .nonce(3) + .sign("this is a top secret passphrase") + .transaction; + + assertTrue(actualV2.verify()); + } + + @Test + void buildSecondSignature() { + Transaction actualV2 = + new Ipfs() + .ipfsAsset("QmR45FmbVVrixReBwJkhEKde2qwHYaQzGxu4ZoDeswuF9w") + .version(2) + .nonce(3) + .sign("this is a top secret passphrase") + .secondSign("this is a top secret second passphrase") + .transaction; + + assertTrue(actualV2.verify()); + assertTrue( + actualV2.secondVerify( + "03699e966b2525f9088a6941d8d94f7869964a000efe65783d78ac82e1199fe609")); + } +} diff --git a/src/test/java/org/arkecosystem/crypto/transactions/builder/MultiPaymentTest.java b/src/test/java/org/arkecosystem/crypto/transactions/builder/MultiPaymentTest.java new file mode 100644 index 00000000..12777a34 --- /dev/null +++ b/src/test/java/org/arkecosystem/crypto/transactions/builder/MultiPaymentTest.java @@ -0,0 +1,75 @@ +package org.arkecosystem.crypto.transactions.builder; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.arkecosystem.crypto.configuration.Network; +import org.arkecosystem.crypto.networks.Devnet; +import org.arkecosystem.crypto.networks.Testnet; +import org.arkecosystem.crypto.transactions.Transaction; +import org.junit.jupiter.api.Test; + +public class MultiPaymentTest { + @Test + void build() { + Transaction actual = + new MultiPayment() + .addPayment("AXoXnFi4z1Z6aFvjEYkDVCtBGW2PaRiM25", 1) + .addPayment("AXoXnFi4z1Z6aFvjEYkDVCtBGW2PaRiM25", 2) + .addPayment("AXoXnFi4z1Z6aFvjEYkDVCtBGW2PaRiM25", 3) + .vendorField("This is a transaction from Java") + .sign("this is a top secret passphrase") + .transaction; + + assertTrue(actual.verify()); + } + + @Test + void buildDevnet() { + Network.set(new Devnet()); + Transaction actual = + new MultiPayment() + .addPayment("DNA6BqdX2mYw3PtPfGmEz2bGyyCA9hbaED", 1) + .addPayment("D65rqoZU7U4FdqLVF9KsEF9GBtvwDEVTBt", 2) + .addPayment("D88ZXZ5MaeZFA6xrJPSgJ92qWVWY1462dD", 3) + .vendorField("Zan Vendor Field arghhh") + .nonce(2) + .sign( + "nurse organ hub theory mad strike desert add heavy deposit immune inform") + .transaction; + + System.out.println(actual.toJson()); + System.out.println(actual.serialize()); + assertTrue(actual.verify()); + } + + @Test + void buildTestnet() { + Network.set(new Testnet()); + Transaction actual = + new MultiPayment() + .addPayment("AHXtmB84sTZ9Zd35h9Y1vfFvPE2Xzqj8ri", 1) + .addPayment("AZFEPTWnn2Sn8wDZgCRF8ohwKkrmk2AZi1", 2) + .nonce(1) + .sign("this is a top secret passphrase") + .transaction; + + System.out.println(actual.toJson()); + System.out.println(actual.serialize()); + assertTrue(actual.verify()); + } + + @Test + void buildSecondSignature() { + Transaction actual = + new MultiPayment() + .addPayment("AXoXnFi4z1Z6aFvjEYkDVCtBGW2PaRiM25", 1) + .addPayment("AXoXnFi4z1Z6aFvjEYkDVCtBGW2PaRiM25", 2) + .addPayment("AXoXnFi4z1Z6aFvjEYkDVCtBGW2PaRiM25", 3) + .vendorField("This is a transaction from Java") + .sign("this is a top secret passphrase") + .secondSign("this is a top secret second passphrase") + .transaction; + + assertTrue(actual.verify()); + } +} diff --git a/src/test/java/org/arkecosystem/crypto/transactions/builder/MultiSignatureRegistrationTest.java b/src/test/java/org/arkecosystem/crypto/transactions/builder/MultiSignatureRegistrationTest.java index afb8f4f2..2c141819 100644 --- a/src/test/java/org/arkecosystem/crypto/transactions/builder/MultiSignatureRegistrationTest.java +++ b/src/test/java/org/arkecosystem/crypto/transactions/builder/MultiSignatureRegistrationTest.java @@ -1,44 +1,48 @@ package org.arkecosystem.crypto.transactions.builder; -import org.arkecosystem.crypto.transactions.Transaction; -import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Arrays; - -import static org.junit.jupiter.api.Assertions.assertTrue; +import org.arkecosystem.crypto.transactions.Transaction; +import org.junit.jupiter.api.Test; public class MultiSignatureRegistrationTest { @Test void build() { - Transaction actual = new MultiSignatureRegistration() - .min(2) - .lifetime(255) - .keysgroup(Arrays.asList( - "03a02b9d5fdd1307c2ee4652ba54d492d1fd11a7d1bb3f3a44c4a05e79f19de933", - "13a02b9d5fdd1307c2ee4652ba54d492d1fd11a7d1bb3f3a44c4a05e79f19de933", - "23a02b9d5fdd1307c2ee4652ba54d492d1fd11a7d1bb3f3a44c4a05e79f19de933")) - .sign("this is a top secret passphrase") - .transaction; - - assertTrue(actual.verify()); + Transaction actualV1 = + new MultiSignatureRegistration() + .min(2) + .lifetime(255) + .keysgroup( + Arrays.asList( + "03a02b9d5fdd1307c2ee4652ba54d492d1fd11a7d1bb3f3a44c4a05e79f19de933", + "13a02b9d5fdd1307c2ee4652ba54d492d1fd11a7d1bb3f3a44c4a05e79f19de933", + "23a02b9d5fdd1307c2ee4652ba54d492d1fd11a7d1bb3f3a44c4a05e79f19de933")) + .sign("this is a top secret passphrase") + .transaction; + + assertTrue(actualV1.verify()); } @Test void buildSecondSignature() { - Transaction actual = new MultiSignatureRegistration() - .min(2) - .lifetime(255) - .keysgroup(Arrays.asList( - "03a02b9d5fdd1307c2ee4652ba54d492d1fd11a7d1bb3f3a44c4a05e79f19de933", - "13a02b9d5fdd1307c2ee4652ba54d492d1fd11a7d1bb3f3a44c4a05e79f19de933", - "23a02b9d5fdd1307c2ee4652ba54d492d1fd11a7d1bb3f3a44c4a05e79f19de933")) - .sign("this is a top secret passphrase") - .secondSign("this is a top secret second passphrase") - .transaction; + Transaction actual = + new MultiSignatureRegistration() + .min(2) + .lifetime(255) + .keysgroup( + Arrays.asList( + "03a02b9d5fdd1307c2ee4652ba54d492d1fd11a7d1bb3f3a44c4a05e79f19de933", + "13a02b9d5fdd1307c2ee4652ba54d492d1fd11a7d1bb3f3a44c4a05e79f19de933", + "23a02b9d5fdd1307c2ee4652ba54d492d1fd11a7d1bb3f3a44c4a05e79f19de933")) + .sign("this is a top secret passphrase") + .secondSign("this is a top secret second passphrase") + .transaction; assertTrue(actual.verify()); - assertTrue(actual.secondVerify("03699e966b2525f9088a6941d8d94f7869964a000efe65783d78ac82e1199fe609")); + assertTrue( + actual.secondVerify( + "03699e966b2525f9088a6941d8d94f7869964a000efe65783d78ac82e1199fe609")); } - } diff --git a/src/test/java/org/arkecosystem/crypto/transactions/builder/SecondSignatureRegistrationTest.java b/src/test/java/org/arkecosystem/crypto/transactions/builder/SecondSignatureRegistrationTest.java index 493398be..f4f89d62 100644 --- a/src/test/java/org/arkecosystem/crypto/transactions/builder/SecondSignatureRegistrationTest.java +++ b/src/test/java/org/arkecosystem/crypto/transactions/builder/SecondSignatureRegistrationTest.java @@ -1,20 +1,31 @@ package org.arkecosystem.crypto.transactions.builder; +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.arkecosystem.crypto.transactions.Transaction; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertTrue; - public class SecondSignatureRegistrationTest { @Test void build() { - Transaction actual = new SecondSignatureRegistration() - .signature("this is a top secret second passphrase'") - .sign("this is a top secret passphrase") - .transaction; + Transaction actualV1 = + new SecondSignatureRegistration() + .signature("this is a top secret second passphrase'") + .version(1) + .sign("this is a top secret passphrase") + .transaction; - assertTrue(actual.verify()); - } + assertTrue(actualV1.verify()); + + Transaction actualV2 = + new SecondSignatureRegistration() + .signature("this is a top secret second passphrase'") + .version(2) + .nonce(3) + .sign("this is a top secret passphrase") + .transaction; + assertTrue(actualV2.verify()); + } } diff --git a/src/test/java/org/arkecosystem/crypto/transactions/builder/TransferTest.java b/src/test/java/org/arkecosystem/crypto/transactions/builder/TransferTest.java index ad2e1e11..f5f3ade8 100644 --- a/src/test/java/org/arkecosystem/crypto/transactions/builder/TransferTest.java +++ b/src/test/java/org/arkecosystem/crypto/transactions/builder/TransferTest.java @@ -1,36 +1,69 @@ package org.arkecosystem.crypto.transactions.builder; +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.arkecosystem.crypto.transactions.Transaction; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertTrue; - public class TransferTest { @Test void build() { - Transaction actual = new Transfer() - .recipient("AXoXnFi4z1Z6aFvjEYkDVCtBGW2PaRiM25") - .amount(133380000000L) - .vendorField("This is a transaction from Java") - .sign("this is a top secret passphrase") - .transaction; - - assertTrue(actual.verify()); + Transaction actualV1 = + new Transfer() + .recipient("AXoXnFi4z1Z6aFvjEYkDVCtBGW2PaRiM25") + .amount(133380000000L) + .vendorField("This is a transaction from Java") + .version(1) + .sign("this is a top secret passphrase") + .transaction; + + assertTrue(actualV1.verify()); + + Transaction actualV2 = + new Transfer() + .recipient("AXoXnFi4z1Z6aFvjEYkDVCtBGW2PaRiM25") + .amount(133380000000L) + .vendorField("This is a transaction from Java") + .version(2) + .nonce(3) + .sign("this is a top secret passphrase") + .transaction; + + assertTrue(actualV2.verify()); } @Test void buildSecondSignature() { - Transaction actual = new Transfer() - .recipient("AXoXnFi4z1Z6aFvjEYkDVCtBGW2PaRiM25") - .amount(133380000000L) - .vendorField("This is a transaction from Java") - .sign("this is a top secret passphrase") - .secondSign("this is a top secret second passphrase") - .transaction; - - assertTrue(actual.verify()); - assertTrue(actual.secondVerify("03699e966b2525f9088a6941d8d94f7869964a000efe65783d78ac82e1199fe609")); - } + Transaction actualV1 = + new Transfer() + .recipient("AXoXnFi4z1Z6aFvjEYkDVCtBGW2PaRiM25") + .amount(133380000000L) + .vendorField("This is a transaction from Java") + .version(1) + .sign("this is a top secret passphrase") + .secondSign("this is a top secret second passphrase") + .transaction; + + assertTrue(actualV1.verify()); + assertTrue( + actualV1.secondVerify( + "03699e966b2525f9088a6941d8d94f7869964a000efe65783d78ac82e1199fe609")); + Transaction actualV2 = + new Transfer() + .recipient("AXoXnFi4z1Z6aFvjEYkDVCtBGW2PaRiM25") + .amount(133380000000L) + .vendorField("This is a transaction from Java") + .version(2) + .nonce(3) + .sign("this is a top secret passphrase") + .secondSign("this is a top secret second passphrase") + .transaction; + + assertTrue(actualV2.verify()); + assertTrue( + actualV2.secondVerify( + "03699e966b2525f9088a6941d8d94f7869964a000efe65783d78ac82e1199fe609")); + } } diff --git a/src/test/java/org/arkecosystem/crypto/transactions/builder/VoteTest.java b/src/test/java/org/arkecosystem/crypto/transactions/builder/VoteTest.java index 8e29d23b..abe2410e 100644 --- a/src/test/java/org/arkecosystem/crypto/transactions/builder/VoteTest.java +++ b/src/test/java/org/arkecosystem/crypto/transactions/builder/VoteTest.java @@ -1,35 +1,70 @@ package org.arkecosystem.crypto.transactions.builder; -import org.arkecosystem.crypto.transactions.Transaction; -import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Arrays; - -import static org.junit.jupiter.api.Assertions.assertTrue; +import org.arkecosystem.crypto.transactions.Transaction; +import org.junit.jupiter.api.Test; public class VoteTest { - @Test void build() { - Transaction actual = new Vote() - .votes(Arrays.asList("'+034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192'")) - .sign("this is a top secret passphrase") - .transaction; + Transaction actualV1 = + new Vote() + .votes( + Arrays.asList( + "'+034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192'")) + .version(1) + .sign("this is a top secret passphrase") + .transaction; + + assertTrue(actualV1.verify()); - assertTrue(actual.verify()); + Transaction actualV2 = + new Vote() + .votes( + Arrays.asList( + "+034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192")) + .version(2) + .nonce(3) + .sign("this is a top secret passphrase") + .transaction; + + assertTrue(actualV2.verify()); } @Test void buildSecondSignature() { - Transaction actual = new Vote() - .votes(Arrays.asList("'+034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192'")) - .sign("this is a top secret passphrase") - .secondSign("this is a top secret second passphrase") - .transaction; - - assertTrue(actual.verify()); - assertTrue(actual.secondVerify("03699e966b2525f9088a6941d8d94f7869964a000efe65783d78ac82e1199fe609")); - } + Transaction actualV1 = + new Vote() + .votes( + Arrays.asList( + "'+034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192'")) + .version(1) + .sign("this is a top secret passphrase") + .secondSign("this is a top secret second passphrase") + .transaction; + assertTrue(actualV1.verify()); + assertTrue( + actualV1.secondVerify( + "03699e966b2525f9088a6941d8d94f7869964a000efe65783d78ac82e1199fe609")); + + Transaction actualV2 = + new Vote() + .votes( + Arrays.asList( + "+034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192")) + .version(2) + .nonce(3) + .sign("this is a top secret passphrase") + .secondSign("this is a top secret second passphrase") + .transaction; + + assertTrue(actualV2.verify()); + assertTrue( + actualV2.secondVerify( + "03699e966b2525f9088a6941d8d94f7869964a000efe65783d78ac82e1199fe609")); + } } diff --git a/src/test/java/org/arkecosystem/crypto/transactions/deserializers/DelegateRegistrationTest.java b/src/test/java/org/arkecosystem/crypto/transactions/deserializers/DelegateRegistrationTest.java index f4455060..f295e91f 100644 --- a/src/test/java/org/arkecosystem/crypto/transactions/deserializers/DelegateRegistrationTest.java +++ b/src/test/java/org/arkecosystem/crypto/transactions/deserializers/DelegateRegistrationTest.java @@ -1,52 +1,106 @@ package org.arkecosystem.crypto.transactions.deserializers; +import static org.junit.jupiter.api.Assertions.assertEquals; + import com.google.gson.internal.LinkedTreeMap; +import org.arkecosystem.crypto.enums.TransactionTypeGroup; import org.arkecosystem.crypto.transactions.Deserializer; import org.arkecosystem.crypto.transactions.FixtureLoader; import org.arkecosystem.crypto.transactions.Transaction; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; - class DelegateRegistrationTest { @Test void passphrase() { - LinkedTreeMap fixture = FixtureLoader.load("transactions/delegate_registration/passphrase"); - LinkedTreeMap data = (LinkedTreeMap) fixture.get("data"); + // V1 tests + LinkedTreeMap fixtureV1 = + FixtureLoader.load("transactions/V1/delegate_registration/passphrase"); + LinkedTreeMap dataV1 = + (LinkedTreeMap) fixtureV1.get("data"); + + Transaction actualV1 = + new Deserializer().deserialize(fixtureV1.get("serialized").toString()); + assertEquals(((Double) dataV1.get("type")).intValue(), actualV1.type); + assertEquals(((Double) dataV1.get("amount")).longValue(), actualV1.amount); + assertEquals(((Double) dataV1.get("fee")).longValue(), actualV1.fee); + assertEquals(((Double) dataV1.get("timestamp")).intValue(), actualV1.timestamp); + assertEquals(dataV1.get("senderPublicKey").toString(), actualV1.senderPublicKey); + assertEquals(dataV1.get("signature").toString(), actualV1.signature); + assertEquals(dataV1.get("id").toString(), actualV1.id); + + LinkedTreeMap assetV1 = + (LinkedTreeMap) + ((LinkedTreeMap) dataV1.get("asset")).get("delegate"); + assertEquals((assetV1.get("username")), actualV1.asset.delegate.username); - Transaction actual = new Deserializer().deserialize(fixture.get("serialized").toString()); - assertEquals(((Double) data.get("type")).intValue(), actual.type.getValue()); - assertEquals(((Double) data.get("amount")).longValue(), actual.amount); - assertEquals(((Double) data.get("fee")).longValue(), actual.fee); - assertEquals(((Double) data.get("timestamp")).intValue(), actual.timestamp); - assertEquals(data.get("senderPublicKey").toString(), actual.senderPublicKey); - assertEquals(data.get("signature").toString(), actual.signature); + // V2 tests + LinkedTreeMap fixtureV2 = + FixtureLoader.load("transactions/v2-ecdsa/delegate-registration-sign"); + LinkedTreeMap dataV2 = + (LinkedTreeMap) fixtureV2.get("data"); - LinkedTreeMap asset = (LinkedTreeMap) ((LinkedTreeMap) data.get("asset")).get("delegate"); - assertEquals((asset.get("username")), actual.asset.delegate.username); + Transaction actualV2 = + new Deserializer().deserialize(fixtureV2.get("serialized").toString()); + assertEquals(((Double) dataV2.get("type")).intValue(), actualV2.type); + assertEquals(TransactionTypeGroup.CORE.getValue(), actualV2.typeGroup); + assertEquals((Long.valueOf((String) dataV2.get("fee"))), actualV2.fee); + assertEquals((Long.valueOf((String) dataV2.get("nonce"))), actualV2.nonce); + assertEquals(dataV2.get("senderPublicKey").toString(), actualV2.senderPublicKey); + assertEquals(dataV2.get("signature").toString(), actualV2.signature); + assertEquals(dataV2.get("id").toString(), actualV2.id); - assertEquals(data.get("id").toString(), actual.id); + LinkedTreeMap assetV2 = + (LinkedTreeMap) + ((LinkedTreeMap) dataV2.get("asset")).get("delegate"); + assertEquals((assetV2.get("username")), actualV2.asset.delegate.username); } @Test void secondPassphrase() { - LinkedTreeMap fixture = FixtureLoader.load("transactions/delegate_registration/second-passphrase"); - LinkedTreeMap data = (LinkedTreeMap) fixture.get("data"); - - Transaction actual = new Deserializer().deserialize(fixture.get("serialized").toString()); - assertEquals(((Double) data.get("type")).intValue(), actual.type.getValue()); - assertEquals(((Double) data.get("amount")).longValue(), actual.amount); - assertEquals(((Double) data.get("fee")).longValue(), actual.fee); - assertEquals(((Double) data.get("timestamp")).intValue(), actual.timestamp); - assertEquals(data.get("senderPublicKey").toString(), actual.senderPublicKey); - assertEquals(data.get("signature").toString(), actual.signature); - assertEquals(data.get("signSignature").toString(), actual.signSignature); - - LinkedTreeMap asset = (LinkedTreeMap) ((LinkedTreeMap) data.get("asset")).get("delegate"); - assertEquals((asset.get("username")), actual.asset.delegate.username); - - assertEquals(data.get("id").toString(), actual.id); - } + // V1 tests + LinkedTreeMap fixtureV1 = + FixtureLoader.load("transactions/V1/delegate_registration/second-passphrase"); + LinkedTreeMap dataV1 = + (LinkedTreeMap) fixtureV1.get("data"); + + Transaction actualV1 = + new Deserializer().deserialize(fixtureV1.get("serialized").toString()); + assertEquals(((Double) dataV1.get("type")).intValue(), actualV1.type); + assertEquals(((Double) dataV1.get("amount")).longValue(), actualV1.amount); + assertEquals(((Double) dataV1.get("fee")).longValue(), actualV1.fee); + assertEquals(((Double) dataV1.get("timestamp")).intValue(), actualV1.timestamp); + assertEquals(dataV1.get("senderPublicKey").toString(), actualV1.senderPublicKey); + assertEquals(dataV1.get("signature").toString(), actualV1.signature); + assertEquals(dataV1.get("signSignature").toString(), actualV1.signSignature); + assertEquals(dataV1.get("id").toString(), actualV1.id); + + LinkedTreeMap assetV1 = + (LinkedTreeMap) + ((LinkedTreeMap) dataV1.get("asset")).get("delegate"); + assertEquals((assetV1.get("username")), actualV1.asset.delegate.username); + // V2 tests + LinkedTreeMap fixtureV2 = + FixtureLoader.load("transactions/v2-ecdsa/delegate-registration-secondSign"); + LinkedTreeMap dataV2 = + (LinkedTreeMap) fixtureV2.get("data"); + + Transaction actualV2 = + new Deserializer().deserialize(fixtureV2.get("serialized").toString()); + assertEquals(((Double) dataV2.get("type")).intValue(), actualV2.type); + assertEquals(TransactionTypeGroup.CORE.getValue(), actualV2.typeGroup); + assertEquals((Long.valueOf((String) dataV2.get("fee"))), actualV2.fee); + assertEquals((Long.valueOf((String) dataV2.get("nonce"))), actualV2.nonce); + assertEquals(dataV2.get("senderPublicKey").toString(), actualV2.senderPublicKey); + assertEquals(dataV2.get("signature").toString(), actualV2.signature); + assertEquals(dataV2.get("secondSignature").toString(), actualV2.signSignature); + assertEquals(dataV2.get("secondSignature").toString(), actualV2.secondSignature); + assertEquals(dataV2.get("id").toString(), actualV2.id); + + LinkedTreeMap assetV2 = + (LinkedTreeMap) + ((LinkedTreeMap) dataV2.get("asset")).get("delegate"); + assertEquals((assetV2.get("username")), actualV2.asset.delegate.username); + } } diff --git a/src/test/java/org/arkecosystem/crypto/transactions/deserializers/DelegateResignationTest.java b/src/test/java/org/arkecosystem/crypto/transactions/deserializers/DelegateResignationTest.java new file mode 100644 index 00000000..623631e1 --- /dev/null +++ b/src/test/java/org/arkecosystem/crypto/transactions/deserializers/DelegateResignationTest.java @@ -0,0 +1,52 @@ +package org.arkecosystem.crypto.transactions.deserializers; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + +import com.google.gson.internal.LinkedTreeMap; +import org.arkecosystem.crypto.enums.TransactionTypeGroup; +import org.arkecosystem.crypto.transactions.Deserializer; +import org.arkecosystem.crypto.transactions.FixtureLoader; +import org.arkecosystem.crypto.transactions.Transaction; +import org.junit.jupiter.api.Test; + +public class DelegateResignationTest { + + @Test + void passphrase() { + LinkedTreeMap fixture = + FixtureLoader.load("transactions/v2-ecdsa/delegate-resignation-sign"); + LinkedTreeMap data = (LinkedTreeMap) fixture.get("data"); + + Transaction actual = new Deserializer().deserialize(fixture.get("serialized").toString()); + assertEquals(((Double) data.get("type")).intValue(), actual.type); + assertEquals(TransactionTypeGroup.CORE.getValue(), actual.typeGroup); + assertEquals((Long.valueOf((String) data.get("fee"))), actual.fee); + assertEquals((Long.valueOf((String) data.get("nonce"))), actual.nonce); + assertEquals(data.get("senderPublicKey").toString(), actual.senderPublicKey); + assertEquals(data.get("signature").toString(), actual.signature); + assertEquals(data.get("id").toString(), actual.id); + + assertNull(data.get("asset")); + } + + @Test + void secondPassphrase() { + LinkedTreeMap fixture = + FixtureLoader.load("transactions/v2-ecdsa/delegate-resignation-secondSign"); + LinkedTreeMap data = (LinkedTreeMap) fixture.get("data"); + + Transaction actual = new Deserializer().deserialize(fixture.get("serialized").toString()); + assertEquals(((Double) data.get("type")).intValue(), actual.type); + assertEquals(TransactionTypeGroup.CORE.getValue(), actual.typeGroup); + assertEquals((Long.valueOf((String) data.get("fee"))), actual.fee); + assertEquals((Long.valueOf((String) data.get("nonce"))), actual.nonce); + assertEquals(data.get("senderPublicKey").toString(), actual.senderPublicKey); + assertEquals(data.get("signature").toString(), actual.signature); + assertEquals(data.get("secondSignature").toString(), actual.signSignature); + assertEquals(data.get("secondSignature").toString(), actual.secondSignature); + assertEquals(data.get("id").toString(), actual.id); + + assertNull(data.get("asset")); + } +} diff --git a/src/test/java/org/arkecosystem/crypto/transactions/deserializers/HtlcClaimTest.java b/src/test/java/org/arkecosystem/crypto/transactions/deserializers/HtlcClaimTest.java new file mode 100644 index 00000000..20b72a49 --- /dev/null +++ b/src/test/java/org/arkecosystem/crypto/transactions/deserializers/HtlcClaimTest.java @@ -0,0 +1,62 @@ +package org.arkecosystem.crypto.transactions.deserializers; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.google.gson.internal.LinkedTreeMap; +import org.arkecosystem.crypto.enums.TransactionTypeGroup; +import org.arkecosystem.crypto.transactions.Deserializer; +import org.arkecosystem.crypto.transactions.FixtureLoader; +import org.arkecosystem.crypto.transactions.Transaction; +import org.junit.jupiter.api.Test; + +public class HtlcClaimTest { + @Test + void passphrase() { + LinkedTreeMap fixture = + FixtureLoader.load("transactions/v2-ecdsa/htlc-claim-sign"); + LinkedTreeMap data = (LinkedTreeMap) fixture.get("data"); + + Transaction actual = new Deserializer().deserialize(fixture.get("serialized").toString()); + assertEquals(((Double) data.get("type")).intValue(), actual.type); + assertEquals(TransactionTypeGroup.CORE.getValue(), actual.typeGroup); + assertEquals((Long.valueOf((String) data.get("fee"))), actual.fee); + assertEquals((Long.valueOf((String) data.get("nonce"))), actual.nonce); + assertEquals(data.get("senderPublicKey").toString(), actual.senderPublicKey); + assertEquals(data.get("signature").toString(), actual.signature); + + LinkedTreeMap asset = + (LinkedTreeMap) + ((LinkedTreeMap) data.get("asset")).get("claim"); + assertEquals( + (asset.get("lockTransactionId")), actual.asset.htlcClaimAsset.lockTransactionId); + assertEquals((asset.get("unlockSecret")), actual.asset.htlcClaimAsset.unlockSecret); + + assertEquals(data.get("id").toString(), actual.id); + } + + @Test + void secondPassphrase() { + LinkedTreeMap fixture = + FixtureLoader.load("transactions/v2-ecdsa/htlc-claim-secondSign"); + LinkedTreeMap data = (LinkedTreeMap) fixture.get("data"); + + Transaction actual = new Deserializer().deserialize(fixture.get("serialized").toString()); + assertEquals(((Double) data.get("type")).intValue(), actual.type); + assertEquals(TransactionTypeGroup.CORE.getValue(), actual.typeGroup); + assertEquals((Long.valueOf((String) data.get("fee"))), actual.fee); + assertEquals((Long.valueOf((String) data.get("nonce"))), actual.nonce); + assertEquals(data.get("senderPublicKey").toString(), actual.senderPublicKey); + assertEquals(data.get("signature").toString(), actual.signature); + assertEquals(data.get("secondSignature").toString(), actual.signSignature); + assertEquals(data.get("secondSignature").toString(), actual.secondSignature); + + LinkedTreeMap asset = + (LinkedTreeMap) + ((LinkedTreeMap) data.get("asset")).get("claim"); + assertEquals( + (asset.get("lockTransactionId")), actual.asset.htlcClaimAsset.lockTransactionId); + assertEquals((asset.get("unlockSecret")), actual.asset.htlcClaimAsset.unlockSecret); + + assertEquals(data.get("id").toString(), actual.id); + } +} diff --git a/src/test/java/org/arkecosystem/crypto/transactions/deserializers/HtlcLockTest.java b/src/test/java/org/arkecosystem/crypto/transactions/deserializers/HtlcLockTest.java new file mode 100644 index 00000000..29b6a8be --- /dev/null +++ b/src/test/java/org/arkecosystem/crypto/transactions/deserializers/HtlcLockTest.java @@ -0,0 +1,76 @@ +package org.arkecosystem.crypto.transactions.deserializers; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.google.gson.internal.LinkedTreeMap; +import org.arkecosystem.crypto.enums.TransactionTypeGroup; +import org.arkecosystem.crypto.transactions.Deserializer; +import org.arkecosystem.crypto.transactions.FixtureLoader; +import org.arkecosystem.crypto.transactions.Transaction; +import org.junit.jupiter.api.Test; + +public class HtlcLockTest { + @Test + void passphrase() { + LinkedTreeMap fixture = + FixtureLoader.load("transactions/v2-ecdsa/htlc-lock-sign"); + LinkedTreeMap data = (LinkedTreeMap) fixture.get("data"); + + Transaction actual = new Deserializer().deserialize(fixture.get("serialized").toString()); + assertEquals(((Double) data.get("type")).intValue(), actual.type); + assertEquals(TransactionTypeGroup.CORE.getValue(), actual.typeGroup); + assertEquals((Long.valueOf((String) data.get("fee"))), actual.fee); + assertEquals((Long.valueOf((String) data.get("nonce"))), actual.nonce); + assertEquals(data.get("senderPublicKey").toString(), actual.senderPublicKey); + assertEquals(data.get("signature").toString(), actual.signature); + + LinkedTreeMap asset = + (LinkedTreeMap) + ((LinkedTreeMap) data.get("asset")).get("lock"); + assertEquals((asset.get("secretHash")), actual.asset.htlcLockAsset.secretHash); + LinkedTreeMap assetExpiration = + (LinkedTreeMap) + ((LinkedTreeMap) asset.get("expiration")); + assertEquals( + ((Double) assetExpiration.get("type")).intValue(), + actual.asset.htlcLockAsset.expiration.type.getValue()); + assertEquals( + ((Double) assetExpiration.get("value")).intValue(), + actual.asset.htlcLockAsset.expiration.value); + + assertEquals(data.get("id").toString(), actual.id); + } + + @Test + void secondPassphrase() { + LinkedTreeMap fixture = + FixtureLoader.load("transactions/v2-ecdsa/htlc-lock-secondSign"); + LinkedTreeMap data = (LinkedTreeMap) fixture.get("data"); + + Transaction actual = new Deserializer().deserialize(fixture.get("serialized").toString()); + assertEquals(((Double) data.get("type")).intValue(), actual.type); + assertEquals(TransactionTypeGroup.CORE.getValue(), actual.typeGroup); + assertEquals((Long.valueOf((String) data.get("fee"))), actual.fee); + assertEquals((Long.valueOf((String) data.get("nonce"))), actual.nonce); + assertEquals(data.get("senderPublicKey").toString(), actual.senderPublicKey); + assertEquals(data.get("signature").toString(), actual.signature); + assertEquals(data.get("secondSignature").toString(), actual.signSignature); + assertEquals(data.get("secondSignature").toString(), actual.secondSignature); + + LinkedTreeMap asset = + (LinkedTreeMap) + ((LinkedTreeMap) data.get("asset")).get("lock"); + assertEquals((asset.get("secretHash")), actual.asset.htlcLockAsset.secretHash); + LinkedTreeMap assetExpiration = + (LinkedTreeMap) + ((LinkedTreeMap) asset.get("expiration")); + assertEquals( + ((Double) assetExpiration.get("type")).intValue(), + actual.asset.htlcLockAsset.expiration.type.getValue()); + assertEquals( + ((Double) assetExpiration.get("value")).intValue(), + actual.asset.htlcLockAsset.expiration.value); + + assertEquals(data.get("id").toString(), actual.id); + } +} diff --git a/src/test/java/org/arkecosystem/crypto/transactions/deserializers/HtlcRefundTest.java b/src/test/java/org/arkecosystem/crypto/transactions/deserializers/HtlcRefundTest.java new file mode 100644 index 00000000..ab32b5bb --- /dev/null +++ b/src/test/java/org/arkecosystem/crypto/transactions/deserializers/HtlcRefundTest.java @@ -0,0 +1,61 @@ +package org.arkecosystem.crypto.transactions.deserializers; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.google.gson.internal.LinkedTreeMap; +import org.arkecosystem.crypto.enums.TransactionTypeGroup; +import org.arkecosystem.crypto.transactions.Deserializer; +import org.arkecosystem.crypto.transactions.FixtureLoader; +import org.arkecosystem.crypto.transactions.Transaction; +import org.junit.jupiter.api.Test; + +public class HtlcRefundTest { + + @Test + void passphrase() { + LinkedTreeMap fixture = + FixtureLoader.load("transactions/v2-ecdsa/htlc-refund-sign"); + LinkedTreeMap data = (LinkedTreeMap) fixture.get("data"); + + Transaction actual = new Deserializer().deserialize(fixture.get("serialized").toString()); + assertEquals(((Double) data.get("type")).intValue(), actual.type); + assertEquals(TransactionTypeGroup.CORE.getValue(), actual.typeGroup); + assertEquals((Long.valueOf((String) data.get("fee"))), actual.fee); + assertEquals((Long.valueOf((String) data.get("nonce"))), actual.nonce); + assertEquals(data.get("senderPublicKey").toString(), actual.senderPublicKey); + assertEquals(data.get("signature").toString(), actual.signature); + + LinkedTreeMap asset = + (LinkedTreeMap) + ((LinkedTreeMap) data.get("asset")).get("refund"); + assertEquals( + (asset.get("lockTransactionId")), actual.asset.htlcRefundAsset.lockTransactionId); + + assertEquals(data.get("id").toString(), actual.id); + } + + @Test + void secondPassphrase() { + LinkedTreeMap fixture = + FixtureLoader.load("transactions/v2-ecdsa/htlc-refund-secondSign"); + LinkedTreeMap data = (LinkedTreeMap) fixture.get("data"); + + Transaction actual = new Deserializer().deserialize(fixture.get("serialized").toString()); + assertEquals(((Double) data.get("type")).intValue(), actual.type); + assertEquals(TransactionTypeGroup.CORE.getValue(), actual.typeGroup); + assertEquals((Long.valueOf((String) data.get("fee"))), actual.fee); + assertEquals((Long.valueOf((String) data.get("nonce"))), actual.nonce); + assertEquals(data.get("senderPublicKey").toString(), actual.senderPublicKey); + assertEquals(data.get("signature").toString(), actual.signature); + assertEquals(data.get("secondSignature").toString(), actual.signSignature); + assertEquals(data.get("secondSignature").toString(), actual.secondSignature); + + LinkedTreeMap asset = + (LinkedTreeMap) + ((LinkedTreeMap) data.get("asset")).get("refund"); + assertEquals( + (asset.get("lockTransactionId")), actual.asset.htlcRefundAsset.lockTransactionId); + + assertEquals(data.get("id").toString(), actual.id); + } +} diff --git a/src/test/java/org/arkecosystem/crypto/transactions/deserializers/IpfsTest.java b/src/test/java/org/arkecosystem/crypto/transactions/deserializers/IpfsTest.java new file mode 100644 index 00000000..8cc64764 --- /dev/null +++ b/src/test/java/org/arkecosystem/crypto/transactions/deserializers/IpfsTest.java @@ -0,0 +1,53 @@ +package org.arkecosystem.crypto.transactions.deserializers; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.google.gson.internal.LinkedTreeMap; +import org.arkecosystem.crypto.enums.TransactionTypeGroup; +import org.arkecosystem.crypto.transactions.Deserializer; +import org.arkecosystem.crypto.transactions.FixtureLoader; +import org.arkecosystem.crypto.transactions.Transaction; +import org.junit.jupiter.api.Test; + +public class IpfsTest { + + @Test + void passphrase() { + LinkedTreeMap fixture = + FixtureLoader.load("transactions/v2-ecdsa/ipfs-sign"); + LinkedTreeMap data = (LinkedTreeMap) fixture.get("data"); + + Transaction actual = new Deserializer().deserialize(fixture.get("serialized").toString()); + assertEquals(((Double) data.get("type")).intValue(), actual.type); + assertEquals(TransactionTypeGroup.CORE.getValue(), actual.typeGroup); + assertEquals((Long.valueOf((String) data.get("fee"))), actual.fee); + assertEquals((Long.valueOf((String) data.get("nonce"))), actual.nonce); + assertEquals(data.get("senderPublicKey").toString(), actual.senderPublicKey); + assertEquals(data.get("signature").toString(), actual.signature); + assertEquals(data.get("id").toString(), actual.id); + + LinkedTreeMap asset = ((LinkedTreeMap) data.get("asset")); + assertEquals((asset.get("ipfs")), actual.asset.ipfs); + } + + @Test + void secondPassphrase() { + LinkedTreeMap fixture = + FixtureLoader.load("transactions/v2-ecdsa/ipfs-secondSign"); + LinkedTreeMap data = (LinkedTreeMap) fixture.get("data"); + + Transaction actual = new Deserializer().deserialize(fixture.get("serialized").toString()); + assertEquals(((Double) data.get("type")).intValue(), actual.type); + assertEquals(TransactionTypeGroup.CORE.getValue(), actual.typeGroup); + assertEquals((Long.valueOf((String) data.get("fee"))), actual.fee); + assertEquals((Long.valueOf((String) data.get("nonce"))), actual.nonce); + assertEquals(data.get("senderPublicKey").toString(), actual.senderPublicKey); + assertEquals(data.get("signature").toString(), actual.signature); + assertEquals(data.get("secondSignature").toString(), actual.signSignature); + assertEquals(data.get("secondSignature").toString(), actual.secondSignature); + assertEquals(data.get("id").toString(), actual.id); + + LinkedTreeMap asset = ((LinkedTreeMap) data.get("asset")); + assertEquals((asset.get("ipfs")), actual.asset.ipfs); + } +} diff --git a/src/test/java/org/arkecosystem/crypto/transactions/deserializers/MultiPaymentTest.java b/src/test/java/org/arkecosystem/crypto/transactions/deserializers/MultiPaymentTest.java new file mode 100644 index 00000000..28924e0f --- /dev/null +++ b/src/test/java/org/arkecosystem/crypto/transactions/deserializers/MultiPaymentTest.java @@ -0,0 +1,71 @@ +package org.arkecosystem.crypto.transactions.deserializers; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.google.gson.internal.LinkedTreeMap; +import java.util.ArrayList; +import org.arkecosystem.crypto.enums.TransactionTypeGroup; +import org.arkecosystem.crypto.transactions.Deserializer; +import org.arkecosystem.crypto.transactions.FixtureLoader; +import org.arkecosystem.crypto.transactions.Transaction; +import org.junit.jupiter.api.Test; + +public class MultiPaymentTest { + @Test + void passphrase() { + LinkedTreeMap fixture = + FixtureLoader.load("transactions/v2-ecdsa/multi-payment-sign"); + LinkedTreeMap data = (LinkedTreeMap) fixture.get("data"); + + Transaction actual = new Deserializer().deserialize(fixture.get("serialized").toString()); + assertEquals(((Double) data.get("type")).intValue(), actual.type); + assertEquals(TransactionTypeGroup.CORE.getValue(), actual.typeGroup); + assertEquals((Long.valueOf((String) data.get("fee"))), actual.fee); + assertEquals((Long.valueOf((String) data.get("nonce"))), actual.nonce); + assertEquals(data.get("senderPublicKey").toString(), actual.senderPublicKey); + assertEquals(data.get("signature").toString(), actual.signature); + assertEquals(data.get("id").toString(), actual.id); + + LinkedTreeMap asset = (LinkedTreeMap) data.get("asset"); + ArrayList payments = ((ArrayList) asset.get("payments")); + for (int i = 0; i < payments.size(); i++) { + String recipientId = + (String) ((LinkedTreeMap) payments.get(i)).get("recipientId"); + String amount = + ((String) ((LinkedTreeMap) payments.get(i)).get("amount")); + assertEquals(recipientId, actual.asset.multiPayment.payments.get(i).recipientId); + assertEquals(Long.valueOf(amount), actual.asset.multiPayment.payments.get(i).amount); + } + } + + @Test + void secondPassphrase() { + LinkedTreeMap fixture = + FixtureLoader.load("transactions/v2-ecdsa/multi-payment-secondSign"); + LinkedTreeMap data = (LinkedTreeMap) fixture.get("data"); + + Transaction actual = new Deserializer().deserialize(fixture.get("serialized").toString()); + assertEquals(((Double) data.get("type")).intValue(), actual.type); + assertEquals(TransactionTypeGroup.CORE.getValue(), actual.typeGroup); + assertEquals((Long.valueOf((String) data.get("fee"))), actual.fee); + assertEquals((Long.valueOf((String) data.get("nonce"))), actual.nonce); + assertEquals(data.get("senderPublicKey").toString(), actual.senderPublicKey); + assertEquals(data.get("signature").toString(), actual.signature); + assertEquals(data.get("secondSignature").toString(), actual.signSignature); + assertEquals(data.get("secondSignature").toString(), actual.secondSignature); + assertEquals(data.get("id").toString(), actual.id); + + LinkedTreeMap asset = (LinkedTreeMap) data.get("asset"); + ArrayList payments = ((ArrayList) asset.get("payments")); + for (int i = 0; i < payments.size(); i++) { + String recipientId = + (String) ((LinkedTreeMap) payments.get(i)).get("recipientId"); + String amount = + ((String) ((LinkedTreeMap) payments.get(i)).get("amount")); + assertEquals(recipientId, actual.asset.multiPayment.payments.get(i).recipientId); + assertEquals(Long.valueOf(amount), actual.asset.multiPayment.payments.get(i).amount); + } + + assertEquals(data.get("id").toString(), actual.id); + } +} diff --git a/src/test/java/org/arkecosystem/crypto/transactions/deserializers/MultiSignatureRegistrationTest.java b/src/test/java/org/arkecosystem/crypto/transactions/deserializers/MultiSignatureRegistrationTest.java index 9100772c..2da0eb02 100644 --- a/src/test/java/org/arkecosystem/crypto/transactions/deserializers/MultiSignatureRegistrationTest.java +++ b/src/test/java/org/arkecosystem/crypto/transactions/deserializers/MultiSignatureRegistrationTest.java @@ -1,22 +1,23 @@ package org.arkecosystem.crypto.transactions.deserializers; +import static org.junit.jupiter.api.Assertions.assertEquals; + import com.google.gson.internal.LinkedTreeMap; import org.arkecosystem.crypto.transactions.Deserializer; import org.arkecosystem.crypto.transactions.FixtureLoader; import org.arkecosystem.crypto.transactions.Transaction; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; - class MultiSignatureRegistrationTest { @Test void passphrase() { - LinkedTreeMap fixture = FixtureLoader.load("transactions/multi_signature_registration/passphrase"); + LinkedTreeMap fixture = + FixtureLoader.load("transactions/V1/multi_signature_registration/passphrase"); LinkedTreeMap data = (LinkedTreeMap) fixture.get("data"); Transaction actual = new Deserializer().deserialize(fixture.get("serialized").toString()); - assertEquals(((Double) data.get("type")).intValue(), actual.type.getValue()); + assertEquals(((Double) data.get("type")).intValue(), actual.type); assertEquals(((Double) data.get("amount")).longValue(), actual.amount); assertEquals(((Double) data.get("fee")).longValue(), actual.fee); assertEquals(((Double) data.get("timestamp")).intValue(), actual.timestamp); @@ -24,12 +25,14 @@ void passphrase() { assertEquals(data.get("signature").toString(), actual.signature); assertEquals(data.get("signatures"), actual.signatures); - LinkedTreeMap asset = (LinkedTreeMap) ((LinkedTreeMap) data.get("asset")).get("multisignature"); + LinkedTreeMap asset = + (LinkedTreeMap) + ((LinkedTreeMap) data.get("asset")).get("multisignature"); assertEquals(((Double) asset.get("min")).intValue(), actual.asset.multisignature.min); - assertEquals(((Double) asset.get("lifetime")).intValue(), actual.asset.multisignature.lifetime); + assertEquals( + ((Double) asset.get("lifetime")).intValue(), actual.asset.multisignature.lifetime); assertEquals((asset.get("keysgroup")), actual.asset.multisignature.keysgroup); assertEquals(data.get("id").toString(), actual.id); } - } diff --git a/src/test/java/org/arkecosystem/crypto/transactions/deserializers/SecondSignatureRegistrationTest.java b/src/test/java/org/arkecosystem/crypto/transactions/deserializers/SecondSignatureRegistrationTest.java index 894696be..628e4fc0 100644 --- a/src/test/java/org/arkecosystem/crypto/transactions/deserializers/SecondSignatureRegistrationTest.java +++ b/src/test/java/org/arkecosystem/crypto/transactions/deserializers/SecondSignatureRegistrationTest.java @@ -1,32 +1,39 @@ package org.arkecosystem.crypto.transactions.deserializers; +import static org.junit.jupiter.api.Assertions.assertEquals; + import com.google.gson.internal.LinkedTreeMap; +import org.arkecosystem.crypto.enums.TransactionTypeGroup; import org.arkecosystem.crypto.transactions.Deserializer; import org.arkecosystem.crypto.transactions.FixtureLoader; import org.arkecosystem.crypto.transactions.Transaction; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; - class SecondSignatureRegistrationTest { @Test void passphrase() { - LinkedTreeMap fixture = FixtureLoader.load("transactions/second_signature_registration/second-passphrase"); - LinkedTreeMap data = (LinkedTreeMap) fixture.get("data"); - - Transaction actual = new Deserializer().deserialize(fixture.get("serialized").toString()); - assertEquals(((Double) data.get("type")).intValue(), actual.type.getValue()); - assertEquals(((Double) data.get("amount")).longValue(), actual.amount); - assertEquals(((Double) data.get("fee")).longValue(), actual.fee); - assertEquals(((Double) data.get("timestamp")).intValue(), actual.timestamp); - assertEquals(data.get("senderPublicKey").toString(), actual.senderPublicKey); - assertEquals(data.get("signature").toString(), actual.signature); - - LinkedTreeMap asset = (LinkedTreeMap) ((LinkedTreeMap) data.get("asset")).get("signature"); - assertEquals((asset.get("publicKey")), actual.asset.signature.publicKey); - - assertEquals(data.get("id").toString(), actual.id); + LinkedTreeMap fixtureV2 = + FixtureLoader.load("transactions/v2-ecdsa/second-signature-registration"); + LinkedTreeMap dataV2 = + (LinkedTreeMap) fixtureV2.get("data"); + + Transaction actualV2 = + new Deserializer().deserialize(fixtureV2.get("serialized").toString()); + + assertEquals(((Double) dataV2.get("type")).intValue(), actualV2.type); + assertEquals(TransactionTypeGroup.CORE.getValue(), actualV2.typeGroup); + assertEquals((Long.valueOf((String) dataV2.get("fee"))), actualV2.fee); + assertEquals((Long.valueOf((String) dataV2.get("nonce"))), actualV2.nonce); + assertEquals(dataV2.get("senderPublicKey").toString(), actualV2.senderPublicKey); + assertEquals(dataV2.get("signature").toString(), actualV2.signature); + assertEquals(dataV2.get("id").toString(), actualV2.id); + + LinkedTreeMap assetV2 = + (LinkedTreeMap) + ((LinkedTreeMap) dataV2.get("asset")).get("signature"); + assertEquals((assetV2.get("publicKey")), actualV2.asset.signature.publicKey); + + assertEquals(dataV2.get("id").toString(), actualV2.id); } - } diff --git a/src/test/java/org/arkecosystem/crypto/transactions/deserializers/TransferTest.java b/src/test/java/org/arkecosystem/crypto/transactions/deserializers/TransferTest.java index 117a09ee..724eca2b 100644 --- a/src/test/java/org/arkecosystem/crypto/transactions/deserializers/TransferTest.java +++ b/src/test/java/org/arkecosystem/crypto/transactions/deserializers/TransferTest.java @@ -1,116 +1,179 @@ package org.arkecosystem.crypto.transactions.deserializers; +import static org.junit.jupiter.api.Assertions.assertEquals; + import com.google.gson.internal.LinkedTreeMap; +import org.arkecosystem.crypto.enums.TransactionTypeGroup; import org.arkecosystem.crypto.transactions.Deserializer; import org.arkecosystem.crypto.transactions.FixtureLoader; import org.arkecosystem.crypto.transactions.Transaction; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; - class TransferTest { @Test void passphrase() { - LinkedTreeMap fixture = FixtureLoader.load("transactions/transfer/passphrase"); - LinkedTreeMap data = (LinkedTreeMap) fixture.get("data"); - - Transaction actual = new Deserializer().deserialize(fixture.get("serialized").toString()); - assertEquals(((Double) data.get("type")).intValue(), actual.type.getValue()); - assertEquals(((Double) data.get("amount")).longValue(), actual.amount); - assertEquals(((Double) data.get("fee")).longValue(), actual.fee); - assertEquals(data.get("recipientId").toString(), actual.recipientId); - assertEquals(((Double) data.get("timestamp")).intValue(), actual.timestamp); - assertEquals(data.get("senderPublicKey").toString(), actual.senderPublicKey); - assertEquals(data.get("signature").toString(), actual.signature); - assertEquals(data.get("id").toString(), actual.id); + // V1 tests + LinkedTreeMap fixtureV1 = + FixtureLoader.load("transactions/V1/transfer/passphrase"); + LinkedTreeMap dataV1 = + (LinkedTreeMap) fixtureV1.get("data"); + + Transaction actualV1 = + new Deserializer().deserialize(fixtureV1.get("serialized").toString()); + assertEquals(((Double) dataV1.get("type")).intValue(), actualV1.type); + assertEquals(((Double) dataV1.get("amount")).longValue(), actualV1.amount); + assertEquals(((Double) dataV1.get("fee")).longValue(), actualV1.fee); + assertEquals(dataV1.get("recipientId").toString(), actualV1.recipientId); + assertEquals(((Double) dataV1.get("timestamp")).intValue(), actualV1.timestamp); + assertEquals(dataV1.get("senderPublicKey").toString(), actualV1.senderPublicKey); + assertEquals(dataV1.get("signature").toString(), actualV1.signature); + assertEquals(dataV1.get("id").toString(), actualV1.id); + + // V2 tests + LinkedTreeMap fixtureV2 = + FixtureLoader.load("transactions/v2-ecdsa/transfer-sign"); + LinkedTreeMap dataV2 = + (LinkedTreeMap) fixtureV2.get("data"); + + Transaction actualV2 = + new Deserializer().deserialize(fixtureV2.get("serialized").toString()); + assertEquals(((Double) dataV2.get("type")).intValue(), actualV2.type); + assertEquals(TransactionTypeGroup.CORE.getValue(), actualV2.typeGroup); + assertEquals((Long.valueOf((String) dataV2.get("fee"))), actualV2.fee); + assertEquals(dataV2.get("recipientId").toString(), actualV2.recipientId); + assertEquals((Long.valueOf((String) dataV2.get("nonce"))), actualV2.nonce); + assertEquals(dataV2.get("senderPublicKey").toString(), actualV2.senderPublicKey); + assertEquals(dataV2.get("signature").toString(), actualV2.signature); + assertEquals(dataV2.get("id").toString(), actualV2.id); + + assertEquals((Long.valueOf((String) dataV2.get("amount"))), actualV2.amount); } @Test void passphraseVendorField() { - LinkedTreeMap fixture = FixtureLoader.load("transactions/transfer/passphrase-with-vendor-field"); - LinkedTreeMap data = (LinkedTreeMap) fixture.get("data"); - - Transaction actual = new Deserializer().deserialize(fixture.get("serialized").toString()); - assertEquals(((Double) data.get("type")).intValue(), actual.type.getValue()); - assertEquals(((Double) data.get("amount")).longValue(), actual.amount); - assertEquals(((Double) data.get("fee")).longValue(), actual.fee); - assertEquals(data.get("recipientId").toString(), actual.recipientId); - assertEquals(((Double) data.get("timestamp")).intValue(), actual.timestamp); - assertEquals(data.get("senderPublicKey").toString(), actual.senderPublicKey); - assertEquals(data.get("vendorField").toString(), actual.vendorField); - assertEquals(data.get("signature").toString(), actual.signature); - assertEquals(data.get("id").toString(), actual.id); - } - - @Test - void passphraseVendorFieldHex() { - LinkedTreeMap fixture = FixtureLoader.load("transactions/transfer/passphrase-with-vendor-field-hex"); - LinkedTreeMap data = (LinkedTreeMap) fixture.get("data"); - - Transaction actual = new Deserializer().deserialize(fixture.get("serialized").toString()); - assertEquals(((Double) data.get("type")).intValue(), actual.type.getValue()); - assertEquals(((Double) data.get("amount")).longValue(), actual.amount); - assertEquals(((Double) data.get("fee")).longValue(), actual.fee); - assertEquals(data.get("recipientId").toString(), actual.recipientId); - assertEquals(((Double) data.get("timestamp")).intValue(), actual.timestamp); - assertEquals(data.get("senderPublicKey").toString(), actual.senderPublicKey); - assertEquals(data.get("vendorFieldHex").toString(), actual.vendorFieldHex); - assertEquals(data.get("signature").toString(), actual.signature); - assertEquals(data.get("id").toString(), actual.id); + // V1 tests + LinkedTreeMap fixtureV1 = + FixtureLoader.load("transactions/V1/transfer/passphrase-with-vendor-field"); + LinkedTreeMap dataV1 = + (LinkedTreeMap) fixtureV1.get("data"); + + Transaction actualV1 = + new Deserializer().deserialize(fixtureV1.get("serialized").toString()); + assertEquals(((Double) dataV1.get("type")).intValue(), actualV1.type); + assertEquals(((Double) dataV1.get("amount")).longValue(), actualV1.amount); + assertEquals(((Double) dataV1.get("fee")).longValue(), actualV1.fee); + assertEquals(dataV1.get("recipientId").toString(), actualV1.recipientId); + assertEquals(((Double) dataV1.get("timestamp")).intValue(), actualV1.timestamp); + assertEquals(dataV1.get("senderPublicKey").toString(), actualV1.senderPublicKey); + assertEquals(dataV1.get("vendorField").toString(), actualV1.vendorField); + assertEquals(dataV1.get("signature").toString(), actualV1.signature); + assertEquals(dataV1.get("id").toString(), actualV1.id); + + // V2 tests + LinkedTreeMap fixtureV2 = + FixtureLoader.load("transactions/v2-ecdsa/transfer-with-vendor-field-sign"); + LinkedTreeMap dataV2 = + (LinkedTreeMap) fixtureV2.get("data"); + + Transaction actualV2 = + new Deserializer().deserialize(fixtureV2.get("serialized").toString()); + assertEquals(((Double) dataV2.get("type")).intValue(), actualV2.type); + assertEquals(TransactionTypeGroup.CORE.getValue(), actualV2.typeGroup); + assertEquals((Long.valueOf((String) dataV2.get("fee"))), actualV2.fee); + assertEquals(dataV2.get("recipientId").toString(), actualV2.recipientId); + assertEquals((Long.valueOf((String) dataV2.get("nonce"))), actualV2.nonce); + assertEquals(dataV2.get("senderPublicKey").toString(), actualV2.senderPublicKey); + assertEquals(dataV2.get("signature").toString(), actualV2.signature); + assertEquals(dataV2.get("id").toString(), actualV2.id); + + assertEquals((Long.valueOf((String) dataV2.get("amount"))), actualV2.amount); + assertEquals(dataV2.get("vendorField").toString(), actualV2.vendorField); } @Test void secondPassphrase() { - LinkedTreeMap fixture = FixtureLoader.load("transactions/transfer/second-passphrase"); - LinkedTreeMap data = (LinkedTreeMap) fixture.get("data"); - - Transaction actual = new Deserializer().deserialize(fixture.get("serialized").toString()); - assertEquals(((Double) data.get("type")).intValue(), actual.type.getValue()); - assertEquals(((Double) data.get("amount")).longValue(), actual.amount); - assertEquals(((Double) data.get("fee")).longValue(), actual.fee); - assertEquals(data.get("recipientId").toString(), actual.recipientId); - assertEquals(((Double) data.get("timestamp")).intValue(), actual.timestamp); - assertEquals(data.get("senderPublicKey").toString(), actual.senderPublicKey); - assertEquals(data.get("signature").toString(), actual.signature); - assertEquals(data.get("signSignature").toString(), actual.signSignature); - assertEquals(data.get("id").toString(), actual.id); + // V1 tests + LinkedTreeMap fixtureV1 = + FixtureLoader.load("transactions/V1/transfer/second-passphrase"); + LinkedTreeMap dataV1 = + (LinkedTreeMap) fixtureV1.get("data"); + + Transaction actualV1 = + new Deserializer().deserialize(fixtureV1.get("serialized").toString()); + assertEquals(((Double) dataV1.get("type")).intValue(), actualV1.type); + assertEquals(((Double) dataV1.get("amount")).longValue(), actualV1.amount); + assertEquals(((Double) dataV1.get("fee")).longValue(), actualV1.fee); + assertEquals(dataV1.get("recipientId").toString(), actualV1.recipientId); + assertEquals(((Double) dataV1.get("timestamp")).intValue(), actualV1.timestamp); + assertEquals(dataV1.get("senderPublicKey").toString(), actualV1.senderPublicKey); + assertEquals(dataV1.get("signature").toString(), actualV1.signature); + assertEquals(dataV1.get("signSignature").toString(), actualV1.signSignature); + assertEquals(dataV1.get("id").toString(), actualV1.id); + + // V2 tests + LinkedTreeMap fixtureV2 = + FixtureLoader.load("transactions/v2-ecdsa/transfer-with-vendor-field-secondSign"); + LinkedTreeMap dataV2 = + (LinkedTreeMap) fixtureV2.get("data"); + + Transaction actualV2 = + new Deserializer().deserialize(fixtureV2.get("serialized").toString()); + assertEquals(((Double) dataV2.get("type")).intValue(), actualV2.type); + assertEquals(TransactionTypeGroup.CORE.getValue(), actualV2.typeGroup); + assertEquals((Long.valueOf((String) dataV2.get("fee"))), actualV2.fee); + assertEquals(dataV2.get("recipientId").toString(), actualV2.recipientId); + assertEquals((Long.valueOf((String) dataV2.get("nonce"))), actualV2.nonce); + assertEquals(dataV2.get("senderPublicKey").toString(), actualV2.senderPublicKey); + assertEquals(dataV2.get("signature").toString(), actualV2.signature); + assertEquals(dataV2.get("id").toString(), actualV2.id); + + assertEquals((Long.valueOf((String) dataV2.get("amount"))), actualV2.amount); + assertEquals(dataV2.get("secondSignature").toString(), actualV2.signSignature); + assertEquals(dataV2.get("secondSignature").toString(), actualV2.secondSignature); } @Test void secondPassphraseVendorField() { - LinkedTreeMap fixture = FixtureLoader.load("transactions/transfer/second-passphrase-with-vendor-field"); - LinkedTreeMap data = (LinkedTreeMap) fixture.get("data"); - - Transaction actual = new Deserializer().deserialize(fixture.get("serialized").toString()); - assertEquals(((Double) data.get("type")).intValue(), actual.type.getValue()); - assertEquals(((Double) data.get("amount")).longValue(), actual.amount); - assertEquals(((Double) data.get("fee")).longValue(), actual.fee); - assertEquals(data.get("recipientId").toString(), actual.recipientId); - assertEquals(((Double) data.get("timestamp")).intValue(), actual.timestamp); - assertEquals(data.get("senderPublicKey").toString(), actual.senderPublicKey); - assertEquals(data.get("vendorField").toString(), actual.vendorField); - assertEquals(data.get("signature").toString(), actual.signature); - assertEquals(data.get("signSignature").toString(), actual.signSignature); - assertEquals(data.get("id").toString(), actual.id); + // V1 tests + LinkedTreeMap fixtureV1 = + FixtureLoader.load("transactions/V1/transfer/second-passphrase-with-vendor-field"); + LinkedTreeMap dataV1 = + (LinkedTreeMap) fixtureV1.get("data"); + + Transaction actualV1 = + new Deserializer().deserialize(fixtureV1.get("serialized").toString()); + assertEquals(((Double) dataV1.get("type")).intValue(), actualV1.type); + assertEquals(((Double) dataV1.get("amount")).longValue(), actualV1.amount); + assertEquals(((Double) dataV1.get("fee")).longValue(), actualV1.fee); + assertEquals(dataV1.get("recipientId").toString(), actualV1.recipientId); + assertEquals(((Double) dataV1.get("timestamp")).intValue(), actualV1.timestamp); + assertEquals(dataV1.get("senderPublicKey").toString(), actualV1.senderPublicKey); + assertEquals(dataV1.get("vendorField").toString(), actualV1.vendorField); + assertEquals(dataV1.get("signature").toString(), actualV1.signature); + assertEquals(dataV1.get("signSignature").toString(), actualV1.signSignature); + assertEquals(dataV1.get("id").toString(), actualV1.id); + + // V2 tests + LinkedTreeMap fixtureV2 = + FixtureLoader.load("transactions/v2-ecdsa/transfer-with-vendor-field-secondSign"); + LinkedTreeMap dataV2 = + (LinkedTreeMap) fixtureV2.get("data"); + + Transaction actualV2 = + new Deserializer().deserialize(fixtureV2.get("serialized").toString()); + assertEquals(((Double) dataV2.get("type")).intValue(), actualV2.type); + assertEquals(TransactionTypeGroup.CORE.getValue(), actualV2.typeGroup); + assertEquals((Long.valueOf((String) dataV2.get("fee"))), actualV2.fee); + assertEquals(dataV2.get("recipientId").toString(), actualV2.recipientId); + assertEquals((Long.valueOf((String) dataV2.get("nonce"))), actualV2.nonce); + assertEquals(dataV2.get("senderPublicKey").toString(), actualV2.senderPublicKey); + assertEquals(dataV2.get("signature").toString(), actualV2.signature); + assertEquals(dataV2.get("id").toString(), actualV2.id); + + assertEquals((Long.valueOf((String) dataV2.get("amount"))), actualV2.amount); + assertEquals(dataV2.get("secondSignature").toString(), actualV2.signSignature); + assertEquals(dataV2.get("secondSignature").toString(), actualV2.secondSignature); + assertEquals(dataV2.get("vendorField").toString(), actualV2.vendorField); } - - @Test - void secondPassphraseVendorFieldHex() { - LinkedTreeMap fixture = FixtureLoader.load("transactions/transfer/second-passphrase-with-vendor-field-hex"); - LinkedTreeMap data = (LinkedTreeMap) fixture.get("data"); - - Transaction actual = new Deserializer().deserialize(fixture.get("serialized").toString()); - assertEquals(((Double) data.get("type")).intValue(), actual.type.getValue()); - assertEquals(((Double) data.get("amount")).longValue(), actual.amount); - assertEquals(((Double) data.get("fee")).longValue(), actual.fee); - assertEquals(data.get("recipientId").toString(), actual.recipientId); - assertEquals(((Double) data.get("timestamp")).intValue(), actual.timestamp); - assertEquals(data.get("senderPublicKey").toString(), actual.senderPublicKey); - assertEquals(data.get("vendorFieldHex").toString(), actual.vendorFieldHex); - assertEquals(data.get("signature").toString(), actual.signature); - assertEquals(data.get("signSignature").toString(), actual.signSignature); - assertEquals(data.get("id").toString(), actual.id); - } - } diff --git a/src/test/java/org/arkecosystem/crypto/transactions/deserializers/VoteTest.java b/src/test/java/org/arkecosystem/crypto/transactions/deserializers/VoteTest.java index b90fe2ce..d3dfa977 100644 --- a/src/test/java/org/arkecosystem/crypto/transactions/deserializers/VoteTest.java +++ b/src/test/java/org/arkecosystem/crypto/transactions/deserializers/VoteTest.java @@ -1,54 +1,107 @@ package org.arkecosystem.crypto.transactions.deserializers; +import static org.junit.jupiter.api.Assertions.assertEquals; + import com.google.gson.internal.LinkedTreeMap; +import org.arkecosystem.crypto.enums.TransactionTypeGroup; import org.arkecosystem.crypto.transactions.Deserializer; import org.arkecosystem.crypto.transactions.FixtureLoader; import org.arkecosystem.crypto.transactions.Transaction; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; - class VoteTest { @Test void passphrase() { - LinkedTreeMap fixture = FixtureLoader.load("transactions/vote/passphrase"); - LinkedTreeMap data = (LinkedTreeMap) fixture.get("data"); - - Transaction actual = new Deserializer().deserialize(fixture.get("serialized").toString()); - assertEquals(((Double) data.get("type")).intValue(), actual.type.getValue()); - assertEquals(((Double) data.get("amount")).longValue(), actual.amount); - assertEquals(((Double) data.get("fee")).longValue(), actual.fee); - assertEquals(data.get("recipientId").toString(), actual.recipientId); - assertEquals(((Double) data.get("timestamp")).intValue(), actual.timestamp); - assertEquals(data.get("senderPublicKey").toString(), actual.senderPublicKey); - assertEquals(data.get("signature").toString(), actual.signature); - - LinkedTreeMap asset = (LinkedTreeMap) data.get("asset"); - assertEquals((asset.get("votes")), actual.asset.votes); - - assertEquals(data.get("id").toString(), actual.id); + // V1 tests + LinkedTreeMap fixtureV1 = + FixtureLoader.load("transactions/V1/vote/passphrase"); + LinkedTreeMap dataV1 = + (LinkedTreeMap) fixtureV1.get("data"); + + Transaction actualV1 = + new Deserializer().deserialize(fixtureV1.get("serialized").toString()); + assertEquals(((Double) dataV1.get("type")).intValue(), actualV1.type); + assertEquals(((Double) dataV1.get("amount")).longValue(), actualV1.amount); + assertEquals(((Double) dataV1.get("fee")).longValue(), actualV1.fee); + assertEquals(dataV1.get("recipientId").toString(), actualV1.recipientId); + assertEquals(((Double) dataV1.get("timestamp")).intValue(), actualV1.timestamp); + assertEquals(dataV1.get("senderPublicKey").toString(), actualV1.senderPublicKey); + assertEquals(dataV1.get("signature").toString(), actualV1.signature); + + LinkedTreeMap assetV1 = (LinkedTreeMap) dataV1.get("asset"); + assertEquals((assetV1.get("votes")), actualV1.asset.votes); + + assertEquals(dataV1.get("id").toString(), actualV1.id); + + // V2 tests + LinkedTreeMap fixtureV2 = + FixtureLoader.load("transactions/v2-ecdsa/vote-sign"); + LinkedTreeMap dataV2 = + (LinkedTreeMap) fixtureV2.get("data"); + + Transaction actualV2 = + new Deserializer().deserialize(fixtureV2.get("serialized").toString()); + assertEquals(((Double) dataV2.get("type")).intValue(), actualV2.type); + assertEquals(TransactionTypeGroup.CORE.getValue(), actualV2.typeGroup); + assertEquals((Long.valueOf((String) dataV2.get("fee"))), actualV2.fee); + assertEquals((Long.valueOf((String) dataV2.get("nonce"))), actualV2.nonce); + assertEquals(dataV2.get("senderPublicKey").toString(), actualV2.senderPublicKey); + assertEquals(dataV2.get("signature").toString(), actualV2.signature); + assertEquals(dataV2.get("id").toString(), actualV2.id); + + LinkedTreeMap assetV2 = (LinkedTreeMap) dataV2.get("asset"); + assertEquals((assetV2.get("votes")), actualV2.asset.votes); + + assertEquals(dataV2.get("id").toString(), actualV2.id); } @Test void secondPassphrase() { - LinkedTreeMap fixture = FixtureLoader.load("transactions/vote/second-passphrase"); - LinkedTreeMap data = (LinkedTreeMap) fixture.get("data"); - - Transaction actual = new Deserializer().deserialize(fixture.get("serialized").toString()); - assertEquals(((Double) data.get("type")).intValue(), actual.type.getValue()); - assertEquals(((Double) data.get("amount")).longValue(), actual.amount); - assertEquals(((Double) data.get("fee")).longValue(), actual.fee); - assertEquals(data.get("recipientId").toString(), actual.recipientId); - assertEquals(((Double) data.get("timestamp")).intValue(), actual.timestamp); - assertEquals(data.get("senderPublicKey").toString(), actual.senderPublicKey); - assertEquals(data.get("signature").toString(), actual.signature); - assertEquals(data.get("signSignature").toString(), actual.signSignature); - - LinkedTreeMap asset = (LinkedTreeMap) data.get("asset"); - assertEquals((asset.get("votes")), actual.asset.votes); - - assertEquals(data.get("id").toString(), actual.id); - } + // V1 tests + LinkedTreeMap fixtureV1 = + FixtureLoader.load("transactions/V1/vote/second-passphrase"); + LinkedTreeMap dataV1 = + (LinkedTreeMap) fixtureV1.get("data"); + + Transaction actualV1 = + new Deserializer().deserialize(fixtureV1.get("serialized").toString()); + assertEquals(((Double) dataV1.get("type")).intValue(), actualV1.type); + assertEquals(((Double) dataV1.get("amount")).longValue(), actualV1.amount); + assertEquals(((Double) dataV1.get("fee")).longValue(), actualV1.fee); + assertEquals(dataV1.get("recipientId").toString(), actualV1.recipientId); + assertEquals(((Double) dataV1.get("timestamp")).intValue(), actualV1.timestamp); + assertEquals(dataV1.get("senderPublicKey").toString(), actualV1.senderPublicKey); + assertEquals(dataV1.get("signature").toString(), actualV1.signature); + assertEquals(dataV1.get("signSignature").toString(), actualV1.signSignature); + + LinkedTreeMap assetV1 = (LinkedTreeMap) dataV1.get("asset"); + assertEquals((assetV1.get("votes")), actualV1.asset.votes); + + assertEquals(dataV1.get("id").toString(), actualV1.id); + // V2 tests + LinkedTreeMap fixtureV2 = + FixtureLoader.load("transactions/v2-ecdsa/vote-secondSign"); + LinkedTreeMap dataV2 = + (LinkedTreeMap) fixtureV2.get("data"); + + Transaction actualV2 = + new Deserializer().deserialize(fixtureV2.get("serialized").toString()); + assertEquals(((Double) dataV2.get("type")).intValue(), actualV2.type); + assertEquals(TransactionTypeGroup.CORE.getValue(), actualV2.typeGroup); + assertEquals((Long.valueOf((String) dataV2.get("fee"))), actualV2.fee); + assertEquals((Long.valueOf((String) dataV2.get("nonce"))), actualV2.nonce); + assertEquals(dataV2.get("senderPublicKey").toString(), actualV2.senderPublicKey); + assertEquals(dataV2.get("signature").toString(), actualV2.signature); + assertEquals(dataV2.get("id").toString(), actualV2.id); + assertEquals((Long.valueOf((String) dataV2.get("amount"))), actualV2.amount); + assertEquals(dataV2.get("secondSignature").toString(), actualV2.signSignature); + assertEquals(dataV2.get("secondSignature").toString(), actualV2.secondSignature); + + LinkedTreeMap assetV2 = (LinkedTreeMap) dataV2.get("asset"); + assertEquals((assetV2.get("votes")), actualV2.asset.votes); + + assertEquals(dataV2.get("id").toString(), actualV2.id); + } } diff --git a/src/test/java/org/arkecosystem/crypto/transactions/serializers/DelegateRegistrationTest.java b/src/test/java/org/arkecosystem/crypto/transactions/serializers/DelegateRegistrationTest.java index fa72fdb2..1b9e7605 100644 --- a/src/test/java/org/arkecosystem/crypto/transactions/serializers/DelegateRegistrationTest.java +++ b/src/test/java/org/arkecosystem/crypto/transactions/serializers/DelegateRegistrationTest.java @@ -1,5 +1,7 @@ package org.arkecosystem.crypto.transactions.serializers; +import static org.junit.jupiter.api.Assertions.assertEquals; + import com.google.gson.internal.LinkedTreeMap; import org.arkecosystem.crypto.encoding.Hex; import org.arkecosystem.crypto.transactions.Deserializer; @@ -8,28 +10,51 @@ import org.arkecosystem.crypto.transactions.Transaction; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; - class DelegateRegistrationTest { @Test void passphrase() { - LinkedTreeMap fixture = FixtureLoader.load("transactions/delegate_registration/passphrase"); + // V1 tests + LinkedTreeMap fixtureV1 = + FixtureLoader.load("transactions/V1/delegate_registration/passphrase"); + + Transaction transactionV1 = + new Deserializer().deserialize(fixtureV1.get("serialized").toString()); + String actualV1 = Hex.encode(new Serializer().serialize(transactionV1)); + + assertEquals(fixtureV1.get("serialized").toString(), actualV1); - Transaction transaction = new Deserializer().deserialize(fixture.get("serialized").toString()); - String actual = Hex.encode(new Serializer().serialize(transaction)); + // V2 tests + LinkedTreeMap fixtureV2 = + FixtureLoader.load("transactions/v2-ecdsa/delegate-registration-sign"); - assertEquals(fixture.get("serialized").toString(), actual); + Transaction transactionV2 = + new Deserializer().deserialize(fixtureV2.get("serialized").toString()); + String actualV2 = Hex.encode(new Serializer().serialize(transactionV2)); + + assertEquals(fixtureV2.get("serialized").toString(), actualV2); } @Test void secondPassphrase() { - LinkedTreeMap fixture = FixtureLoader.load("transactions/delegate_registration/second-passphrase"); + // V1 tests + LinkedTreeMap fixtureV1 = + FixtureLoader.load("transactions/V1/delegate_registration/second-passphrase"); - Transaction transaction = new Deserializer().deserialize(fixture.get("serialized").toString()); - String actual = Hex.encode(new Serializer().serialize(transaction)); + Transaction transactionV1 = + new Deserializer().deserialize(fixtureV1.get("serialized").toString()); + String actualV1 = Hex.encode(new Serializer().serialize(transactionV1)); - assertEquals(fixture.get("serialized").toString(), actual); - } + assertEquals(fixtureV1.get("serialized").toString(), actualV1); + + // V2 tests + LinkedTreeMap fixtureV2 = + FixtureLoader.load("transactions/v2-ecdsa/delegate-registration-secondSign"); + Transaction transactionV2 = + new Deserializer().deserialize(fixtureV2.get("serialized").toString()); + String actualV2 = Hex.encode(new Serializer().serialize(transactionV2)); + + assertEquals(fixtureV2.get("serialized").toString(), actualV2); + } } diff --git a/src/test/java/org/arkecosystem/crypto/transactions/serializers/DelegateResignationTest.java b/src/test/java/org/arkecosystem/crypto/transactions/serializers/DelegateResignationTest.java new file mode 100644 index 00000000..c9767c06 --- /dev/null +++ b/src/test/java/org/arkecosystem/crypto/transactions/serializers/DelegateResignationTest.java @@ -0,0 +1,38 @@ +package org.arkecosystem.crypto.transactions.serializers; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.google.gson.internal.LinkedTreeMap; +import org.arkecosystem.crypto.encoding.Hex; +import org.arkecosystem.crypto.transactions.Deserializer; +import org.arkecosystem.crypto.transactions.FixtureLoader; +import org.arkecosystem.crypto.transactions.Serializer; +import org.arkecosystem.crypto.transactions.Transaction; +import org.junit.jupiter.api.Test; + +public class DelegateResignationTest { + + @Test + void passphrase() { + LinkedTreeMap fixture = + FixtureLoader.load("transactions/v2-ecdsa/delegate-resignation-sign"); + + Transaction transaction = + new Deserializer().deserialize(fixture.get("serialized").toString()); + String actual = Hex.encode(new Serializer().serialize(transaction)); + + assertEquals(fixture.get("serialized").toString(), actual); + } + + @Test + void secondPassphrase() { + LinkedTreeMap fixture = + FixtureLoader.load("transactions/v2-ecdsa/delegate-resignation-secondSign"); + + Transaction transaction = + new Deserializer().deserialize(fixture.get("serialized").toString()); + String actual = Hex.encode(new Serializer().serialize(transaction)); + + assertEquals(fixture.get("serialized").toString(), actual); + } +} diff --git a/src/test/java/org/arkecosystem/crypto/transactions/serializers/HtlcClaimTest.java b/src/test/java/org/arkecosystem/crypto/transactions/serializers/HtlcClaimTest.java new file mode 100644 index 00000000..68ae14a8 --- /dev/null +++ b/src/test/java/org/arkecosystem/crypto/transactions/serializers/HtlcClaimTest.java @@ -0,0 +1,37 @@ +package org.arkecosystem.crypto.transactions.serializers; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.google.gson.internal.LinkedTreeMap; +import org.arkecosystem.crypto.encoding.Hex; +import org.arkecosystem.crypto.transactions.Deserializer; +import org.arkecosystem.crypto.transactions.FixtureLoader; +import org.arkecosystem.crypto.transactions.Serializer; +import org.arkecosystem.crypto.transactions.Transaction; +import org.junit.jupiter.api.Test; + +public class HtlcClaimTest { + + @Test + void passphrase() { + LinkedTreeMap fixture = + FixtureLoader.load("transactions/v2-ecdsa/htlc-claim-sign"); + + Transaction transaction = + new Deserializer().deserialize(fixture.get("serialized").toString()); + String actual = Hex.encode(new Serializer().serialize(transaction)); + assertEquals(fixture.get("serialized").toString(), actual); + } + + @Test + void secondPassphrase() { + LinkedTreeMap fixture = + FixtureLoader.load("transactions/v2-ecdsa/htlc-claim-secondSign"); + + Transaction transaction = + new Deserializer().deserialize(fixture.get("serialized").toString()); + String actual = Hex.encode(new Serializer().serialize(transaction)); + + assertEquals(fixture.get("serialized").toString(), actual); + } +} diff --git a/src/test/java/org/arkecosystem/crypto/transactions/serializers/HtlcLockTest.java b/src/test/java/org/arkecosystem/crypto/transactions/serializers/HtlcLockTest.java new file mode 100644 index 00000000..cdf5126a --- /dev/null +++ b/src/test/java/org/arkecosystem/crypto/transactions/serializers/HtlcLockTest.java @@ -0,0 +1,37 @@ +package org.arkecosystem.crypto.transactions.serializers; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.google.gson.internal.LinkedTreeMap; +import org.arkecosystem.crypto.encoding.Hex; +import org.arkecosystem.crypto.transactions.Deserializer; +import org.arkecosystem.crypto.transactions.FixtureLoader; +import org.arkecosystem.crypto.transactions.Serializer; +import org.arkecosystem.crypto.transactions.Transaction; +import org.junit.jupiter.api.Test; + +public class HtlcLockTest { + + @Test + void passphrase() { + LinkedTreeMap fixture = + FixtureLoader.load("transactions/v2-ecdsa/htlc-lock-sign"); + + Transaction transaction = + new Deserializer().deserialize(fixture.get("serialized").toString()); + String actual = Hex.encode(new Serializer().serialize(transaction)); + assertEquals(fixture.get("serialized").toString(), actual); + } + + @Test + void secondPassphrase() { + LinkedTreeMap fixture = + FixtureLoader.load("transactions/v2-ecdsa/htlc-lock-secondSign"); + + Transaction transaction = + new Deserializer().deserialize(fixture.get("serialized").toString()); + String actual = Hex.encode(new Serializer().serialize(transaction)); + + assertEquals(fixture.get("serialized").toString(), actual); + } +} diff --git a/src/test/java/org/arkecosystem/crypto/transactions/serializers/HtlcRefundTest.java b/src/test/java/org/arkecosystem/crypto/transactions/serializers/HtlcRefundTest.java new file mode 100644 index 00000000..74073c83 --- /dev/null +++ b/src/test/java/org/arkecosystem/crypto/transactions/serializers/HtlcRefundTest.java @@ -0,0 +1,36 @@ +package org.arkecosystem.crypto.transactions.serializers; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.google.gson.internal.LinkedTreeMap; +import org.arkecosystem.crypto.encoding.Hex; +import org.arkecosystem.crypto.transactions.Deserializer; +import org.arkecosystem.crypto.transactions.FixtureLoader; +import org.arkecosystem.crypto.transactions.Serializer; +import org.arkecosystem.crypto.transactions.Transaction; +import org.junit.jupiter.api.Test; + +public class HtlcRefundTest { + @Test + void passphrase() { + LinkedTreeMap fixture = + FixtureLoader.load("transactions/v2-ecdsa/htlc-refund-sign"); + + Transaction transaction = + new Deserializer().deserialize(fixture.get("serialized").toString()); + String actual = Hex.encode(new Serializer().serialize(transaction)); + assertEquals(fixture.get("serialized").toString(), actual); + } + + @Test + void secondPassphrase() { + LinkedTreeMap fixture = + FixtureLoader.load("transactions/v2-ecdsa/htlc-refund-secondSign"); + + Transaction transaction = + new Deserializer().deserialize(fixture.get("serialized").toString()); + String actual = Hex.encode(new Serializer().serialize(transaction)); + + assertEquals(fixture.get("serialized").toString(), actual); + } +} diff --git a/src/test/java/org/arkecosystem/crypto/transactions/serializers/IpfsTest.java b/src/test/java/org/arkecosystem/crypto/transactions/serializers/IpfsTest.java new file mode 100644 index 00000000..1ee57bae --- /dev/null +++ b/src/test/java/org/arkecosystem/crypto/transactions/serializers/IpfsTest.java @@ -0,0 +1,38 @@ +package org.arkecosystem.crypto.transactions.serializers; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.google.gson.internal.LinkedTreeMap; +import org.arkecosystem.crypto.encoding.Hex; +import org.arkecosystem.crypto.transactions.Deserializer; +import org.arkecosystem.crypto.transactions.FixtureLoader; +import org.arkecosystem.crypto.transactions.Serializer; +import org.arkecosystem.crypto.transactions.Transaction; +import org.junit.jupiter.api.Test; + +public class IpfsTest { + + @Test + void passphrase() { + LinkedTreeMap fixture = + FixtureLoader.load("transactions/v2-ecdsa/ipfs-sign"); + + Transaction transaction = + new Deserializer().deserialize(fixture.get("serialized").toString()); + String actual = Hex.encode(new Serializer().serialize(transaction)); + + assertEquals(fixture.get("serialized").toString(), actual); + } + + @Test + void secondPassphrase() { + LinkedTreeMap fixture = + FixtureLoader.load("transactions/v2-ecdsa/ipfs-secondSign"); + + Transaction transaction = + new Deserializer().deserialize(fixture.get("serialized").toString()); + String actual = Hex.encode(new Serializer().serialize(transaction)); + + assertEquals(fixture.get("serialized").toString(), actual); + } +} diff --git a/src/test/java/org/arkecosystem/crypto/transactions/serializers/MultiPaymentTest.java b/src/test/java/org/arkecosystem/crypto/transactions/serializers/MultiPaymentTest.java new file mode 100644 index 00000000..32ad3381 --- /dev/null +++ b/src/test/java/org/arkecosystem/crypto/transactions/serializers/MultiPaymentTest.java @@ -0,0 +1,39 @@ +package org.arkecosystem.crypto.transactions.serializers; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.google.gson.internal.LinkedTreeMap; +import org.arkecosystem.crypto.encoding.Hex; +import org.arkecosystem.crypto.transactions.Deserializer; +import org.arkecosystem.crypto.transactions.FixtureLoader; +import org.arkecosystem.crypto.transactions.Serializer; +import org.arkecosystem.crypto.transactions.Transaction; +import org.junit.jupiter.api.Test; + +public class MultiPaymentTest { + + @Test + void passphrase() { + LinkedTreeMap fixture = + FixtureLoader.load("transactions/v2-ecdsa/multi-payment-sign"); + + Transaction transaction = + new Deserializer().deserialize(fixture.get("serialized").toString()); + System.out.println(transaction.toJson()); + String actual = Hex.encode(new Serializer().serialize(transaction)); + + assertEquals(fixture.get("serialized").toString(), actual); + } + + @Test + void secondPassphrase() { + LinkedTreeMap fixture = + FixtureLoader.load("transactions/v2-ecdsa/multi-payment-secondSign"); + + Transaction transaction = + new Deserializer().deserialize(fixture.get("serialized").toString()); + String actual = Hex.encode(new Serializer().serialize(transaction)); + + assertEquals(fixture.get("serialized").toString(), actual); + } +} diff --git a/src/test/java/org/arkecosystem/crypto/transactions/serializers/MultiSignatureRegistrationTest.java b/src/test/java/org/arkecosystem/crypto/transactions/serializers/MultiSignatureRegistrationTest.java index 8bbad4df..a08edc4a 100644 --- a/src/test/java/org/arkecosystem/crypto/transactions/serializers/MultiSignatureRegistrationTest.java +++ b/src/test/java/org/arkecosystem/crypto/transactions/serializers/MultiSignatureRegistrationTest.java @@ -1,5 +1,7 @@ package org.arkecosystem.crypto.transactions.serializers; +import static org.junit.jupiter.api.Assertions.assertEquals; + import com.google.gson.internal.LinkedTreeMap; import org.arkecosystem.crypto.encoding.Hex; import org.arkecosystem.crypto.transactions.Deserializer; @@ -8,18 +10,17 @@ import org.arkecosystem.crypto.transactions.Transaction; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; - class MultiSignatureRegistrationTest { @Test void passphrase() { - LinkedTreeMap fixture = FixtureLoader.load("transactions/multi_signature_registration/passphrase"); + LinkedTreeMap fixture = + FixtureLoader.load("transactions/V1/multi_signature_registration/passphrase"); - Transaction transaction = new Deserializer().deserialize(fixture.get("serialized").toString()); + Transaction transaction = + new Deserializer().deserialize(fixture.get("serialized").toString()); String actual = Hex.encode(new Serializer().serialize(transaction)); assertEquals(fixture.get("serialized").toString(), actual); } - } diff --git a/src/test/java/org/arkecosystem/crypto/transactions/serializers/SecondSignatureRegistrationTest.java b/src/test/java/org/arkecosystem/crypto/transactions/serializers/SecondSignatureRegistrationTest.java index 958343a8..0fd3e861 100644 --- a/src/test/java/org/arkecosystem/crypto/transactions/serializers/SecondSignatureRegistrationTest.java +++ b/src/test/java/org/arkecosystem/crypto/transactions/serializers/SecondSignatureRegistrationTest.java @@ -1,5 +1,7 @@ package org.arkecosystem.crypto.transactions.serializers; +import static org.junit.jupiter.api.Assertions.assertEquals; + import com.google.gson.internal.LinkedTreeMap; import org.arkecosystem.crypto.encoding.Hex; import org.arkecosystem.crypto.transactions.Deserializer; @@ -8,18 +10,18 @@ import org.arkecosystem.crypto.transactions.Transaction; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; - class SecondSignatureRegistrationTest { @Test void passphrase() { - LinkedTreeMap fixture = FixtureLoader.load("transactions/second_signature_registration/second-passphrase"); + // V2 tests + LinkedTreeMap fixtureV2 = + FixtureLoader.load("transactions/v2-ecdsa/second-signature-registration"); - Transaction transaction = new Deserializer().deserialize(fixture.get("serialized").toString()); - String actual = Hex.encode(new Serializer().serialize(transaction)); + Transaction transactionV2 = + new Deserializer().deserialize(fixtureV2.get("serialized").toString()); + String actualV2 = Hex.encode(new Serializer().serialize(transactionV2)); - assertEquals(fixture.get("serialized").toString(), actual); + assertEquals(fixtureV2.get("serialized").toString(), actualV2); } - } diff --git a/src/test/java/org/arkecosystem/crypto/transactions/serializers/TransferTest.java b/src/test/java/org/arkecosystem/crypto/transactions/serializers/TransferTest.java index bff2419c..e5c87ee2 100644 --- a/src/test/java/org/arkecosystem/crypto/transactions/serializers/TransferTest.java +++ b/src/test/java/org/arkecosystem/crypto/transactions/serializers/TransferTest.java @@ -1,5 +1,7 @@ package org.arkecosystem.crypto.transactions.serializers; +import static org.junit.jupiter.api.Assertions.assertEquals; + import com.google.gson.internal.LinkedTreeMap; import org.arkecosystem.crypto.encoding.Hex; import org.arkecosystem.crypto.transactions.Deserializer; @@ -8,68 +10,144 @@ import org.arkecosystem.crypto.transactions.Transaction; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; - public class TransferTest { @Test void passphrase() { - LinkedTreeMap fixture = FixtureLoader.load("transactions/transfer/passphrase"); + // V1 tests + LinkedTreeMap fixture = + FixtureLoader.load("transactions/V1/transfer/passphrase"); - Transaction transaction = new Deserializer().deserialize(fixture.get("serialized").toString()); + Transaction transaction = + new Deserializer().deserialize(fixture.get("serialized").toString()); String actual = Hex.encode(new Serializer().serialize(transaction)); assertEquals(fixture.get("serialized").toString(), actual); + + // V2 tests + LinkedTreeMap fixtureV2 = + FixtureLoader.load("transactions/v2-ecdsa/transfer-sign"); + + Transaction transaction2 = + new Deserializer().deserialize(fixtureV2.get("serialized").toString()); + String actual2 = Hex.encode(new Serializer().serialize(transaction2)); + + assertEquals(fixtureV2.get("serialized").toString(), actual2); } @Test void passphraseVendorField() { - LinkedTreeMap fixture = FixtureLoader.load("transactions/transfer/passphrase-with-vendor-field"); + // V1 tests + LinkedTreeMap fixtureV1 = + FixtureLoader.load("transactions/V1/transfer/passphrase-with-vendor-field"); - Transaction transaction = new Deserializer().deserialize(fixture.get("serialized").toString()); - String actual = Hex.encode(new Serializer().serialize(transaction)); + Transaction transactionV1 = + new Deserializer().deserialize(fixtureV1.get("serialized").toString()); + String actualV1 = Hex.encode(new Serializer().serialize(transactionV1)); - assertEquals(fixture.get("serialized").toString(), actual); + assertEquals(fixtureV1.get("serialized").toString(), actualV1); + + // V2 tests + LinkedTreeMap fixtureV2 = + FixtureLoader.load("transactions/v2-ecdsa/transfer-with-vendor-field-sign"); + + Transaction transactionV2 = + new Deserializer().deserialize(fixtureV2.get("serialized").toString()); + String actualV2 = Hex.encode(new Serializer().serialize(transactionV2)); + + assertEquals(fixtureV2.get("serialized").toString(), actualV2); } @Test void passphraseVendorFieldHex() { - LinkedTreeMap fixture = FixtureLoader.load("transactions/transfer/passphrase-with-vendor-field-hex"); + // V1 tests + LinkedTreeMap fixtureV1 = + FixtureLoader.load("transactions/V1/transfer/passphrase-with-vendor-field-hex"); - Transaction transaction = new Deserializer().deserialize(fixture.get("serialized").toString()); - String actual = Hex.encode(new Serializer().serialize(transaction)); + Transaction transactionV1 = + new Deserializer().deserialize(fixtureV1.get("serialized").toString()); + String actualV1 = Hex.encode(new Serializer().serialize(transactionV1)); - assertEquals(fixture.get("serialized").toString(), actual); + assertEquals(fixtureV1.get("serialized").toString(), actualV1); + + // V2 tests + LinkedTreeMap fixtureV2 = + FixtureLoader.load("transactions/v2-ecdsa/transfer-with-vendor-field-sign"); + + Transaction transactionV2 = + new Deserializer().deserialize(fixtureV2.get("serialized").toString()); + String actualV2 = Hex.encode(new Serializer().serialize(transactionV2)); + + assertEquals(fixtureV2.get("serialized").toString(), actualV2); } @Test void secondPassphrase() { - LinkedTreeMap fixture = FixtureLoader.load("transactions/transfer/second-passphrase"); + // V1 tests + LinkedTreeMap fixtureV1 = + FixtureLoader.load("transactions/V1/transfer/second-passphrase"); - Transaction transaction = new Deserializer().deserialize(fixture.get("serialized").toString()); - String actual = Hex.encode(new Serializer().serialize(transaction)); + Transaction transactionV1 = + new Deserializer().deserialize(fixtureV1.get("serialized").toString()); + String actualV1 = Hex.encode(new Serializer().serialize(transactionV1)); - assertEquals(fixture.get("serialized").toString(), actual); + assertEquals(fixtureV1.get("serialized").toString(), actualV1); + + // V2 tests + LinkedTreeMap fixtureV2 = + FixtureLoader.load("transactions/v2-ecdsa/transfer-with-vendor-field-secondSign"); + + Transaction transactionV2 = + new Deserializer().deserialize(fixtureV2.get("serialized").toString()); + String actualV2 = Hex.encode(new Serializer().serialize(transactionV2)); + + assertEquals(fixtureV2.get("serialized").toString(), actualV2); } @Test void secondPassphraseVendorField() { - LinkedTreeMap fixture = FixtureLoader.load("transactions/transfer/second-passphrase-with-vendor-field"); + // V1 tests + LinkedTreeMap fixtureV1 = + FixtureLoader.load("transactions/V1/transfer/second-passphrase-with-vendor-field"); - Transaction transaction = new Deserializer().deserialize(fixture.get("serialized").toString()); - String actual = Hex.encode(new Serializer().serialize(transaction)); + Transaction transactionV1 = + new Deserializer().deserialize(fixtureV1.get("serialized").toString()); + String actualV1 = Hex.encode(new Serializer().serialize(transactionV1)); - assertEquals(fixture.get("serialized").toString(), actual); + assertEquals(fixtureV1.get("serialized").toString(), actualV1); + + // V2 tests + LinkedTreeMap fixtureV2 = + FixtureLoader.load("transactions/v2-ecdsa/transfer-with-vendor-field-secondSign"); + + Transaction transactionV2 = + new Deserializer().deserialize(fixtureV2.get("serialized").toString()); + String actualV2 = Hex.encode(new Serializer().serialize(transactionV2)); + + assertEquals(fixtureV2.get("serialized").toString(), actualV2); } @Test void secondPassphraseVendorFieldHex() { - LinkedTreeMap fixture = FixtureLoader.load("transactions/transfer/second-passphrase-with-vendor-field-hex"); + // V1 tests + LinkedTreeMap fixtureV1 = + FixtureLoader.load( + "transactions/V1/transfer/second-passphrase-with-vendor-field-hex"); - Transaction transaction = new Deserializer().deserialize(fixture.get("serialized").toString()); - String actual = Hex.encode(new Serializer().serialize(transaction)); + Transaction transactionV1 = + new Deserializer().deserialize(fixtureV1.get("serialized").toString()); + String actualV1 = Hex.encode(new Serializer().serialize(transactionV1)); - assertEquals(fixture.get("serialized").toString(), actual); - } + assertEquals(fixtureV1.get("serialized").toString(), actualV1); + + // V2 tests + LinkedTreeMap fixtureV2 = + FixtureLoader.load("transactions/v2-ecdsa/transfer-with-vendor-field-secondSign"); + Transaction transactionV2 = + new Deserializer().deserialize(fixtureV2.get("serialized").toString()); + String actualV2 = Hex.encode(new Serializer().serialize(transactionV2)); + + assertEquals(fixtureV2.get("serialized").toString(), actualV2); + } } diff --git a/src/test/java/org/arkecosystem/crypto/transactions/serializers/VoteTest.java b/src/test/java/org/arkecosystem/crypto/transactions/serializers/VoteTest.java index 42830e77..fa27a0ac 100644 --- a/src/test/java/org/arkecosystem/crypto/transactions/serializers/VoteTest.java +++ b/src/test/java/org/arkecosystem/crypto/transactions/serializers/VoteTest.java @@ -1,5 +1,7 @@ package org.arkecosystem.crypto.transactions.serializers; +import static org.junit.jupiter.api.Assertions.assertEquals; + import com.google.gson.internal.LinkedTreeMap; import org.arkecosystem.crypto.encoding.Hex; import org.arkecosystem.crypto.transactions.Deserializer; @@ -8,28 +10,51 @@ import org.arkecosystem.crypto.transactions.Transaction; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; - class VoteTest { @Test void passphrase() { - LinkedTreeMap fixture = FixtureLoader.load("transactions/vote/passphrase"); + // V1 tests + LinkedTreeMap fixtureV1 = + FixtureLoader.load("transactions/V1/vote/passphrase"); + + Transaction transactionV1 = + new Deserializer().deserialize(fixtureV1.get("serialized").toString()); + String actualV1 = Hex.encode(new Serializer().serialize(transactionV1)); + + assertEquals(fixtureV1.get("serialized").toString(), actualV1); - Transaction transaction = new Deserializer().deserialize(fixture.get("serialized").toString()); - String actual = Hex.encode(new Serializer().serialize(transaction)); + // V2 tests + LinkedTreeMap fixtureV2 = + FixtureLoader.load("transactions/v2-ecdsa/vote-sign"); - assertEquals(fixture.get("serialized").toString(), actual); + Transaction transactionV2 = + new Deserializer().deserialize(fixtureV2.get("serialized").toString()); + String actualV2 = Hex.encode(new Serializer().serialize(transactionV2)); + + assertEquals(fixtureV2.get("serialized").toString(), actualV2); } @Test void secondPassphrase() { - LinkedTreeMap fixture = FixtureLoader.load("transactions/vote/second-passphrase"); + // V1 tests + LinkedTreeMap fixtureV1 = + FixtureLoader.load("transactions/V1/vote/second-passphrase"); - Transaction transaction = new Deserializer().deserialize(fixture.get("serialized").toString()); - String actual = Hex.encode(new Serializer().serialize(transaction)); + Transaction transactionV1 = + new Deserializer().deserialize(fixtureV1.get("serialized").toString()); + String actualV1 = Hex.encode(new Serializer().serialize(transactionV1)); - assertEquals(fixture.get("serialized").toString(), actual); - } + assertEquals(fixtureV1.get("serialized").toString(), actualV1); + + // V2 tests + LinkedTreeMap fixtureV2 = + FixtureLoader.load("transactions/v2-ecdsa/vote-secondSign"); + Transaction transactionV2 = + new Deserializer().deserialize(fixtureV2.get("serialized").toString()); + String actualV2 = Hex.encode(new Serializer().serialize(transactionV2)); + + assertEquals(fixtureV2.get("serialized").toString(), actualV2); + } } diff --git a/src/test/java/org/arkecosystem/crypto/utils/MessageTest.java b/src/test/java/org/arkecosystem/crypto/utils/MessageTest.java index 0a243bc2..820cdf65 100644 --- a/src/test/java/org/arkecosystem/crypto/utils/MessageTest.java +++ b/src/test/java/org/arkecosystem/crypto/utils/MessageTest.java @@ -1,18 +1,21 @@ package org.arkecosystem.crypto.utils; -import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Map; - -import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; class MessageTest { @Test void sign() { Message message = Message.sign("Hello World", "this is a top secret passphrase"); - assertEquals("034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", message.getPublickey()); - assertEquals("304402200fb4adddd1f1d652b544ea6ab62828a0a65b712ed447e2538db0caebfa68929e02205ecb2e1c63b29879c2ecf1255db506d671c8b3fa6017f67cfd1bf07e6edd1cc8", message.getSignature()); + assertEquals( + "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + message.getPublickey()); + assertEquals( + "304402200fb4adddd1f1d652b544ea6ab62828a0a65b712ed447e2538db0caebfa68929e02205ecb2e1c63b29879c2ecf1255db506d671c8b3fa6017f67cfd1bf07e6edd1cc8", + message.getSignature()); assertEquals("Hello World", message.getMessage()); } @@ -26,8 +29,12 @@ void verify() { void toMap() { Message message = Message.sign("Hello World", "this is a top secret passphrase"); Map map = message.toMap(); - assertEquals("034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", map.get("publickey")); - assertEquals("304402200fb4adddd1f1d652b544ea6ab62828a0a65b712ed447e2538db0caebfa68929e02205ecb2e1c63b29879c2ecf1255db506d671c8b3fa6017f67cfd1bf07e6edd1cc8", map.get("signature")); + assertEquals( + "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + map.get("publickey")); + assertEquals( + "304402200fb4adddd1f1d652b544ea6ab62828a0a65b712ed447e2538db0caebfa68929e02205ecb2e1c63b29879c2ecf1255db506d671c8b3fa6017f67cfd1bf07e6edd1cc8", + map.get("signature")); assertEquals("Hello World", map.get("message")); } @@ -35,7 +42,8 @@ void toMap() { void toJson() { Message message = Message.sign("Hello World", "this is a top secret passphrase"); String json = message.toJson(); - assertEquals("{\"signature\":\"304402200fb4adddd1f1d652b544ea6ab62828a0a65b712ed447e2538db0caebfa68929e02205ecb2e1c63b29879c2ecf1255db506d671c8b3fa6017f67cfd1bf07e6edd1cc8\",\"publickey\":\"034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192\",\"message\":\"Hello World\"}", json); + assertEquals( + "{\"signature\":\"304402200fb4adddd1f1d652b544ea6ab62828a0a65b712ed447e2538db0caebfa68929e02205ecb2e1c63b29879c2ecf1255db506d671c8b3fa6017f67cfd1bf07e6edd1cc8\",\"publickey\":\"034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192\",\"message\":\"Hello World\"}", + json); } - } diff --git a/src/test/java/org/arkecosystem/crypto/utils/SlotTest.java b/src/test/java/org/arkecosystem/crypto/utils/SlotTest.java index ca4e4b05..d65af18c 100644 --- a/src/test/java/org/arkecosystem/crypto/utils/SlotTest.java +++ b/src/test/java/org/arkecosystem/crypto/utils/SlotTest.java @@ -1,9 +1,9 @@ package org.arkecosystem.crypto.utils; -import org.junit.jupiter.api.Test; - import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; + class SlotTest { @Test diff --git a/src/test/resources/transactions/delegate_registration/passphrase.json b/src/test/resources/transactions/V1/delegate_registration/passphrase.json similarity index 100% rename from src/test/resources/transactions/delegate_registration/passphrase.json rename to src/test/resources/transactions/V1/delegate_registration/passphrase.json diff --git a/src/test/resources/transactions/delegate_registration/second-passphrase.json b/src/test/resources/transactions/V1/delegate_registration/second-passphrase.json similarity index 100% rename from src/test/resources/transactions/delegate_registration/second-passphrase.json rename to src/test/resources/transactions/V1/delegate_registration/second-passphrase.json diff --git a/src/test/resources/transactions/multi_signature_registration/passphrase.json b/src/test/resources/transactions/V1/multi_signature_registration/passphrase.json similarity index 100% rename from src/test/resources/transactions/multi_signature_registration/passphrase.json rename to src/test/resources/transactions/V1/multi_signature_registration/passphrase.json diff --git a/src/test/resources/transactions/second_signature_registration/second-passphrase.json b/src/test/resources/transactions/V1/second_signature_registration/second-passphrase.json similarity index 100% rename from src/test/resources/transactions/second_signature_registration/second-passphrase.json rename to src/test/resources/transactions/V1/second_signature_registration/second-passphrase.json diff --git a/src/test/resources/transactions/transfer/passphrase-with-vendor-field-hex.json b/src/test/resources/transactions/V1/transfer/passphrase-with-vendor-field-hex.json similarity index 100% rename from src/test/resources/transactions/transfer/passphrase-with-vendor-field-hex.json rename to src/test/resources/transactions/V1/transfer/passphrase-with-vendor-field-hex.json diff --git a/src/test/resources/transactions/transfer/passphrase-with-vendor-field.json b/src/test/resources/transactions/V1/transfer/passphrase-with-vendor-field.json similarity index 100% rename from src/test/resources/transactions/transfer/passphrase-with-vendor-field.json rename to src/test/resources/transactions/V1/transfer/passphrase-with-vendor-field.json diff --git a/src/test/resources/transactions/transfer/passphrase.json b/src/test/resources/transactions/V1/transfer/passphrase.json similarity index 100% rename from src/test/resources/transactions/transfer/passphrase.json rename to src/test/resources/transactions/V1/transfer/passphrase.json diff --git a/src/test/resources/transactions/transfer/second-passphrase-with-vendor-field-hex.json b/src/test/resources/transactions/V1/transfer/second-passphrase-with-vendor-field-hex.json similarity index 100% rename from src/test/resources/transactions/transfer/second-passphrase-with-vendor-field-hex.json rename to src/test/resources/transactions/V1/transfer/second-passphrase-with-vendor-field-hex.json diff --git a/src/test/resources/transactions/transfer/second-passphrase-with-vendor-field.json b/src/test/resources/transactions/V1/transfer/second-passphrase-with-vendor-field.json similarity index 100% rename from src/test/resources/transactions/transfer/second-passphrase-with-vendor-field.json rename to src/test/resources/transactions/V1/transfer/second-passphrase-with-vendor-field.json diff --git a/src/test/resources/transactions/transfer/second-passphrase.json b/src/test/resources/transactions/V1/transfer/second-passphrase.json similarity index 100% rename from src/test/resources/transactions/transfer/second-passphrase.json rename to src/test/resources/transactions/V1/transfer/second-passphrase.json diff --git a/src/test/resources/transactions/vote/passphrase.json b/src/test/resources/transactions/V1/vote/passphrase.json similarity index 100% rename from src/test/resources/transactions/vote/passphrase.json rename to src/test/resources/transactions/V1/vote/passphrase.json diff --git a/src/test/resources/transactions/vote/second-passphrase.json b/src/test/resources/transactions/V1/vote/second-passphrase.json similarity index 100% rename from src/test/resources/transactions/vote/second-passphrase.json rename to src/test/resources/transactions/V1/vote/second-passphrase.json diff --git a/src/test/resources/transactions/delegate_resignation/passphrase.json b/src/test/resources/transactions/delegate_resignation/passphrase.json deleted file mode 100644 index ab15244c..00000000 --- a/src/test/resources/transactions/delegate_resignation/passphrase.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "data": {}, - "serialized": "" -} diff --git a/src/test/resources/transactions/ipfs/passphrase.json b/src/test/resources/transactions/ipfs/passphrase.json deleted file mode 100644 index ab15244c..00000000 --- a/src/test/resources/transactions/ipfs/passphrase.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "data": {}, - "serialized": "" -} diff --git a/src/test/resources/transactions/multi_payment/passphrase.json b/src/test/resources/transactions/multi_payment/passphrase.json deleted file mode 100644 index ab15244c..00000000 --- a/src/test/resources/transactions/multi_payment/passphrase.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "data": {}, - "serialized": "" -} diff --git a/src/test/resources/transactions/timelock_transfer/passphrase.json b/src/test/resources/transactions/timelock_transfer/passphrase.json deleted file mode 100644 index ab15244c..00000000 --- a/src/test/resources/transactions/timelock_transfer/passphrase.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "data": {}, - "serialized": "" -} diff --git a/src/test/resources/transactions/v2-ecdsa/delegate-registration-multiSign.json b/src/test/resources/transactions/v2-ecdsa/delegate-registration-multiSign.json new file mode 100644 index 00000000..aa18c641 --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/delegate-registration-multiSign.json @@ -0,0 +1,20 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 2, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "2500000000", + "amount": "0", + "asset": { + "delegate": { + "username": "boldninja" + } + }, + "signature": "304502210094d93b799526337256850011fd9a065a944c5bb58e730882393be62a01991cd70220715d66eb3377b59f2b51ca9616e7c252cb66ebf40f96cf469987dd4a9aaa60cd", + "id": "59a41e4411c9fac688ac22a10ba88a6ef6f513b2b8de05c94793e5434b1eb2e5" + }, + "serialized": "ff02170100000002000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed19200f90295000000000009626f6c646e696e6a61304502210094d93b799526337256850011fd9a065a944c5bb58e730882393be62a01991cd70220715d66eb3377b59f2b51ca9616e7c252cb66ebf40f96cf469987dd4a9aaa60cd" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/delegate-registration-secondSign.json b/src/test/resources/transactions/v2-ecdsa/delegate-registration-secondSign.json new file mode 100644 index 00000000..a83b52f1 --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/delegate-registration-secondSign.json @@ -0,0 +1,21 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 2, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "2500000000", + "amount": "0", + "asset": { + "delegate": { + "username": "boldninja" + } + }, + "signature": "304502210094d93b799526337256850011fd9a065a944c5bb58e730882393be62a01991cd70220715d66eb3377b59f2b51ca9616e7c252cb66ebf40f96cf469987dd4a9aaa60cd", + "secondSignature": "3045022100f6098d565170c3bf7b031098c4b1287dc12dbca6ebc5d824180cb070c97c208602205e6be08766e6a5649407867d3d5caa24431387427ab5057a699839e4000174a1", + "id": "4f00274e818eb3defdbe3ce5cc1d7637664f015c68c649ebc6cf1cbd24a9f94c" + }, + "serialized": "ff02170100000002000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed19200f90295000000000009626f6c646e696e6a61304502210094d93b799526337256850011fd9a065a944c5bb58e730882393be62a01991cd70220715d66eb3377b59f2b51ca9616e7c252cb66ebf40f96cf469987dd4a9aaa60cd3045022100f6098d565170c3bf7b031098c4b1287dc12dbca6ebc5d824180cb070c97c208602205e6be08766e6a5649407867d3d5caa24431387427ab5057a699839e4000174a1" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/delegate-registration-sign.json b/src/test/resources/transactions/v2-ecdsa/delegate-registration-sign.json new file mode 100644 index 00000000..aa18c641 --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/delegate-registration-sign.json @@ -0,0 +1,20 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 2, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "2500000000", + "amount": "0", + "asset": { + "delegate": { + "username": "boldninja" + } + }, + "signature": "304502210094d93b799526337256850011fd9a065a944c5bb58e730882393be62a01991cd70220715d66eb3377b59f2b51ca9616e7c252cb66ebf40f96cf469987dd4a9aaa60cd", + "id": "59a41e4411c9fac688ac22a10ba88a6ef6f513b2b8de05c94793e5434b1eb2e5" + }, + "serialized": "ff02170100000002000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed19200f90295000000000009626f6c646e696e6a61304502210094d93b799526337256850011fd9a065a944c5bb58e730882393be62a01991cd70220715d66eb3377b59f2b51ca9616e7c252cb66ebf40f96cf469987dd4a9aaa60cd" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/delegate-resignation-multiSign.json b/src/test/resources/transactions/v2-ecdsa/delegate-resignation-multiSign.json new file mode 100644 index 00000000..494e5359 --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/delegate-resignation-multiSign.json @@ -0,0 +1,15 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 7, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "2500000000", + "amount": "0", + "signature": "3045022100aa113ddefb502d868219339d16b8d448c8e69c8e320664e12903cc84420c159d02201b6206c7cb9442f6ef07dd0824aeb0cc393d8f9f9909988da6687c44ef897070", + "id": "a8cf10c6a7d2e5c82bff0860f83f917f426bdd1ee25bd8d5dad2358973ce4ecb" + }, + "serialized": "ff02170100000007000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed19200f9029500000000003045022100aa113ddefb502d868219339d16b8d448c8e69c8e320664e12903cc84420c159d02201b6206c7cb9442f6ef07dd0824aeb0cc393d8f9f9909988da6687c44ef897070" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/delegate-resignation-secondSign.json b/src/test/resources/transactions/v2-ecdsa/delegate-resignation-secondSign.json new file mode 100644 index 00000000..78483326 --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/delegate-resignation-secondSign.json @@ -0,0 +1,16 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 7, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "2500000000", + "amount": "0", + "signature": "3045022100aa113ddefb502d868219339d16b8d448c8e69c8e320664e12903cc84420c159d02201b6206c7cb9442f6ef07dd0824aeb0cc393d8f9f9909988da6687c44ef897070", + "secondSignature": "3045022100979dc1c57b2bfb033676ba9f659f995b688b5e9ed726d4a42523c4cdf2503731022072e13f61defa89a07369c9ef090a4bdc80eb36a2abc61e801bf66525e96adb7f", + "id": "cb6764194faeee2e283c0238adf57c08ffbf068407937bc13eddea1bc02b2a42" + }, + "serialized": "ff02170100000007000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed19200f9029500000000003045022100aa113ddefb502d868219339d16b8d448c8e69c8e320664e12903cc84420c159d02201b6206c7cb9442f6ef07dd0824aeb0cc393d8f9f9909988da6687c44ef8970703045022100979dc1c57b2bfb033676ba9f659f995b688b5e9ed726d4a42523c4cdf2503731022072e13f61defa89a07369c9ef090a4bdc80eb36a2abc61e801bf66525e96adb7f" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/delegate-resignation-sign.json b/src/test/resources/transactions/v2-ecdsa/delegate-resignation-sign.json new file mode 100644 index 00000000..494e5359 --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/delegate-resignation-sign.json @@ -0,0 +1,15 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 7, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "2500000000", + "amount": "0", + "signature": "3045022100aa113ddefb502d868219339d16b8d448c8e69c8e320664e12903cc84420c159d02201b6206c7cb9442f6ef07dd0824aeb0cc393d8f9f9909988da6687c44ef897070", + "id": "a8cf10c6a7d2e5c82bff0860f83f917f426bdd1ee25bd8d5dad2358973ce4ecb" + }, + "serialized": "ff02170100000007000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed19200f9029500000000003045022100aa113ddefb502d868219339d16b8d448c8e69c8e320664e12903cc84420c159d02201b6206c7cb9442f6ef07dd0824aeb0cc393d8f9f9909988da6687c44ef897070" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/htlc-claim-multiSign.json b/src/test/resources/transactions/v2-ecdsa/htlc-claim-multiSign.json new file mode 100644 index 00000000..76e87284 --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/htlc-claim-multiSign.json @@ -0,0 +1,21 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 9, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "0", + "amount": "0", + "asset": { + "claim": { + "lockTransactionId": "9c1a3815d49e0c9f78b872bfb017e825ea2db708158b70815526a830c85912b4", + "unlockSecret": "c27f1ce845d8c29eebc9006be932b604fd06755521b1a8b0be4204c65377151a" + } + }, + "signature": "3045022100f4115db125d14edd248b39459ae8a6d112f8d9cdbcf69da03dce597c048d99260220069d4a07229684f91b492979f0050400c323eb4096f586dedc101f0f5a3ac476", + "id": "fd6eb162c34dadcd66a5e86ce534a1df946b8fa4291ed17c085b252dafbdf30b" + }, + "serialized": "ff02170100000009000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed1920000000000000000009c1a3815d49e0c9f78b872bfb017e825ea2db708158b70815526a830c85912b4c27f1ce845d8c29eebc9006be932b604fd06755521b1a8b0be4204c65377151a3045022100f4115db125d14edd248b39459ae8a6d112f8d9cdbcf69da03dce597c048d99260220069d4a07229684f91b492979f0050400c323eb4096f586dedc101f0f5a3ac476" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/htlc-claim-secondSign.json b/src/test/resources/transactions/v2-ecdsa/htlc-claim-secondSign.json new file mode 100644 index 00000000..813794c1 --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/htlc-claim-secondSign.json @@ -0,0 +1,22 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 9, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "0", + "amount": "0", + "asset": { + "claim": { + "lockTransactionId": "9c1a3815d49e0c9f78b872bfb017e825ea2db708158b70815526a830c85912b4", + "unlockSecret": "c27f1ce845d8c29eebc9006be932b604fd06755521b1a8b0be4204c65377151a" + } + }, + "signature": "3045022100f4115db125d14edd248b39459ae8a6d112f8d9cdbcf69da03dce597c048d99260220069d4a07229684f91b492979f0050400c323eb4096f586dedc101f0f5a3ac476", + "secondSignature": "3045022100abe4c9bce127caeb5856a3f01dc216a6ac1100c2f9ec04ebcb3a2bb184fff0de022058b3045a4a4fd14fcd2e9a80edcb616582e28cfd0b6a78966e91a3786bbc8c8d", + "id": "3e857d6d7851340ff47cd9ccb8d3faf55add8e35d7a24128ac033102d3abb986" + }, + "serialized": "ff02170100000009000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed1920000000000000000009c1a3815d49e0c9f78b872bfb017e825ea2db708158b70815526a830c85912b4c27f1ce845d8c29eebc9006be932b604fd06755521b1a8b0be4204c65377151a3045022100f4115db125d14edd248b39459ae8a6d112f8d9cdbcf69da03dce597c048d99260220069d4a07229684f91b492979f0050400c323eb4096f586dedc101f0f5a3ac4763045022100abe4c9bce127caeb5856a3f01dc216a6ac1100c2f9ec04ebcb3a2bb184fff0de022058b3045a4a4fd14fcd2e9a80edcb616582e28cfd0b6a78966e91a3786bbc8c8d" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/htlc-claim-sign.json b/src/test/resources/transactions/v2-ecdsa/htlc-claim-sign.json new file mode 100644 index 00000000..76e87284 --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/htlc-claim-sign.json @@ -0,0 +1,21 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 9, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "0", + "amount": "0", + "asset": { + "claim": { + "lockTransactionId": "9c1a3815d49e0c9f78b872bfb017e825ea2db708158b70815526a830c85912b4", + "unlockSecret": "c27f1ce845d8c29eebc9006be932b604fd06755521b1a8b0be4204c65377151a" + } + }, + "signature": "3045022100f4115db125d14edd248b39459ae8a6d112f8d9cdbcf69da03dce597c048d99260220069d4a07229684f91b492979f0050400c323eb4096f586dedc101f0f5a3ac476", + "id": "fd6eb162c34dadcd66a5e86ce534a1df946b8fa4291ed17c085b252dafbdf30b" + }, + "serialized": "ff02170100000009000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed1920000000000000000009c1a3815d49e0c9f78b872bfb017e825ea2db708158b70815526a830c85912b4c27f1ce845d8c29eebc9006be932b604fd06755521b1a8b0be4204c65377151a3045022100f4115db125d14edd248b39459ae8a6d112f8d9cdbcf69da03dce597c048d99260220069d4a07229684f91b492979f0050400c323eb4096f586dedc101f0f5a3ac476" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/htlc-lock-multiSign.json b/src/test/resources/transactions/v2-ecdsa/htlc-lock-multiSign.json new file mode 100644 index 00000000..ac0e1617 --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/htlc-lock-multiSign.json @@ -0,0 +1,25 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 8, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "10000000", + "amount": "200000000", + "recipientId": "AGeYmgbg2LgGxRW2vNNJvQ88PknEJsYizC", + "asset": { + "lock": { + "secretHash": "0f128d401958b1b30ad0d10406f47f9489321017b4614e6cb993fc63913c5454", + "expiration": { + "type": 1, + "value": 1581339432 + } + } + }, + "signature": "3045022100968071560adef123ebc908bb11f46550339c52c997829f597a539e5616f79f8d0220533c0992b991b5d9a670ea1877cd5306bef5963b9a868fadf4122329fd4b2712", + "id": "cfb37ec05433841cd8d25c3e8d353dc519a6dcb583edd75085b671bff4075b40" + }, + "serialized": "ff02170100000008000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed19280969800000000000000c2eb0b000000000f128d401958b1b30ad0d10406f47f9489321017b4614e6cb993fc63913c5454012853415e170995750207ecaf0ccf251c1265b92ad84f5536623045022100968071560adef123ebc908bb11f46550339c52c997829f597a539e5616f79f8d0220533c0992b991b5d9a670ea1877cd5306bef5963b9a868fadf4122329fd4b2712" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/htlc-lock-secondSign.json b/src/test/resources/transactions/v2-ecdsa/htlc-lock-secondSign.json new file mode 100644 index 00000000..819f2807 --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/htlc-lock-secondSign.json @@ -0,0 +1,26 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 8, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "10000000", + "amount": "200000000", + "recipientId": "AGeYmgbg2LgGxRW2vNNJvQ88PknEJsYizC", + "asset": { + "lock": { + "secretHash": "0f128d401958b1b30ad0d10406f47f9489321017b4614e6cb993fc63913c5454", + "expiration": { + "type": 1, + "value": 1581339432 + } + } + }, + "signature": "3045022100968071560adef123ebc908bb11f46550339c52c997829f597a539e5616f79f8d0220533c0992b991b5d9a670ea1877cd5306bef5963b9a868fadf4122329fd4b2712", + "secondSignature": "304402203c3ef3dfe32837b19460bf8bfc7ec7bd003f773efa09d1966886ff361ef9afb302203a95e56d72c24f2a3313444d1fcd4971dcc67bcb54235a67b964f93201debdda", + "id": "06ab23a6a9355ed3deb4a5ecdb085a77862bf8eb5f270b773009199087890dd1" + }, + "serialized": "ff02170100000008000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed19280969800000000000000c2eb0b000000000f128d401958b1b30ad0d10406f47f9489321017b4614e6cb993fc63913c5454012853415e170995750207ecaf0ccf251c1265b92ad84f5536623045022100968071560adef123ebc908bb11f46550339c52c997829f597a539e5616f79f8d0220533c0992b991b5d9a670ea1877cd5306bef5963b9a868fadf4122329fd4b2712304402203c3ef3dfe32837b19460bf8bfc7ec7bd003f773efa09d1966886ff361ef9afb302203a95e56d72c24f2a3313444d1fcd4971dcc67bcb54235a67b964f93201debdda" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/htlc-lock-sign.json b/src/test/resources/transactions/v2-ecdsa/htlc-lock-sign.json new file mode 100644 index 00000000..ac0e1617 --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/htlc-lock-sign.json @@ -0,0 +1,25 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 8, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "10000000", + "amount": "200000000", + "recipientId": "AGeYmgbg2LgGxRW2vNNJvQ88PknEJsYizC", + "asset": { + "lock": { + "secretHash": "0f128d401958b1b30ad0d10406f47f9489321017b4614e6cb993fc63913c5454", + "expiration": { + "type": 1, + "value": 1581339432 + } + } + }, + "signature": "3045022100968071560adef123ebc908bb11f46550339c52c997829f597a539e5616f79f8d0220533c0992b991b5d9a670ea1877cd5306bef5963b9a868fadf4122329fd4b2712", + "id": "cfb37ec05433841cd8d25c3e8d353dc519a6dcb583edd75085b671bff4075b40" + }, + "serialized": "ff02170100000008000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed19280969800000000000000c2eb0b000000000f128d401958b1b30ad0d10406f47f9489321017b4614e6cb993fc63913c5454012853415e170995750207ecaf0ccf251c1265b92ad84f5536623045022100968071560adef123ebc908bb11f46550339c52c997829f597a539e5616f79f8d0220533c0992b991b5d9a670ea1877cd5306bef5963b9a868fadf4122329fd4b2712" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/htlc-lock-with-vendor-field-multiSign.json b/src/test/resources/transactions/v2-ecdsa/htlc-lock-with-vendor-field-multiSign.json new file mode 100644 index 00000000..cea1f04f --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/htlc-lock-with-vendor-field-multiSign.json @@ -0,0 +1,26 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 8, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "10000000", + "amount": "200000000", + "vendorField": "this is a top secret vendor field", + "recipientId": "AGeYmgbg2LgGxRW2vNNJvQ88PknEJsYizC", + "asset": { + "lock": { + "secretHash": "0f128d401958b1b30ad0d10406f47f9489321017b4614e6cb993fc63913c5454", + "expiration": { + "type": 1, + "value": 1581339432 + } + } + }, + "signature": "304402206b83b7976c08bbc1f67a17d5481f498bdadd761826379489b9c44390c1c1621002205fe8ab97de3a08305967c9bf66d19a8426bd0d97d744639ab220a03ca8b5ef78", + "id": "d0361b035f314a248020f955eff949af0e979a41cc6b420683fc76f9391f598f" + }, + "serialized": "ff02170100000008000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed19280969800000000002174686973206973206120746f70207365637265742076656e646f72206669656c6400c2eb0b000000000f128d401958b1b30ad0d10406f47f9489321017b4614e6cb993fc63913c5454012853415e170995750207ecaf0ccf251c1265b92ad84f553662304402206b83b7976c08bbc1f67a17d5481f498bdadd761826379489b9c44390c1c1621002205fe8ab97de3a08305967c9bf66d19a8426bd0d97d744639ab220a03ca8b5ef78" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/htlc-lock-with-vendor-field-secondSign.json b/src/test/resources/transactions/v2-ecdsa/htlc-lock-with-vendor-field-secondSign.json new file mode 100644 index 00000000..49f29658 --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/htlc-lock-with-vendor-field-secondSign.json @@ -0,0 +1,27 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 8, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "10000000", + "amount": "200000000", + "vendorField": "this is a top secret vendor field", + "recipientId": "AGeYmgbg2LgGxRW2vNNJvQ88PknEJsYizC", + "asset": { + "lock": { + "secretHash": "0f128d401958b1b30ad0d10406f47f9489321017b4614e6cb993fc63913c5454", + "expiration": { + "type": 1, + "value": 1581339432 + } + } + }, + "signature": "304402206b83b7976c08bbc1f67a17d5481f498bdadd761826379489b9c44390c1c1621002205fe8ab97de3a08305967c9bf66d19a8426bd0d97d744639ab220a03ca8b5ef78", + "secondSignature": "304402202646835437728c73293f3bdba5c3ec8c48e33503b609ae7a12ca6202e42711ac0220448f344f014c69fa6c791972f5ab4cd6561504030b058aa8fe3c16947b6f207e", + "id": "8dd3093cfc16a8c77fcea60ba79515d50ab5d3f6e02864cc5a8f3757c1f00c83" + }, + "serialized": "ff02170100000008000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed19280969800000000002174686973206973206120746f70207365637265742076656e646f72206669656c6400c2eb0b000000000f128d401958b1b30ad0d10406f47f9489321017b4614e6cb993fc63913c5454012853415e170995750207ecaf0ccf251c1265b92ad84f553662304402206b83b7976c08bbc1f67a17d5481f498bdadd761826379489b9c44390c1c1621002205fe8ab97de3a08305967c9bf66d19a8426bd0d97d744639ab220a03ca8b5ef78304402202646835437728c73293f3bdba5c3ec8c48e33503b609ae7a12ca6202e42711ac0220448f344f014c69fa6c791972f5ab4cd6561504030b058aa8fe3c16947b6f207e" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/htlc-lock-with-vendor-field-sign.json b/src/test/resources/transactions/v2-ecdsa/htlc-lock-with-vendor-field-sign.json new file mode 100644 index 00000000..cea1f04f --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/htlc-lock-with-vendor-field-sign.json @@ -0,0 +1,26 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 8, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "10000000", + "amount": "200000000", + "vendorField": "this is a top secret vendor field", + "recipientId": "AGeYmgbg2LgGxRW2vNNJvQ88PknEJsYizC", + "asset": { + "lock": { + "secretHash": "0f128d401958b1b30ad0d10406f47f9489321017b4614e6cb993fc63913c5454", + "expiration": { + "type": 1, + "value": 1581339432 + } + } + }, + "signature": "304402206b83b7976c08bbc1f67a17d5481f498bdadd761826379489b9c44390c1c1621002205fe8ab97de3a08305967c9bf66d19a8426bd0d97d744639ab220a03ca8b5ef78", + "id": "d0361b035f314a248020f955eff949af0e979a41cc6b420683fc76f9391f598f" + }, + "serialized": "ff02170100000008000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed19280969800000000002174686973206973206120746f70207365637265742076656e646f72206669656c6400c2eb0b000000000f128d401958b1b30ad0d10406f47f9489321017b4614e6cb993fc63913c5454012853415e170995750207ecaf0ccf251c1265b92ad84f553662304402206b83b7976c08bbc1f67a17d5481f498bdadd761826379489b9c44390c1c1621002205fe8ab97de3a08305967c9bf66d19a8426bd0d97d744639ab220a03ca8b5ef78" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/htlc-refund-multiSign.json b/src/test/resources/transactions/v2-ecdsa/htlc-refund-multiSign.json new file mode 100644 index 00000000..f36eb19c --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/htlc-refund-multiSign.json @@ -0,0 +1,20 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 10, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "0", + "amount": "0", + "asset": { + "refund": { + "lockTransactionId": "943c220691e711c39c79d437ce185748a0018940e1a4144293af9d05627d2eb4" + } + }, + "signature": "3044022039b189def165ca903805e35f0fa8d0b5820861227d677909acb1650698a63415022020a124f535f92100cd8233f9b5e01eebda72b59c858600934f586fc7ee236574", + "id": "c8cf015e1566d9d63236e70c12988f6f13161f90d30ff5120ee62e37484034e3" + }, + "serialized": "ff0217010000000a000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192000000000000000000943c220691e711c39c79d437ce185748a0018940e1a4144293af9d05627d2eb43044022039b189def165ca903805e35f0fa8d0b5820861227d677909acb1650698a63415022020a124f535f92100cd8233f9b5e01eebda72b59c858600934f586fc7ee236574" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/htlc-refund-secondSign.json b/src/test/resources/transactions/v2-ecdsa/htlc-refund-secondSign.json new file mode 100644 index 00000000..0da0f345 --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/htlc-refund-secondSign.json @@ -0,0 +1,21 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 10, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "0", + "amount": "0", + "asset": { + "refund": { + "lockTransactionId": "943c220691e711c39c79d437ce185748a0018940e1a4144293af9d05627d2eb4" + } + }, + "signature": "3044022039b189def165ca903805e35f0fa8d0b5820861227d677909acb1650698a63415022020a124f535f92100cd8233f9b5e01eebda72b59c858600934f586fc7ee236574", + "secondSignature": "3044022018cae203467050b6e5c9f095ef8730b51eb8f1f0770be77da45aca6c275c635d02207dd4bd55309f7bac05ad4d3e71a7c3e2182ec4aea4549d443aec6dd3fac831f1", + "id": "6b6f8705c0df33ad0b2491c89788661f7fa834d8414658f836903cc5e4e190de" + }, + "serialized": "ff0217010000000a000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192000000000000000000943c220691e711c39c79d437ce185748a0018940e1a4144293af9d05627d2eb43044022039b189def165ca903805e35f0fa8d0b5820861227d677909acb1650698a63415022020a124f535f92100cd8233f9b5e01eebda72b59c858600934f586fc7ee2365743044022018cae203467050b6e5c9f095ef8730b51eb8f1f0770be77da45aca6c275c635d02207dd4bd55309f7bac05ad4d3e71a7c3e2182ec4aea4549d443aec6dd3fac831f1" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/htlc-refund-sign.json b/src/test/resources/transactions/v2-ecdsa/htlc-refund-sign.json new file mode 100644 index 00000000..f36eb19c --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/htlc-refund-sign.json @@ -0,0 +1,20 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 10, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "0", + "amount": "0", + "asset": { + "refund": { + "lockTransactionId": "943c220691e711c39c79d437ce185748a0018940e1a4144293af9d05627d2eb4" + } + }, + "signature": "3044022039b189def165ca903805e35f0fa8d0b5820861227d677909acb1650698a63415022020a124f535f92100cd8233f9b5e01eebda72b59c858600934f586fc7ee236574", + "id": "c8cf015e1566d9d63236e70c12988f6f13161f90d30ff5120ee62e37484034e3" + }, + "serialized": "ff0217010000000a000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192000000000000000000943c220691e711c39c79d437ce185748a0018940e1a4144293af9d05627d2eb43044022039b189def165ca903805e35f0fa8d0b5820861227d677909acb1650698a63415022020a124f535f92100cd8233f9b5e01eebda72b59c858600934f586fc7ee236574" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/ipfs-multiSign.json b/src/test/resources/transactions/v2-ecdsa/ipfs-multiSign.json new file mode 100644 index 00000000..27747208 --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/ipfs-multiSign.json @@ -0,0 +1,18 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 5, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "500000000", + "amount": "0", + "asset": { + "ipfs": "QmR45FmbVVrixReBwJkhEKde2qwHYaQzGxu4ZoDeswuF9w" + }, + "signature": "3045022100e7d20c81b32e7a30fb741ba76fc823b667f38389b0a19d5e0a5779029843b792022050133f52000dc4327548c6f757f6ab2386f080d0fada8902de3d1372a2a9ff92", + "id": "b38f24116758b9b2fdb1f80b5ce02044af640f77d552080768942f9a9cfa2a88" + }, + "serialized": "ff02170100000005000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed1920065cd1d000000000012202853f0f11ab91d73b73a2a86606103f45dd469ad2e89ec6f9a25febe8758d3fe3045022100e7d20c81b32e7a30fb741ba76fc823b667f38389b0a19d5e0a5779029843b792022050133f52000dc4327548c6f757f6ab2386f080d0fada8902de3d1372a2a9ff92" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/ipfs-secondSign.json b/src/test/resources/transactions/v2-ecdsa/ipfs-secondSign.json new file mode 100644 index 00000000..a4070c90 --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/ipfs-secondSign.json @@ -0,0 +1,19 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 5, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "500000000", + "amount": "0", + "asset": { + "ipfs": "QmR45FmbVVrixReBwJkhEKde2qwHYaQzGxu4ZoDeswuF9w" + }, + "signature": "3045022100e7d20c81b32e7a30fb741ba76fc823b667f38389b0a19d5e0a5779029843b792022050133f52000dc4327548c6f757f6ab2386f080d0fada8902de3d1372a2a9ff92", + "secondSignature": "30450221009a210886183630f56aa2341db8d2fa142a82871290bcd1c95f15c864dbe207ff02206dbaf3ecf954047ab7c507b3a8d12096872f7c43986b26b436df6d01961803b4", + "id": "6ff039ec2ae3a6e48f629ad26d429f0a6d4c888439db4424d417cea7c32fa95a" + }, + "serialized": "ff02170100000005000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed1920065cd1d000000000012202853f0f11ab91d73b73a2a86606103f45dd469ad2e89ec6f9a25febe8758d3fe3045022100e7d20c81b32e7a30fb741ba76fc823b667f38389b0a19d5e0a5779029843b792022050133f52000dc4327548c6f757f6ab2386f080d0fada8902de3d1372a2a9ff9230450221009a210886183630f56aa2341db8d2fa142a82871290bcd1c95f15c864dbe207ff02206dbaf3ecf954047ab7c507b3a8d12096872f7c43986b26b436df6d01961803b4" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/ipfs-sign.json b/src/test/resources/transactions/v2-ecdsa/ipfs-sign.json new file mode 100644 index 00000000..27747208 --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/ipfs-sign.json @@ -0,0 +1,18 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 5, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "500000000", + "amount": "0", + "asset": { + "ipfs": "QmR45FmbVVrixReBwJkhEKde2qwHYaQzGxu4ZoDeswuF9w" + }, + "signature": "3045022100e7d20c81b32e7a30fb741ba76fc823b667f38389b0a19d5e0a5779029843b792022050133f52000dc4327548c6f757f6ab2386f080d0fada8902de3d1372a2a9ff92", + "id": "b38f24116758b9b2fdb1f80b5ce02044af640f77d552080768942f9a9cfa2a88" + }, + "serialized": "ff02170100000005000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed1920065cd1d000000000012202853f0f11ab91d73b73a2a86606103f45dd469ad2e89ec6f9a25febe8758d3fe3045022100e7d20c81b32e7a30fb741ba76fc823b667f38389b0a19d5e0a5779029843b792022050133f52000dc4327548c6f757f6ab2386f080d0fada8902de3d1372a2a9ff92" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/multi-payment-multiSign.json b/src/test/resources/transactions/v2-ecdsa/multi-payment-multiSign.json new file mode 100644 index 00000000..811601d1 --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/multi-payment-multiSign.json @@ -0,0 +1,27 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 6, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "10000000", + "amount": "0", + "asset": { + "payments": [ + { + "amount": "1", + "recipientId": "AHXtmB84sTZ9Zd35h9Y1vfFvPE2Xzqj8ri" + }, + { + "amount": "2", + "recipientId": "AZFEPTWnn2Sn8wDZgCRF8ohwKkrmk2AZi1" + } + ] + }, + "signature": "3044022068ecfe918717a0890ae0480045d526a7f14f163377e5e6dc4ce3bdd70c20cf750220261eaacb731cf386d5439e651fb2068ab59cb9ea2503d4a522f2da299870b3ae", + "id": "df4759a599ec78ac1cfb19ded5985312266dd009610eee5e71d55e69076c7d35" + }, + "serialized": "ff02170100000006000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed1928096980000000000000200010000000000000017134b5be4b327ddf9c2bb47fec8a1a44189e90f74020000000000000017bfa6aec83cf1bd03a0cab9f35c85ff51a3e9f0413044022068ecfe918717a0890ae0480045d526a7f14f163377e5e6dc4ce3bdd70c20cf750220261eaacb731cf386d5439e651fb2068ab59cb9ea2503d4a522f2da299870b3ae" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/multi-payment-secondSign.json b/src/test/resources/transactions/v2-ecdsa/multi-payment-secondSign.json new file mode 100644 index 00000000..2f55cf1b --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/multi-payment-secondSign.json @@ -0,0 +1,28 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 6, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "10000000", + "amount": "0", + "asset": { + "payments": [ + { + "amount": "1", + "recipientId": "AHXtmB84sTZ9Zd35h9Y1vfFvPE2Xzqj8ri" + }, + { + "amount": "2", + "recipientId": "AZFEPTWnn2Sn8wDZgCRF8ohwKkrmk2AZi1" + } + ] + }, + "signature": "3044022068ecfe918717a0890ae0480045d526a7f14f163377e5e6dc4ce3bdd70c20cf750220261eaacb731cf386d5439e651fb2068ab59cb9ea2503d4a522f2da299870b3ae", + "secondSignature": "3045022100c8c77d296b2e9cb0f2af7ac9fa5d4c30d188e580ed888a2e1afc694b206b308d02200c08cdc6cef86418ebcf181efb60a814066ef67413f57069f32d8b563b2b543b", + "id": "3aa197c202b1d7e17bdd21be4b510802f91aab028ff24dafdb8c9514c201e05f" + }, + "serialized": "ff02170100000006000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed1928096980000000000000200010000000000000017134b5be4b327ddf9c2bb47fec8a1a44189e90f74020000000000000017bfa6aec83cf1bd03a0cab9f35c85ff51a3e9f0413044022068ecfe918717a0890ae0480045d526a7f14f163377e5e6dc4ce3bdd70c20cf750220261eaacb731cf386d5439e651fb2068ab59cb9ea2503d4a522f2da299870b3ae3045022100c8c77d296b2e9cb0f2af7ac9fa5d4c30d188e580ed888a2e1afc694b206b308d02200c08cdc6cef86418ebcf181efb60a814066ef67413f57069f32d8b563b2b543b" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/multi-payment-sign.json b/src/test/resources/transactions/v2-ecdsa/multi-payment-sign.json new file mode 100644 index 00000000..811601d1 --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/multi-payment-sign.json @@ -0,0 +1,27 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 6, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "10000000", + "amount": "0", + "asset": { + "payments": [ + { + "amount": "1", + "recipientId": "AHXtmB84sTZ9Zd35h9Y1vfFvPE2Xzqj8ri" + }, + { + "amount": "2", + "recipientId": "AZFEPTWnn2Sn8wDZgCRF8ohwKkrmk2AZi1" + } + ] + }, + "signature": "3044022068ecfe918717a0890ae0480045d526a7f14f163377e5e6dc4ce3bdd70c20cf750220261eaacb731cf386d5439e651fb2068ab59cb9ea2503d4a522f2da299870b3ae", + "id": "df4759a599ec78ac1cfb19ded5985312266dd009610eee5e71d55e69076c7d35" + }, + "serialized": "ff02170100000006000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed1928096980000000000000200010000000000000017134b5be4b327ddf9c2bb47fec8a1a44189e90f74020000000000000017bfa6aec83cf1bd03a0cab9f35c85ff51a3e9f0413044022068ecfe918717a0890ae0480045d526a7f14f163377e5e6dc4ce3bdd70c20cf750220261eaacb731cf386d5439e651fb2068ab59cb9ea2503d4a522f2da299870b3ae" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/multi-payment-with-vendor-field-multiSign.json b/src/test/resources/transactions/v2-ecdsa/multi-payment-with-vendor-field-multiSign.json new file mode 100644 index 00000000..a0138200 --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/multi-payment-with-vendor-field-multiSign.json @@ -0,0 +1,28 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 6, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "10000000", + "amount": "0", + "vendorField": "this is a top secret vendor field", + "asset": { + "payments": [ + { + "amount": "1", + "recipientId": "AHXtmB84sTZ9Zd35h9Y1vfFvPE2Xzqj8ri" + }, + { + "amount": "2", + "recipientId": "AZFEPTWnn2Sn8wDZgCRF8ohwKkrmk2AZi1" + } + ] + }, + "signature": "304402205d6a667239481f9306f37b35976626a39993b1088ee8ff2dee638905590c9508022040aa06bce7d20146c179d1106f29a821aa7278816e1f77f325e02caec3129565", + "id": "7bd4861b168d903500ecf15503804c9625f0eb0d86d350e3f0b73765f6ce2c7c" + }, + "serialized": "ff02170100000006000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed19280969800000000002174686973206973206120746f70207365637265742076656e646f72206669656c640200010000000000000017134b5be4b327ddf9c2bb47fec8a1a44189e90f74020000000000000017bfa6aec83cf1bd03a0cab9f35c85ff51a3e9f041304402205d6a667239481f9306f37b35976626a39993b1088ee8ff2dee638905590c9508022040aa06bce7d20146c179d1106f29a821aa7278816e1f77f325e02caec3129565" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/multi-payment-with-vendor-field-secondSign.json b/src/test/resources/transactions/v2-ecdsa/multi-payment-with-vendor-field-secondSign.json new file mode 100644 index 00000000..05f2f6ab --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/multi-payment-with-vendor-field-secondSign.json @@ -0,0 +1,29 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 6, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "10000000", + "amount": "0", + "vendorField": "this is a top secret vendor field", + "asset": { + "payments": [ + { + "amount": "1", + "recipientId": "AHXtmB84sTZ9Zd35h9Y1vfFvPE2Xzqj8ri" + }, + { + "amount": "2", + "recipientId": "AZFEPTWnn2Sn8wDZgCRF8ohwKkrmk2AZi1" + } + ] + }, + "signature": "304402205d6a667239481f9306f37b35976626a39993b1088ee8ff2dee638905590c9508022040aa06bce7d20146c179d1106f29a821aa7278816e1f77f325e02caec3129565", + "secondSignature": "3044022049d89e8cc29e8febd60b3f2482cf39ee8ed71de07bd3834025067aa80a6ff97b022036d5c300b23806c2d694d2172785f57896312c61a19ddacb4c895f3a44ec1db4", + "id": "64bccef76c16c06e4cb20398b9db02c92e38878dd1afe798b6298d1cbc80d53d" + }, + "serialized": "ff02170100000006000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed19280969800000000002174686973206973206120746f70207365637265742076656e646f72206669656c640200010000000000000017134b5be4b327ddf9c2bb47fec8a1a44189e90f74020000000000000017bfa6aec83cf1bd03a0cab9f35c85ff51a3e9f041304402205d6a667239481f9306f37b35976626a39993b1088ee8ff2dee638905590c9508022040aa06bce7d20146c179d1106f29a821aa7278816e1f77f325e02caec31295653044022049d89e8cc29e8febd60b3f2482cf39ee8ed71de07bd3834025067aa80a6ff97b022036d5c300b23806c2d694d2172785f57896312c61a19ddacb4c895f3a44ec1db4" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/multi-payment-with-vendor-field-sign.json b/src/test/resources/transactions/v2-ecdsa/multi-payment-with-vendor-field-sign.json new file mode 100644 index 00000000..a0138200 --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/multi-payment-with-vendor-field-sign.json @@ -0,0 +1,28 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 6, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "10000000", + "amount": "0", + "vendorField": "this is a top secret vendor field", + "asset": { + "payments": [ + { + "amount": "1", + "recipientId": "AHXtmB84sTZ9Zd35h9Y1vfFvPE2Xzqj8ri" + }, + { + "amount": "2", + "recipientId": "AZFEPTWnn2Sn8wDZgCRF8ohwKkrmk2AZi1" + } + ] + }, + "signature": "304402205d6a667239481f9306f37b35976626a39993b1088ee8ff2dee638905590c9508022040aa06bce7d20146c179d1106f29a821aa7278816e1f77f325e02caec3129565", + "id": "7bd4861b168d903500ecf15503804c9625f0eb0d86d350e3f0b73765f6ce2c7c" + }, + "serialized": "ff02170100000006000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed19280969800000000002174686973206973206120746f70207365637265742076656e646f72206669656c640200010000000000000017134b5be4b327ddf9c2bb47fec8a1a44189e90f74020000000000000017bfa6aec83cf1bd03a0cab9f35c85ff51a3e9f041304402205d6a667239481f9306f37b35976626a39993b1088ee8ff2dee638905590c9508022040aa06bce7d20146c179d1106f29a821aa7278816e1f77f325e02caec3129565" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/second-signature-registration.json b/src/test/resources/transactions/v2-ecdsa/second-signature-registration.json new file mode 100644 index 00000000..359f9fbe --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/second-signature-registration.json @@ -0,0 +1,20 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 1, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "500000000", + "amount": "0", + "asset": { + "signature": { + "publicKey": "03699e966b2525f9088a6941d8d94f7869964a000efe65783d78ac82e1199fe609" + } + }, + "signature": "f9a1e2244c8318e8be85482fc02659e5c1775d246d73d5d0699ae4a1d5e3a3e84f9dcf68ee015f943d2a82eb829f35abd7901279761d96f6b43431520e955c67", + "id": "173a3230159b45d772b2e0348f42af53913bf3e376397f29b8e0bda290badbe4" + }, + "serialized": "ff02170100000001000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed1920065cd1d000000000003699e966b2525f9088a6941d8d94f7869964a000efe65783d78ac82e1199fe609f9a1e2244c8318e8be85482fc02659e5c1775d246d73d5d0699ae4a1d5e3a3e84f9dcf68ee015f943d2a82eb829f35abd7901279761d96f6b43431520e955c67" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/test.json b/src/test/resources/transactions/v2-ecdsa/test.json new file mode 100644 index 00000000..bb8810f0 --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/test.json @@ -0,0 +1,7 @@ +{ + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "signSignature": "0220261eaacb731cf386d5439e651fb2068ab59cb9ea2503d4a522f2da299870b3ae", + "signature": "022068ecfe918717a0890ae0480045d526a7f14f163377e5e6dc4ce3bdd70c20cf75", + "id": "93ddabea6c2c7761ecf4ee3ec988e1d971cffedf2363c5b06bc3ba29f3b48931", + } +} diff --git a/src/test/resources/transactions/v2-ecdsa/transfer-multiSign.json b/src/test/resources/transactions/v2-ecdsa/transfer-multiSign.json new file mode 100644 index 00000000..19a6a8bb --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/transfer-multiSign.json @@ -0,0 +1,17 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 0, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "10000000", + "amount": "200000000", + "expiration": 0, + "recipientId": "AGeYmgbg2LgGxRW2vNNJvQ88PknEJsYizC", + "signature": "3045022100af4741f03fdc64f0d6ed1dc69ecc77a000532ec1e3e30b9eb72d74eec404b25a0220437850da2e15b672e7ce55277b716770b99b3db995921cd2c69debafbcf22170", + "id": "9b038513f4dd77507da8a71d0204e491324d49f4598fe41f6c6985baae7d3517" + }, + "serialized": "ff02170100000000000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed19280969800000000000000c2eb0b0000000000000000170995750207ecaf0ccf251c1265b92ad84f5536623045022100af4741f03fdc64f0d6ed1dc69ecc77a000532ec1e3e30b9eb72d74eec404b25a0220437850da2e15b672e7ce55277b716770b99b3db995921cd2c69debafbcf22170" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/transfer-secondSign.json b/src/test/resources/transactions/v2-ecdsa/transfer-secondSign.json new file mode 100644 index 00000000..d385c749 --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/transfer-secondSign.json @@ -0,0 +1,18 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 0, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "10000000", + "amount": "200000000", + "expiration": 0, + "recipientId": "AGeYmgbg2LgGxRW2vNNJvQ88PknEJsYizC", + "signature": "3045022100af4741f03fdc64f0d6ed1dc69ecc77a000532ec1e3e30b9eb72d74eec404b25a0220437850da2e15b672e7ce55277b716770b99b3db995921cd2c69debafbcf22170", + "secondSignature": "3045022100a85e21b1014113abafabd3b04023cb8a2fbb782f76094a34ed1f4e107b2ded67022040bf517fcb5102a214bd6af98bbad126de2103c63b1099e41da30ae239c95d16", + "id": "c12582cfa32281459cb2cf42c7b87e2f2b27eb2e05caceffd40f6c096c8ef792" + }, + "serialized": "ff02170100000000000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed19280969800000000000000c2eb0b0000000000000000170995750207ecaf0ccf251c1265b92ad84f5536623045022100af4741f03fdc64f0d6ed1dc69ecc77a000532ec1e3e30b9eb72d74eec404b25a0220437850da2e15b672e7ce55277b716770b99b3db995921cd2c69debafbcf221703045022100a85e21b1014113abafabd3b04023cb8a2fbb782f76094a34ed1f4e107b2ded67022040bf517fcb5102a214bd6af98bbad126de2103c63b1099e41da30ae239c95d16" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/transfer-sign.json b/src/test/resources/transactions/v2-ecdsa/transfer-sign.json new file mode 100644 index 00000000..19a6a8bb --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/transfer-sign.json @@ -0,0 +1,17 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 0, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "10000000", + "amount": "200000000", + "expiration": 0, + "recipientId": "AGeYmgbg2LgGxRW2vNNJvQ88PknEJsYizC", + "signature": "3045022100af4741f03fdc64f0d6ed1dc69ecc77a000532ec1e3e30b9eb72d74eec404b25a0220437850da2e15b672e7ce55277b716770b99b3db995921cd2c69debafbcf22170", + "id": "9b038513f4dd77507da8a71d0204e491324d49f4598fe41f6c6985baae7d3517" + }, + "serialized": "ff02170100000000000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed19280969800000000000000c2eb0b0000000000000000170995750207ecaf0ccf251c1265b92ad84f5536623045022100af4741f03fdc64f0d6ed1dc69ecc77a000532ec1e3e30b9eb72d74eec404b25a0220437850da2e15b672e7ce55277b716770b99b3db995921cd2c69debafbcf22170" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/transfer-with-vendor-field-multiSign.json b/src/test/resources/transactions/v2-ecdsa/transfer-with-vendor-field-multiSign.json new file mode 100644 index 00000000..27a9e3ab --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/transfer-with-vendor-field-multiSign.json @@ -0,0 +1,18 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 0, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "10000000", + "amount": "200000000", + "vendorField": "this is a top secret vendor field", + "expiration": 0, + "recipientId": "AGeYmgbg2LgGxRW2vNNJvQ88PknEJsYizC", + "signature": "3045022100ef3a6127cfc4336be5f92c6133ea46d180eb90a526d7de2359f1f39ba4624ee30220718f4d2f2edb62a44d14a1c661d08d7454b55ecbe66160d0dfd7dd06e7b343a8", + "id": "0ad296322bfb656490b2d7a5dfc1fd88f840d412c4c8467ddba9890134647659" + }, + "serialized": "ff02170100000000000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed19280969800000000002174686973206973206120746f70207365637265742076656e646f72206669656c6400c2eb0b0000000000000000170995750207ecaf0ccf251c1265b92ad84f5536623045022100ef3a6127cfc4336be5f92c6133ea46d180eb90a526d7de2359f1f39ba4624ee30220718f4d2f2edb62a44d14a1c661d08d7454b55ecbe66160d0dfd7dd06e7b343a8" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/transfer-with-vendor-field-secondSign.json b/src/test/resources/transactions/v2-ecdsa/transfer-with-vendor-field-secondSign.json new file mode 100644 index 00000000..7152c7a8 --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/transfer-with-vendor-field-secondSign.json @@ -0,0 +1,19 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 0, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "10000000", + "amount": "200000000", + "vendorField": "this is a top secret vendor field", + "expiration": 0, + "recipientId": "AGeYmgbg2LgGxRW2vNNJvQ88PknEJsYizC", + "signature": "3045022100ef3a6127cfc4336be5f92c6133ea46d180eb90a526d7de2359f1f39ba4624ee30220718f4d2f2edb62a44d14a1c661d08d7454b55ecbe66160d0dfd7dd06e7b343a8", + "secondSignature": "3045022100e3879d1998844ec4a101d9e52bb73d89257fd19142926ff341ce3d8d51925ad302203e26c1413180a6a7a7ebe04c2ec2d2087e7205b18e58bf69c6fe75067939c51a", + "id": "e7268723a7917a421abe00d8731fb1924be7f11e1f4c8f68964b537dcf6b5f37" + }, + "serialized": "ff02170100000000000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed19280969800000000002174686973206973206120746f70207365637265742076656e646f72206669656c6400c2eb0b0000000000000000170995750207ecaf0ccf251c1265b92ad84f5536623045022100ef3a6127cfc4336be5f92c6133ea46d180eb90a526d7de2359f1f39ba4624ee30220718f4d2f2edb62a44d14a1c661d08d7454b55ecbe66160d0dfd7dd06e7b343a83045022100e3879d1998844ec4a101d9e52bb73d89257fd19142926ff341ce3d8d51925ad302203e26c1413180a6a7a7ebe04c2ec2d2087e7205b18e58bf69c6fe75067939c51a" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/transfer-with-vendor-field-sign.json b/src/test/resources/transactions/v2-ecdsa/transfer-with-vendor-field-sign.json new file mode 100644 index 00000000..27a9e3ab --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/transfer-with-vendor-field-sign.json @@ -0,0 +1,18 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 0, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "10000000", + "amount": "200000000", + "vendorField": "this is a top secret vendor field", + "expiration": 0, + "recipientId": "AGeYmgbg2LgGxRW2vNNJvQ88PknEJsYizC", + "signature": "3045022100ef3a6127cfc4336be5f92c6133ea46d180eb90a526d7de2359f1f39ba4624ee30220718f4d2f2edb62a44d14a1c661d08d7454b55ecbe66160d0dfd7dd06e7b343a8", + "id": "0ad296322bfb656490b2d7a5dfc1fd88f840d412c4c8467ddba9890134647659" + }, + "serialized": "ff02170100000000000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed19280969800000000002174686973206973206120746f70207365637265742076656e646f72206669656c6400c2eb0b0000000000000000170995750207ecaf0ccf251c1265b92ad84f5536623045022100ef3a6127cfc4336be5f92c6133ea46d180eb90a526d7de2359f1f39ba4624ee30220718f4d2f2edb62a44d14a1c661d08d7454b55ecbe66160d0dfd7dd06e7b343a8" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/unvote-multiSign.json b/src/test/resources/transactions/v2-ecdsa/unvote-multiSign.json new file mode 100644 index 00000000..251ab2af --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/unvote-multiSign.json @@ -0,0 +1,20 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 3, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "100000000", + "amount": "0", + "asset": { + "votes": [ + "-022cca9529ec97a772156c152a00aad155ee6708243e65c9d211a589cb5d43234d" + ] + }, + "signature": "3045022100b3d67da287f35bb4f5ae28239cef8b5e82581f8030fe374c0ed86223d66b11bb02200a1ef45b603f70265a7437411565d9d577265452250bf279477f05b09feb5776", + "id": "cbfcca4f96dece8446c355052eb0aab2af82a526c0e4412140b865bc6336fc0e" + }, + "serialized": "ff02170100000003000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed19200e1f50500000000000100022cca9529ec97a772156c152a00aad155ee6708243e65c9d211a589cb5d43234d3045022100b3d67da287f35bb4f5ae28239cef8b5e82581f8030fe374c0ed86223d66b11bb02200a1ef45b603f70265a7437411565d9d577265452250bf279477f05b09feb5776" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/unvote-secondSign.json b/src/test/resources/transactions/v2-ecdsa/unvote-secondSign.json new file mode 100644 index 00000000..d309512d --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/unvote-secondSign.json @@ -0,0 +1,21 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 3, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "100000000", + "amount": "0", + "asset": { + "votes": [ + "-022cca9529ec97a772156c152a00aad155ee6708243e65c9d211a589cb5d43234d" + ] + }, + "signature": "3045022100b3d67da287f35bb4f5ae28239cef8b5e82581f8030fe374c0ed86223d66b11bb02200a1ef45b603f70265a7437411565d9d577265452250bf279477f05b09feb5776", + "secondSignature": "3045022100955a00393e7f22397f36e76e39046375dcc9b4e853050a921a904981453a8da8022049175702a8be7de15afcccf3feab568352fe3a2355357495691a1bf6a7a26d13", + "id": "40e0640fe655b1a119051a9ed205a95a32dc95d31354375147e20e57d37161c1" + }, + "serialized": "ff02170100000003000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed19200e1f50500000000000100022cca9529ec97a772156c152a00aad155ee6708243e65c9d211a589cb5d43234d3045022100b3d67da287f35bb4f5ae28239cef8b5e82581f8030fe374c0ed86223d66b11bb02200a1ef45b603f70265a7437411565d9d577265452250bf279477f05b09feb57763045022100955a00393e7f22397f36e76e39046375dcc9b4e853050a921a904981453a8da8022049175702a8be7de15afcccf3feab568352fe3a2355357495691a1bf6a7a26d13" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/unvote-sign.json b/src/test/resources/transactions/v2-ecdsa/unvote-sign.json new file mode 100644 index 00000000..251ab2af --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/unvote-sign.json @@ -0,0 +1,20 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 3, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "100000000", + "amount": "0", + "asset": { + "votes": [ + "-022cca9529ec97a772156c152a00aad155ee6708243e65c9d211a589cb5d43234d" + ] + }, + "signature": "3045022100b3d67da287f35bb4f5ae28239cef8b5e82581f8030fe374c0ed86223d66b11bb02200a1ef45b603f70265a7437411565d9d577265452250bf279477f05b09feb5776", + "id": "cbfcca4f96dece8446c355052eb0aab2af82a526c0e4412140b865bc6336fc0e" + }, + "serialized": "ff02170100000003000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed19200e1f50500000000000100022cca9529ec97a772156c152a00aad155ee6708243e65c9d211a589cb5d43234d3045022100b3d67da287f35bb4f5ae28239cef8b5e82581f8030fe374c0ed86223d66b11bb02200a1ef45b603f70265a7437411565d9d577265452250bf279477f05b09feb5776" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/vote-multiSign.json b/src/test/resources/transactions/v2-ecdsa/vote-multiSign.json new file mode 100644 index 00000000..dd68ea89 --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/vote-multiSign.json @@ -0,0 +1,20 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 3, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "100000000", + "amount": "0", + "asset": { + "votes": [ + "+022cca9529ec97a772156c152a00aad155ee6708243e65c9d211a589cb5d43234d" + ] + }, + "signature": "304402206a7a9baa573ab08bb4220450ace0d73ac9c768ef38b07a82ca19b2e2f11d0b550220665938431da66ad0b49e2267d65b220c59a35e1fea50083d45560a544f077eb6", + "id": "b8dce941db9d3b04a7afd142fc26e40ecc73f2865fbc84597dca9b907f9791f6" + }, + "serialized": "ff02170100000003000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed19200e1f50500000000000101022cca9529ec97a772156c152a00aad155ee6708243e65c9d211a589cb5d43234d304402206a7a9baa573ab08bb4220450ace0d73ac9c768ef38b07a82ca19b2e2f11d0b550220665938431da66ad0b49e2267d65b220c59a35e1fea50083d45560a544f077eb6" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/vote-secondSign.json b/src/test/resources/transactions/v2-ecdsa/vote-secondSign.json new file mode 100644 index 00000000..43e4a41f --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/vote-secondSign.json @@ -0,0 +1,21 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 3, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "100000000", + "amount": "0", + "asset": { + "votes": [ + "+022cca9529ec97a772156c152a00aad155ee6708243e65c9d211a589cb5d43234d" + ] + }, + "signature": "304402206a7a9baa573ab08bb4220450ace0d73ac9c768ef38b07a82ca19b2e2f11d0b550220665938431da66ad0b49e2267d65b220c59a35e1fea50083d45560a544f077eb6", + "secondSignature": "30450221009d26b579f96e92f4dde323c380769e94d359b6a6455d959dfae49bf1bdea7b5b02207d433fcf262d6552f7edc22ac9141e15e3a7dc379b84ddb61af458ee14b0f0bb", + "id": "dd5bbb65a9d72609ab7c813e2fc7bc03ec3b0adf803a8ddfb42fd788497fbaa4" + }, + "serialized": "ff02170100000003000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed19200e1f50500000000000101022cca9529ec97a772156c152a00aad155ee6708243e65c9d211a589cb5d43234d304402206a7a9baa573ab08bb4220450ace0d73ac9c768ef38b07a82ca19b2e2f11d0b550220665938431da66ad0b49e2267d65b220c59a35e1fea50083d45560a544f077eb630450221009d26b579f96e92f4dde323c380769e94d359b6a6455d959dfae49bf1bdea7b5b02207d433fcf262d6552f7edc22ac9141e15e3a7dc379b84ddb61af458ee14b0f0bb" +} \ No newline at end of file diff --git a/src/test/resources/transactions/v2-ecdsa/vote-sign.json b/src/test/resources/transactions/v2-ecdsa/vote-sign.json new file mode 100644 index 00000000..dd68ea89 --- /dev/null +++ b/src/test/resources/transactions/v2-ecdsa/vote-sign.json @@ -0,0 +1,20 @@ +{ + "data": { + "version": 2, + "network": 23, + "typeGroup": 1, + "type": 3, + "nonce": "1", + "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", + "fee": "100000000", + "amount": "0", + "asset": { + "votes": [ + "+022cca9529ec97a772156c152a00aad155ee6708243e65c9d211a589cb5d43234d" + ] + }, + "signature": "304402206a7a9baa573ab08bb4220450ace0d73ac9c768ef38b07a82ca19b2e2f11d0b550220665938431da66ad0b49e2267d65b220c59a35e1fea50083d45560a544f077eb6", + "id": "b8dce941db9d3b04a7afd142fc26e40ecc73f2865fbc84597dca9b907f9791f6" + }, + "serialized": "ff02170100000003000100000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed19200e1f50500000000000101022cca9529ec97a772156c152a00aad155ee6708243e65c9d211a589cb5d43234d304402206a7a9baa573ab08bb4220450ace0d73ac9c768ef38b07a82ca19b2e2f11d0b550220665938431da66ad0b49e2267d65b220c59a35e1fea50083d45560a544f077eb6" +} \ No newline at end of file