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

doc: Fix RPC result documentation #22798

Merged
merged 1 commit into from
Sep 23, 2021
Merged

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Aug 25, 2021

Fix:

  • Incorrectly named fields
  • Add missing ones
  • Add missing optional flag

@jonatack
Copy link
Member

Wow. Concept ACK.

@ghost
Copy link

ghost commented Aug 25, 2021

If RPC result documentation is fixed in bulk, maybe this can be added: #22430

@theStack
Copy link
Contributor

Concept ACK

@maflcko
Copy link
Member Author

maflcko commented Aug 25, 2021

@prayank23 My plan is to auto-generate the RPC examples, so that such issues are impossible. See #22799 for the meta issue.

@maflcko
Copy link
Member Author

maflcko commented Aug 25, 2021

For reference, if someone wants to export the RPC docs to produce a rendered diff, the following patch might be useful:

(dump_dir is a directory created by git init)

diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp
index cf80b08b96..6c6a71c6e4 100644
--- a/src/rpc/server.cpp
+++ b/src/rpc/server.cpp
@@ -95,7 +95,7 @@ std::string CRPCTable::help(const std::string& strCommand, const JSONRPCRequest&
     {
         const CRPCCommand *pcmd = command.second;
         std::string strMethod = pcmd->name;
-        if ((strCommand != "" || pcmd->category == "hidden") && strMethod != strCommand)
+        if ((strCommand != "") && strMethod != strCommand)
             continue;
         jreq.strMethod = strMethod;
         try
diff --git a/test/functional/rpc_help.py b/test/functional/rpc_help.py
index de21f43747..753ee771ad 100755
--- a/test/functional/rpc_help.py
+++ b/test/functional/rpc_help.py
@@ -100,7 +100,7 @@ class HelpRpcTest(BitcoinTestFramework):
         # command titles
         titles = [line[3:-3] for line in node.help().splitlines() if line.startswith('==')]
 
-        components = ['Blockchain', 'Control', 'Generating', 'Mining', 'Network', 'Rawtransactions', 'Util']
+        components = ['Blockchain', 'Control', 'Generating', 'Hidden', 'Mining', 'Network', 'Rawtransactions', 'Util']
 
         if self.is_wallet_compiled():
             components.append('Wallet')
@@ -116,7 +116,8 @@ class HelpRpcTest(BitcoinTestFramework):
     def dump_help(self):
         dump_dir = os.path.join(self.options.tmpdir, 'rpc_help_dump')
         os.mkdir(dump_dir)
-        calls = [line.split(' ', 1)[0] for line in self.nodes[0].help().splitlines() if line and not line.startswith('==')]
+        dump_dir = '/tmp/temp_git/' ##HACK
+        calls = [line.split(' ', 1)[0].split('|', 1)[0] for line in self.nodes[0].help().splitlines() if line and not line.startswith('==')]
         for call in calls:
             with open(os.path.join(dump_dir, call), 'w', encoding='utf-8') as f:
                 # Make sure the node can generate the help at runtime without crashing

@DrahtBot
Copy link
Contributor

DrahtBot commented Aug 25, 2021

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #22650 (Remove -deprecatedrpc=addresses flag and corresponding code/logic by mjdietzx)
  • #22558 (psbt: Taproot fields for PSBT by achow101)
  • #22525 (docs: Update the explainer text for the listunspent RPC by Fonta1n3)
  • #22016 (rpc: add period_start to version bits statistics by Sjors)
  • #21283 (Implement BIP 370 PSBTv2 by achow101)
  • #19888 (rpc, test: Improve getblockstats for unspendables by fjahr)
  • #19002 (docs: Document that 'fee' is unavailable when there are non-wallet inputs by shesek)

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

@Herrytheeagle Herrytheeagle left a comment

Choose a reason for hiding this comment

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

Properly fixed with the comment integration for clear and understandable codebase

@lsilva01
Copy link
Contributor

Concept ACK

@practicalswift
Copy link
Contributor

Concept ACK

Copy link
Member

@fanquake fanquake left a comment

Choose a reason for hiding this comment

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

ACK fa1d3dd - Clearly this is a big improvement, some of the docs here are flat out wrong.

@@ -1078,22 +1083,23 @@ static RPCHelpMan decodepsbt()
}},
Copy link
Member

Choose a reason for hiding this comment

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

In decodepsbt, looks like scriptPubKey -> address should also be marked optional.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, fixed.

@@ -3426,6 +3429,10 @@ RPCHelpMan signrawtransactionwithwallet()
{
{RPCResult::Type::STR_HEX, "txid", "The hash of the referenced, previous transaction"},
{RPCResult::Type::NUM, "vout", "The index of the output to spent and used as input"},
{RPCResult::Type::ARR, "witness", "",
Copy link
Member

Choose a reason for hiding this comment

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

Should be added to signrawtransactionwithkey() as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

It already is?

{RPCResult::Type::NUM, "pingwait", "ping wait (if non-zero)"},
{RPCResult::Type::NUM, "pingtime", /* optional */ true, "ping time (if available)"},
{RPCResult::Type::NUM, "minping", /* optional */ true, "minimum observed ping time (if any at all)"},
{RPCResult::Type::NUM, "pingwait", /* optional */ true, "ping wait (if non-zero)"},
{RPCResult::Type::NUM, "version", "The peer version, such as 70001"},
{RPCResult::Type::STR, "subver", "The string version"},
{RPCResult::Type::BOOL, "inbound", "Inbound (true) or Outbound (false)"},
Copy link
Member

Choose a reason for hiding this comment

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

Should startingheight, synced_headers, synced_blocks .... addr_rate_limited be optional as well? They are dependant on fStateStats same as pingwait.

Copy link
Member Author

Choose a reason for hiding this comment

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

Strictly they are conditional. Though I think the RPC should be changed to not be racy, unless there is a strong reason for it to prefer to be racy.

Copy link
Member Author

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

Force pushed to reply to feedback

{RPCResult::Type::NUM, "pingwait", "ping wait (if non-zero)"},
{RPCResult::Type::NUM, "pingtime", /* optional */ true, "ping time (if available)"},
{RPCResult::Type::NUM, "minping", /* optional */ true, "minimum observed ping time (if any at all)"},
{RPCResult::Type::NUM, "pingwait", /* optional */ true, "ping wait (if non-zero)"},
{RPCResult::Type::NUM, "version", "The peer version, such as 70001"},
{RPCResult::Type::STR, "subver", "The string version"},
{RPCResult::Type::BOOL, "inbound", "Inbound (true) or Outbound (false)"},
Copy link
Member Author

Choose a reason for hiding this comment

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

Strictly they are conditional. Though I think the RPC should be changed to not be racy, unless there is a strong reason for it to prefer to be racy.

@@ -3426,6 +3429,10 @@ RPCHelpMan signrawtransactionwithwallet()
{
{RPCResult::Type::STR_HEX, "txid", "The hash of the referenced, previous transaction"},
{RPCResult::Type::NUM, "vout", "The index of the output to spent and used as input"},
{RPCResult::Type::ARR, "witness", "",
Copy link
Member Author

Choose a reason for hiding this comment

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

It already is?

@@ -1078,22 +1083,23 @@ static RPCHelpMan decodepsbt()
}},
Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, fixed.

@maflcko maflcko closed this Sep 21, 2021
@maflcko maflcko reopened this Sep 21, 2021
@maflcko
Copy link
Member Author

maflcko commented Sep 21, 2021

Failing CI can be ignored

Copy link
Member

@fanquake fanquake left a comment

Choose a reason for hiding this comment

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

ACK fa10fbc

@fanquake fanquake merged commit faecb2e into bitcoin:master Sep 23, 2021
@maflcko maflcko deleted the 2108-docRpc branch September 23, 2021 14:25
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Sep 24, 2021
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Dec 14, 2021
@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.

8 participants