Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
getrawtransaction should take a bool for verbose #9025
Conversation
|
utACK, but please remove the deprecation warning. We may want to repurpose the ints as 'verbosity level' in the future, if an even more verbose mode is added. See #8704 (comment) . There's zero overhead in simply accepting both without warnings or complaints. Maybe add a |
|
Seems if we're going to do a verbosity level for getblock, we should just make that the "preferred" form here too? |
NACK. There are several other RPCs which take a bool for a more verbose output: getrawmempool, getmempoolancestors, getmempooldescendants, getblockheader, getblock, gettxout (where the option is includemempool). As far as I can tell, getrawtransaction is the only call which currently takes a num. It's less disruptive to change one RPC to use a bool than change all the others to use nums. |
|
@laanwj - warning removed and commits squashed. |
laanwj
added
the
RPC/REST/ZMQ
label
Oct 26, 2016
| "\nArguments:\n" | ||
| "1. \"txid\" (string, required) The transaction id\n" | ||
| - "2. verbose (numeric, optional, default=0) If 0, return a string, other return a json object\n" | ||
| + "2. verbose (bool, optional, default=false) If true, return a string, other return a json object\n" | ||
| "\nResult (if verbose is not set or set to 0):\n" |
| - fVerbose = (request.params[1].get_int() != 0); | ||
| + if ((request.params.size() > 1) && | ||
| + ((request.params[1].isNum() && request.params[1].get_int() != 0) || | ||
| + (request.params[1].isBool() && request.params[1].get_bool()))) |
jonasschnelli
Oct 28, 2016
Member
maybe simplify with s/(request.params[1].isBool() && request.params[1].get_bool())/request.params[1].isTrue()/
|
utACK 837c06f, maybe consider nits/simplifications. |
|
Thanks @jonasschnelli . Nits fixed and squashed. |
| - fVerbose = (request.params[1].get_int() != 0); | ||
| + if ((request.params.size() > 1) && | ||
| + ((request.params[1].isNum() && request.params[1].get_int() != 0) || | ||
| + (request.params[1].isTrue()))) |
laanwj
Nov 2, 2016
Owner
Note that isTrue doesn't fail if the value is not a bool, so this also accepts non-bool and non-int values. E.g.:
src/bitcoin-cli -regtest getrawtransaction 0000000000000000000000000000000000000000000000000000000000000000 '"b"'
error code: -5
error message:
No information available about transaction
Same for {} [] etc. Should probably raise an error in that case.
|
@jnewbery this just needs my above comment fixed and it can be merged. |
|
Thanks @laanwj . I've made the suggested change. I want to write some additional test cases to cover the new code and then I'll push the new commits. |
jnewbery
added some commits
Oct 26, 2016
|
@laanwj - as requested, |
|
utACK 240189b |
jnewbery commentedOct 26, 2016
As suggested by @gmaxwell in #9024 .
getrawtransaction now takes a bool for verbose. It will still take an int for verbose for back-compatibility, but issue a warning to the user.