MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / walletlock

Function walletlock

src/wallet/rpcwallet.cpp:2688–2725  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2686
2687
2688static UniValue walletlock(const JSONRPCRequest& request)
2689{
2690 std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
2691 CWallet* const pwallet = wallet.get();
2692
2693 if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
2694 return NullUniValue;
2695 }
2696
2697 if (request.fHelp || request.params.size() != 0) {
2698 throw std::runtime_error(
2699 "walletlock\n"
2700 "\nRemoves the wallet encryption key from memory, locking the wallet.\n"
2701 "After calling this method, you will need to call walletpassphrase again\n"
2702 "before being able to call any methods which require the wallet to be unlocked.\n"
2703 "\nExamples:\n"
2704 "\nSet the passphrase for 2 minutes to perform a transaction\n"
2705 + HelpExampleCli("walletpassphrase", "\"my pass phrase\" 120") +
2706 "\nPerform a send (requires passphrase set)\n"
2707 + HelpExampleCli("sendtoaddress", "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 1.0") +
2708 "\nClear the passphrase since we are done before 2 minutes is up\n"
2709 + HelpExampleCli("walletlock", "") +
2710 "\nAs json rpc call\n"
2711 + HelpExampleRpc("walletlock", "")
2712 );
2713 }
2714
2715 LOCK2(cs_main, pwallet->cs_wallet);
2716
2717 if (!pwallet->IsCrypted()) {
2718 throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an unencrypted wallet, but walletlock was called.");
2719 }
2720
2721 pwallet->Lock();
2722 pwallet->nRelockTime = 0;
2723
2724 return NullUniValue;
2725}
2726
2727
2728static UniValue encryptwallet(const JSONRPCRequest& request)

Callers

nothing calls this directly

Calls 9

EnsureWalletIsAvailableFunction · 0.85
HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
JSONRPCErrorFunction · 0.85
getMethod · 0.80
IsCryptedMethod · 0.80
sizeMethod · 0.45
LockMethod · 0.45

Tested by

no test coverage detected