diff --git a/binding.gyp b/binding.gyp index e29cfdd..3d36a97 100644 --- a/binding.gyp +++ b/binding.gyp @@ -11,29 +11,33 @@ "Zano/src/crypto/tree-hash.c", "Zano/src/crypto/crypto.cpp", "Zano/src/crypto/crypto-ops.c", + "Zano/src/crypto/crypto-sugar.cpp", + "Zano/src/crypto/zarcanum.cpp", + "Zano/src/crypto/range_proofs.cpp", "Zano/src/crypto/crypto-ops-data.c", "Zano/src/crypto/hash.c", "Zano/src/crypto/keccak.c", "Zano/src/common/base58.cpp", - "Zano/src/contrib/ethereum/libethash/ethash.cpp", - "Zano/src/contrib/ethereum/libethash/keccak.c", - "Zano/src/contrib/ethereum/libethash/keccakf800.c", - "Zano/src/contrib/ethereum/libethash/progpow.cpp", - "Zano/src/contrib/ethereum/libethash/managed.cpp", + "Zano/contrib/ethereum/libethash/ethash.cpp", + "Zano/contrib/ethereum/libethash/keccak.c", + "Zano/contrib/ethereum/libethash/keccakf800.c", + "Zano/contrib/ethereum/libethash/progpow.cpp", + "Zano/contrib/ethereum/libethash/managed.cpp", "Zano/src/currency_core/currency_format_utils_transactions.cpp", "Zano/src/currency_core/genesis.cpp", "Zano/src/currency_core/genesis_acc.cpp", "Zano/src/crypto/random.c", - "Zano/src/contrib/ethereum/libethash/keccakf1600.c", - "Zano/src/contrib/ethereum/libethash/managed.cpp", - "Zano/src/contrib/ethereum/libethash/primes.c" + "Zano/contrib/ethereum/libethash/keccakf1600.c", + "Zano/contrib/ethereum/libethash/managed.cpp", + "Zano/contrib/ethereum/libethash/primes.c" ], "include_dirs": [ + "Zano/src/crypto", "Zano/src", - "Zano/src/contrib", - "Zano/src/contrib/epee/include", - "Zano/src/contrib/eos_portable_archive", - "Zano/src/contrib/ethereum/libethash", + "Zano/contrib", + "Zano/contrib/epee/include", + "Zano/contrib/eos_portable_archive", + "Zano/contrib/ethereum/libethash", " #include #include @@ -38,14 +37,20 @@ blobdata uint64be_to_blob(uint64_t num) { return res; } +const size_t MM_NONCE_SIZE = 1 + 2 + sizeof(crypto::hash); +NAN_METHOD(get_merged_mining_nonce_size) { + Local returnValue = Nan::New(static_cast(MM_NONCE_SIZE)); + info.GetReturnValue().Set(returnValue); +} NAN_METHOD(convert_blob) { if (info.Length() < 1) return THROW_ERROR_EXCEPTION("You must provide one argument."); - Local target = info[0]->ToObject(); + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + Local target = info[0]->ToObject(isolate->GetCurrentContext()).ToLocalChecked(); if (!Buffer::HasInstance(target)) return THROW_ERROR_EXCEPTION("Argument should be a buffer object."); @@ -71,8 +76,8 @@ void address_decode(const Nan::FunctionCallbackInfo& info) { if (info.Length() < 1) return THROW_ERROR_EXCEPTION("You must provide one argument."); - - Local target = info[0]->ToObject(); + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + Local target = info[0]->ToObject(isolate->GetCurrentContext()).ToLocalChecked(); if (!Buffer::HasInstance(target)) return THROW_ERROR_EXCEPTION("Argument should be a buffer object."); @@ -112,9 +117,9 @@ void address_decode(const Nan::FunctionCallbackInfo& info) { } #define SET_BUFFER_RETURN(x, len) \ - v8::Isolate* isolate = args.GetIsolate(); \ args.GetReturnValue().Set(Buffer::Copy(isolate, x, len).ToLocalChecked()); + /* Arguments: 1: block_header_hash - 32-byte buffer @@ -126,10 +131,14 @@ void get_pow_hash(const Nan::FunctionCallbackInfo& args) { if (args.Length() < 3) return THROW_ERROR_EXCEPTION("You must provide 3 arguments."); - Local block_header_hash = args[0]->ToObject(); - Local nonce = args[1]->ToObject(); - Local height = args[2]->ToObject(); + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + Local block_header_hash = args[0]->ToObject(isolate->GetCurrentContext()).ToLocalChecked(); + //Local nonce = args[1]->ToObject(); + Local nonce = args[1]->ToObject(isolate->GetCurrentContext()).ToLocalChecked(); + + //Local height = args[2]->ToObject(); + Local height = args[2]->ToObject(isolate->GetCurrentContext()).ToLocalChecked(); if(!Buffer::HasInstance(block_header_hash)) return THROW_ERROR_EXCEPTION("Argument 1 should be a buffer object."); @@ -172,9 +181,11 @@ void get_hash_from_block_template_with_extra(const Nan::FunctionCallbackInfo block_template_buffer = args[0]->ToObject(); - Local extra_data = args[1]->ToObject(); + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + Local block_template_buffer = args[0]->ToObject(isolate->GetCurrentContext()).ToLocalChecked(); + //Local extra_data = args[1]->ToObject(); + Local extra_data = args[1]->ToObject(isolate->GetCurrentContext()).ToLocalChecked(); if (!Buffer::HasInstance(block_template_buffer)) return THROW_ERROR_EXCEPTION("Argument 1 should be a buffer object."); @@ -215,9 +226,14 @@ void get_blob_from_block_template(const Nan::FunctionCallbackInfo& ar if (args.Length() < 3) return THROW_ERROR_EXCEPTION("You must provide 3 arguments."); - Local block_template_buffer = args[0]->ToObject(); - Local extra_data = args[1]->ToObject(); - Local nonce = args[2]->ToObject(); + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + Local block_template_buffer = args[0]->ToObject(isolate->GetCurrentContext()).ToLocalChecked(); + + //Local extra_data = args[1]->ToObject(); + Local extra_data = args[1]->ToObject(isolate->GetCurrentContext()).ToLocalChecked(); + + //Local nonce = args[2]->ToObject(); + Local nonce = args[2]->ToObject(isolate->GetCurrentContext()).ToLocalChecked(); if (!Buffer::HasInstance(block_template_buffer)) @@ -266,8 +282,8 @@ void get_id_hash(const Nan::FunctionCallbackInfo& args) { if (args.Length() < 1) return THROW_ERROR_EXCEPTION("You must provide 2 arguments."); - - Local block_buffer = args[0]->ToObject(); + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + Local block_buffer = args[0]->ToObject(isolate->GetCurrentContext()).ToLocalChecked(); if (!Buffer::HasInstance(block_buffer)) @@ -295,8 +311,8 @@ void is_address_valid(const Nan::FunctionCallbackInfo& info) if (info.Length() < 1) return THROW_ERROR_EXCEPTION("You must provide one argument."); - Local target = info[0]->ToObject(); - + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + Local target = info[0]->ToObject(isolate->GetCurrentContext()).ToLocalChecked(); if (!Buffer::HasInstance(target)) return THROW_ERROR_EXCEPTION("Argument should be a buffer object."); @@ -323,6 +339,7 @@ NAN_MODULE_INIT(init) { Nan::Set(target, Nan::New("get_blob_from_block_template").ToLocalChecked(), Nan::GetFunction(Nan::New(get_blob_from_block_template)).ToLocalChecked()); Nan::Set(target, Nan::New("get_id_hash").ToLocalChecked(), Nan::GetFunction(Nan::New(get_id_hash)).ToLocalChecked()); Nan::Set(target, Nan::New("is_address_valid").ToLocalChecked(), Nan::GetFunction(Nan::New(is_address_valid)).ToLocalChecked()); + Nan::Set(target, Nan::New("get_merged_mining_nonce_size").ToLocalChecked(), Nan::GetFunction(Nan::New(get_merged_mining_nonce_size)).ToLocalChecked()); } NODE_MODULE(cryptonote, init)