| 153 | |
| 154 | |
| 155 | RPCHelpMan walletlock() |
| 156 | { |
| 157 | return RPCHelpMan{"walletlock", |
| 158 | "\nRemoves the wallet encryption key from memory, locking the wallet.\n" |
| 159 | "After calling this method, you will need to call walletpassphrase again\n" |
| 160 | "before being able to call any methods which require the wallet to be unlocked.\n", |
| 161 | {}, |
| 162 | RPCResult{RPCResult::Type::NONE, "", ""}, |
| 163 | RPCExamples{ |
| 164 | "\nSet the passphrase for 2 minutes to perform a transaction\n" |
| 165 | + HelpExampleCli("walletpassphrase", "\"my pass phrase\" 120") + |
| 166 | "\nPerform a send (requires passphrase set)\n" |
| 167 | + HelpExampleCli("sendtoaddress", "\"" + EXAMPLE_ADDRESS[0] + "\" 1.0") + |
| 168 | "\nClear the passphrase since we are done before 2 minutes is up\n" |
| 169 | + HelpExampleCli("walletlock", "") + |
| 170 | "\nAs a JSON-RPC call\n" |
| 171 | + HelpExampleRpc("walletlock", "") |
| 172 | }, |
| 173 | [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue |
| 174 | { |
| 175 | std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request); |
| 176 | if (!pwallet) return NullUniValue; |
| 177 | |
| 178 | LOCK(pwallet->cs_wallet); |
| 179 | |
| 180 | if (!pwallet->IsCrypted()) { |
| 181 | throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an unencrypted wallet, but walletlock was called."); |
| 182 | } |
| 183 | |
| 184 | pwallet->Lock(); |
| 185 | pwallet->nRelockTime = 0; |
| 186 | |
| 187 | return NullUniValue; |
| 188 | }, |
| 189 | }; |
| 190 | } |
| 191 | |
| 192 | |
| 193 | RPCHelpMan encryptwallet() |
nothing calls this directly
no test coverage detected