diff --git a/src/Nimiq/Transaction.cpp b/src/Nimiq/Transaction.cpp index e5ba42006fe..9a832240ce6 100644 --- a/src/Nimiq/Transaction.cpp +++ b/src/Nimiq/Transaction.cpp @@ -9,13 +9,14 @@ namespace TW::Nimiq { -const uint8_t NETWORK_ID = 42; +const uint8_t NETWORK_ID = 24; const uint8_t EMPTY_FLAGS = 0; std::vector Transaction::serialize() const { std::vector data; data.push_back(0x00); // Basic TX type + data.push_back(0x00); // Signature Proof type and flags (Ed25519 type and no flags) data.insert(data.end(), sender_pub_key.begin(), sender_pub_key.end()); data.insert(data.end(), destination.bytes.begin(), destination.bytes.end()); encode64BE(amount, data); @@ -42,6 +43,7 @@ std::vector Transaction::getPreImage() const { encode32BE(vsh, data); data.push_back(NETWORK_ID); data.push_back(EMPTY_FLAGS); + data.push_back(0x00); // Sender Data size (+ 0 bytes of data) return data; } diff --git a/swift/Tests/Blockchains/NimiqTests.swift b/swift/Tests/Blockchains/NimiqTests.swift index 8ee8dac51ed..1c89cd6d74c 100644 --- a/swift/Tests/Blockchains/NimiqTests.swift +++ b/swift/Tests/Blockchains/NimiqTests.swift @@ -18,6 +18,6 @@ class NimiqTests: XCTestCase { let output: NimiqSigningOutput = AnySigner.sign(input: input, coin: .nimiq) - XCTAssertEqual(output.encoded.hexString, "0070c7492aaa9c9ac7a05bc0d9c5db2dae9372029654f71f0c7f95deed5099b7021450ffc385cd4e7c6ac9a7e91614ca67ff90568a00000000028182ba00000000000003e80004cb2f2a74dc7f6e0ab58a0bf52cc6e8801b0cca132dd4229d9a3e3a3d2f90e4d8f045d981b771bf5fc3851a98f3c617b1a943228f963e910e061808a721cfa0e3cad50b") + XCTAssertEqual(output.encoded.hexString, "000070c7492aaa9c9ac7a05bc0d9c5db2dae9372029654f71f0c7f95deed5099b7021450ffc385cd4e7c6ac9a7e91614ca67ff90568a00000000028182ba00000000000003e80004cb2f180ba678744be3bf9cd44fbcdabfb5be209f21739934836e26055610ab02720fa99489219d9f3581664473a1b40b30ad1f6e13150d59f8234a42c3f0de3d505405") } } diff --git a/tests/chains/Nimiq/SignerTests.cpp b/tests/chains/Nimiq/SignerTests.cpp index c22441f2f39..e29208e10ec 100644 --- a/tests/chains/Nimiq/SignerTests.cpp +++ b/tests/chains/Nimiq/SignerTests.cpp @@ -37,7 +37,7 @@ TEST(NimiqSigner, Sign) { signer.sign(privateKey, tx); ASSERT_EQ(hex(tx.signature), - "74dc7f6e0ab58a0bf52cc6e8801b0cca132dd4229d9a3e3a3d2f90e4d8f045d981b771bf5fc3851a98f3c617b1a943228f963e910e061808a721cfa0e3cad50b"); + "0ba678744be3bf9cd44fbcdabfb5be209f21739934836e26055610ab02720fa99489219d9f3581664473a1b40b30ad1f6e13150d59f8234a42c3f0de3d505405"); } } // namespace TW::Nimiq diff --git a/tests/chains/Nimiq/TWAnySignerTests.cpp b/tests/chains/Nimiq/TWAnySignerTests.cpp index a618b1ac04f..3d0cb3d9327 100644 --- a/tests/chains/Nimiq/TWAnySignerTests.cpp +++ b/tests/chains/Nimiq/TWAnySignerTests.cpp @@ -25,7 +25,7 @@ TEST(TWAnySignerNimiq, Sign) { Proto::SigningOutput output; ANY_SIGN(input, TWCoinTypeNimiq); - EXPECT_EQ(hex(output.encoded()), "0070c7492aaa9c9ac7a05bc0d9c5db2dae9372029654f71f0c7f95deed5099b7021450ffc385cd4e7c6ac9a7e91614ca67ff90568a00000000028182ba00000000000003e80004cb2f2a74dc7f6e0ab58a0bf52cc6e8801b0cca132dd4229d9a3e3a3d2f90e4d8f045d981b771bf5fc3851a98f3c617b1a943228f963e910e061808a721cfa0e3cad50b"); + EXPECT_EQ(hex(output.encoded()), "000070c7492aaa9c9ac7a05bc0d9c5db2dae9372029654f71f0c7f95deed5099b7021450ffc385cd4e7c6ac9a7e91614ca67ff90568a00000000028182ba00000000000003e80004cb2f180ba678744be3bf9cd44fbcdabfb5be209f21739934836e26055610ab02720fa99489219d9f3581664473a1b40b30ad1f6e13150d59f8234a42c3f0de3d505405"); } } // namespace TW::Nimiq::tests diff --git a/tests/chains/Nimiq/TransactionTests.cpp b/tests/chains/Nimiq/TransactionTests.cpp index 679f955f4ca..90e6381a0e2 100644 --- a/tests/chains/Nimiq/TransactionTests.cpp +++ b/tests/chains/Nimiq/TransactionTests.cpp @@ -25,7 +25,7 @@ TEST(NimiqTransaction, PreImage) { 314159 ); ASSERT_EQ(hex(tx.getPreImage()), - "000082d5f776378ccbe34a3d941f22d4715bc9f81e0d001450ffc385cd4e7c6ac9a7e91614ca67ff90568a0000000000028182ba00000000000003e80004cb2f2a00"); + "000082d5f776378ccbe34a3d941f22d4715bc9f81e0d001450ffc385cd4e7c6ac9a7e91614ca67ff90568a0000000000028182ba00000000000003e80004cb2f180000"); } TEST(NimiqTransaction, Serialize) { @@ -42,11 +42,11 @@ TEST(NimiqTransaction, Serialize) { 314159 ); - const auto signature = parse_hex("74dc7f6e0ab58a0bf52cc6e8801b0cca132dd4229d9a3e3a3d2f90e4d8f045d981b771bf5fc3851a98f3c617b1a943228f963e910e061808a721cfa0e3cad50b"); + const auto signature = parse_hex("0ba678744be3bf9cd44fbcdabfb5be209f21739934836e26055610ab02720fa99489219d9f3581664473a1b40b30ad1f6e13150d59f8234a42c3f0de3d505405"); std::copy(signature.begin(), signature.end(), tx.signature.begin()); ASSERT_EQ(hex(tx.serialize()), - "0070c7492aaa9c9ac7a05bc0d9c5db2dae9372029654f71f0c7f95deed5099b7021450ffc385cd4e7c6ac9a7e91614ca67ff90568a00000000028182ba00000000000003e80004cb2f2a74dc7f6e0ab58a0bf52cc6e8801b0cca132dd4229d9a3e3a3d2f90e4d8f045d981b771bf5fc3851a98f3c617b1a943228f963e910e061808a721cfa0e3cad50b"); + "000070c7492aaa9c9ac7a05bc0d9c5db2dae9372029654f71f0c7f95deed5099b7021450ffc385cd4e7c6ac9a7e91614ca67ff90568a00000000028182ba00000000000003e80004cb2f180ba678744be3bf9cd44fbcdabfb5be209f21739934836e26055610ab02720fa99489219d9f3581664473a1b40b30ad1f6e13150d59f8234a42c3f0de3d505405"); } } // namespace TW::Nimiq