Skip to content

rpc: Validate provided keys for query_options parameter in listunspent - #19169

Merged
maflcko merged 1 commit into
bitcoin:masterfrom
PastaPastaPasta:bitcoin-validate-keys-listunspent
Aug 27, 2020
Merged

maflcko merged 1 commit into
bitcoin:masterfrom
PastaPastaPasta:bitcoin-validate-keys-listunspent

Conversation

@PastaPastaPasta

Copy link
Copy Markdown
Contributor

At Dash, one of our developers was working with the listunspent RPC command, but instead of saying "minimumAmount" he said "minimmumAmount" as such the RPC wasn't working as expected.

In dashpay#3507 we implemented a check so that listunspent returns an error if an unrecognized option is given. I figured I might as well adapt the code and throw up a PR here.

Cheers!

@luke-jr luke-jr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you refactor this to use RPCTypeCheckObj?

@PastaPastaPasta
PastaPastaPasta force-pushed the bitcoin-validate-keys-listunspent branch from 604b265 to 79f31d5 Compare June 5, 2020 18:40
@PastaPastaPasta

Copy link
Copy Markdown
Contributor Author

I like that, makes it simpler, changed, and squashed/force-pushed

@PastaPastaPasta

Copy link
Copy Markdown
Contributor Author

Tested with

generatetoaddress 105 bcrt1qwq0cnj557dn070dd8l52dhkathpx083qlg5v4w
listunspent 1 99999999 [] true "{\"minimumAmount\" : 49}"
listunspent 1 99999999 [] true "{\"minimumAmount\" : 51}"
listunspent 1 99999999 [] true "{\"minimumAAmount\" : 51}"

Everything worked as expected

With this change listunspent will throw an error if there is a wrong key
in the query_option object.

Signed-off-by: pasta <[email protected]>
@PastaPastaPasta
PastaPastaPasta force-pushed the bitcoin-validate-keys-listunspent branch from 79f31d5 to a99a3c0 Compare June 5, 2020 20:03
@PastaPastaPasta

Copy link
Copy Markdown
Contributor Author

Resolved test failure. made amounts not have their type checked since that gets checked anyway in AmountFromValue

luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Jun 9, 2020
With this change listunspent will throw an error if there is a wrong key
in the query_option object.

Signed-off-by: pasta <[email protected]>

Github-Pull: bitcoin#19169
Rebased-From: a99a3c0
@adaminsky

Copy link
Copy Markdown
Contributor

ACK a99a3c0bd
Built, ran unit tests and functional tests, and manually tested RPCs with different query_options objects including unsupported parameters. Reviewed the code and it looks good.

@meshcollider meshcollider left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems fine to me. utACK a99a3c0

@fanquake

Copy link
Copy Markdown
Member

@MarcoFalke can you take a look here?

@maflcko

maflcko commented Aug 27, 2020

Copy link
Copy Markdown
Member

RPCman will do this in the future, but nothing wrong adding something like that in the meantime

@maflcko
maflcko merged commit b987e65 into bitcoin:master Aug 27, 2020
@PastaPastaPasta
PastaPastaPasta deleted the bitcoin-validate-keys-listunspent branch September 11, 2021 20:09
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Sep 16, 2021
Summary:
> With this change listunspent will throw an error if there is a wrong key
> in the query_option object.
>
> Signed-off-by: pasta <[email protected]>

Comment by @MarcoFalke:
> RPCman will do this in the future, but nothing wrong adding something like that in the meantime

This is a backport of [[bitcoin/bitcoin#19169 | core#19169]]

Test Plan: `ninja all check-all`

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D10129
@bitcoin bitcoin locked and limited conversation to collaborators Oct 30, 2022
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