Merge pull request #3 from nmateo/master

fix build binding missing files, std=c++17, update v8::value::toObject() for node 14
This commit is contained in:
cryptozoidberg 2024-04-26 15:42:49 +02:00 committed by GitHub
commit 2d1e03a9fd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 53 additions and 31 deletions

View file

@ -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",
"<!(node -e \"require('nan')\")"
],
"link_settings": {
@ -51,7 +55,7 @@
"-fno-rtti"
],
"cflags_cc": [
"-std=c++0x",
"-std=c++17",
"-fexceptions",
"-frtti"
],
@ -68,4 +72,5 @@
]
}
]
}
}

51
main.cc
View file

@ -1,4 +1,3 @@
#include <node.h>
#include <node_buffer.h>
#include <v8.h>
@ -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<Integer> returnValue = Nan::New(static_cast<uint32_t>(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<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.");
@ -71,8 +76,8 @@ void address_decode(const Nan::FunctionCallbackInfo<v8::Value>& info) {
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.");
@ -112,9 +117,9 @@ void address_decode(const Nan::FunctionCallbackInfo<v8::Value>& 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<v8::Value>& args) {
if (args.Length() < 3)
return THROW_ERROR_EXCEPTION("You must provide 3 arguments.");
Local<Object> block_header_hash = args[0]->ToObject();
Local<Object> nonce = args[1]->ToObject();
Local<Object> height = args[2]->ToObject();
v8::Isolate *isolate = v8::Isolate::GetCurrent();
Local<Object> block_header_hash = args[0]->ToObject(isolate->GetCurrentContext()).ToLocalChecked();
//Local<Object> nonce = args[1]->ToObject();
Local<Object> nonce = args[1]->ToObject(isolate->GetCurrentContext()).ToLocalChecked();
//Local<Object> height = args[2]->ToObject();
Local<Object> 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<v8:
if (args.Length() < 2)
return THROW_ERROR_EXCEPTION("You must provide 2 arguments.");
Local<Object> block_template_buffer = args[0]->ToObject();
Local<Object> extra_data = args[1]->ToObject();
v8::Isolate *isolate = v8::Isolate::GetCurrent();
Local<Object> block_template_buffer = args[0]->ToObject(isolate->GetCurrentContext()).ToLocalChecked();
//Local<Object> extra_data = args[1]->ToObject();
Local<Object> 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<v8::Value>& ar
if (args.Length() < 3)
return THROW_ERROR_EXCEPTION("You must provide 3 arguments.");
Local<Object> block_template_buffer = args[0]->ToObject();
Local<Object> extra_data = args[1]->ToObject();
Local<Object> nonce = args[2]->ToObject();
v8::Isolate *isolate = v8::Isolate::GetCurrent();
Local<Object> block_template_buffer = args[0]->ToObject(isolate->GetCurrentContext()).ToLocalChecked();
//Local<Object> extra_data = args[1]->ToObject();
Local<Object> extra_data = args[1]->ToObject(isolate->GetCurrentContext()).ToLocalChecked();
//Local<Object> nonce = args[2]->ToObject();
Local<Object> nonce = args[2]->ToObject(isolate->GetCurrentContext()).ToLocalChecked();
if (!Buffer::HasInstance(block_template_buffer))
@ -266,8 +282,8 @@ void get_id_hash(const Nan::FunctionCallbackInfo<v8::Value>& args) {
if (args.Length() < 1)
return THROW_ERROR_EXCEPTION("You must provide 2 arguments.");
Local<Object> block_buffer = args[0]->ToObject();
v8::Isolate *isolate = v8::Isolate::GetCurrent();
Local<Object> block_buffer = args[0]->ToObject(isolate->GetCurrentContext()).ToLocalChecked();
if (!Buffer::HasInstance(block_buffer))
@ -295,8 +311,8 @@ void is_address_valid(const Nan::FunctionCallbackInfo<v8::Value>& info)
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.");
@ -323,6 +339,7 @@ NAN_MODULE_INIT(init) {
Nan::Set(target, Nan::New("get_blob_from_block_template").ToLocalChecked(), Nan::GetFunction(Nan::New<FunctionTemplate>(get_blob_from_block_template)).ToLocalChecked());
Nan::Set(target, Nan::New("get_id_hash").ToLocalChecked(), Nan::GetFunction(Nan::New<FunctionTemplate>(get_id_hash)).ToLocalChecked());
Nan::Set(target, Nan::New("is_address_valid").ToLocalChecked(), Nan::GetFunction(Nan::New<FunctionTemplate>(is_address_valid)).ToLocalChecked());
Nan::Set(target, Nan::New("get_merged_mining_nonce_size").ToLocalChecked(), Nan::GetFunction(Nan::New<FunctionTemplate>(get_merged_mining_nonce_size)).ToLocalChecked());
}
NODE_MODULE(cryptonote, init)