fix build errors. improve GetRecipients().
This commit is contained in:
parent
9f5ac9ae40
commit
20301e4f4f
|
@ -360,10 +360,7 @@ Bitcoin.prototype.getRecipients = function(options) {
|
|||
Bitcoin.prototype.getRecipient = function(options) {
|
||||
options = options || {};
|
||||
var label = options.label || label;
|
||||
var recipients = bitcoindjs.getRecipients(options);
|
||||
return recipients.filter(function(recipient) {
|
||||
return recipient.label === label;
|
||||
})[0];
|
||||
return bitcoindjs.getRecipients({ _label: label });
|
||||
};
|
||||
|
||||
Bitcoin.prototype.setRecipient = function(options) {
|
||||
|
|
|
@ -1487,6 +1487,8 @@ NAN_METHOD(GetRecipients) {
|
|||
"Usage: bitcoindjs.getRecipients(options)");
|
||||
}
|
||||
|
||||
Local<Object> options = Local<Object>::Cast(args[0]);
|
||||
|
||||
Local<Array> array = NanNew<Array>();
|
||||
int i = 0;
|
||||
|
||||
|
@ -1495,13 +1497,20 @@ NAN_METHOD(GetRecipients) {
|
|||
const string& strName = item.second.name;
|
||||
if (item.second.purpose == "send" && address.IsValid()) {
|
||||
Local<Object> recipient = NanNew<Object>();
|
||||
recipient->Set(NanNew<String>("label"), strName);
|
||||
recipient->Set(NanNew<String>("address"), address.ToString());
|
||||
recipient->Set(NanNew<String>("label"), NanNew<String>(strName));
|
||||
recipient->Set(NanNew<String>("address"), NanNew<String>(address.ToString()));
|
||||
array->Set(i, recipient);
|
||||
i++;
|
||||
if (options->Get(NanNew<String>("_label"))->IsString()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (options->Get(NanNew<String>("_label"))->IsString()) {
|
||||
NanReturnValue(array->Get(0));
|
||||
}
|
||||
|
||||
NanReturnValue(array);
|
||||
}
|
||||
|
||||
|
@ -1519,6 +1528,8 @@ NAN_METHOD(SetRecipient) {
|
|||
"Usage: bitcoindjs.setRecipient(options)");
|
||||
}
|
||||
|
||||
Local<Object> options = Local<Object>::Cast(args[0]);
|
||||
|
||||
String::Utf8Value addr_(options->Get(NanNew<String>("address"))->ToString());
|
||||
std::string addr = std::string(*addr_);
|
||||
|
||||
|
@ -1546,6 +1557,8 @@ NAN_METHOD(RemoveRecipient) {
|
|||
"Usage: bitcoindjs.removeRecipient(options)");
|
||||
}
|
||||
|
||||
Local<Object> options = Local<Object>::Cast(args[0]);
|
||||
|
||||
String::Utf8Value addr_(options->Get(NanNew<String>("address"))->ToString());
|
||||
std::string addr = std::string(*addr_);
|
||||
|
||||
|
|
Loading…
Reference in New Issue