Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 1,240 Lines • ▼ Show 20 Lines | |||||
static UniValue sendfrom(const Config &config, const JSONRPCRequest &request) { | static UniValue sendfrom(const Config &config, const JSONRPCRequest &request) { | ||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | ||||
CWallet *const pwallet = wallet.get(); | CWallet *const pwallet = wallet.get(); | ||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | ||||
return NullUniValue; | 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 || | if (request.fHelp || request.params.size() < 3 || | ||||
request.params.size() > 6) { | request.params.size() > 6) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"sendfrom \"fromaccount\" \"toaddress\" amount ( minconf " | "sendfrom \"fromaccount\" \"toaddress\" amount ( minconf " | ||||
"\"comment\" \"comment_to\" )\n" | "\"comment\" \"comment_to\" )\n" | ||||
"\nDEPRECATED (use sendtoaddress). Sent an amount from an account " | "\nDEPRECATED (use sendtoaddress). Sent an amount from an account " | ||||
"to a bitcoin address." + | "to a bitcoin address." + | ||||
HelpRequiringPassphrase(pwallet) + | HelpRequiringPassphrase(pwallet) + | ||||
▲ Show 20 Lines • Show All 322 Lines • ▼ Show 20 Lines | for (const std::string &name_ : keys) { | ||||
CRecipient recipient = {scriptPubKey, nAmount, fSubtractFeeFromAmount}; | CRecipient recipient = {scriptPubKey, nAmount, fSubtractFeeFromAmount}; | ||||
vecSend.push_back(recipient); | vecSend.push_back(recipient); | ||||
} | } | ||||
EnsureWalletIsUnlocked(pwallet); | EnsureWalletIsUnlocked(pwallet); | ||||
// Check funds | // Check funds | ||||
Amount nBalance = | if (IsDeprecatedRPCEnabled(gArgs, "accounts") && | ||||
pwallet->GetLegacyBalance(ISMINE_SPENDABLE, nMinDepth, &strAccount); | totalAmount > pwallet->GetLegacyBalance(ISMINE_SPENDABLE, nMinDepth, | ||||
if (totalAmount > nBalance) { | &strAccount)) { | ||||
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, | throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, | ||||
"Account has 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 | // Shuffle recipient list | ||||
std::shuffle(vecSend.begin(), vecSend.end(), FastRandomContext()); | std::shuffle(vecSend.begin(), vecSend.end(), FastRandomContext()); | ||||
// Send | // Send | ||||
CReserveKey keyChange(pwallet); | CReserveKey keyChange(pwallet); | ||||
Amount nFeeRequired = Amount::zero(); | Amount nFeeRequired = Amount::zero(); | ||||
▲ Show 20 Lines • Show All 3,793 Lines • ▼ Show 20 Lines | static const ContextFreeRPCCommand commands[] = { | ||||
{ "wallet", "listsinceblock", listsinceblock, {"blockhash","target_confirmations","include_watchonly","include_removed"} }, | { "wallet", "listsinceblock", listsinceblock, {"blockhash","target_confirmations","include_watchonly","include_removed"} }, | ||||
{ "wallet", "listtransactions", listtransactions, {"account|dummy","count","skip","include_watchonly"} }, | { "wallet", "listtransactions", listtransactions, {"account|dummy","count","skip","include_watchonly"} }, | ||||
{ "wallet", "listunspent", listunspent, {"minconf","maxconf","addresses","include_unsafe","query_options"} }, | { "wallet", "listunspent", listunspent, {"minconf","maxconf","addresses","include_unsafe","query_options"} }, | ||||
{ "wallet", "listwallets", listwallets, {} }, | { "wallet", "listwallets", listwallets, {} }, | ||||
{ "wallet", "loadwallet", loadwallet, {"filename"} }, | { "wallet", "loadwallet", loadwallet, {"filename"} }, | ||||
{ "wallet", "lockunspent", lockunspent, {"unlock","transactions"} }, | { "wallet", "lockunspent", lockunspent, {"unlock","transactions"} }, | ||||
{ "wallet", "rescanblockchain", rescanblockchain, {"start_height", "stop_height"} }, | { "wallet", "rescanblockchain", rescanblockchain, {"start_height", "stop_height"} }, | ||||
{ "wallet", "sethdseed", sethdseed, {"newkeypool","seed"} }, | { "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", "sendmany", sendmany, {"fromaccount|dummy","amounts","minconf","comment","subtractfeefrom"} }, | ||||
{ "wallet", "sendtoaddress", sendtoaddress, {"address","amount","comment","comment_to","subtractfeefromamount"} }, | { "wallet", "sendtoaddress", sendtoaddress, {"address","amount","comment","comment_to","subtractfeefromamount"} }, | ||||
{ "wallet", "settxfee", settxfee, {"amount"} }, | { "wallet", "settxfee", settxfee, {"amount"} }, | ||||
{ "wallet", "signmessage", signmessage, {"address","message"} }, | { "wallet", "signmessage", signmessage, {"address","message"} }, | ||||
{ "wallet", "signrawtransactionwithwallet", signrawtransactionwithwallet, {"hextring","prevtxs","sighashtype"} }, | { "wallet", "signrawtransactionwithwallet", signrawtransactionwithwallet, {"hextring","prevtxs","sighashtype"} }, | ||||
{ "wallet", "unloadwallet", unloadwallet, {"wallet_name"} }, | { "wallet", "unloadwallet", unloadwallet, {"wallet_name"} }, | ||||
{ "wallet", "walletlock", walletlock, {} }, | { "wallet", "walletlock", walletlock, {} }, | ||||
{ "wallet", "walletpassphrasechange", walletpassphrasechange, {"oldpassphrase","newpassphrase"} }, | { "wallet", "walletpassphrasechange", walletpassphrasechange, {"oldpassphrase","newpassphrase"} }, | ||||
{ "wallet", "walletpassphrase", walletpassphrase, {"passphrase","timeout"} }, | { "wallet", "walletpassphrase", walletpassphrase, {"passphrase","timeout"} }, | ||||
/** Account functions (deprecated) */ | /** Account functions (deprecated) */ | ||||
{ "wallet", "getaccountaddress", getaccountaddress, {"account"} }, | { "wallet", "getaccountaddress", getaccountaddress, {"account"} }, | ||||
{ "wallet", "getaccount", getaccount, {"address"} }, | { "wallet", "getaccount", getaccount, {"address"} }, | ||||
{ "wallet", "getaddressesbyaccount", getaddressesbyaccount, {"account"} }, | { "wallet", "getaddressesbyaccount", getaddressesbyaccount, {"account"} }, | ||||
{ "wallet", "getreceivedbyaccount", getreceivedbylabel, {"account","minconf"} }, | { "wallet", "getreceivedbyaccount", getreceivedbylabel, {"account","minconf"} }, | ||||
{ "wallet", "listaccounts", listaccounts, {"minconf","include_watchonly"} }, | { "wallet", "listaccounts", listaccounts, {"minconf","include_watchonly"} }, | ||||
{ "wallet", "listreceivedbyaccount", listreceivedbylabel, {"minconf","include_empty","include_watchonly"} }, | { "wallet", "listreceivedbyaccount", listreceivedbylabel, {"minconf","include_empty","include_watchonly"} }, | ||||
{ "wallet", "setaccount", setlabel, {"address","account"} }, | { "wallet", "setaccount", setlabel, {"address","account"} }, | ||||
{ "wallet", "sendfrom", sendfrom, {"fromaccount","toaddress","amount","minconf","comment","comment_to"} }, | |||||
{ "wallet", "move", movecmd, {"fromaccount","toaccount","amount","minconf","comment"} }, | { "wallet", "move", movecmd, {"fromaccount","toaccount","amount","minconf","comment"} }, | ||||
/** Label functions (to replace non-balance account functions) */ | /** Label functions (to replace non-balance account functions) */ | ||||
{ "wallet", "getaddressesbylabel", getaddressesbylabel, {"label"} }, | { "wallet", "getaddressesbylabel", getaddressesbylabel, {"label"} }, | ||||
{ "wallet", "getreceivedbylabel", getreceivedbylabel, {"label","minconf"} }, | { "wallet", "getreceivedbylabel", getreceivedbylabel, {"label","minconf"} }, | ||||
{ "wallet", "listlabels", listlabels, {"purpose"} }, | { "wallet", "listlabels", listlabels, {"purpose"} }, | ||||
{ "wallet", "listreceivedbylabel", listreceivedbylabel, {"minconf","include_empty","include_watchonly"} }, | { "wallet", "listreceivedbylabel", listreceivedbylabel, {"minconf","include_empty","include_watchonly"} }, | ||||
{ "wallet", "setlabel", setlabel, {"address","label"} }, | { "wallet", "setlabel", setlabel, {"address","label"} }, | ||||
Show All 10 Lines |