Skip to content

Conversation

@ryanofsky
Copy link
Contributor

@ryanofsky ryanofsky commented Aug 14, 2017

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:

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.
Copy link
Contributor

@promag promag left a 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);
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, you did!

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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()) {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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).

Copy link
Member

@laanwj laanwj Aug 15, 2017

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.

@ryanofsky
Copy link
Contributor Author

Added a documentation commit 4195613 -> f4c29d6 (pr/narg.2 -> pr/narg.3, compare)

@promag
Copy link
Contributor

promag commented Aug 15, 2017

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.
@ryanofsky
Copy link
Contributor Author

ryanofsky commented Aug 15, 2017

Added another commit to clean up getbalance code a little and make it return nicer errors: f4c29d6 -> a53cb75 (pr/narg.3 -> pr/narg.4, compare).

Updated commit messages (no code changes): a53cb75 -> 745d2e3 (pr/narg.4 -> pr/narg.5)

@meshcollider
Copy link
Contributor

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())
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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)

Copy link
Member

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())
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@jnewbery jnewbery left a 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);
Copy link
Contributor

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.

Copy link
Contributor Author

@ryanofsky ryanofsky left a 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);
Copy link
Contributor Author

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.

Copy link
Contributor

@jnewbery jnewbery left a 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);
Copy link
Contributor

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();
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add {} where appropriate.

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

@promag
Copy link
Contributor

promag commented Aug 18, 2017

utACK 745d2e3.

@TheBlueMatt
Copy link
Contributor

utACK 745d2e3

@laanwj
Copy link
Member

laanwj commented Aug 22, 2017

utACK 745d2e3

@laanwj laanwj merged commit 745d2e3 into bitcoin:master Aug 22, 2017
laanwj added a commit that referenced this pull request Aug 22, 2017
…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
mempko pushed a commit to meritlabs/merit that referenced this pull request Sep 28, 2017
…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
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 25, 2019
…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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Dec 9, 2019
… 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
codablock added a commit to codablock/dash that referenced this pull request Dec 31, 2019
codablock added a commit to codablock/dash that referenced this pull request Dec 31, 2019
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 3, 2020
… 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]>
jonspock pushed a commit to jonspock/devault that referenced this pull request Oct 1, 2020
…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
jonspock pushed a commit to jonspock/devault that referenced this pull request Oct 1, 2020
…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
jonspock pushed a commit to jonspock/devault that referenced this pull request Oct 5, 2020
…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
jonspock pushed a commit to devaultcrypto/devault that referenced this pull request Oct 10, 2020
…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
gades pushed a commit to cosanta/cosanta-core that referenced this pull request Jun 26, 2021
… 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]>
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants