| 2193 | |
| 2194 | |
| 2195 | UniValue walletlock(const UniValue& params, bool fHelp) |
| 2196 | { |
| 2197 | if (pwalletMain->IsCrypted() && (fHelp || params.size() != 0)) |
| 2198 | throw runtime_error( |
| 2199 | "walletlock\n" |
| 2200 | "\nRemoves the wallet encryption key from memory, locking the wallet.\n" |
| 2201 | "After calling this method, you will need to call walletpassphrase again\n" |
| 2202 | "before being able to call any methods which require the wallet to be unlocked.\n" |
| 2203 | "\nExamples:\n" |
| 2204 | "\nSet the passphrase for 2 minutes to perform a transaction\n" + |
| 2205 | HelpExampleCli("walletpassphrase", "\"my pass phrase\" 120") + |
| 2206 | "\nPerform a send (requires passphrase set)\n" + HelpExampleCli("sendtoaddress", "\"LgAskSorXfCYUweZcCTpGNtpcFotS2rqDF\" 1.0") + |
| 2207 | "\nClear the passphrase since we are done before 2 minutes is up\n" + HelpExampleCli("walletlock", "") + |
| 2208 | "\nAs json rpc call\n" + HelpExampleRpc("walletlock", "")); |
| 2209 | |
| 2210 | LOCK2(cs_main, pwalletMain->cs_wallet); |
| 2211 | |
| 2212 | if (fHelp) |
| 2213 | return true; |
| 2214 | if (!pwalletMain->IsCrypted()) |
| 2215 | throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an unencrypted wallet, but walletlock was called."); |
| 2216 | |
| 2217 | { |
| 2218 | LOCK(cs_nWalletUnlockTime); |
| 2219 | pwalletMain->Lock(); |
| 2220 | nWalletUnlockTime = 0; |
| 2221 | } |
| 2222 | |
| 2223 | return NullUniValue; |
| 2224 | } |
| 2225 | |
| 2226 | |
| 2227 | UniValue encryptwallet(const UniValue& params, bool fHelp) |
nothing calls this directly
no test coverage detected