diff --git a/binding.gyp b/binding.gyp index 612d74b5..50b9802a 100644 --- a/binding.gyp +++ b/binding.gyp @@ -6,6 +6,9 @@ "src/main.cc", "src/cryptonote_core/cryptonote_format_utils.cpp", "src/crypto/tree-hash.c", + "src/crypto/crypto.cpp", + "src/crypto/crypto-ops.c", + "src/crypto/crypto-ops-data.c", "src/crypto/hash.c", "src/crypto/keccak.c", "src/common/base58.cpp", diff --git a/src/main.cc b/src/main.cc index 0e507824..abd62c15 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,3 +1,4 @@ +#include #include #include #include @@ -10,6 +11,7 @@ #include "crypto/crypto.h" #include "crypto/hash.h" #include "common/base58.h" +#include "serialization/binary_utils.h" using namespace node; using namespace v8; @@ -94,17 +96,20 @@ Handle address_decode(const Arguments& args) { return except("Argument should be a buffer object."); blobdata input = std::string(Buffer::Data(target), Buffer::Length(target)); - blobdata output = ""; + blobdata data; uint64_t prefix; + if (!tools::base58::decode_addr(input, prefix, data)) + return scope.Close(Undefined()); - tools::base58::decode_addr(input, prefix, output); - - if(output.length()) - output = uint64be_to_blob(prefix) + output; + account_public_address adr; + if (!::serialization::parse_binary(data, adr)) + return scope.Close(Undefined()); - Buffer* buff = Buffer::New(output.data(), output.size()); - return scope.Close(buff->handle_); + if (!crypto::check_key(adr.m_spend_public_key) || !crypto::check_key(adr.m_view_public_key)) + return scope.Close(Undefined()); + + return scope.Close(Integer::New(static_cast(prefix))); } void init(Handle exports) {