diff --git a/src/bitcoindjs.cc b/src/bitcoindjs.cc index a8c99739..7ed2b4f1 100644 --- a/src/bitcoindjs.cc +++ b/src/bitcoindjs.cc @@ -2980,7 +2980,7 @@ NAN_METHOD(WalletGetAccountAddress) { } if (strAccount == EMPTY) { - return NanThrowError("No account provided."); + return NanThrowError("No account name provided."); } std::string ret = GetAccountAddress(strAccount).ToString(); @@ -3194,7 +3194,7 @@ NAN_METHOD(WalletSetRecipient) { } if (strAccount == EMPTY) { - return NanThrowError("No account provided."); + return NanThrowError("No account name provided."); } CTxDestination address = CBitcoinAddress(addr).Get(); @@ -3802,7 +3802,7 @@ NAN_METHOD(WalletGetBalance) { Local options = Local::Cast(args[0]); - std::string strAccount = ""; + std::string strAccount = std::string(EMPTY); int nMinDepth = 1; if (options->Get(NanNew("account"))->IsString()) { @@ -3824,6 +3824,10 @@ NAN_METHOD(WalletGetBalance) { nMinDepth = options->Get(NanNew("nMinDepth"))->IntegerValue(); } + if (strAccount == EMPTY) { + return NanThrowError("No account name provided."); + } + if (strAccount == "*") { // Calculate total balance a different way from GetBalance() // (GetBalance() sums up all unspent TxOuts) @@ -4662,14 +4666,28 @@ NAN_METHOD(WalletImportKey) { } std::string strSecret = ""; - std::string strLabel = ""; + std::string strAccount = std::string(EMPTY); String::Utf8Value key_(options->Get(NanNew("key"))->ToString()); strSecret = std::string(*key_); + if (options->Get(NanNew("account"))->IsString()) { + String::Utf8Value label_(options->Get(NanNew("account"))->ToString()); + strAccount = std::string(*label_); + } + if (options->Get(NanNew("label"))->IsString()) { String::Utf8Value label_(options->Get(NanNew("label"))->ToString()); - strLabel = std::string(*label_); + strAccount = std::string(*label_); + } + + if (options->Get(NanNew("name"))->IsString()) { + String::Utf8Value label_(options->Get(NanNew("name"))->ToString()); + strAccount = std::string(*label_); + } + + if (strAccount == EMPTY) { + return NanThrowError("No account name provided."); } // Call to: EnsureWalletIsUnlocked() @@ -4700,7 +4718,7 @@ NAN_METHOD(WalletImportKey) { LOCK2(cs_main, pwalletMain->cs_wallet); pwalletMain->MarkDirty(); - pwalletMain->SetAddressBook(vchAddress, strLabel, "receive"); + pwalletMain->SetAddressBook(vchAddress, strAccount, "receive"); // Don't throw error in case a key is already there if (pwalletMain->HaveKey(vchAddress)) {