@@ -2496,6 +2496,7 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
24962496 " \" changePosition\" (numeric, optional, default random) The index of the change output\n "
24972497 " \" includeWatching\" (boolean, optional, default false) Also select inputs which are watch only\n "
24982498 " \" lockUnspents\" (boolean, optional, default false) Lock selected unspent outputs\n "
2499+ " \" reserveChangeKey\" (boolean, optional, default true) Reserves the change output key from the keypool\n "
24992500 " \" feeRate\" (numeric, optional, default not set: makes wallet determine the fee) Set a specific feerate (" + CURRENCY_UNIT + " per KB)\n "
25002501 " \" subtractFeeFromOutputs\" (array, optional) A json array of integers.\n "
25012502 " The fee will be equally deducted from the amount of each specified output.\n "
@@ -2528,6 +2529,7 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
25282529 int changePosition = -1 ;
25292530 bool includeWatching = false ;
25302531 bool lockUnspents = false ;
2532+ bool reserveChangeKey = true ;
25312533 CFeeRate feeRate = CFeeRate (0 );
25322534 bool overrideEstimatedFeerate = false ;
25332535 UniValue subtractFeeFromOutputs;
@@ -2549,6 +2551,7 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
25492551 {" changePosition" , UniValueType (UniValue::VNUM)},
25502552 {" includeWatching" , UniValueType (UniValue::VBOOL)},
25512553 {" lockUnspents" , UniValueType (UniValue::VBOOL)},
2554+ {" reserveChangeKey" , UniValueType (UniValue::VBOOL)},
25522555 {" feeRate" , UniValueType ()}, // will be checked below
25532556 {" subtractFeeFromOutputs" , UniValueType (UniValue::VARR)},
25542557 },
@@ -2572,6 +2575,9 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
25722575 if (options.exists (" lockUnspents" ))
25732576 lockUnspents = options[" lockUnspents" ].get_bool ();
25742577
2578+ if (options.exists (" reserveChangeKey" ))
2579+ reserveChangeKey = options[" reserveChangeKey" ].get_bool ();
2580+
25752581 if (options.exists (" feeRate" ))
25762582 {
25772583 feeRate = CFeeRate (AmountFromValue (options[" feeRate" ]));
@@ -2608,7 +2614,7 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
26082614 CAmount nFeeOut;
26092615 string strFailReason;
26102616
2611- if (!pwalletMain->FundTransaction (tx, nFeeOut, overrideEstimatedFeerate, feeRate, changePosition, strFailReason, includeWatching, lockUnspents, setSubtractFeeFromOutputs, changeAddress))
2617+ if (!pwalletMain->FundTransaction (tx, nFeeOut, overrideEstimatedFeerate, feeRate, changePosition, strFailReason, includeWatching, lockUnspents, setSubtractFeeFromOutputs, reserveChangeKey, changeAddress))
26122618 throw JSONRPCError (RPC_INTERNAL_ERROR, strFailReason);
26132619
26142620 UniValue result (UniValue::VOBJ);
0 commit comments