@@ -205,47 +205,40 @@ Handle<Value> convert_blob_bb(const Arguments& args) {
205205 return scope.Close (buff->handle_ );
206206}
207207
208- Handle<Value> check_address (const Arguments& args) {
208+ Handle<Value> address_decode (const Arguments& args) {
209209 HandleScope scope;
210210
211- if (args.Length () < 2 )
212- return except (" You must provide two arguments ." );
211+ if (args.Length () < 1 )
212+ return except (" You must provide one argument ." );
213213
214214 Local<Object> target = args[0 ]->ToObject ();
215215
216216 if (!Buffer::HasInstance (target))
217- return except (" First argument should be a buffer object." );
218-
219- if (!args[1 ]->IsNumber ())
220- return except (" Second argument should be an unsigned integer number." );
217+ return except (" Argument should be a buffer object." );
221218
222219 blobdata input = std::string (Buffer::Data (target), Buffer::Length (target));
223- Local<Number> expected_prefix = Number::New (args[1 ]->NumberValue ());
224220
225221 blobdata data;
226222 uint64_t prefix;
227223 if (!tools::base58::decode_addr (input, prefix, data))
228- return scope.Close (Boolean::New (false ));
229-
230- if (static_cast <uint64_t >(llround (expected_prefix->NumberValue ())) != prefix)
231- return scope.Close (Boolean::New (false ));
224+ return scope.Close (Undefined ());
232225
233226 account_public_address adr;
234227 if (!::serialization::parse_binary (data, adr))
235- return scope.Close (Boolean::New ( false ));
228+ return scope.Close (Undefined ( ));
236229
237- // if (!crypto::check_key(adr.m_spend_public_key) || !crypto::check_key(adr.m_view_public_key))
238- // return scope.Close(Boolean::New(false ));
230+ if (!crypto::check_key (adr.m_spend_public_key ) || !crypto::check_key (adr.m_view_public_key ))
231+ return scope.Close (Undefined ( ));
239232
240- return scope.Close (Boolean ::New (true ));
233+ return scope.Close (Integer ::New (static_cast < uint32_t >(prefix) ));
241234}
242235
243236void init (Handle<Object> exports) {
244237 exports->Set (String::NewSymbol (" construct_block_blob" ), FunctionTemplate::New (construct_block_blob)->GetFunction ());
245238 exports->Set (String::NewSymbol (" get_block_id" ), FunctionTemplate::New (get_block_id)->GetFunction ());
246239 exports->Set (String::NewSymbol (" convert_blob" ), FunctionTemplate::New (convert_blob)->GetFunction ());
247240 exports->Set (String::NewSymbol (" convert_blob_bb" ), FunctionTemplate::New (convert_blob_bb)->GetFunction ());
248- exports->Set (String::NewSymbol (" check_address " ), FunctionTemplate::New (check_address )->GetFunction ());
241+ exports->Set (String::NewSymbol (" address_decode " ), FunctionTemplate::New (address_decode )->GetFunction ());
249242}
250243
251244NODE_MODULE (cryptonote, init)
0 commit comments