21
21
#include " timedata.h"
22
22
#include " util.h"
23
23
#include " utilmoneystr.h"
24
+ #include " wallet/coincontrol.h"
24
25
#include " wallet/feebumper.h"
25
26
#include " wallet/wallet.h"
26
27
#include " wallet/walletdb.h"
@@ -2678,20 +2679,21 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
2678
2679
2679
2680
RPCTypeCheck (request.params , boost::assign::list_of (UniValue::VSTR));
2680
2681
2681
- CTxDestination changeAddress = CNoDestination ();
2682
+ CCoinControl coinControl;
2683
+ coinControl.destChange = CNoDestination ();
2682
2684
int changePosition = -1 ;
2683
- bool includeWatching = false ;
2685
+ coinControl. fAllowWatchOnly = false ; // include watching
2684
2686
bool lockUnspents = false ;
2685
2687
bool reserveChangeKey = true ;
2686
- CFeeRate feeRate = CFeeRate (0 );
2687
- bool overrideEstimatedFeerate = false ;
2688
+ coinControl. nFeeRate = CFeeRate (0 );
2689
+ coinControl. fOverrideFeeRate = false ;
2688
2690
UniValue subtractFeeFromOutputs;
2689
2691
std::set<int > setSubtractFeeFromOutputs;
2690
2692
2691
2693
if (request.params .size () > 1 ) {
2692
2694
if (request.params [1 ].type () == UniValue::VBOOL) {
2693
2695
// backward compatibility bool only fallback
2694
- includeWatching = request.params [1 ].get_bool ();
2696
+ coinControl. fAllowWatchOnly = request.params [1 ].get_bool ();
2695
2697
}
2696
2698
else {
2697
2699
RPCTypeCheck (request.params , boost::assign::list_of (UniValue::VSTR)(UniValue::VOBJ));
@@ -2716,14 +2718,14 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
2716
2718
if (!address.IsValid ())
2717
2719
throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, " changeAddress must be a valid bitcoin address" );
2718
2720
2719
- changeAddress = address.Get ();
2721
+ coinControl. destChange = address.Get ();
2720
2722
}
2721
2723
2722
2724
if (options.exists (" changePosition" ))
2723
2725
changePosition = options[" changePosition" ].get_int ();
2724
2726
2725
2727
if (options.exists (" includeWatching" ))
2726
- includeWatching = options[" includeWatching" ].get_bool ();
2728
+ coinControl. fAllowWatchOnly = options[" includeWatching" ].get_bool ();
2727
2729
2728
2730
if (options.exists (" lockUnspents" ))
2729
2731
lockUnspents = options[" lockUnspents" ].get_bool ();
@@ -2733,8 +2735,8 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
2733
2735
2734
2736
if (options.exists (" feeRate" ))
2735
2737
{
2736
- feeRate = CFeeRate (AmountFromValue (options[" feeRate" ]));
2737
- overrideEstimatedFeerate = true ;
2738
+ coinControl. nFeeRate = CFeeRate (AmountFromValue (options[" feeRate" ]));
2739
+ coinControl. fOverrideFeeRate = true ;
2738
2740
}
2739
2741
2740
2742
if (options.exists (" subtractFeeFromOutputs" ))
@@ -2767,7 +2769,7 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
2767
2769
CAmount nFeeOut;
2768
2770
std::string strFailReason;
2769
2771
2770
- if (!pwallet->FundTransaction (tx, nFeeOut, overrideEstimatedFeerate, feeRate, changePosition, strFailReason, includeWatching, lockUnspents, setSubtractFeeFromOutputs, reserveChangeKey, changeAddress )) {
2772
+ if (!pwallet->FundTransaction (tx, nFeeOut, changePosition, strFailReason, lockUnspents, setSubtractFeeFromOutputs, coinControl, reserveChangeKey )) {
2771
2773
throw JSONRPCError (RPC_WALLET_ERROR, strFailReason);
2772
2774
}
2773
2775
0 commit comments