Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
19 changes: 12 additions & 7 deletions src/main.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <cmath>
#include <node.h>
#include <node_buffer.h>
#include <v8.h>
Expand All @@ -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;
Expand Down Expand Up @@ -94,17 +96,20 @@ Handle<Value> 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<uint32_t>(prefix)));
}

void init(Handle<Object> exports) {
Expand Down