Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 72a565e915 | |||
| 5227c71f55 | |||
| fa902cffee | |||
| ff900741ab | |||
| b47f6475ac | |||
| 219a850c97 | |||
| f3cc70cc01 | |||
| c9d115445d |
@@ -16,6 +16,7 @@
|
||||
"include_dirs": [
|
||||
"src",
|
||||
"src/contrib/epee/include",
|
||||
"/usr/local/opt/boost/include",
|
||||
"<!(node -e \"require('nan')\")",
|
||||
],
|
||||
"link_settings": {
|
||||
|
||||
@@ -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];
|
||||
};
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
@@ -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()
|
||||
};
|
||||
|
||||
|
||||
@@ -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<const char*>(&b.minor_version), sizeof(b.minor_version));
|
||||
blob.append(reinterpret_cast<const char*>(&b.timestamp), sizeof(b.timestamp));
|
||||
@@ -444,7 +444,7 @@ namespace cryptonote
|
||||
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) {
|
||||
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;
|
||||
|
||||
+24
-11
@@ -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,8 +189,9 @@ 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.");
|
||||
|
||||
@@ -219,7 +222,13 @@ NAN_METHOD(construct_block_blob) { // (parentBlockTemplateBuffer, nonceBuffer, c
|
||||
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(i)->NumberValue();
|
||||
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");
|
||||
@@ -231,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.");
|
||||
|
||||
@@ -261,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.");
|
||||
|
||||
@@ -296,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");
|
||||
@@ -329,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");
|
||||
|
||||
@@ -54,6 +54,7 @@ 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);
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user