diff options
author | Luke Dashjr <luke-jr+git@utopios.org> | 2016-09-09 07:48:10 +0000 |
---|---|---|
committer | Luke Dashjr <luke-jr+git@utopios.org> | 2017-02-27 20:45:17 +0000 |
commit | 2e518e313b5d5320c16bdb33ebd008b6d30a90f2 (patch) | |
tree | 12fc602f93dea67cb3fabef7c9bbf2908e4887da /src/wallet/rpcwallet.cpp | |
parent | d77ad6d41666b4c41abe1ba3b63300df1903643e (diff) |
Move nWalletUnlockTime to CWallet::nRelockTime, and name timed task unique per CWallet
Diffstat (limited to 'src/wallet/rpcwallet.cpp')
-rw-r--r-- | src/wallet/rpcwallet.cpp | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 478d92cda3..b36a99013e 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -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()) |