aboutsummaryrefslogtreecommitdiff
path: root/src/rpc.cpp
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2011-07-02 16:46:07 -0400
committerJeff Garzik <jgarzik@pobox.com>2011-07-02 16:46:07 -0400
commita76899624ab4987dab7ca81d5ed22af140482d42 (patch)
tree6a36c5573151f4a6e5bba7c39e4e05380ded8a02 /src/rpc.cpp
parent1a19fc17b27e72991265a7a28c4f818d36820e43 (diff)
parent4d410cfce967a42cca7db13288b72baec29423d1 (diff)
Merge branch 'tmp2' into tmp3
Diffstat (limited to 'src/rpc.cpp')
-rw-r--r--src/rpc.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/rpc.cpp b/src/rpc.cpp
index 780209920e..6f951b7431 100644
--- a/src/rpc.cpp
+++ b/src/rpc.cpp
@@ -332,12 +332,15 @@ Value getnewaddress(const Array& params, bool fHelp)
// Generate a new key that is added to wallet
string strAddress = PubKeyToAddress(pwalletMain->GetKeyFromKeyPool());
- pwalletMain->SetAddressBookName(strAddress, strAccount);
+ // This could be done in the same main CS as GetKeyFromKeyPool.
+ CRITICAL_BLOCK(pwalletMain->cs_mapAddressBook)
+ pwalletMain->SetAddressBookName(strAddress, strAccount);
+
return strAddress;
}
-// requires cs_main, cs_mapWallet locks
+// requires cs_main, cs_mapWallet, cs_mapAddressBook locks
string GetAccountAddress(string strAccount, bool bForceNew=false)
{
string strAddress;
@@ -393,6 +396,7 @@ Value getaccountaddress(const Array& params, bool fHelp)
CRITICAL_BLOCK(cs_main)
CRITICAL_BLOCK(pwalletMain->cs_mapWallet)
+ CRITICAL_BLOCK(pwalletMain->cs_mapAddressBook)
{
ret = GetAccountAddress(strAccount);
}
@@ -431,9 +435,10 @@ Value setaccount(const Array& params, bool fHelp)
if (strAddress == GetAccountAddress(strOldAccount))
GetAccountAddress(strOldAccount, true);
}
+
+ pwalletMain->SetAddressBookName(strAddress, strAccount);
}
- pwalletMain->SetAddressBookName(strAddress, strAccount);
return Value::null;
}