[wallet] Deprecate the generate RPC method

pull/14468/head
John Newbery 6 years ago
parent aab81720de
commit c9f02955b2

@ -0,0 +1,15 @@
Wallet `generate` RPC method deprecated
---------------------------------------
The wallet's `generate` RPC method has been deprecated and will be fully
removed in v0.19.
`generate` is only used for testing. The RPC call reaches across multiple
subsystems (wallet and mining), so is deprecated to simplify the wallet-node
interface. Projects that are using `generate` for testing purposes should
transition to using the `generatetoaddress` call, which does not require or use
the wallet component. Calling `generatetoaddress` with an address returned by
`getnewaddress` gives the same functionality as the old `generate` method.
To continue using `generate` in v0.18, restart bitcoind with the
`-deprecatedrpc=generate` configuration.

@ -3289,6 +3289,12 @@ UniValue generate(const JSONRPCRequest& request)
);
}
if (!IsDeprecatedRPCEnabled("generate")) {
throw JSONRPCError(RPC_METHOD_DEPRECATED, "The wallet generate rpc method is deprecated and will be fully removed in v0.19. "
"To use generate in v0.18, restart bitcoind with -deprecatedrpc=generate.\n"
"Clients should transition to using the node rpc method generatetoaddress\n");
}
int num_generate = request.params[0].get_int();
uint64_t max_tries = 1000000;
if (!request.params[1].isNull()) {

@ -4,12 +4,17 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test deprecation of RPC calls."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_raises_rpc_error
class DeprecatedRpcTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 2
self.setup_clean_chain = True
self.extra_args = [[], ["-deprecatedrpc=validateaddress"]]
self.extra_args = [[], ["-deprecatedrpc=generate"]]
def skip_test_if_missing_module(self):
# The generate RPC method requires the wallet to be compiled
self.skip_if_no_wallet()
def run_test(self):
# This test should be used to verify correct behaviour of deprecated
@ -18,7 +23,10 @@ class DeprecatedRpcTest(BitcoinTestFramework):
# self.log.info("Make sure that -deprecatedrpc=createmultisig allows it to take addresses")
# assert_raises_rpc_error(-5, "Invalid public key", self.nodes[0].createmultisig, 1, [self.nodes[0].getnewaddress()])
# self.nodes[1].createmultisig(1, [self.nodes[1].getnewaddress()])
pass
self.log.info("Test generate RPC")
assert_raises_rpc_error(-32, 'The wallet generate rpc method is deprecated', self.nodes[0].rpc.generate, 1)
self.nodes[1].generate(1)
if __name__ == '__main__':
DeprecatedRpcTest().main()

Loading…
Cancel
Save