-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Avoid treating null RPC arguments different from missing arguments #11050
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
No change in behavior.
This changes RPC methods to treat null arguments the same as missing arguments, instead of throwing type errors. Specifically: - `getbalance` method now returns the wallet balance when the `account` param is null instead of throwing a type error (same as when parameter is missing). It is still an error to supply `minconf` or `watchonly` options when the account is null. - `addnode` and `setban` methods now return help text instead of type errors if `command` params are null (same as when params are missing). - `sendrawtransaction`, `setaccount`, `movecmd`, `sendfrom`, `addmultisigaddress`, `listaccounts`, `lockunspent` methods accept null default values where missing values were previously allowed, and treat them the same.
promag
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 4195613 modulo nits.
| return true; | ||
| } | ||
|
|
||
| RPCTypeCheckArgument(request.params[1], UniValue::VARR); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_array already throws and above you also replace RPCTypeCheck validation with get_bool. Remove?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_array already throws and above you also replace RPCTypeCheck validation with get_bool. Remove?
It throws a different error that doesn't specify passed type name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So add RPCTypeCheckArgument for 1st param?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, you did!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It throws a different error that doesn't specify passed type name.
So we should update is_<type>() error message to output the passed type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we should update is_() error message to output the passed type.
If you mean get_<type>() error message, we can do this but it would involve making a change upstream in https://github.com/jgarzik/univalue. Anyway this commit is trying to do exactly one thing: "treat null arguments the same as missing arguments, instead of throwing type errors". If people don't like RPCTypeCheck functions and would prefer to rely on UniValue exceptions, it really seems like a followup for a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I meant get_<type>().
Agree that this should be done in a follow-up PR. I've tested that this PR maintains existing behaviour for the error checking in lockunspent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added as followup in #11050 (comment)
| bool fUnlock = request.params[0].get_bool(); | ||
|
|
||
| if (request.params.size() == 1) { | ||
| if (request.params[1].isNull()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO size() sounds better in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with checking size == 1 is that it's fragile and will break if you want to add new arguments to the RPC.
Checking params.size() can also create confusion when using named arguments, because the current named argument implementation creates variable length null-padded arrays, so adding or removing one named argument can cause a completely different argument to switch from missing to null or vice versa.
The point of this PR is to avoid uses of params.size() to prevent missing arguments from being treated differently than null arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If another argument is added then this would be if (request.params[1].isNull() && request.params[2].isNull()) right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thread #11050 (comment)
No, params[1] is the transactions argument to the lockunspent RPC. The transactions argument may be an array of transaction outputs, or it may be null, or it may be missing.
This code is just saying that if the transactions argument is null or missing, then all transactions should be unlocked. The previous code only worked if transactions argument was missing, but not if the transactions argument was null (because it would trigger a type error).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with ryanofsky. isNull is correct here.
|
utACK f4c29d6. |
Only change in behavior is that unsupported combinations of parameters now trigger more specific error messages instead of the vague "JSON value is not a string as expected" error.
|
utACK 745d2e3 |
|
|
||
| CAmount nMaxRawTxFee = maxTxFee; | ||
| if (request.params.size() > 1 && request.params[1].get_bool()) | ||
| if (!request.params[1].isNull() && request.params[1].get_bool()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldnt this just be request.params[1].isTrue() like many other checks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldnt this just be request.params[1].isTrue() like many other checks?
This would be a different (and I think worse) behavior. Calling get_bool will throw an exception if the type is not boolean, while calling isTrue will just return false. I think it's better to throw an exception if a value other than true, false, or null is passed, instead taking all strings, objects and numbers to be false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is safer. It throws an error when the user passes in "True" as a string (rather than silently evaluating to false)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rather than silently evaluating to false
Yes, please be careful to throw exceptions on wrong types instead of silently ignoring errors. Than can lead to hazardous bugs in user code.
| if (nAmount <= 0) | ||
| throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); | ||
| if (request.params.size() > 3) | ||
| if (!request.params[3].isNull()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we just stop type-checking it instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we just stop type-checking it instead?
I think there's some benefit to keeping the type checking here, and it doesn't really cost anything. Maybe somebody forgets the dummy parameter and is calling this RPC with a comment. Slightly better to throw an error in get_int instead of silently dropping the comment.
jnewbery
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 745d2e3
I especially like the changes to getbalance. Returning an error is preferable to silently ignoring arguments passed in.
| return true; | ||
| } | ||
|
|
||
| RPCTypeCheckArgument(request.params[1], UniValue::VARR); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It throws a different error that doesn't specify passed type name.
So we should update is_<type>() error message to output the passed type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review.
I especially like the changes to getbalance. Returning an error is preferable to silently ignoring arguments passed in.
Note that the arguments weren't silently ignored before. They would just trigger more opaque "JSON value is not a string as expected" errors if they were non-null. (This is mentioned in the commit message.)
| return true; | ||
| } | ||
|
|
||
| RPCTypeCheckArgument(request.params[1], UniValue::VARR); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we should update is_() error message to output the passed type.
If you mean get_<type>() error message, we can do this but it would involve making a change upstream in https://github.com/jgarzik/univalue. Anyway this commit is trying to do exactly one thing: "treat null arguments the same as missing arguments, instead of throwing type errors". If people don't like RPCTypeCheck functions and would prefer to rely on UniValue exceptions, it really seems like a followup for a separate PR.
jnewbery
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK
| return true; | ||
| } | ||
|
|
||
| RPCTypeCheckArgument(request.params[1], UniValue::VARR); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I meant get_<type>().
Agree that this should be done in a follow-up PR. I've tested that this PR maintains existing behaviour for the error checking in lockunspent
| } | ||
|
|
||
| bool rbfOptIn = request.params.size() > 3 ? request.params[3].isTrue() : false; | ||
| bool rbfOptIn = request.params[3].isTrue(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This param should be type checked?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This param should be type checked?
Added as followup in #11050 (comment). This commit is not changing behavior in any way, and the PR is not adding new type checking in other places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit is not changing behavior
Right!
| { | ||
| std::string strCommand; | ||
| if (request.params.size() == 2) | ||
| if (!request.params[1].isNull()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add {} where appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add {} where appropriate.
Added as followup in #11050 (comment). This PR is already doing a bunch of different things and has been reviewed by 4 people. I don't want to add noise, delay, and complexity sticking braces everywhere as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
|
utACK 745d2e3. |
|
utACK 745d2e3 |
|
utACK 745d2e3 |
…g arguments 745d2e3 Clean up getbalance RPC parameter handling (Russell Yanofsky) fd5d71e Update developer notes after params.size() cleanup (Russell Yanofsky) e067673 Avoid treating null RPC arguments different from missing arguments (Russell Yanofsky) e666efc Get rid of redundant RPC params.size() checks (Russell Yanofsky) Pull request description: This is a followup to #10783. - The first commit doesn't change behavior at all, just simplifies code. - The second commit just changes RPC methods to treat null arguments the same as missing arguments instead of throwing type errors. - The third commit updates developer notes after the cleanup. - The forth commit does some additional code cleanup in `getbalance`. Followup changes that should happen in future PRs: - [ ] Replace uses of `.isTrue()` with calls to `.get_bool()` so numbers, objects, and strings cause type errors instead of being interpreted as false. #11050 (comment) - [ ] Add braces around if statements. #11050 (comment) - [ ] Maybe improve UniValue type error exceptions and eliminate RPCTypeCheck and RPCTypeCheckArgument functions. #11050 (comment) Tree-SHA512: e72f696011d20acc0778e996659e41f9426bffce387b29ff63bf59ad1163d5146761e4445b2b9b9e069a80596a57c7f4402b75a15d5d20f69f775ae558cf67e9
…g arguments 745d2e3 Clean up getbalance RPC parameter handling (Russell Yanofsky) fd5d71e Update developer notes after params.size() cleanup (Russell Yanofsky) e067673 Avoid treating null RPC arguments different from missing arguments (Russell Yanofsky) e666efc Get rid of redundant RPC params.size() checks (Russell Yanofsky) Pull request description: This is a followup to #10783. - The first commit doesn't change behavior at all, just simplifies code. - The second commit just changes RPC methods to treat null arguments the same as missing arguments instead of throwing type errors. - The third commit updates developer notes after the cleanup. - The forth commit does some additional code cleanup in `getbalance`. Followup changes that should happen in future PRs: - [ ] Replace uses of `.isTrue()` with calls to `.get_bool()` so numbers, objects, and strings cause type errors instead of being interpreted as false. bitcoin/bitcoin#11050 (comment) - [ ] Add braces around if statements. bitcoin/bitcoin#11050 (comment) - [ ] Maybe improve UniValue type error exceptions and eliminate RPCTypeCheck and RPCTypeCheckArgument functions. bitcoin/bitcoin#11050 (comment) Tree-SHA512: e72f696011d20acc0778e996659e41f9426bffce387b29ff63bf59ad1163d5146761e4445b2b9b9e069a80596a57c7f4402b75a15d5d20f69f775ae558cf67e9
…g arguments Summary: 745d2e3 Clean up getbalance RPC parameter handling (Russell Yanofsky) fd5d71e Update developer notes after params.size() cleanup (Russell Yanofsky) e067673 Avoid treating null RPC arguments different from missing arguments (Russell Yanofsky) e666efc Get rid of redundant RPC params.size() checks (Russell Yanofsky) Pull request description: This is a followup to #10783. - The first commit doesn't change behavior at all, just simplifies code. - The second commit just changes RPC methods to treat null arguments the same as missing arguments instead of throwing type errors. - The third commit updates developer notes after the cleanup. - The forth commit does some additional code cleanup in `getbalance`. Followup changes that should happen in future PRs: - [ ] Replace uses of `.isTrue()` with calls to `.get_bool()` so numbers, objects, and strings cause type errors instead of being interpreted as false. bitcoin/bitcoin#11050 (comment) - [ ] Add braces around if statements. bitcoin/bitcoin#11050 (comment) - [ ] Maybe improve UniValue type error exceptions and eliminate RPCTypeCheck and RPCTypeCheckArgument functions. bitcoin/bitcoin#11050 (comment) Tree-SHA512: e72f696011d20acc0778e996659e41f9426bffce387b29ff63bf59ad1163d5146761e4445b2b9b9e069a80596a57c7f4402b75a15d5d20f69f775ae558cf67e9 Backport of Core PR11050 bitcoin/bitcoin#11050 Depends on D3464 Test Plan: make check test_runner.py Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc Reviewed By: Fabien, O1 Bitcoin ABC, #bitcoin_abc Differential Revision: https://reviews.bitcoinabc.org/D3997
… missing arguments 745d2e3 Clean up getbalance RPC parameter handling (Russell Yanofsky) fd5d71e Update developer notes after params.size() cleanup (Russell Yanofsky) e067673 Avoid treating null RPC arguments different from missing arguments (Russell Yanofsky) e666efc Get rid of redundant RPC params.size() checks (Russell Yanofsky) Pull request description: This is a followup to bitcoin#10783. - The first commit doesn't change behavior at all, just simplifies code. - The second commit just changes RPC methods to treat null arguments the same as missing arguments instead of throwing type errors. - The third commit updates developer notes after the cleanup. - The forth commit does some additional code cleanup in `getbalance`. Followup changes that should happen in future PRs: - [ ] Replace uses of `.isTrue()` with calls to `.get_bool()` so numbers, objects, and strings cause type errors instead of being interpreted as false. bitcoin#11050 (comment) - [ ] Add braces around if statements. bitcoin#11050 (comment) - [ ] Maybe improve UniValue type error exceptions and eliminate RPCTypeCheck and RPCTypeCheckArgument functions. bitcoin#11050 (comment) Tree-SHA512: e72f696011d20acc0778e996659e41f9426bffce387b29ff63bf59ad1163d5146761e4445b2b9b9e069a80596a57c7f4402b75a15d5d20f69f775ae558cf67e9
… missing arguments 745d2e3 Clean up getbalance RPC parameter handling (Russell Yanofsky) fd5d71e Update developer notes after params.size() cleanup (Russell Yanofsky) e067673 Avoid treating null RPC arguments different from missing arguments (Russell Yanofsky) e666efc Get rid of redundant RPC params.size() checks (Russell Yanofsky) Pull request description: This is a followup to bitcoin#10783. - The first commit doesn't change behavior at all, just simplifies code. - The second commit just changes RPC methods to treat null arguments the same as missing arguments instead of throwing type errors. - The third commit updates developer notes after the cleanup. - The forth commit does some additional code cleanup in `getbalance`. Followup changes that should happen in future PRs: - [ ] Replace uses of `.isTrue()` with calls to `.get_bool()` so numbers, objects, and strings cause type errors instead of being interpreted as false. bitcoin#11050 (comment) - [ ] Add braces around if statements. bitcoin#11050 (comment) - [ ] Maybe improve UniValue type error exceptions and eliminate RPCTypeCheck and RPCTypeCheckArgument functions. bitcoin#11050 (comment) Tree-SHA512: e72f696011d20acc0778e996659e41f9426bffce387b29ff63bf59ad1163d5146761e4445b2b9b9e069a80596a57c7f4402b75a15d5d20f69f775ae558cf67e9 More of 11050 Fixes for bitcoin#11050 backport Fixes for bitcoin#11050 Fix masternode_winners RPC help check and revert few params[x].isNull() changes RPC: resolve index and '!' problems Co-Authored-By: UdjinM6 <[email protected]>
…g arguments Summary: 745d2e3 Clean up getbalance RPC parameter handling (Russell Yanofsky) fd5d71e Update developer notes after params.size() cleanup (Russell Yanofsky) e067673 Avoid treating null RPC arguments different from missing arguments (Russell Yanofsky) e666efc Get rid of redundant RPC params.size() checks (Russell Yanofsky) Pull request description: This is a followup to #10783. - The first commit doesn't change behavior at all, just simplifies code. - The second commit just changes RPC methods to treat null arguments the same as missing arguments instead of throwing type errors. - The third commit updates developer notes after the cleanup. - The forth commit does some additional code cleanup in `getbalance`. Followup changes that should happen in future PRs: - [ ] Replace uses of `.isTrue()` with calls to `.get_bool()` so numbers, objects, and strings cause type errors instead of being interpreted as false. bitcoin/bitcoin#11050 (comment) - [ ] Add braces around if statements. bitcoin/bitcoin#11050 (comment) - [ ] Maybe improve UniValue type error exceptions and eliminate RPCTypeCheck and RPCTypeCheckArgument functions. bitcoin/bitcoin#11050 (comment) Tree-SHA512: e72f696011d20acc0778e996659e41f9426bffce387b29ff63bf59ad1163d5146761e4445b2b9b9e069a80596a57c7f4402b75a15d5d20f69f775ae558cf67e9 Backport of Core PR11050 bitcoin/bitcoin#11050 Depends on D3464 Test Plan: make check test_runner.py Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc Reviewed By: Fabien, O1 Bitcoin ABC, #bitcoin_abc Differential Revision: https://reviews.bitcoinabc.org/D3997
…g arguments Summary: 745d2e3 Clean up getbalance RPC parameter handling (Russell Yanofsky) fd5d71e Update developer notes after params.size() cleanup (Russell Yanofsky) e067673 Avoid treating null RPC arguments different from missing arguments (Russell Yanofsky) e666efc Get rid of redundant RPC params.size() checks (Russell Yanofsky) Pull request description: This is a followup to #10783. - The first commit doesn't change behavior at all, just simplifies code. - The second commit just changes RPC methods to treat null arguments the same as missing arguments instead of throwing type errors. - The third commit updates developer notes after the cleanup. - The forth commit does some additional code cleanup in `getbalance`. Followup changes that should happen in future PRs: - [ ] Replace uses of `.isTrue()` with calls to `.get_bool()` so numbers, objects, and strings cause type errors instead of being interpreted as false. bitcoin/bitcoin#11050 (comment) - [ ] Add braces around if statements. bitcoin/bitcoin#11050 (comment) - [ ] Maybe improve UniValue type error exceptions and eliminate RPCTypeCheck and RPCTypeCheckArgument functions. bitcoin/bitcoin#11050 (comment) Tree-SHA512: e72f696011d20acc0778e996659e41f9426bffce387b29ff63bf59ad1163d5146761e4445b2b9b9e069a80596a57c7f4402b75a15d5d20f69f775ae558cf67e9 Backport of Core PR11050 bitcoin/bitcoin#11050 Depends on D3464 Test Plan: make check test_runner.py Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc Reviewed By: Fabien, O1 Bitcoin ABC, #bitcoin_abc Differential Revision: https://reviews.bitcoinabc.org/D3997
…g arguments Summary: 745d2e3 Clean up getbalance RPC parameter handling (Russell Yanofsky) fd5d71e Update developer notes after params.size() cleanup (Russell Yanofsky) e067673 Avoid treating null RPC arguments different from missing arguments (Russell Yanofsky) e666efc Get rid of redundant RPC params.size() checks (Russell Yanofsky) Pull request description: This is a followup to #10783. - The first commit doesn't change behavior at all, just simplifies code. - The second commit just changes RPC methods to treat null arguments the same as missing arguments instead of throwing type errors. - The third commit updates developer notes after the cleanup. - The forth commit does some additional code cleanup in `getbalance`. Followup changes that should happen in future PRs: - [ ] Replace uses of `.isTrue()` with calls to `.get_bool()` so numbers, objects, and strings cause type errors instead of being interpreted as false. bitcoin/bitcoin#11050 (comment) - [ ] Add braces around if statements. bitcoin/bitcoin#11050 (comment) - [ ] Maybe improve UniValue type error exceptions and eliminate RPCTypeCheck and RPCTypeCheckArgument functions. bitcoin/bitcoin#11050 (comment) Tree-SHA512: e72f696011d20acc0778e996659e41f9426bffce387b29ff63bf59ad1163d5146761e4445b2b9b9e069a80596a57c7f4402b75a15d5d20f69f775ae558cf67e9 Backport of Core PR11050 bitcoin/bitcoin#11050 Depends on D3464 Test Plan: make check test_runner.py Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc Reviewed By: Fabien, O1 Bitcoin ABC, #bitcoin_abc Differential Revision: https://reviews.bitcoinabc.org/D3997
…g arguments Summary: 745d2e3 Clean up getbalance RPC parameter handling (Russell Yanofsky) fd5d71e Update developer notes after params.size() cleanup (Russell Yanofsky) e067673 Avoid treating null RPC arguments different from missing arguments (Russell Yanofsky) e666efc Get rid of redundant RPC params.size() checks (Russell Yanofsky) Pull request description: This is a followup to #10783. - The first commit doesn't change behavior at all, just simplifies code. - The second commit just changes RPC methods to treat null arguments the same as missing arguments instead of throwing type errors. - The third commit updates developer notes after the cleanup. - The forth commit does some additional code cleanup in `getbalance`. Followup changes that should happen in future PRs: - [ ] Replace uses of `.isTrue()` with calls to `.get_bool()` so numbers, objects, and strings cause type errors instead of being interpreted as false. bitcoin/bitcoin#11050 (comment) - [ ] Add braces around if statements. bitcoin/bitcoin#11050 (comment) - [ ] Maybe improve UniValue type error exceptions and eliminate RPCTypeCheck and RPCTypeCheckArgument functions. bitcoin/bitcoin#11050 (comment) Tree-SHA512: e72f696011d20acc0778e996659e41f9426bffce387b29ff63bf59ad1163d5146761e4445b2b9b9e069a80596a57c7f4402b75a15d5d20f69f775ae558cf67e9 Backport of Core PR11050 bitcoin/bitcoin#11050 Depends on D3464 Test Plan: make check test_runner.py Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc Reviewed By: Fabien, O1 Bitcoin ABC, #bitcoin_abc Differential Revision: https://reviews.bitcoinabc.org/D3997
… missing arguments 745d2e3 Clean up getbalance RPC parameter handling (Russell Yanofsky) fd5d71e Update developer notes after params.size() cleanup (Russell Yanofsky) e067673 Avoid treating null RPC arguments different from missing arguments (Russell Yanofsky) e666efc Get rid of redundant RPC params.size() checks (Russell Yanofsky) Pull request description: This is a followup to bitcoin#10783. - The first commit doesn't change behavior at all, just simplifies code. - The second commit just changes RPC methods to treat null arguments the same as missing arguments instead of throwing type errors. - The third commit updates developer notes after the cleanup. - The forth commit does some additional code cleanup in `getbalance`. Followup changes that should happen in future PRs: - [ ] Replace uses of `.isTrue()` with calls to `.get_bool()` so numbers, objects, and strings cause type errors instead of being interpreted as false. bitcoin#11050 (comment) - [ ] Add braces around if statements. bitcoin#11050 (comment) - [ ] Maybe improve UniValue type error exceptions and eliminate RPCTypeCheck and RPCTypeCheckArgument functions. bitcoin#11050 (comment) Tree-SHA512: e72f696011d20acc0778e996659e41f9426bffce387b29ff63bf59ad1163d5146761e4445b2b9b9e069a80596a57c7f4402b75a15d5d20f69f775ae558cf67e9 More of 11050 Fixes for bitcoin#11050 backport Fixes for bitcoin#11050 Fix masternode_winners RPC help check and revert few params[x].isNull() changes RPC: resolve index and '!' problems Co-Authored-By: UdjinM6 <[email protected]>
This is a followup to #10783.
getbalance.Followup changes that should happen in future PRs:
.isTrue()with calls to.get_bool()so numbers, objects, and strings cause type errors instead of being interpreted as false. Avoid treating null RPC arguments different from missing arguments #11050 (comment)