@ -346,21 +346,17 @@ Value getnewaddress(const Array& params, bool fHelp)
CBitcoinAddress address ( pwalletMain - > GetOrReuseKeyFromPool ( ) ) ;
CBitcoinAddress address ( pwalletMain - > GetOrReuseKeyFromPool ( ) ) ;
// This could be done in the same main CS as GetKeyFromKeyPool.
// This could be done in the same main CS as GetKeyFromKeyPool.
CRITICAL_BLOCK ( pwalletMain - > cs_mapAddressBook )
pwalletMain - > SetAddressBookName ( address , strAccount ) ;
pwalletMain - > SetAddressBookName ( address , strAccount ) ;
return address . ToString ( ) ;
return address . ToString ( ) ;
}
}
// requires cs_main, cs_mapWallet, cs_mapAddressBook locks
CBitcoinAddress GetAccountAddress ( string strAccount , bool bForceNew = false )
CBitcoinAddress GetAccountAddress ( string strAccount , bool bForceNew = false )
{
{
CWalletDB walletdb ( pwalletMain - > strWalletFile ) ;
CWalletDB walletdb ( pwalletMain - > strWalletFile ) ;
CAccount account ;
CAccount account ;
CRITICAL_BLOCK ( pwalletMain - > cs_mapAddressBook )
{
walletdb . ReadAccount ( strAccount , account ) ;
walletdb . ReadAccount ( strAccount , account ) ;
bool bKeyUsed = false ;
bool bKeyUsed = false ;
@ -396,7 +392,6 @@ CBitcoinAddress GetAccountAddress(string strAccount, bool bForceNew=false)
walletdb . WriteAccount ( strAccount , account ) ;
walletdb . WriteAccount ( strAccount , account ) ;
}
}
}
}
}
return CBitcoinAddress ( account . vchPubKey ) ;
return CBitcoinAddress ( account . vchPubKey ) ;
}
}
@ -413,12 +408,7 @@ Value getaccountaddress(const Array& params, bool fHelp)
Value ret ;
Value ret ;
CRITICAL_BLOCK ( cs_main )
CRITICAL_BLOCK ( pwalletMain - > cs_mapWallet )
CRITICAL_BLOCK ( pwalletMain - > cs_mapAddressBook )
{
ret = GetAccountAddress ( strAccount ) . ToString ( ) ;
ret = GetAccountAddress ( strAccount ) . ToString ( ) ;
}
return ret ;
return ret ;
}
}
@ -442,10 +432,6 @@ Value setaccount(const Array& params, bool fHelp)
strAccount = AccountFromValue ( params [ 1 ] ) ;
strAccount = AccountFromValue ( params [ 1 ] ) ;
// Detect when changing the account of an address that is the 'unused current key' of another account:
// Detect when changing the account of an address that is the 'unused current key' of another account:
CRITICAL_BLOCK ( cs_main )
CRITICAL_BLOCK ( pwalletMain - > cs_mapWallet )
CRITICAL_BLOCK ( pwalletMain - > cs_mapAddressBook )
{
if ( pwalletMain - > mapAddressBook . count ( address ) )
if ( pwalletMain - > mapAddressBook . count ( address ) )
{
{
string strOldAccount = pwalletMain - > mapAddressBook [ address ] ;
string strOldAccount = pwalletMain - > mapAddressBook [ address ] ;
@ -454,7 +440,6 @@ Value setaccount(const Array& params, bool fHelp)
}
}
pwalletMain - > SetAddressBookName ( address , strAccount ) ;
pwalletMain - > SetAddressBookName ( address , strAccount ) ;
}
return Value : : null ;
return Value : : null ;
}
}
@ -472,12 +457,9 @@ Value getaccount(const Array& params, bool fHelp)
throw JSONRPCError ( - 5 , " Invalid bitcoin address " ) ;
throw JSONRPCError ( - 5 , " Invalid bitcoin address " ) ;
string strAccount ;
string strAccount ;
CRITICAL_BLOCK ( pwalletMain - > cs_mapAddressBook )
{
map < CBitcoinAddress , string > : : iterator mi = pwalletMain - > mapAddressBook . find ( address ) ;
map < CBitcoinAddress , string > : : iterator mi = pwalletMain - > mapAddressBook . find ( address ) ;
if ( mi ! = pwalletMain - > mapAddressBook . end ( ) & & ! ( * mi ) . second . empty ( ) )
if ( mi ! = pwalletMain - > mapAddressBook . end ( ) & & ! ( * mi ) . second . empty ( ) )
strAccount = ( * mi ) . second ;
strAccount = ( * mi ) . second ;
}
return strAccount ;
return strAccount ;
}
}
@ -493,8 +475,6 @@ Value getaddressesbyaccount(const Array& params, bool fHelp)
// Find all addresses that have the given account
// Find all addresses that have the given account
Array ret ;
Array ret ;
CRITICAL_BLOCK ( pwalletMain - > cs_mapAddressBook )
{
BOOST_FOREACH ( const PAIRTYPE ( CBitcoinAddress , string ) & item , pwalletMain - > mapAddressBook )
BOOST_FOREACH ( const PAIRTYPE ( CBitcoinAddress , string ) & item , pwalletMain - > mapAddressBook )
{
{
const CBitcoinAddress & address = item . first ;
const CBitcoinAddress & address = item . first ;
@ -502,7 +482,6 @@ Value getaddressesbyaccount(const Array& params, bool fHelp)
if ( strName = = strAccount )
if ( strName = = strAccount )
ret . push_back ( address . ToString ( ) ) ;
ret . push_back ( address . ToString ( ) ) ;
}
}
}
return ret ;
return ret ;
}
}
@ -548,16 +527,12 @@ Value sendtoaddress(const Array& params, bool fHelp)
if ( params . size ( ) > 3 & & params [ 3 ] . type ( ) ! = null_type & & ! params [ 3 ] . get_str ( ) . empty ( ) )
if ( params . size ( ) > 3 & & params [ 3 ] . type ( ) ! = null_type & & ! params [ 3 ] . get_str ( ) . empty ( ) )
wtx . mapValue [ " to " ] = params [ 3 ] . get_str ( ) ;
wtx . mapValue [ " to " ] = params [ 3 ] . get_str ( ) ;
CRITICAL_BLOCK ( cs_main )
if ( pwalletMain - > IsLocked ( ) )
CRITICAL_BLOCK ( pwalletMain - > cs_vMasterKey )
{
if ( pwalletMain - > IsLocked ( ) )
throw JSONRPCError ( - 13 , " Error: Please enter the wallet passphrase with walletpassphrase first. " ) ;
throw JSONRPCError ( - 13 , " Error: Please enter the wallet passphrase with walletpassphrase first. " ) ;
string strError = pwalletMain - > SendMoneyToBitcoinAddress ( address , nAmount , wtx ) ;
string strError = pwalletMain - > SendMoneyToBitcoinAddress ( address , nAmount , wtx ) ;
if ( strError ! = " " )
if ( strError ! = " " )
throw JSONRPCError ( - 4 , strError ) ;
throw JSONRPCError ( - 4 , strError ) ;
}
return wtx . GetHash ( ) . GetHex ( ) ;
return wtx . GetHash ( ) . GetHex ( ) ;
}
}
@ -586,8 +561,6 @@ Value getreceivedbyaddress(const Array& params, bool fHelp)
// Tally
// Tally
int64 nAmount = 0 ;
int64 nAmount = 0 ;
CRITICAL_BLOCK ( pwalletMain - > cs_mapWallet )
{
for ( map < uint256 , CWalletTx > : : iterator it = pwalletMain - > mapWallet . begin ( ) ; it ! = pwalletMain - > mapWallet . end ( ) ; + + it )
for ( map < uint256 , CWalletTx > : : iterator it = pwalletMain - > mapWallet . begin ( ) ; it ! = pwalletMain - > mapWallet . end ( ) ; + + it )
{
{
const CWalletTx & wtx = ( * it ) . second ;
const CWalletTx & wtx = ( * it ) . second ;
@ -599,7 +572,6 @@ Value getreceivedbyaddress(const Array& params, bool fHelp)
if ( wtx . GetDepthInMainChain ( ) > = nMinDepth )
if ( wtx . GetDepthInMainChain ( ) > = nMinDepth )
nAmount + = txout . nValue ;
nAmount + = txout . nValue ;
}
}
}
return ValueFromAmount ( nAmount ) ;
return ValueFromAmount ( nAmount ) ;
}
}
@ -607,8 +579,6 @@ Value getreceivedbyaddress(const Array& params, bool fHelp)
void GetAccountAddresses ( string strAccount , set < CBitcoinAddress > & setAddress )
void GetAccountAddresses ( string strAccount , set < CBitcoinAddress > & setAddress )
{
{
CRITICAL_BLOCK ( pwalletMain - > cs_mapAddressBook )
{
BOOST_FOREACH ( const PAIRTYPE ( CBitcoinAddress , string ) & item , pwalletMain - > mapAddressBook )
BOOST_FOREACH ( const PAIRTYPE ( CBitcoinAddress , string ) & item , pwalletMain - > mapAddressBook )
{
{
const CBitcoinAddress & address = item . first ;
const CBitcoinAddress & address = item . first ;
@ -616,7 +586,6 @@ void GetAccountAddresses(string strAccount, set<CBitcoinAddress>& setAddress)
if ( strName = = strAccount )
if ( strName = = strAccount )
setAddress . insert ( address ) ;
setAddress . insert ( address ) ;
}
}
}
}
}
@ -639,8 +608,6 @@ Value getreceivedbyaccount(const Array& params, bool fHelp)
// Tally
// Tally
int64 nAmount = 0 ;
int64 nAmount = 0 ;
CRITICAL_BLOCK ( pwalletMain - > cs_mapWallet )
{
for ( map < uint256 , CWalletTx > : : iterator it = pwalletMain - > mapWallet . begin ( ) ; it ! = pwalletMain - > mapWallet . end ( ) ; + + it )
for ( map < uint256 , CWalletTx > : : iterator it = pwalletMain - > mapWallet . begin ( ) ; it ! = pwalletMain - > mapWallet . end ( ) ; + + it )
{
{
const CWalletTx & wtx = ( * it ) . second ;
const CWalletTx & wtx = ( * it ) . second ;
@ -655,7 +622,6 @@ Value getreceivedbyaccount(const Array& params, bool fHelp)
nAmount + = txout . nValue ;
nAmount + = txout . nValue ;
}
}
}
}
}
return ( double ) nAmount / ( double ) COIN ;
return ( double ) nAmount / ( double ) COIN ;
}
}
@ -664,8 +630,7 @@ Value getreceivedbyaccount(const Array& params, bool fHelp)
int64 GetAccountBalance ( CWalletDB & walletdb , const string & strAccount , int nMinDepth )
int64 GetAccountBalance ( CWalletDB & walletdb , const string & strAccount , int nMinDepth )
{
{
int64 nBalance = 0 ;
int64 nBalance = 0 ;
CRITICAL_BLOCK ( pwalletMain - > cs_mapWallet )
{
// Tally wallet transactions
// Tally wallet transactions
for ( map < uint256 , CWalletTx > : : iterator it = pwalletMain - > mapWallet . begin ( ) ; it ! = pwalletMain - > mapWallet . end ( ) ; + + it )
for ( map < uint256 , CWalletTx > : : iterator it = pwalletMain - > mapWallet . begin ( ) ; it ! = pwalletMain - > mapWallet . end ( ) ; + + it )
{
{
@ -683,7 +648,6 @@ int64 GetAccountBalance(CWalletDB& walletdb, const string& strAccount, int nMinD
// Tally internal accounting entries
// Tally internal accounting entries
nBalance + = walletdb . GetAccountCreditDebit ( strAccount ) ;
nBalance + = walletdb . GetAccountCreditDebit ( strAccount ) ;
}
return nBalance ;
return nBalance ;
}
}
@ -763,8 +727,6 @@ Value movecmd(const Array& params, bool fHelp)
if ( params . size ( ) > 4 )
if ( params . size ( ) > 4 )
strComment = params [ 4 ] . get_str ( ) ;
strComment = params [ 4 ] . get_str ( ) ;
CRITICAL_BLOCK ( pwalletMain - > cs_mapWallet )
{
CWalletDB walletdb ( pwalletMain - > strWalletFile ) ;
CWalletDB walletdb ( pwalletMain - > strWalletFile ) ;
walletdb . TxnBegin ( ) ;
walletdb . TxnBegin ( ) ;
@ -789,7 +751,7 @@ Value movecmd(const Array& params, bool fHelp)
walletdb . WriteAccountingEntry ( credit ) ;
walletdb . WriteAccountingEntry ( credit ) ;
walletdb . TxnCommit ( ) ;
walletdb . TxnCommit ( ) ;
}
return true ;
return true ;
}
}
@ -822,11 +784,7 @@ Value sendfrom(const Array& params, bool fHelp)
if ( params . size ( ) > 5 & & params [ 5 ] . type ( ) ! = null_type & & ! params [ 5 ] . get_str ( ) . empty ( ) )
if ( params . size ( ) > 5 & & params [ 5 ] . type ( ) ! = null_type & & ! params [ 5 ] . get_str ( ) . empty ( ) )
wtx . mapValue [ " to " ] = params [ 5 ] . get_str ( ) ;
wtx . mapValue [ " to " ] = params [ 5 ] . get_str ( ) ;
CRITICAL_BLOCK ( cs_main )
if ( pwalletMain - > IsLocked ( ) )
CRITICAL_BLOCK ( pwalletMain - > cs_mapWallet )
CRITICAL_BLOCK ( pwalletMain - > cs_vMasterKey )
{
if ( pwalletMain - > IsLocked ( ) )
throw JSONRPCError ( - 13 , " Error: Please enter the wallet passphrase with walletpassphrase first. " ) ;
throw JSONRPCError ( - 13 , " Error: Please enter the wallet passphrase with walletpassphrase first. " ) ;
// Check funds
// Check funds
@ -838,7 +796,6 @@ Value sendfrom(const Array& params, bool fHelp)
string strError = pwalletMain - > SendMoneyToBitcoinAddress ( address , nAmount , wtx ) ;
string strError = pwalletMain - > SendMoneyToBitcoinAddress ( address , nAmount , wtx ) ;
if ( strError ! = " " )
if ( strError ! = " " )
throw JSONRPCError ( - 4 , strError ) ;
throw JSONRPCError ( - 4 , strError ) ;
}
return wtx . GetHash ( ) . GetHex ( ) ;
return wtx . GetHash ( ) . GetHex ( ) ;
}
}
@ -889,11 +846,7 @@ Value sendmany(const Array& params, bool fHelp)
vecSend . push_back ( make_pair ( scriptPubKey , nAmount ) ) ;
vecSend . push_back ( make_pair ( scriptPubKey , nAmount ) ) ;
}
}
CRITICAL_BLOCK ( cs_main )
if ( pwalletMain - > IsLocked ( ) )
CRITICAL_BLOCK ( pwalletMain - > cs_mapWallet )
CRITICAL_BLOCK ( pwalletMain - > cs_vMasterKey )
{
if ( pwalletMain - > IsLocked ( ) )
throw JSONRPCError ( - 13 , " Error: Please enter the wallet passphrase with walletpassphrase first. " ) ;
throw JSONRPCError ( - 13 , " Error: Please enter the wallet passphrase with walletpassphrase first. " ) ;
// Check funds
// Check funds
@ -913,7 +866,6 @@ Value sendmany(const Array& params, bool fHelp)
}
}
if ( ! pwalletMain - > CommitTransaction ( wtx , keyChange ) )
if ( ! pwalletMain - > CommitTransaction ( wtx , keyChange ) )
throw JSONRPCError ( - 4 , " Transaction commit failed " ) ;
throw JSONRPCError ( - 4 , " Transaction commit failed " ) ;
}
return wtx . GetHash ( ) . GetHex ( ) ;
return wtx . GetHash ( ) . GetHex ( ) ;
}
}
@ -944,8 +896,6 @@ Value ListReceived(const Array& params, bool fByAccounts)
// Tally
// Tally
map < CBitcoinAddress , tallyitem > mapTally ;
map < CBitcoinAddress , tallyitem > mapTally ;
CRITICAL_BLOCK ( pwalletMain - > cs_mapWallet )
{
for ( map < uint256 , CWalletTx > : : iterator it = pwalletMain - > mapWallet . begin ( ) ; it ! = pwalletMain - > mapWallet . end ( ) ; + + it )
for ( map < uint256 , CWalletTx > : : iterator it = pwalletMain - > mapWallet . begin ( ) ; it ! = pwalletMain - > mapWallet . end ( ) ; + + it )
{
{
const CWalletTx & wtx = ( * it ) . second ;
const CWalletTx & wtx = ( * it ) . second ;
@ -967,13 +917,10 @@ Value ListReceived(const Array& params, bool fByAccounts)
item . nConf = min ( item . nConf , nDepth ) ;
item . nConf = min ( item . nConf , nDepth ) ;
}
}
}
}
}
// Reply
// Reply
Array ret ;
Array ret ;
map < string , tallyitem > mapAccountTally ;
map < string , tallyitem > mapAccountTally ;
CRITICAL_BLOCK ( pwalletMain - > cs_mapAddressBook )
{
BOOST_FOREACH ( const PAIRTYPE ( CBitcoinAddress , string ) & item , pwalletMain - > mapAddressBook )
BOOST_FOREACH ( const PAIRTYPE ( CBitcoinAddress , string ) & item , pwalletMain - > mapAddressBook )
{
{
const CBitcoinAddress & address = item . first ;
const CBitcoinAddress & address = item . first ;
@ -1007,7 +954,6 @@ Value ListReceived(const Array& params, bool fByAccounts)
ret . push_back ( obj ) ;
ret . push_back ( obj ) ;
}
}
}
}
}
if ( fByAccounts )
if ( fByAccounts )
{
{
@ -1107,8 +1053,6 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
// Received
// Received
if ( listReceived . size ( ) > 0 & & wtx . GetDepthInMainChain ( ) > = nMinDepth )
if ( listReceived . size ( ) > 0 & & wtx . GetDepthInMainChain ( ) > = nMinDepth )
CRITICAL_BLOCK ( pwalletMain - > cs_mapAddressBook )
{
BOOST_FOREACH ( const PAIRTYPE ( CBitcoinAddress , int64 ) & r , listReceived )
BOOST_FOREACH ( const PAIRTYPE ( CBitcoinAddress , int64 ) & r , listReceived )
{
{
string account ;
string account ;
@ -1126,8 +1070,6 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
ret . push_back ( entry ) ;
ret . push_back ( entry ) ;
}
}
}
}
}
}
}
void AcentryToJSON ( const CAccountingEntry & acentry , const string & strAccount , Array & ret )
void AcentryToJSON ( const CAccountingEntry & acentry , const string & strAccount , Array & ret )
@ -1167,8 +1109,6 @@ Value listtransactions(const Array& params, bool fHelp)
Array ret ;
Array ret ;
CWalletDB walletdb ( pwalletMain - > strWalletFile ) ;
CWalletDB walletdb ( pwalletMain - > strWalletFile ) ;
CRITICAL_BLOCK ( pwalletMain - > cs_mapWallet )
{
// Firs: get all CWalletTx and CAccountingEntry into a sorted-by-time multimap:
// Firs: get all CWalletTx and CAccountingEntry into a sorted-by-time multimap:
typedef pair < CWalletTx * , CAccountingEntry * > TxPair ;
typedef pair < CWalletTx * , CAccountingEntry * > TxPair ;
typedef multimap < int64 , TxPair > TxItems ;
typedef multimap < int64 , TxPair > TxItems ;
@ -1201,7 +1141,6 @@ Value listtransactions(const Array& params, bool fHelp)
if ( ret . size ( ) > = nCount ) break ;
if ( ret . size ( ) > = nCount ) break ;
}
}
// ret is now newest to oldest
// ret is now newest to oldest
}
// Make sure we return only last nCount items (sends-to-self might give us an extra):
// Make sure we return only last nCount items (sends-to-self might give us an extra):
if ( ret . size ( ) > nCount )
if ( ret . size ( ) > nCount )
@ -1227,9 +1166,6 @@ Value listaccounts(const Array& params, bool fHelp)
nMinDepth = params [ 0 ] . get_int ( ) ;
nMinDepth = params [ 0 ] . get_int ( ) ;
map < string , int64 > mapAccountBalances ;
map < string , int64 > mapAccountBalances ;
CRITICAL_BLOCK ( pwalletMain - > cs_mapWallet )
CRITICAL_BLOCK ( pwalletMain - > cs_mapAddressBook )
{
BOOST_FOREACH ( const PAIRTYPE ( CBitcoinAddress , string ) & entry , pwalletMain - > mapAddressBook ) {
BOOST_FOREACH ( const PAIRTYPE ( CBitcoinAddress , string ) & entry , pwalletMain - > mapAddressBook ) {
if ( pwalletMain - > HaveKey ( entry . first ) ) // This address belongs to me
if ( pwalletMain - > HaveKey ( entry . first ) ) // This address belongs to me
mapAccountBalances [ entry . second ] = 0 ;
mapAccountBalances [ entry . second ] = 0 ;
@ -1256,7 +1192,6 @@ Value listaccounts(const Array& params, bool fHelp)
mapAccountBalances [ " " ] + = r . second ;
mapAccountBalances [ " " ] + = r . second ;
}
}
}
}
}
list < CAccountingEntry > acentries ;
list < CAccountingEntry > acentries ;
CWalletDB ( pwalletMain - > strWalletFile ) . ListAccountCreditDebit ( " * " , acentries ) ;
CWalletDB ( pwalletMain - > strWalletFile ) . ListAccountCreditDebit ( " * " , acentries ) ;
@ -1281,8 +1216,7 @@ Value gettransaction(const Array& params, bool fHelp)
hash . SetHex ( params [ 0 ] . get_str ( ) ) ;
hash . SetHex ( params [ 0 ] . get_str ( ) ) ;
Object entry ;
Object entry ;
CRITICAL_BLOCK ( pwalletMain - > cs_mapWallet )
{
if ( ! pwalletMain - > mapWallet . count ( hash ) )
if ( ! pwalletMain - > mapWallet . count ( hash ) )
throw JSONRPCError ( - 5 , " Invalid or non-wallet transaction id " ) ;
throw JSONRPCError ( - 5 , " Invalid or non-wallet transaction id " ) ;
const CWalletTx & wtx = pwalletMain - > mapWallet [ hash ] ;
const CWalletTx & wtx = pwalletMain - > mapWallet [ hash ] ;
@ -1301,7 +1235,6 @@ Value gettransaction(const Array& params, bool fHelp)
Array details ;
Array details ;
ListTransactions ( pwalletMain - > mapWallet [ hash ] , " * " , 0 , false , details ) ;
ListTransactions ( pwalletMain - > mapWallet [ hash ] , " * " , 0 , false , details ) ;
entry . push_back ( Pair ( " details " , details ) ) ;
entry . push_back ( Pair ( " details " , details ) ) ;
}
return entry ;
return entry ;
}
}
@ -1332,13 +1265,10 @@ Value keypoolrefill(const Array& params, bool fHelp)
" keypoolrefill \n "
" keypoolrefill \n "
" Fills the keypool. " ) ;
" Fills the keypool. " ) ;
CRITICAL_BLOCK ( pwalletMain - > cs_vMasterKey )
{
if ( pwalletMain - > IsLocked ( ) )
if ( pwalletMain - > IsLocked ( ) )
throw JSONRPCError ( - 13 , " Error: Please enter the wallet passphrase with walletpassphrase first. " ) ;
throw JSONRPCError ( - 13 , " Error: Please enter the wallet passphrase with walletpassphrase first. " ) ;
pwalletMain - > TopUpKeyPool ( ) ;
pwalletMain - > TopUpKeyPool ( ) ;
}
if ( pwalletMain - > GetKeyPoolSize ( ) < GetArg ( " -keypool " , 100 ) )
if ( pwalletMain - > GetKeyPoolSize ( ) < GetArg ( " -keypool " , 100 ) )
throw JSONRPCError ( - 4 , " Error refreshing keypool. " ) ;
throw JSONRPCError ( - 4 , " Error refreshing keypool. " ) ;
@ -1407,8 +1337,6 @@ Value walletpassphrase(const Array& params, bool fHelp)
mlock ( & strWalletPass [ 0 ] , strWalletPass . capacity ( ) ) ;
mlock ( & strWalletPass [ 0 ] , strWalletPass . capacity ( ) ) ;
strWalletPass = params [ 0 ] . get_str ( ) ;
strWalletPass = params [ 0 ] . get_str ( ) ;
CRITICAL_BLOCK ( pwalletMain - > cs_vMasterKey )
{
if ( strWalletPass . length ( ) > 0 )
if ( strWalletPass . length ( ) > 0 )
{
{
if ( ! pwalletMain - > Unlock ( strWalletPass ) )
if ( ! pwalletMain - > Unlock ( strWalletPass ) )
@ -1424,7 +1352,6 @@ Value walletpassphrase(const Array& params, bool fHelp)
throw runtime_error (
throw runtime_error (
" walletpassphrase <passphrase> <timeout> \n "
" walletpassphrase <passphrase> <timeout> \n "
" Stores the wallet decryption key in memory for <timeout> seconds. " ) ;
" Stores the wallet decryption key in memory for <timeout> seconds. " ) ;
}
CreateThread ( ThreadTopUpKeyPool , NULL ) ;
CreateThread ( ThreadTopUpKeyPool , NULL ) ;
int * pnSleepTime = new int ( params [ 1 ] . get_int ( ) ) ;
int * pnSleepTime = new int ( params [ 1 ] . get_int ( ) ) ;
@ -1553,12 +1480,9 @@ Value validateaddress(const Array& params, bool fHelp)
string currentAddress = address . ToString ( ) ;
string currentAddress = address . ToString ( ) ;
ret . push_back ( Pair ( " address " , currentAddress ) ) ;
ret . push_back ( Pair ( " address " , currentAddress ) ) ;
ret . push_back ( Pair ( " ismine " , ( pwalletMain - > HaveKey ( address ) > 0 ) ) ) ;
ret . push_back ( Pair ( " ismine " , ( pwalletMain - > HaveKey ( address ) > 0 ) ) ) ;
CRITICAL_BLOCK ( pwalletMain - > cs_mapAddressBook )
{
if ( pwalletMain - > mapAddressBook . count ( address ) )
if ( pwalletMain - > mapAddressBook . count ( address ) )
ret . push_back ( Pair ( " account " , pwalletMain - > mapAddressBook [ address ] ) ) ;
ret . push_back ( Pair ( " account " , pwalletMain - > mapAddressBook [ address ] ) ) ;
}
}
}
return ret ;
return ret ;
}
}
@ -2233,7 +2157,10 @@ void ThreadRPCServer2(void* parg)
try
try
{
{
// Execute
// Execute
Value result = ( * ( * mi ) . second ) ( params , false ) ;
Value result ;
CRITICAL_BLOCK ( cs_main )
CRITICAL_BLOCK ( pwalletMain - > cs_wallet )
result = ( * ( * mi ) . second ) ( params , false ) ;
// Send reply
// Send reply
string strReply = JSONRPCReply ( result , Value : : null , id ) ;
string strReply = JSONRPCReply ( result , Value : : null , id ) ;