diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1246,6 +1246,18 @@ return NullUniValue; } + if (!IsDeprecatedRPCEnabled(gArgs, "accounts")) { + if (request.fHelp) { + throw std::runtime_error( + "sendfrom (Deprecated, will be removed in V0.21. To use this " + "command, start bitcoind with -deprecatedrpc=accounts)"); + } + throw JSONRPCError( + RPC_METHOD_DEPRECATED, + "sendfrom is deprecated and will be removed in V0.21. To use this " + "command, start bitcoind with -deprecatedrpc=accounts."); + } + if (request.fHelp || request.params.size() < 3 || request.params.size() > 6) { throw std::runtime_error( @@ -1584,11 +1596,16 @@ EnsureWalletIsUnlocked(pwallet); // Check funds - Amount nBalance = - pwallet->GetLegacyBalance(ISMINE_SPENDABLE, nMinDepth, &strAccount); - if (totalAmount > nBalance) { + if (IsDeprecatedRPCEnabled(gArgs, "accounts") && + totalAmount > pwallet->GetLegacyBalance(ISMINE_SPENDABLE, nMinDepth, + &strAccount)) { throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Account has insufficient funds"); + } else if (!IsDeprecatedRPCEnabled(gArgs, "accounts") && + totalAmount > pwallet->GetLegacyBalance(ISMINE_SPENDABLE, + nMinDepth, nullptr)) { + throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, + "Wallet has insufficient funds"); } // Shuffle recipient list @@ -5403,7 +5420,6 @@ { "wallet", "lockunspent", lockunspent, {"unlock","transactions"} }, { "wallet", "rescanblockchain", rescanblockchain, {"start_height", "stop_height"} }, { "wallet", "sethdseed", sethdseed, {"newkeypool","seed"} }, - { "wallet", "sendfrom", sendfrom, {"fromaccount","toaddress","amount","minconf","comment","comment_to"} }, { "wallet", "sendmany", sendmany, {"fromaccount|dummy","amounts","minconf","comment","subtractfeefrom"} }, { "wallet", "sendtoaddress", sendtoaddress, {"address","amount","comment","comment_to","subtractfeefromamount"} }, { "wallet", "settxfee", settxfee, {"amount"} }, @@ -5422,6 +5438,7 @@ { "wallet", "listaccounts", listaccounts, {"minconf","include_watchonly"} }, { "wallet", "listreceivedbyaccount", listreceivedbylabel, {"minconf","include_empty","include_watchonly"} }, { "wallet", "setaccount", setlabel, {"address","account"} }, + { "wallet", "sendfrom", sendfrom, {"fromaccount","toaddress","amount","minconf","comment","comment_to"} }, { "wallet", "move", movecmd, {"fromaccount","toaccount","amount","minconf","comment"} }, /** Label functions (to replace non-balance account functions) */ diff --git a/test/functional/wallet_labels.py b/test/functional/wallet_labels.py --- a/test/functional/wallet_labels.py +++ b/test/functional/wallet_labels.py @@ -124,8 +124,7 @@ node.sendfrom( label.name, to_label.receive_address, amount_to_send) else: - node.sendfrom( - label.name, to_label.addresses[0], amount_to_send) + node.sendtoaddress(to_label.addresses[0], amount_to_send) node.generate(1) for label in labels: if accounts_api: @@ -168,7 +167,8 @@ label.add_address(multisig_address) label.purpose[multisig_address] = "send" label.verify(node) - node.sendfrom("", multisig_address, 50) + if accounts_api: + node.sendfrom("", multisig_address, 50) node.generate(101) if accounts_api: for label in labels: