Move nWalletUnlockTime to CWallet::nRelockTime, and name timed task unique per CWallet

This commit is contained in:
Luke Dashjr
2016-09-09 07:48:10 +00:00
parent d77ad6d416
commit 2e518e313b
4 changed files with 11 additions and 16 deletions
+7 -14
View File
@@ -29,9 +29,6 @@
using namespace std;
int64_t nWalletUnlockTime;
static CCriticalSection cs_nWalletUnlockTime;
CWallet *GetWalletForJSONRPCRequest(const JSONRPCRequest& request)
{
return pwalletMain;
@@ -2004,8 +2001,8 @@ UniValue keypoolrefill(const JSONRPCRequest& request)
static void LockWallet(CWallet* pWallet)
{
LOCK(cs_nWalletUnlockTime);
nWalletUnlockTime = 0;
LOCK(pWallet->cs_wallet);
pWallet->nRelockTime = 0;
pWallet->Lock();
}
@@ -2063,9 +2060,8 @@ UniValue walletpassphrase(const JSONRPCRequest& request)
pwallet->TopUpKeyPool();
int64_t nSleepTime = request.params[1].get_int64();
LOCK(cs_nWalletUnlockTime);
nWalletUnlockTime = GetTime() + nSleepTime;
RPCRunLater("lockwallet", boost::bind(LockWallet, pwallet), nSleepTime);
pwallet->nRelockTime = GetTime() + nSleepTime;
RPCRunLater(strprintf("lockwallet_%u", uintptr_t(pwallet)), boost::bind(LockWallet, pwallet), nSleepTime);
return NullUniValue;
}
@@ -2150,11 +2146,8 @@ UniValue walletlock(const JSONRPCRequest& request)
if (!pwallet->IsCrypted())
throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an unencrypted wallet, but walletlock was called.");
{
LOCK(cs_nWalletUnlockTime);
pwallet->Lock();
nWalletUnlockTime = 0;
}
pwallet->Lock();
pwallet->nRelockTime = 0;
return NullUniValue;
}
@@ -2430,7 +2423,7 @@ UniValue getwalletinfo(const JSONRPCRequest& request)
obj.push_back(Pair("keypoololdest", pwallet->GetOldestKeyPoolTime()));
obj.push_back(Pair("keypoolsize", (int)pwallet->GetKeyPoolSize()));
if (pwallet->IsCrypted())
obj.push_back(Pair("unlocked_until", nWalletUnlockTime));
obj.push_back(Pair("unlocked_until", pwallet->nRelockTime));
obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK())));
CKeyID masterKeyID = pwallet->GetHDChain().masterKeyID;
if (!masterKeyID.IsNull())