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

Function movecmd

src/wallet/rpcwallet.cpp:972–1028  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

970
971
972static UniValue movecmd(const JSONRPCRequest& request)
973{
974 std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
975 CWallet* const pwallet = wallet.get();
976
977 if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
978 return NullUniValue;
979 }
980
981 if (!IsDeprecatedRPCEnabled("accounts")) {
982 if (request.fHelp) {
983 throw std::runtime_error("move (Deprecated, will be removed in V0.18. To use this command, start bgoldd with -deprecatedrpc=accounts)");
984 }
985 throw JSONRPCError(RPC_METHOD_DEPRECATED, "move is deprecated and will be removed in V0.18. To use this command, start bgoldd with -deprecatedrpc=accounts.");
986 }
987
988 if (request.fHelp || request.params.size() < 3 || request.params.size() > 5)
989 throw std::runtime_error(
990 "move \"fromaccount\" \"toaccount\" amount ( minconf \"comment\" )\n"
991 "\nDEPRECATED. Move a specified amount from one account in your wallet to another.\n"
992 "\nArguments:\n"
993 "1. \"fromaccount\" (string, required) The name of the account to move funds from. May be the default account using \"\".\n"
994 "2. \"toaccount\" (string, required) The name of the account to move funds to. May be the default account using \"\".\n"
995 "3. amount (numeric) Quantity of " + CURRENCY_UNIT + " to move between accounts.\n"
996 "4. (dummy) (numeric, optional) Ignored. Remains for backward compatibility.\n"
997 "5. \"comment\" (string, optional) An optional comment, stored in the wallet only.\n"
998 "\nResult:\n"
999 "true|false (boolean) true if successful.\n"
1000 "\nExamples:\n"
1001 "\nMove 0.01 " + CURRENCY_UNIT + " from the default account to the account named tabby\n"
1002 + HelpExampleCli("move", "\"\" \"tabby\" 0.01") +
1003 "\nMove 0.01 " + CURRENCY_UNIT + " timotei to akiko with a comment and funds have 6 confirmations\n"
1004 + HelpExampleCli("move", "\"timotei\" \"akiko\" 0.01 6 \"happy birthday!\"") +
1005 "\nAs a json rpc call\n"
1006 + HelpExampleRpc("move", "\"timotei\", \"akiko\", 0.01, 6, \"happy birthday!\"")
1007 );
1008
1009 LOCK2(cs_main, pwallet->cs_wallet);
1010
1011 std::string strFrom = LabelFromValue(request.params[0]);
1012 std::string strTo = LabelFromValue(request.params[1]);
1013 CAmount nAmount = AmountFromValue(request.params[2]);
1014 if (nAmount <= 0)
1015 throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send");
1016 if (!request.params[3].isNull())
1017 // unused parameter, used to be nMinDepth, keep type-checking it though
1018 (void)request.params[3].get_int();
1019 std::string strComment;
1020 if (!request.params[4].isNull())
1021 strComment = request.params[4].get_str();
1022
1023 if (!pwallet->AccountMove(strFrom, strTo, nAmount, strComment)) {
1024 throw JSONRPCError(RPC_DATABASE_ERROR, "database error");
1025 }
1026
1027 return true;
1028}
1029

Callers

nothing calls this directly

Calls 13

EnsureWalletIsAvailableFunction · 0.85
IsDeprecatedRPCEnabledFunction · 0.85
JSONRPCErrorFunction · 0.85
HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
LabelFromValueFunction · 0.85
getMethod · 0.80
isNullMethod · 0.80
get_intMethod · 0.80
AccountMoveMethod · 0.80
AmountFromValueFunction · 0.50

Tested by

no test coverage detected