Skip to content
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

rpc: Properly document return values (submitblock, gettxout, getblocktemplate, scantxoutset) #20556

Merged
merged 4 commits into from
Mar 15, 2021

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Dec 3, 2020

Currently a few return values are undocumented. This is causing confusion at the least. See for example #18476

@DrahtBot
Copy link
Contributor

DrahtBot commented Dec 3, 2020

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

Copy link
Member

@jarolrod jarolrod left a comment

Choose a reason for hiding this comment

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

Testing fa3cbac
Calling gettxout with an invalid utxo returns no output using bitcoin-cli, but returns null in the gui. I think the better behavior would be to return an empty json block like we do with other rpc commands such as listtransactions

@maflcko
Copy link
Member Author

maflcko commented Dec 4, 2020

This can be discussed in #18476 further. The goal of this pull is to simply document the return values as they are and always have been.

@jonasschnelli
Copy link
Contributor

Looks good.
What is the rational in renaming STR_AMOUNT to NUM_AMOUNT? It creates a fairly large diff and IMO it still is represented as a string on the JSON layer.

@maflcko
Copy link
Member Author

maflcko commented Dec 7, 2020

The (scripted) diff is only 50 lines. If there are any conflicts, it should be trivial to resolve. That the internal representation is a string could be a coincidence. The type is really VNUM (numeric) and not VSTR (string).

I checked that the only conflict due to this scripted diff is #19002.

@laanwj
Copy link
Member

laanwj commented Dec 18, 2020

Just an aside: there used to be talk of, at some point, of making ValueFromAmount return a decimal string instead of a number, or at least having an option to do so, because it's easier to parse exactly in some languages that interpret javascript numbers as floating point number (which are unwise to use for monetary amounts). See e.g. #3759.

This bled out but seeing them as separate types an abstraction level above JSON string/value distinction makes sense.

@maflcko
Copy link
Member Author

maflcko commented Dec 21, 2020

Ok, dropped the scripted diff because it seemed controversial

@maflcko
Copy link
Member Author

maflcko commented Jan 29, 2021

Rebased

Copy link
Contributor

@amitiuttarwar amitiuttarwar left a comment

Choose a reason for hiding this comment

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

concept ACK. one improvement requested, otherwise generally looks good. I checked most of the documented results actually match up.

src/rpc/blockchain.cpp Outdated Show resolved Hide resolved
src/rpc/mining.cpp Outdated Show resolved Hide resolved
MarcoFalke added 2 commits February 25, 2021 08:06
Can be reviewed with --ignore-all-space
Can be reviewed with --ignore-all-space
MarcoFalke added 2 commits February 25, 2021 08:21
Can be reviewed with --ignore-all-space
Can be reviewed with --ignore-all-space
@maflcko
Copy link
Member Author

maflcko commented Feb 25, 2021

Force pushed to address feedback. Should be easy to re-ACK with git range-diff

Copy link
Contributor

@amitiuttarwar amitiuttarwar left a comment

Choose a reason for hiding this comment

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

tACK fa7ff07

  • gettxout -> checked we get an empty result if UTXO is not found
  • scantxoutset -> checked abort returns bool, status returns empty or progress based on if scan is occurring, the existing docs apply to results from start command.
  • getblocktemplate -> checked we get string result if proposal is rejected, didn't test an accepted proposal, but saw in the code that we would return null, saw the existing docs apply to other modes.
  • submitblock -> same, saw string for failure, looked at code for success

made sure all the help docs make sense & look good when called from command line

the changes from }, \n }, -> }}, kind of confuse me, but I assume its fine considering code compiles & help docs are showing up correctly.

src/rpc/mining.cpp Show resolved Hide resolved
@fjahr
Copy link
Contributor

fjahr commented Mar 14, 2021

utACK fa7ff07

Reviewed changes ignoring whitespace.

@fanquake fanquake merged commit 16209b1 into bitcoin:master Mar 15, 2021
@maflcko maflcko deleted the 2012-rpcDoc branch March 15, 2021 08:20
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Mar 15, 2021
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Dec 14, 2021
Can be reviewed with --ignore-all-space

Github-Pull: bitcoin#20556
Rebased-From: faa2059
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Dec 14, 2021
Can be reviewed with --ignore-all-space

Github-Pull: bitcoin#20556
Rebased-From: fabaccf
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Dec 14, 2021
Can be reviewed with --ignore-all-space

Github-Pull: bitcoin#20556
Rebased-From: fae542c
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Dec 14, 2021
Can be reviewed with --ignore-all-space

Github-Pull: bitcoin#20556
Rebased-From: fa7ff07
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Apr 13, 2022
…template, scantxoutset)

Summary: This is a backport of [[bitcoin/bitcoin#20556 | core#20556]]

Test Plan:
```
src/bitcoin-cli help submitblock
src/bitcoin-cli help gettxout
src/bitcoin-cli help getblocktemplate
src/bitcoin-cli help scantxoutset

```

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D11337
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 16, 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.

None yet

8 participants