1996 | @@ -2004,7 +1997,14 @@ static UniValue walletpassphrase(const JSONRPCRequest& request)
1997 | pwallet->TopUpKeyPool();
1998 |
1999 | pwallet->nRelockTime = GetTime() + nSleepTime;
2000 | - RPCRunLater(strprintf("lockwallet(%s)", pwallet->GetName()), std::bind(LockWallet, pwallet), nSleepTime);
2001 | + std::weak_ptr<CWallet> weak_wallet = wallet;
2002 | + RPCRunLater(strprintf("lockwallet(%s)", pwallet->GetName()), [weak_wallet] {
2003 | + if (auto wallet = weak_wallet.lock()) {
Use another name here to avoid shadowing existing local variable wallet :-)
Sorry, sloppy wording from me - it is not a local variable. Still better to minimize surprises by not re-using the name, no?
What surprise?
Surprise of having two different variables inside the walletpassphrase function with same name. I agree it would be a little clearer to rename this latter wallet variable to something like shared_wallet to differentiate it.