diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3465,8 +3465,6 @@ "false) Also select inputs which are watch only\n" " \"lockUnspents\" (boolean, optional, default " "false) Lock selected unspent outputs\n" - " \"reserveChangeKey\" (boolean, optional, default true) " - "Reserves the change output key from the keypool\n" " \"feeRate\" (numeric, optional, default not " "set: makes wallet determine the fee) Set a specific feerate (" + CURRENCY_UNIT + @@ -3517,7 +3515,6 @@ CCoinControl coinControl; int changePosition = -1; bool lockUnspents = false; - bool reserveChangeKey = true; UniValue subtractFeeFromOutputs; std::set setSubtractFeeFromOutputs; @@ -3537,6 +3534,8 @@ {"changePosition", UniValueType(UniValue::VNUM)}, {"includeWatching", UniValueType(UniValue::VBOOL)}, {"lockUnspents", UniValueType(UniValue::VBOOL)}, + // DEPRECATED (and ignored), should be removed in 0.16 or + // so. {"reserveChangeKey", UniValueType(UniValue::VBOOL)}, // will be checked below {"feeRate", UniValueType()}, @@ -3571,10 +3570,6 @@ lockUnspents = options["lockUnspents"].get_bool(); } - if (options.exists("reserveChangeKey")) { - reserveChangeKey = options["reserveChangeKey"].get_bool(); - } - if (options.exists("feeRate")) { coinControl.m_feerate = CFeeRate(AmountFromValue(options["feeRate"])); @@ -3630,7 +3625,7 @@ if (!pwallet->FundTransaction(tx, nFeeOut, changePosition, strFailReason, lockUnspents, setSubtractFeeFromOutputs, - coinControl, reserveChangeKey)) { + coinControl)) { 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 @@ -988,7 +988,7 @@ int &nChangePosInOut, std::string &strFailReason, bool lockUnspents, const std::set &setSubtractFeeFromOutputs, - CCoinControl coinControl, bool keepReserveKey = true); + CCoinControl coinControl); 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 @@ -2760,7 +2760,7 @@ int &nChangePosInOut, std::string &strFailReason, bool lockUnspents, const std::set &setSubtractFeeFromOutputs, - CCoinControl coinControl, bool keepReserveKey) { + CCoinControl coinControl) { std::vector vecSend; // Turn the txout set into a CRecipient vector. @@ -2788,6 +2788,9 @@ if (nChangePosInOut != -1) { tx.vout.insert(tx.vout.begin() + nChangePosInOut, tx_new->vout[nChangePosInOut]); + // we dont have the normal Create/Commit cycle, and dont want to risk + // reusing change, so just remove the key from the keypool here. + reservekey.KeepKey(); } // Copy output sizes from new transaction; they may have had the fee @@ -2808,11 +2811,6 @@ } } - // Optionally keep the change output key. - if (keepReserveKey) { - reservekey.KeepKey(); - } - return true; } diff --git a/test/functional/rpc_fundrawtransaction.py b/test/functional/rpc_fundrawtransaction.py --- a/test/functional/rpc_fundrawtransaction.py +++ b/test/functional/rpc_fundrawtransaction.py @@ -681,21 +681,9 @@ result3['fee'], FromHex(CTransaction(), result3['hex']).billable_size(), 10 * result_fee_rate, 10) # - # Test address reuse option # + # Test no address reuse occurs # # - result3 = self.nodes[3].fundrawtransaction( - rawTx, {"reserveChangeKey": False}) - res_dec = self.nodes[0].decoderawtransaction(result3["hex"]) - changeaddress = "" - for out in res_dec['vout']: - if out['value'] > 1.0: - changeaddress += out['scriptPubKey']['addresses'][0] - assert(changeaddress != "") - nextaddr = self.nodes[3].getrawchangeaddress() - # frt should not have removed the key from the keypool - assert(changeaddress == nextaddr) - result3 = self.nodes[3].fundrawtransaction(rawTx) res_dec = self.nodes[0].decoderawtransaction(result3["hex"]) changeaddress = ""