diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3481,20 +3481,22 @@ // the user could have gotten from another RPC command prior to now pwallet->BlockUntilSyncedToCurrentChain(); - CTxDestination changeAddress = CNoDestination(); + CCoinControl coinControl; + coinControl.destChange = CNoDestination(); int changePosition = -1; - bool includeWatching = false; + // include watching + coinControl.fAllowWatchOnly = false; bool lockUnspents = false; bool reserveChangeKey = true; - CFeeRate feeRate = CFeeRate(Amount::zero()); - bool overrideEstimatedFeerate = false; + coinControl.nFeeRate = CFeeRate(Amount::zero()); + coinControl.fOverrideFeeRate = false; UniValue subtractFeeFromOutputs; std::set 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, {UniValue::VSTR, UniValue::VOBJ}); @@ -3525,7 +3527,7 @@ "changeAddress must be a valid bitcoin address"); } - changeAddress = dest; + coinControl.destChange = dest; } if (options.exists("changePosition")) { @@ -3533,7 +3535,8 @@ } if (options.exists("includeWatching")) { - includeWatching = options["includeWatching"].get_bool(); + coinControl.fAllowWatchOnly = + options["includeWatching"].get_bool(); } if (options.exists("lockUnspents")) { @@ -3545,8 +3548,9 @@ } if (options.exists("feeRate")) { - feeRate = CFeeRate(AmountFromValue(options["feeRate"])); - overrideEstimatedFeerate = true; + coinControl.nFeeRate = + CFeeRate(AmountFromValue(options["feeRate"])); + coinControl.fOverrideFeeRate = true; } if (options.exists("subtractFeeFromOutputs")) { @@ -3596,10 +3600,9 @@ Amount 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); } diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -993,13 +993,10 @@ * CreateTransaction(); */ bool FundTransaction(CMutableTransaction &tx, Amount &nFeeRet, - bool overrideEstimatedFeeRate, - const CFeeRate &specificFeeRate, int &nChangePosInOut, - std::string &strFailReason, bool includeWatching, + int &nChangePosInOut, std::string &strFailReason, bool lockUnspents, const std::set &setSubtractFeeFromOutputs, - bool keepReserveKey = true, - const CTxDestination &destChange = CNoDestination()); + CCoinControl coinControl, bool keepReserveKey = true); bool SignTransaction(CMutableTransaction &tx); /** diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2754,13 +2754,10 @@ } bool CWallet::FundTransaction(CMutableTransaction &tx, Amount &nFeeRet, - bool overrideEstimatedFeeRate, - const CFeeRate &specificFeeRate, int &nChangePosInOut, std::string &strFailReason, - bool includeWatching, bool lockUnspents, + bool lockUnspents, const std::set &setSubtractFeeFromOutputs, - bool keepReserveKey, - const CTxDestination &destChange) { + CCoinControl coinControl, bool keepReserveKey) { std::vector vecSend; // Turn the txout set into a CRecipient vector. @@ -2771,12 +2768,7 @@ vecSend.push_back(recipient); } - CCoinControl coinControl; - coinControl.destChange = destChange; coinControl.fAllowOtherInputs = true; - coinControl.fAllowWatchOnly = includeWatching; - coinControl.fOverrideFeeRate = overrideEstimatedFeeRate; - coinControl.nFeeRate = specificFeeRate; for (const CTxIn &txin : tx.vin) { coinControl.Select(txin.prevout);