diff --git a/doc/release-notes.md b/doc/release-notes.md --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -3,4 +3,4 @@ This release includes the following features and fixes: - + - Deprecated the `-reserveChangeKey` option for `fundrawtransaction` wallet rpc command. 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,8 @@ "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" + " \"reserveChangeKey\" (boolean, optional) " + "DEPRECATED. 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 +3517,8 @@ CCoinControl coinControl; int changePosition = -1; bool lockUnspents = false; - bool reserveChangeKey = true; + // DEPRECATED, should be removed in 0.20 + bool reserveChangeKey = false; UniValue subtractFeeFromOutputs; std::set setSubtractFeeFromOutputs; @@ -3537,6 +3538,7 @@ {"changePosition", UniValueType(UniValue::VNUM)}, {"includeWatching", UniValueType(UniValue::VBOOL)}, {"lockUnspents", UniValueType(UniValue::VBOOL)}, + // DEPRECATED, should be removed in 0.20 {"reserveChangeKey", UniValueType(UniValue::VBOOL)}, // will be checked below {"feeRate", UniValueType()}, @@ -3571,8 +3573,20 @@ lockUnspents = options["lockUnspents"].get_bool(); } + // DEPRECATED, should be removed in v0.20 if (options.exists("reserveChangeKey")) { - reserveChangeKey = options["reserveChangeKey"].get_bool(); + if (!IsDeprecatedRPCEnabled(gArgs, "fundrawtransaction")) { + throw JSONRPCError( + RPC_METHOD_DEPRECATED, + "fundrawtransaction -reserveChangeKey is deprecated " + "and will be fully removed in v0.20. To use the " + "-reserveChangeKey option in v0.19, restart bitcoind " + "with -deprecatedrpc=fundrawtransaction.\nProjects " + "should transition to expecting change addresses " + "removed from the keypool before upgrading to v0.20"); + } else { + reserveChangeKey = options["reserveChangeKey"].get_bool(); + } } if (options.exists("feeRate")) { 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 keepReserveKey); 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 @@ -19,6 +19,7 @@ #include #include #include +#include // for IsDeprecatedRPCEnabled #include #include