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

Function lockunspent

src/wallet/rpcwallet.cpp:2790–2917  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2788}
2789
2790static UniValue lockunspent(const JSONRPCRequest& request)
2791{
2792 std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
2793 CWallet* const pwallet = wallet.get();
2794
2795 if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
2796 return NullUniValue;
2797 }
2798
2799 if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
2800 throw std::runtime_error(
2801 "lockunspent unlock ([{\"txid\":\"txid\",\"vout\":n},...])\n"
2802 "\nUpdates list of temporarily unspendable outputs.\n"
2803 "Temporarily lock (unlock=false) or unlock (unlock=true) specified transaction outputs.\n"
2804 "If no transaction outputs are specified when unlocking then all current locked transaction outputs are unlocked.\n"
2805 "A locked transaction output will not be chosen by automatic coin selection, when spending bitcoins.\n"
2806 "Locks are stored in memory only. Nodes start with zero locked outputs, and the locked output list\n"
2807 "is always cleared (by virtue of process exit) when a node stops or fails.\n"
2808 "Also see the listunspent call\n"
2809 "\nArguments:\n"
2810 "1. unlock (boolean, required) Whether to unlock (true) or lock (false) the specified transactions\n"
2811 "2. \"transactions\" (string, optional) A json array of objects. Each object the txid (string) vout (numeric)\n"
2812 " [ (json array of json objects)\n"
2813 " {\n"
2814 " \"txid\":\"id\", (string) The transaction id\n"
2815 " \"vout\": n (numeric) The output number\n"
2816 " }\n"
2817 " ,...\n"
2818 " ]\n"
2819
2820 "\nResult:\n"
2821 "true|false (boolean) Whether the command was successful or not\n"
2822
2823 "\nExamples:\n"
2824 "\nList the unspent transactions\n"
2825 + HelpExampleCli("listunspent", "") +
2826 "\nLock an unspent transaction\n"
2827 + HelpExampleCli("lockunspent", "false \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") +
2828 "\nList the locked transactions\n"
2829 + HelpExampleCli("listlockunspent", "") +
2830 "\nUnlock the transaction again\n"
2831 + HelpExampleCli("lockunspent", "true \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") +
2832 "\nAs a json rpc call\n"
2833 + HelpExampleRpc("lockunspent", "false, \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"")
2834 );
2835
2836 // Make sure the results are valid at least up to the most recent block
2837 // the user could have gotten from another RPC command prior to now
2838 pwallet->BlockUntilSyncedToCurrentChain();
2839
2840 LOCK2(cs_main, pwallet->cs_wallet);
2841
2842 RPCTypeCheckArgument(request.params[0], UniValue::VBOOL);
2843
2844 bool fUnlock = request.params[0].get_bool();
2845
2846 if (request.params[1].isNull()) {
2847 if (fUnlock)

Callers

nothing calls this directly

Calls 15

EnsureWalletIsAvailableFunction · 0.85
HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
RPCTypeCheckArgumentFunction · 0.85
RPCTypeCheckObjFunction · 0.85
UniValueTypeClass · 0.85
IsHexFunction · 0.85
JSONRPCErrorFunction · 0.85
uint256SFunction · 0.85
getMethod · 0.80
get_boolMethod · 0.80

Tested by

no test coverage detected