diff options
author | Luke Dashjr <luke-jr+git@utopios.org> | 2017-02-02 22:33:24 +0000 |
---|---|---|
committer | Luke Dashjr <luke-jr+git@utopios.org> | 2017-06-05 23:12:03 +0000 |
commit | 891c5eeec2dbf295d14e8f888de02637367dd930 (patch) | |
tree | caf65931f13e4084c10e8a324ab80c94d137856d /src/wallet/rpcwallet.cpp | |
parent | 578ec80d4fcef6be48acf45185d1248bb62bfdbf (diff) |
Wallet: Refactor FundTransaction to accept parameters via CCoinControl
Diffstat (limited to 'src/wallet/rpcwallet.cpp')
-rw-r--r-- | src/wallet/rpcwallet.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 3b6dfd42ca..5e264dd1a4 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -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); } |