From 5227c71f55b40952f705454216c8f8fe9e6c9a9e Mon Sep 17 00:00:00 2001 From: tubedev2000 Date: Tue, 16 Jun 2020 16:54:18 -0400 Subject: [PATCH] bittube 4 support --- src/crypto/hash.h | 4 ++++ src/cryptonote_config.h | 1 + src/cryptonote_core/cryptonote_basic.h | 4 +++- src/cryptonote_core/cryptonote_format_utils.cpp | 4 ++-- src/main.cc | 6 ++++++ src/serialization/crypto.h | 2 ++ 6 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/crypto/hash.h b/src/crypto/hash.h index a69782c7..a228d6db 100644 --- a/src/crypto/hash.h +++ b/src/crypto/hash.h @@ -20,6 +20,10 @@ namespace crypto { public: uint32_t data[32]; }; + POD_CLASS cycle40 { + public: + uint32_t data[40]; + }; POD_CLASS hash { char data[HASH_SIZE]; }; diff --git a/src/cryptonote_config.h b/src/cryptonote_config.h index 21f9d466..341e5265 100644 --- a/src/cryptonote_config.h +++ b/src/cryptonote_config.h @@ -13,4 +13,5 @@ enum BLOB_TYPE { BLOB_TYPE_AEON = 7, // Aeon BLOB_TYPE_CRYPTONOTE_CUCKOO = 8, // MoneroV / Swap BLOB_TYPE_CRYPTONOTE_XTNC = 9, // XTNC + BLOB_TYPE_CRYPTONOTE_TUBE = 10, // bittube }; diff --git a/src/cryptonote_core/cryptonote_basic.h b/src/cryptonote_core/cryptonote_basic.h index acd54771..40007114 100644 --- a/src/cryptonote_core/cryptonote_basic.h +++ b/src/cryptonote_core/cryptonote_basic.h @@ -432,13 +432,14 @@ namespace cryptonote uint64_t nonce; uint64_t nonce8; crypto::cycle cycle; + crypto::cycle40 cycle40; BEGIN_SERIALIZE() VARINT_FIELD(major_version) VARINT_FIELD(minor_version) if (blob_type != BLOB_TYPE_FORKNOTE2) VARINT_FIELD(timestamp) FIELD(prev_id) - if (blob_type == BLOB_TYPE_CRYPTONOTE_CUCKOO) FIELD(nonce8) + if (blob_type == BLOB_TYPE_CRYPTONOTE_CUCKOO || blob_type == BLOB_TYPE_CRYPTONOTE_TUBE) FIELD(nonce8) if (blob_type != BLOB_TYPE_FORKNOTE2) { if (blob_type == BLOB_TYPE_AEON) { FIELD(nonce) @@ -450,6 +451,7 @@ namespace cryptonote } } if (blob_type == BLOB_TYPE_CRYPTONOTE_XTNC || blob_type == BLOB_TYPE_CRYPTONOTE_CUCKOO) FIELD(cycle) + if (blob_type == BLOB_TYPE_CRYPTONOTE_TUBE) FIELD(cycle40) END_SERIALIZE() }; diff --git a/src/cryptonote_core/cryptonote_format_utils.cpp b/src/cryptonote_core/cryptonote_format_utils.cpp index 3ee70907..05a5376d 100644 --- a/src/cryptonote_core/cryptonote_format_utils.cpp +++ b/src/cryptonote_core/cryptonote_format_utils.cpp @@ -429,7 +429,7 @@ namespace cryptonote //--------------------------------------------------------------- bool get_block_hashing_blob(const block& b, blobdata& blob) { - if (b.blob_type == BLOB_TYPE_CRYPTONOTE_XTNC || b.blob_type == BLOB_TYPE_CRYPTONOTE_CUCKOO) { + if (b.blob_type == BLOB_TYPE_CRYPTONOTE_XTNC || b.blob_type == BLOB_TYPE_CRYPTONOTE_CUCKOO || b.blob_type == BLOB_TYPE_CRYPTONOTE_TUBE) { blob = t_serializable_object_to_blob(b.major_version); blob.append(reinterpret_cast(&b.minor_version), sizeof(b.minor_version)); blob.append(reinterpret_cast(&b.timestamp), sizeof(b.timestamp)); @@ -444,7 +444,7 @@ namespace cryptonote if (b.blob_type == BLOB_TYPE_CRYPTONOTE3) { blob.append(reinterpret_cast(&b.uncle), sizeof(b.uncle)); } - if (b.blob_type == BLOB_TYPE_CRYPTONOTE_CUCKOO) { + if (b.blob_type == BLOB_TYPE_CRYPTONOTE_CUCKOO || b.blob_type == BLOB_TYPE_CRYPTONOTE_TUBE) { blob.append(reinterpret_cast(&b.nonce8), sizeof(b.nonce8)); } return true; diff --git a/src/main.cc b/src/main.cc index 49e485f5..6d85fade 100644 --- a/src/main.cc +++ b/src/main.cc @@ -225,6 +225,12 @@ NAN_METHOD(construct_block_blob) { // (parentBlockTemplateBuffer, nonceBuffer, c for (int i = 0; i < 32; i++ ) b.cycle.data[i] = cycle->Get(isolate->GetCurrentContext(), i).ToLocalChecked()->NumberValue(isolate->GetCurrentContext()).ToChecked(); } + if (blob_type == BLOB_TYPE_CRYPTONOTE_TUBE) { + if (info.Length() != 4) return THROW_ERROR_EXCEPTION("You must provide 4 arguments."); + Local cycle = Local::Cast(info[3]); + for (int i = 0; i < 40; i++ ) b.cycle40.data[i] = cycle->Get(isolate->GetCurrentContext(), i).ToLocalChecked()->NumberValue(isolate->GetCurrentContext()).ToChecked(); + } + if (!block_to_blob(b, output)) return THROW_ERROR_EXCEPTION("Failed to convert block to blob"); v8::Local returnValue = Nan::CopyBuffer((char*)output.data(), output.size()).ToLocalChecked(); diff --git a/src/serialization/crypto.h b/src/serialization/crypto.h index fa38ddba..a5d3f56e 100644 --- a/src/serialization/crypto.h +++ b/src/serialization/crypto.h @@ -54,6 +54,7 @@ bool do_serialize(Archive &ar, std::vector &v) BLOB_SERIALIZER(crypto::chacha8_iv); BLOB_SERIALIZER(crypto::hash); BLOB_SERIALIZER(crypto::cycle); +BLOB_SERIALIZER(crypto::cycle40); BLOB_SERIALIZER(crypto::hash8); BLOB_SERIALIZER(crypto::public_key); BLOB_SERIALIZER(crypto::secret_key); @@ -61,6 +62,7 @@ BLOB_SERIALIZER(crypto::key_derivation); BLOB_SERIALIZER(crypto::key_image); BLOB_SERIALIZER(crypto::signature); VARIANT_TAG(debug_archive, crypto::cycle, "cycle"); +VARIANT_TAG(debug_archive, crypto::cycle40, "cycle40"); VARIANT_TAG(debug_archive, crypto::hash, "hash"); VARIANT_TAG(debug_archive, crypto::hash8, "hash8"); VARIANT_TAG(debug_archive, crypto::public_key, "public_key");