It may be wrong doc-wise, but tests break if you make this mandatory. And it is optional in the code.
Edit: on the same note, this is not a behavior change, for the reasons stated above. It always behaved this way, even if the docs indicated differently.
Edit 2: the thing you pointed at actually throws the help topic because it does not provide any values;
https://github.com/bitcoin/bitcoin/blob/0221420d1a0550cd849e0f3a5ada3738d5931bdd/test/functional/mining_basic.py#L107-L108
When running with
$ git diff | cat
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp
index 1744acbb2..7b664e73b 100644
--- a/src/rpc/mining.cpp
+++ b/src/rpc/mining.cpp
@@ -291,7 +291,7 @@ static UniValue getblocktemplate(const JSONRPCRequest& request)
" https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki#getblocktemplate_changes\n"
" https://github.com/bitcoin/bips/blob/master/bip-0145.mediawiki\n",
{
- {"template_request", RPCArg::Type::OBJ, "{\"mode\":\"template\"}", "A json object in the following spec",
+ {"template_request", RPCArg::Type::OBJ, RPCArg::Optional::NO, "A json object in the following spec",
{
{"mode", RPCArg::Type::STR, /* treat as named arg */ RPCArg::Optional::OMITTED_NAMED_ARG, "This must be set to \"template\", \"proposal\" (see BIP 23), or omitted"},
{"capabilities", RPCArg::Type::ARR, /* treat as named arg */ RPCArg::Optional::OMITTED_NAMED_ARG, "A list of strings",
the output ends up as
$ ./mining_basic.py
[..]
2019-06-19T15:51:46.621000Z TestFramework (INFO): Create some old blocks
2019-06-19T15:51:48.842000Z TestFramework (INFO): getmininginfo
2019-06-19T15:51:48.849000Z TestFramework (INFO): getblocktemplate: Test capability advertised
2019-06-19T15:51:48.870000Z TestFramework (INFO): getblocktemplate: segwit rule must be set
2019-06-19T15:51:48.871000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
File "/Users/user/git/bitcoin/test/functional/test_framework/util.py", line 113, in try_rpc
fun(*args, **kwds)
File "/Users/user/git/bitcoin/test/functional/test_framework/coverage.py", line 47, in __call__
return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
File "/Users/user/git/bitcoin/test/functional/test_framework/authproxy.py", line 141, in __call__
raise JSONRPCException(response['error'], status)
test_framework.authproxy.JSONRPCException: getblocktemplate "template_request"
If the request parameters include a 'mode' key, that is used to explicitly select between the default 'template' request or a 'proposal'.
It returns data needed to construct a block to work on.
For full specification, see BIPs 22, 23, 9, and 145:
https://github.com/bitcoin/bips/blob/master/bip-0022.mediawiki
[...]
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblocktemplate", "params": [{"rules": ["segwit"]}] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/
(-1)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/user/git/bitcoin/test/functional/test_framework/test_framework.py", line 193, in main
self.run_test()
File "./mining_basic.py", line 108, in run_test
assert_raises_rpc_error(-8, "getblocktemplate must be called with the segwit rule set", node.getblocktemplate)
File "/Users/user/git/bitcoin/test/functional/test_framework/util.py", line 105, in assert_raises_rpc_error
assert try_rpc(code, message, fun, *args, **kwds), "No exception raised"
File "/Users/user/git/bitcoin/test/functional/test_framework/util.py", line 117, in try_rpc
raise AssertionError("Unexpected JSONRPC error code %i" % e.error["code"])
AssertionError: Unexpected JSONRPC error code -1
2019-06-19T15:51:48.937000Z TestFramework (INFO): Stopping nodes
2019-06-19T15:51:49.579000Z TestFramework (WARNING): Not cleaning up dir /var/folders/92/y_j8bzw95kn_lky71wr033dw0000gr/T/bitcoin_func_test_7trykhuw
2019-06-19T15:51:49.579000Z TestFramework (ERROR): Test failed. Test logging available at /var/folders/92/y_j8bzw95kn_lky71wr033dw0000gr/T/bitcoin_func_test_7trykhuw/test_framework.log
2019-06-19T15:51:49.580000Z TestFramework (ERROR): Hint: Call /Users/user/git/bitcoin/test/functional/combine_logs.py '/var/folders/92/y_j8bzw95kn_lky71wr033dw0000gr/T/bitcoin_func_test_7trykhuw' to consolidate all logs
which is why I did this fix in the first place.