Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 3,459 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() < 1 || | ||||
" \"changeAddress\" (string, optional, default pool " | " \"changeAddress\" (string, optional, default pool " | ||||
"address) The bitcoin address to receive the change\n" | "address) The bitcoin address to receive the change\n" | ||||
" \"changePosition\" (numeric, optional, default " | " \"changePosition\" (numeric, optional, default " | ||||
"random) The index of the change output\n" | "random) The index of the change output\n" | ||||
" \"includeWatching\" (boolean, optional, default " | " \"includeWatching\" (boolean, optional, default " | ||||
"false) Also select inputs which are watch only\n" | "false) Also select inputs which are watch only\n" | ||||
" \"lockUnspents\" (boolean, optional, default " | " \"lockUnspents\" (boolean, optional, default " | ||||
"false) Lock selected unspent outputs\n" | "false) Lock selected unspent outputs\n" | ||||
" \"reserveChangeKey\" (boolean, optional, default true) " | " \"reserveChangeKey\" (boolean, optional) " | ||||
"Reserves the change output key from the keypool\n" | "DEPRECATED. Reserves the change output key from the keypool\n" | ||||
" \"feeRate\" (numeric, optional, default not " | " \"feeRate\" (numeric, optional, default not " | ||||
"set: makes wallet determine the fee) Set a specific feerate (" + | "set: makes wallet determine the fee) Set a specific feerate (" + | ||||
CURRENCY_UNIT + | CURRENCY_UNIT + | ||||
" per KB)\n" | " per KB)\n" | ||||
" \"subtractFeeFromOutputs\" (array, optional) A json array of " | " \"subtractFeeFromOutputs\" (array, optional) A json array of " | ||||
"integers.\n" | "integers.\n" | ||||
" The fee will be equally deducted " | " The fee will be equally deducted " | ||||
"from the amount of each specified output.\n" | "from the amount of each specified output.\n" | ||||
Show All 34 Lines | static UniValue fundrawtransaction(const Config &config, | ||||
// Make sure the results are valid at least up to the most recent block | // Make sure the results are valid at least up to the most recent block | ||||
// the user could have gotten from another RPC command prior to now | // the user could have gotten from another RPC command prior to now | ||||
pwallet->BlockUntilSyncedToCurrentChain(); | pwallet->BlockUntilSyncedToCurrentChain(); | ||||
CCoinControl coinControl; | CCoinControl coinControl; | ||||
int changePosition = -1; | int changePosition = -1; | ||||
bool lockUnspents = false; | bool lockUnspents = false; | ||||
bool reserveChangeKey = true; | // DEPRECATED, should be removed in 0.20 | ||||
bool reserveChangeKey = false; | |||||
UniValue subtractFeeFromOutputs; | UniValue subtractFeeFromOutputs; | ||||
std::set<int> setSubtractFeeFromOutputs; | std::set<int> setSubtractFeeFromOutputs; | ||||
if (!request.params[1].isNull()) { | if (!request.params[1].isNull()) { | ||||
if (request.params[1].type() == UniValue::VBOOL) { | if (request.params[1].type() == UniValue::VBOOL) { | ||||
// backward compatibility bool only fallback | // backward compatibility bool only fallback | ||||
coinControl.fAllowWatchOnly = request.params[1].get_bool(); | coinControl.fAllowWatchOnly = request.params[1].get_bool(); | ||||
} else { | } else { | ||||
RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VOBJ}); | RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VOBJ}); | ||||
UniValue options = request.params[1]; | UniValue options = request.params[1]; | ||||
RPCTypeCheckObj( | RPCTypeCheckObj( | ||||
options, | options, | ||||
{ | { | ||||
{"changeAddress", UniValueType(UniValue::VSTR)}, | {"changeAddress", UniValueType(UniValue::VSTR)}, | ||||
{"changePosition", UniValueType(UniValue::VNUM)}, | {"changePosition", UniValueType(UniValue::VNUM)}, | ||||
{"includeWatching", UniValueType(UniValue::VBOOL)}, | {"includeWatching", UniValueType(UniValue::VBOOL)}, | ||||
{"lockUnspents", UniValueType(UniValue::VBOOL)}, | {"lockUnspents", UniValueType(UniValue::VBOOL)}, | ||||
// DEPRECATED, should be removed in 0.20 | |||||
{"reserveChangeKey", UniValueType(UniValue::VBOOL)}, | {"reserveChangeKey", UniValueType(UniValue::VBOOL)}, | ||||
// will be checked below | // will be checked below | ||||
{"feeRate", UniValueType()}, | {"feeRate", UniValueType()}, | ||||
{"subtractFeeFromOutputs", UniValueType(UniValue::VARR)}, | {"subtractFeeFromOutputs", UniValueType(UniValue::VARR)}, | ||||
}, | }, | ||||
true, true); | true, true); | ||||
if (options.exists("changeAddress")) { | if (options.exists("changeAddress")) { | ||||
Show All 18 Lines | if (!request.params[1].isNull()) { | ||||
coinControl.fAllowWatchOnly = | coinControl.fAllowWatchOnly = | ||||
options["includeWatching"].get_bool(); | options["includeWatching"].get_bool(); | ||||
} | } | ||||
if (options.exists("lockUnspents")) { | if (options.exists("lockUnspents")) { | ||||
lockUnspents = options["lockUnspents"].get_bool(); | lockUnspents = options["lockUnspents"].get_bool(); | ||||
} | } | ||||
// DEPRECATED, should be removed in v0.20 | |||||
if (options.exists("reserveChangeKey")) { | if (options.exists("reserveChangeKey")) { | ||||
if (!IsDeprecatedRPCEnabled(gArgs, "fundrawtransaction")) { | |||||
throw JSONRPCError( | |||||
RPC_METHOD_DEPRECATED, | |||||
"fundrawtransaction -reserveChangeKey is deprecated " | |||||
"and will be fully removed in v0.20. To use the " | |||||
"-reserveChangeKey option in v0.19, restart bitcoind " | |||||
"with -deprecatedrpc=fundrawtransaction.\nProjects " | |||||
"should transition to expecting change addresses " | |||||
"removed from the keypool before upgrading to v0.20"); | |||||
} else { | |||||
reserveChangeKey = options["reserveChangeKey"].get_bool(); | reserveChangeKey = options["reserveChangeKey"].get_bool(); | ||||
} | } | ||||
} | |||||
if (options.exists("feeRate")) { | if (options.exists("feeRate")) { | ||||
coinControl.m_feerate = | coinControl.m_feerate = | ||||
CFeeRate(AmountFromValue(options["feeRate"])); | CFeeRate(AmountFromValue(options["feeRate"])); | ||||
coinControl.fOverrideFeeRate = true; | coinControl.fOverrideFeeRate = true; | ||||
} | } | ||||
if (options.exists("subtractFeeFromOutputs")) { | if (options.exists("subtractFeeFromOutputs")) { | ||||
▲ Show 20 Lines • Show All 344 Lines • Show Last 20 Lines |