Compare commits

...

15 Commits

Author SHA1 Message Date
MoneroOcean 72a565e915 Merge pull request #12 from BitTubeCash/master
bittube 4 support
2020-06-16 15:15:25 -07:00
tubedev2000 5227c71f55 bittube 4 support 2020-06-16 16:54:18 -04:00
MoneroOcean fa902cffee Merge pull request #11 from bomb-on/master
Update binding.gyp
2020-05-23 12:16:18 -07:00
bomb-on ff900741ab Update binding.gyp 2020-05-21 18:07:22 +00:00
MoneroOcean b47f6475ac Fix for v12 2020-04-24 12:46:49 -07:00
MoneroOcean 219a850c97 Merge pull request #9 from swap-dev/master
Node v12 compatibility
2020-01-05 23:22:51 +01:00
xmvdev f3cc70cc01 node v12 build fix 2020-01-05 04:00:11 +00:00
xmvdev c9d115445d Merge pull request #1 from MoneroOcean/master
merge upstream
2020-01-05 04:46:41 +01:00
MoneroOcean a0461cad63 Fixed XTNC support 2020-01-04 01:19:12 -08:00
MoneroOcean 70420dede1 Fixed XTNC support 2020-01-04 01:17:00 -08:00
MoneroOcean 77ec592672 Fixed XTNC support 2020-01-03 22:54:32 -08:00
MoneroOcean 9451fed838 Fixed XTNC support 2020-01-03 22:54:07 -08:00
MoneroOcean 61fecb0757 Added c29 support 2019-12-24 11:49:51 -08:00
xmvdev af767856f0 monerov support 2019-12-23 06:18:07 +00:00
MoneroOcean 02d48ecc72 Aeon support 2019-10-25 17:22:31 -07:00
8 changed files with 93 additions and 30 deletions
+1
View File
@@ -16,6 +16,7 @@
"include_dirs": [
"src",
"src/contrib/epee/include",
"/usr/local/opt/boost/include",
"<!(node -e \"require('nan')\")",
],
"link_settings": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "cryptoforknote-util",
"version": "5.0.0",
"version": "7.0.2",
"main": "cryptoforknote-util",
"author": {
"name": "LucasJones",
+8
View File
@@ -16,6 +16,14 @@ namespace crypto {
}
#pragma pack(push, 1)
POD_CLASS cycle {
public:
uint32_t data[32];
};
POD_CLASS cycle40 {
public:
uint32_t data[40];
};
POD_CLASS hash {
char data[HASH_SIZE];
};
+11 -7
View File
@@ -3,11 +3,15 @@
#define CURRENT_TRANSACTION_VERSION 1
enum BLOB_TYPE {
BLOB_TYPE_CRYPTONOTE = 0,
BLOB_TYPE_FORKNOTE1 = 1,
BLOB_TYPE_FORKNOTE2 = 2,
BLOB_TYPE_CRYPTONOTE2 = 3, // Masari
BLOB_TYPE_CRYPTONOTE_RYO = 4, // Ryo
BLOB_TYPE_CRYPTONOTE_LOKI = 5, // Loki
BLOB_TYPE_CRYPTONOTE3 = 6, // Masari
BLOB_TYPE_CRYPTONOTE = 0,
BLOB_TYPE_FORKNOTE1 = 1,
BLOB_TYPE_FORKNOTE2 = 2,
BLOB_TYPE_CRYPTONOTE2 = 3, // Masari
BLOB_TYPE_CRYPTONOTE_RYO = 4, // Ryo
BLOB_TYPE_CRYPTONOTE_LOKI = 5, // Loki
BLOB_TYPE_CRYPTONOTE3 = 6, // Masari
BLOB_TYPE_AEON = 7, // Aeon
BLOB_TYPE_CRYPTONOTE_CUCKOO = 8, // MoneroV / Swap
BLOB_TYPE_CRYPTONOTE_XTNC = 9, // XTNC
BLOB_TYPE_CRYPTONOTE_TUBE = 10, // bittube
};
+20 -5
View File
@@ -184,7 +184,7 @@ namespace cryptonote
BEGIN_SERIALIZE()
VARINT_FIELD(version)
if (version > loki_version_2 && blob_type == BLOB_TYPE_CRYPTONOTE_LOKI)
if (version > loki_version_2 && (blob_type == BLOB_TYPE_CRYPTONOTE_LOKI || blob_type == BLOB_TYPE_CRYPTONOTE_XTNC))
{
FIELD(output_unlock_times)
if (version == loki_version_3_per_output_unlock_times)
@@ -193,12 +193,12 @@ namespace cryptonote
VARINT_FIELD(unlock_time)
FIELD(vin)
FIELD(vout)
if (blob_type == BLOB_TYPE_CRYPTONOTE_LOKI)
if (blob_type == BLOB_TYPE_CRYPTONOTE_LOKI || blob_type == BLOB_TYPE_CRYPTONOTE_XTNC)
{
if (version >= loki_version_3_per_output_unlock_times && vout.size() != output_unlock_times.size()) return false;
}
FIELD(extra)
if (blob_type == BLOB_TYPE_CRYPTONOTE_LOKI && version >= loki_version_4_tx_types)
if ((blob_type == BLOB_TYPE_CRYPTONOTE_LOKI || blob_type == BLOB_TYPE_CRYPTONOTE_XTNC) && version >= loki_version_4_tx_types)
{
VARINT_FIELD(type)
if (static_cast<uint16_t>(type) >= loki_type_count) return false;
@@ -429,14 +429,29 @@ namespace cryptonote
uint8_t minor_version;
uint64_t timestamp;
crypto::hash prev_id;
uint32_t nonce;
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_FORKNOTE2) FIELD(nonce)
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)
} else {
uint32_t nonce32;
if (typename Archive<W>::is_saving()) nonce32 = (uint32_t)nonce;
FIELD_N("nonce", nonce32);
if (!typename Archive<W>::is_saving()) nonce = nonce32;
}
}
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()
};
@@ -429,13 +429,24 @@ namespace cryptonote
//---------------------------------------------------------------
bool get_block_hashing_blob(const block& b, blobdata& blob)
{
blob = t_serializable_object_to_blob(static_cast<const block_header&>(b));
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<const char*>(&b.minor_version), sizeof(b.minor_version));
blob.append(reinterpret_cast<const char*>(&b.timestamp), sizeof(b.timestamp));
blob.append(reinterpret_cast<const char*>(&b.prev_id), sizeof(b.prev_id));
}
else {
blob = t_serializable_object_to_blob(static_cast<const block_header&>(b));
}
crypto::hash tree_root_hash = get_tx_tree_hash(b);
blob.append(reinterpret_cast<const char*>(&tree_root_hash), sizeof(tree_root_hash));
blob.append(tools::get_varint_data(b.tx_hashes.size()+1));
if (b.blob_type == BLOB_TYPE_CRYPTONOTE3) {
blob.append(reinterpret_cast<const char*>(&b.uncle), sizeof(b.uncle));
}
if (b.blob_type == BLOB_TYPE_CRYPTONOTE_CUCKOO || b.blob_type == BLOB_TYPE_CRYPTONOTE_TUBE) {
blob.append(reinterpret_cast<const char*>(&b.nonce8), sizeof(b.nonce8));
}
return true;
}
//---------------------------------------------------------------
+36 -16
View File
@@ -130,7 +130,8 @@ static bool construct_parent_block(const cryptonote::block& b, cryptonote::block
NAN_METHOD(convert_blob) { // (parentBlockBuffer, cnBlobType)
if (info.Length() < 1) return THROW_ERROR_EXCEPTION("You must provide one argument.");
Local<Object> target = info[0]->ToObject();
v8::Isolate *isolate = v8::Isolate::GetCurrent();
Local<Object> target = info[0]->ToObject(isolate->GetCurrentContext()).ToLocalChecked();
if (!Buffer::HasInstance(target)) return THROW_ERROR_EXCEPTION("Argument should be a buffer object.");
blobdata input = std::string(Buffer::Data(target), Buffer::Length(target));
@@ -161,7 +162,8 @@ NAN_METHOD(convert_blob) { // (parentBlockBuffer, cnBlobType)
NAN_METHOD(get_block_id) {
if (info.Length() < 1) return THROW_ERROR_EXCEPTION("You must provide one argument.");
Local<Object> target = info[0]->ToObject();
v8::Isolate *isolate = v8::Isolate::GetCurrent();
Local<Object> target = info[0]->ToObject(isolate->GetCurrentContext()).ToLocalChecked();
if (!Buffer::HasInstance(target)) return THROW_ERROR_EXCEPTION("Argument should be a buffer object.");
blobdata input = std::string(Buffer::Data(target), Buffer::Length(target));
@@ -187,15 +189,11 @@ NAN_METHOD(get_block_id) {
NAN_METHOD(construct_block_blob) { // (parentBlockTemplateBuffer, nonceBuffer, cnBlobType)
if (info.Length() < 2) return THROW_ERROR_EXCEPTION("You must provide two arguments.");
Local<Object> block_template_buf = info[0]->ToObject();
Local<Object> nonce_buf = info[1]->ToObject();
v8::Isolate *isolate = v8::Isolate::GetCurrent();
Local<Object> block_template_buf = info[0]->ToObject(isolate->GetCurrentContext()).ToLocalChecked();
Local<Object> nonce_buf = info[1]->ToObject(isolate->GetCurrentContext()).ToLocalChecked();
if (!Buffer::HasInstance(block_template_buf) || !Buffer::HasInstance(nonce_buf)) return THROW_ERROR_EXCEPTION("Both arguments should be buffer objects.");
if (Buffer::Length(nonce_buf) != 4) return THROW_ERROR_EXCEPTION("Nonce buffer has invalid size.");
uint32_t nonce = *reinterpret_cast<uint32_t*>(Buffer::Data(nonce_buf));
blobdata block_template_blob = std::string(Buffer::Data(block_template_buf), Buffer::Length(block_template_buf));
blobdata output = "";
enum BLOB_TYPE blob_type = BLOB_TYPE_CRYPTONOTE;
if (info.Length() >= 3) {
@@ -203,6 +201,12 @@ NAN_METHOD(construct_block_blob) { // (parentBlockTemplateBuffer, nonceBuffer, c
blob_type = static_cast<enum BLOB_TYPE>(Nan::To<int>(info[2]).FromMaybe(0));
}
if (Buffer::Length(nonce_buf) != (blob_type == BLOB_TYPE_AEON ? 8 : 4)) return THROW_ERROR_EXCEPTION("Nonce buffer has invalid size.");
uint64_t nonce = blob_type == BLOB_TYPE_AEON ? *reinterpret_cast<uint64_t*>(Buffer::Data(nonce_buf)) : *reinterpret_cast<uint32_t*>(Buffer::Data(nonce_buf));
blobdata block_template_blob = std::string(Buffer::Data(block_template_buf), Buffer::Length(block_template_buf));
blobdata output = "";
block b = AUTO_VAL_INIT(b);
b.set_blob_type(blob_type);
if (!parse_and_validate_block_from_blob(block_template_blob, b)) return THROW_ERROR_EXCEPTION("Failed to parse block");
@@ -215,6 +219,18 @@ NAN_METHOD(construct_block_blob) { // (parentBlockTemplateBuffer, nonceBuffer, c
if (!mergeBlocks(parent_block, b, std::vector<crypto::hash>())) return THROW_ERROR_EXCEPTION("Failed to postprocess mining block");
}
if (blob_type == BLOB_TYPE_CRYPTONOTE_XTNC || blob_type == BLOB_TYPE_CRYPTONOTE_CUCKOO) {
if (info.Length() != 4) return THROW_ERROR_EXCEPTION("You must provide 4 arguments.");
Local<Array> cycle = Local<Array>::Cast(info[3]);
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<Array> cycle = Local<Array>::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<v8::Value> returnValue = Nan::CopyBuffer((char*)output.data(), output.size()).ToLocalChecked();
@@ -224,7 +240,8 @@ NAN_METHOD(construct_block_blob) { // (parentBlockTemplateBuffer, nonceBuffer, c
NAN_METHOD(address_decode) {
if (info.Length() < 1) return THROW_ERROR_EXCEPTION("You must provide one argument.");
Local<Object> target = info[0]->ToObject();
v8::Isolate *isolate = v8::Isolate::GetCurrent();
Local<Object> target = info[0]->ToObject(isolate->GetCurrentContext()).ToLocalChecked();
if (!Buffer::HasInstance(target)) return THROW_ERROR_EXCEPTION("Argument should be a buffer object.");
@@ -254,7 +271,8 @@ NAN_METHOD(address_decode) {
NAN_METHOD(address_decode_integrated) {
if (info.Length() < 1) return THROW_ERROR_EXCEPTION("You must provide one argument.");
Local<Object> target = info[0]->ToObject();
v8::Isolate *isolate = v8::Isolate::GetCurrent();
Local<Object> target = info[0]->ToObject(isolate->GetCurrentContext()).ToLocalChecked();
if (!Buffer::HasInstance(target)) return THROW_ERROR_EXCEPTION("Argument should be a buffer object.");
@@ -289,8 +307,9 @@ NAN_METHOD(get_merged_mining_nonce_size) {
NAN_METHOD(construct_mm_parent_block_blob) { // (parentBlockTemplate, blob_type, childBlockTemplate)
if (info.Length() < 3) return THROW_ERROR_EXCEPTION("You must provide three arguments (parentBlock, blob_type, childBlock).");
Local<Object> target = info[0]->ToObject();
Local<Object> child_target = info[2]->ToObject();
v8::Isolate *isolate = v8::Isolate::GetCurrent();
Local<Object> target = info[0]->ToObject(isolate->GetCurrentContext()).ToLocalChecked();
Local<Object> child_target = info[2]->ToObject(isolate->GetCurrentContext()).ToLocalChecked();
if (!Buffer::HasInstance(target)) return THROW_ERROR_EXCEPTION("First argument should be a buffer object.");
if (!info[1]->IsNumber()) return THROW_ERROR_EXCEPTION("Second argument should be a number");
@@ -304,7 +323,7 @@ NAN_METHOD(construct_mm_parent_block_blob) { // (parentBlockTemplate, blob_type,
block b = AUTO_VAL_INIT(b);
b.set_blob_type(blob_type);
if (!parse_and_validate_block_from_blob(input, b)) return THROW_ERROR_EXCEPTION("construct_mm_parent_block_blob: Failed to parse prent block");
if (blob_type == BLOB_TYPE_CRYPTONOTE_LOKI) b.miner_tx.version = cryptonote::loki_version_2;
if (blob_type == BLOB_TYPE_CRYPTONOTE_LOKI || blob_type == BLOB_TYPE_CRYPTONOTE_XTNC) b.miner_tx.version = cryptonote::loki_version_2;
block b2 = AUTO_VAL_INIT(b2);
b2.set_blob_type(BLOB_TYPE_FORKNOTE2);
@@ -322,8 +341,9 @@ NAN_METHOD(construct_mm_parent_block_blob) { // (parentBlockTemplate, blob_type,
NAN_METHOD(construct_mm_child_block_blob) { // (shareBuffer, blob_type, childBlockTemplate)
if (info.Length() < 3) return THROW_ERROR_EXCEPTION("You must provide three arguments (shareBuffer, blob_type, block2).");
Local<Object> block_template_buf = info[0]->ToObject();
Local<Object> child_block_template_buf = info[2]->ToObject();
v8::Isolate *isolate = v8::Isolate::GetCurrent();
Local<Object> block_template_buf = info[0]->ToObject(isolate->GetCurrentContext()).ToLocalChecked();
Local<Object> child_block_template_buf = info[2]->ToObject(isolate->GetCurrentContext()).ToLocalChecked();
if (!Buffer::HasInstance(block_template_buf)) return THROW_ERROR_EXCEPTION("First argument should be a buffer object.");
if (!info[1]->IsNumber()) return THROW_ERROR_EXCEPTION("Second argument should be a number");
+4
View File
@@ -53,12 +53,16 @@ bool do_serialize(Archive<true> &ar, std::vector<crypto::signature> &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);
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");