|
29 | 29 |
|
30 | 30 | using namespace std; |
31 | 31 |
|
32 | | -int64_t nWalletUnlockTime; |
33 | | -static CCriticalSection cs_nWalletUnlockTime; |
34 | | - |
35 | 32 | CWallet *GetWalletForJSONRPCRequest(const JSONRPCRequest& request) |
36 | 33 | { |
37 | 34 | return pwalletMain; |
@@ -2004,8 +2001,8 @@ UniValue keypoolrefill(const JSONRPCRequest& request) |
2004 | 2001 |
|
2005 | 2002 | static void LockWallet(CWallet* pWallet) |
2006 | 2003 | { |
2007 | | - LOCK(cs_nWalletUnlockTime); |
2008 | | - nWalletUnlockTime = 0; |
| 2004 | + LOCK(pWallet->cs_wallet); |
| 2005 | + pWallet->nRelockTime = 0; |
2009 | 2006 | pWallet->Lock(); |
2010 | 2007 | } |
2011 | 2008 |
|
@@ -2063,9 +2060,8 @@ UniValue walletpassphrase(const JSONRPCRequest& request) |
2063 | 2060 | pwallet->TopUpKeyPool(); |
2064 | 2061 |
|
2065 | 2062 | int64_t nSleepTime = request.params[1].get_int64(); |
2066 | | - LOCK(cs_nWalletUnlockTime); |
2067 | | - nWalletUnlockTime = GetTime() + nSleepTime; |
2068 | | - RPCRunLater("lockwallet", boost::bind(LockWallet, pwallet), nSleepTime); |
| 2063 | + pwallet->nRelockTime = GetTime() + nSleepTime; |
| 2064 | + RPCRunLater(strprintf("lockwallet_%u", uintptr_t(pwallet)), boost::bind(LockWallet, pwallet), nSleepTime); |
2069 | 2065 |
|
2070 | 2066 | return NullUniValue; |
2071 | 2067 | } |
@@ -2150,11 +2146,8 @@ UniValue walletlock(const JSONRPCRequest& request) |
2150 | 2146 | if (!pwallet->IsCrypted()) |
2151 | 2147 | throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an unencrypted wallet, but walletlock was called."); |
2152 | 2148 |
|
2153 | | - { |
2154 | | - LOCK(cs_nWalletUnlockTime); |
2155 | | - pwallet->Lock(); |
2156 | | - nWalletUnlockTime = 0; |
2157 | | - } |
| 2149 | + pwallet->Lock(); |
| 2150 | + pwallet->nRelockTime = 0; |
2158 | 2151 |
|
2159 | 2152 | return NullUniValue; |
2160 | 2153 | } |
@@ -2430,7 +2423,7 @@ UniValue getwalletinfo(const JSONRPCRequest& request) |
2430 | 2423 | obj.push_back(Pair("keypoololdest", pwallet->GetOldestKeyPoolTime())); |
2431 | 2424 | obj.push_back(Pair("keypoolsize", (int)pwallet->GetKeyPoolSize())); |
2432 | 2425 | if (pwallet->IsCrypted()) |
2433 | | - obj.push_back(Pair("unlocked_until", nWalletUnlockTime)); |
| 2426 | + obj.push_back(Pair("unlocked_until", pwallet->nRelockTime)); |
2434 | 2427 | obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK()))); |
2435 | 2428 | CKeyID masterKeyID = pwallet->GetHDChain().masterKeyID; |
2436 | 2429 | if (!masterKeyID.IsNull()) |
|
0 commit comments