@@ -84,45 +84,38 @@ Handle<Value> convert_blob_bb(const Arguments& args) {
8484 return scope.Close (buff->handle_ );
8585}
8686
87- Handle<Value> check_address (const Arguments& args) {
87+ Handle<Value> address_decode (const Arguments& args) {
8888 HandleScope scope;
8989
90- if (args.Length () < 2 )
91- return except (" You must provide two arguments ." );
90+ if (args.Length () < 1 )
91+ return except (" You must provide one argument ." );
9292
9393 Local<Object> target = args[0 ]->ToObject ();
9494
9595 if (!Buffer::HasInstance (target))
96- return except (" First argument should be a buffer object." );
97-
98- if (!args[1 ]->IsNumber ())
99- return except (" Second argument should be an unsigned integer number." );
96+ return except (" Argument should be a buffer object." );
10097
10198 blobdata input = std::string (Buffer::Data (target), Buffer::Length (target));
102- Local<Number> expected_prefix = Number::New (args[1 ]->NumberValue ());
10399
104100 blobdata data;
105101 uint64_t prefix;
106102 if (!tools::base58::decode_addr (input, prefix, data))
107- return scope.Close (Boolean::New (false ));
108-
109- if (static_cast <uint64_t >(llround (expected_prefix->NumberValue ())) != prefix)
110- return scope.Close (Boolean::New (false ));
103+ return scope.Close (Undefined ());
111104
112105 account_public_address adr;
113106 if (!::serialization::parse_binary (data, adr))
114- return scope.Close (Boolean::New ( false ));
107+ return scope.Close (Undefined ( ));
115108
116- // if (!crypto::check_key(adr.m_spend_public_key) || !crypto::check_key(adr.m_view_public_key))
117- // return scope.Close(Boolean::New(false ));
109+ if (!crypto::check_key (adr.m_spend_public_key ) || !crypto::check_key (adr.m_view_public_key ))
110+ return scope.Close (Undefined ( ));
118111
119- return scope.Close (Boolean ::New (true ));
112+ return scope.Close (Integer ::New (static_cast < uint32_t >(prefix) ));
120113}
121114
122115void init (Handle<Object> exports) {
123116 exports->Set (String::NewSymbol (" convert_blob" ), FunctionTemplate::New (convert_blob)->GetFunction ());
124117 exports->Set (String::NewSymbol (" convert_blob_bb" ), FunctionTemplate::New (convert_blob_bb)->GetFunction ());
125- exports->Set (String::NewSymbol (" check_address " ), FunctionTemplate::New (check_address )->GetFunction ());
118+ exports->Set (String::NewSymbol (" address_decode " ), FunctionTemplate::New (address_decode )->GetFunction ());
126119}
127120
128121NODE_MODULE (cryptonote, init)
0 commit comments