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