|
|
@ -21,6 +21,7 @@ |
|
|
|
#include "timedata.h" |
|
|
|
#include "timedata.h" |
|
|
|
#include "util.h" |
|
|
|
#include "util.h" |
|
|
|
#include "utilmoneystr.h" |
|
|
|
#include "utilmoneystr.h" |
|
|
|
|
|
|
|
#include "wallet/coincontrol.h" |
|
|
|
#include "wallet/feebumper.h" |
|
|
|
#include "wallet/feebumper.h" |
|
|
|
#include "wallet/wallet.h" |
|
|
|
#include "wallet/wallet.h" |
|
|
|
#include "wallet/walletdb.h" |
|
|
|
#include "wallet/walletdb.h" |
|
|
@ -2678,20 +2679,21 @@ UniValue fundrawtransaction(const JSONRPCRequest& request) |
|
|
|
|
|
|
|
|
|
|
|
RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VSTR)); |
|
|
|
RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VSTR)); |
|
|
|
|
|
|
|
|
|
|
|
CTxDestination changeAddress = CNoDestination(); |
|
|
|
CCoinControl coinControl; |
|
|
|
|
|
|
|
coinControl.destChange = CNoDestination(); |
|
|
|
int changePosition = -1; |
|
|
|
int changePosition = -1; |
|
|
|
bool includeWatching = false; |
|
|
|
coinControl.fAllowWatchOnly = false; // include watching
|
|
|
|
bool lockUnspents = false; |
|
|
|
bool lockUnspents = false; |
|
|
|
bool reserveChangeKey = true; |
|
|
|
bool reserveChangeKey = true; |
|
|
|
CFeeRate feeRate = CFeeRate(0); |
|
|
|
coinControl.nFeeRate = CFeeRate(0); |
|
|
|
bool overrideEstimatedFeerate = false; |
|
|
|
coinControl.fOverrideFeeRate = false; |
|
|
|
UniValue subtractFeeFromOutputs; |
|
|
|
UniValue subtractFeeFromOutputs; |
|
|
|
std::set<int> setSubtractFeeFromOutputs; |
|
|
|
std::set<int> setSubtractFeeFromOutputs; |
|
|
|
|
|
|
|
|
|
|
|
if (request.params.size() > 1) { |
|
|
|
if (request.params.size() > 1) { |
|
|
|
if (request.params[1].type() == UniValue::VBOOL) { |
|
|
|
if (request.params[1].type() == UniValue::VBOOL) { |
|
|
|
// backward compatibility bool only fallback
|
|
|
|
// backward compatibility bool only fallback
|
|
|
|
includeWatching = request.params[1].get_bool(); |
|
|
|
coinControl.fAllowWatchOnly = request.params[1].get_bool(); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VSTR)(UniValue::VOBJ)); |
|
|
|
RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VSTR)(UniValue::VOBJ)); |
|
|
@ -2716,14 +2718,14 @@ UniValue fundrawtransaction(const JSONRPCRequest& request) |
|
|
|
if (!address.IsValid()) |
|
|
|
if (!address.IsValid()) |
|
|
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "changeAddress must be a valid bitcoin address"); |
|
|
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "changeAddress must be a valid bitcoin address"); |
|
|
|
|
|
|
|
|
|
|
|
changeAddress = address.Get(); |
|
|
|
coinControl.destChange = address.Get(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (options.exists("changePosition")) |
|
|
|
if (options.exists("changePosition")) |
|
|
|
changePosition = options["changePosition"].get_int(); |
|
|
|
changePosition = options["changePosition"].get_int(); |
|
|
|
|
|
|
|
|
|
|
|
if (options.exists("includeWatching")) |
|
|
|
if (options.exists("includeWatching")) |
|
|
|
includeWatching = options["includeWatching"].get_bool(); |
|
|
|
coinControl.fAllowWatchOnly = options["includeWatching"].get_bool(); |
|
|
|
|
|
|
|
|
|
|
|
if (options.exists("lockUnspents")) |
|
|
|
if (options.exists("lockUnspents")) |
|
|
|
lockUnspents = options["lockUnspents"].get_bool(); |
|
|
|
lockUnspents = options["lockUnspents"].get_bool(); |
|
|
@ -2733,8 +2735,8 @@ UniValue fundrawtransaction(const JSONRPCRequest& request) |
|
|
|
|
|
|
|
|
|
|
|
if (options.exists("feeRate")) |
|
|
|
if (options.exists("feeRate")) |
|
|
|
{ |
|
|
|
{ |
|
|
|
feeRate = CFeeRate(AmountFromValue(options["feeRate"])); |
|
|
|
coinControl.nFeeRate = CFeeRate(AmountFromValue(options["feeRate"])); |
|
|
|
overrideEstimatedFeerate = true; |
|
|
|
coinControl.fOverrideFeeRate = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (options.exists("subtractFeeFromOutputs")) |
|
|
|
if (options.exists("subtractFeeFromOutputs")) |
|
|
@ -2767,7 +2769,7 @@ UniValue fundrawtransaction(const JSONRPCRequest& request) |
|
|
|
CAmount nFeeOut; |
|
|
|
CAmount nFeeOut; |
|
|
|
std::string strFailReason; |
|
|
|
std::string strFailReason; |
|
|
|
|
|
|
|
|
|
|
|
if (!pwallet->FundTransaction(tx, nFeeOut, overrideEstimatedFeerate, feeRate, changePosition, strFailReason, includeWatching, lockUnspents, setSubtractFeeFromOutputs, reserveChangeKey, changeAddress)) { |
|
|
|
if (!pwallet->FundTransaction(tx, nFeeOut, changePosition, strFailReason, lockUnspents, setSubtractFeeFromOutputs, coinControl, reserveChangeKey)) { |
|
|
|
throw JSONRPCError(RPC_WALLET_ERROR, strFailReason); |
|
|
|
throw JSONRPCError(RPC_WALLET_ERROR, strFailReason); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|