Skip to content

rpc: fix getorphantxs verbosity help and type checking - #36979

Open
l0rinc wants to merge 5 commits into
bitcoin:masterfrom
l0rinc:l0rinc/getorphantxs-verbosity-help
Open

l0rinc wants to merge 5 commits into
bitcoin:masterfrom
l0rinc:l0rinc/getorphantxs-verbosity-help

Conversation

@l0rinc

@l0rinc l0rinc commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Problem: #31043 removed the verbose alias from getorphantxs, but all three result headings in its help still use that name. Passing verbose=1 as the help suggests returns Unknown named parameter verbose. The RPC also bypasses the schema’s numeric type check and reports a custom error for boolean inputs.

Fix: Use verbosity in all three result headings. Let the RPC schema check the argument type and supply its declared default of 0. For boolean inputs, the RPC still returns error -3, now with the standard message identifying the argument by name and position.

@DrahtBot DrahtBot added the Docs label Nov 25, 2026
@DrahtBot

DrahtBot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

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

External sites

Reviews

See the guideline and AI policy for information on the review process.
A summary of reviews will appear here.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #36990 (test: replace hard-coded RPC error codes by l0rinc)
  • #36976 (rpc: Use OBJ_NAMED_PARAMS in estimatesmartfee by maflcko)
  • #33741 (rpc: Optionally print feerates in sat/vb by polespinasa)

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.

Comment thread src/rpc/mempool.cpp Outdated
@@ -1303,17 +1303,17 @@ static RPCMethod getorphantxs()
RPCArgOptions{.skip_type_check = true}},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't like skipping type checks, especially when there is a schema now. The schema or the server should take care of all of this, not each rpc method by itself.

Can you drop this?

diff --git a/src/rpc/mempool.cpp b/src/rpc/mempool.cpp
index 792023d..85e990e 100644
--- a/src/rpc/mempool.cpp
+++ b/src/rpc/mempool.cpp
@@ -1301,4 +1301,3 @@ static RPCMethod getorphantxs()
         {
-            {"verbosity", RPCArg::Type::NUM, RPCArg::Default{0}, "0 for an array of txids (may contain duplicates), 1 for an array of objects with tx details, and 2 for details from (1) and tx hex",
-             RPCArgOptions{.skip_type_check = true}},
+            {"verbosity", RPCArg::Type::NUM, RPCArg::Default{0}, "0 for an array of txids (may contain duplicates), 1 for an array of objects with tx details, and 2 for details from (1) and tx hex"},
         },
@@ -1336,3 +1335,3 @@ static RPCMethod getorphantxs()
 
-            int verbosity{ParseVerbosity(request.params[0], /*default_verbosity=*/0, /*allow_bool=*/false)};
+            int verbosity{self.Arg<int>("verbosity")};
 
diff --git a/test/functional/rpc_orphans.py b/test/functional/rpc_orphans.py
index 6addb58..2aeed02 100755
--- a/test/functional/rpc_orphans.py
+++ b/test/functional/rpc_orphans.py
@@ -147,4 +147,4 @@ class OrphanRPCsTest(BitcoinTestFramework):
         node = self.nodes[0]
-        assert_raises_rpc_error(-3, "Verbosity was boolean but only integer allowed", node.getorphantxs, verbosity=True)
-        assert_raises_rpc_error(-3, "Verbosity was boolean but only integer allowed", node.getorphantxs, verbosity=False)
+        assert_raises_rpc_error(-3, "type boolean is not of expected type number", node.getorphantxs, verbosity=True)
+        assert_raises_rpc_error(-3, "type boolean is not of expected type number", node.getorphantxs, verbosity=False)
         help_output = node.help()

@l0rinc l0rinc changed the title doc: correct getorphantxs rpc verbosity labels rpc: fix getorphantxs verbosity help and type checking Nov 25, 2026
@l0rinc
l0rinc force-pushed the l0rinc/getorphantxs-verbosity-help branch from 48beca0 to e913ca2 Compare November 25, 2026 17:01
@l0rinc

l0rinc commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks @maflcko, I’ve applied your suggestion and expanded the PR to test that getorphantxs(verbosity=1) omits tx hex and to remove the redundant allow_bool flag from ParseVerbosity.

@maflcko

maflcko commented Nov 26, 2026

Copy link
Copy Markdown
Member

The ci/cli failure is fixed in https://github.com/bitcoin/bitcoin/pull/36976/commits (ffff10c)

@DrahtBot

Copy link
Copy Markdown
Contributor

🚧 At least one of the CI tasks failed.
Task Alpine (musl): https://github.com/bitcoin/bitcoin/actions/runs/45660194112/job/140644356512
LLM reason (✨ experimental): functional_test_fail: The functional test rpc_orphans.py failed.

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • Intermittent network issues can occur; re-run CI for now, and report the issue if they keep happening.

  • A functional or integration test failure may be intermittent or unrelated to this pull request.
    If no dedicated issue thread exists, create a new one to track it.

Leave a comment here, if you need help tracking down a confusing failure.

This is needed to get the full error message. Otherwise running the test
with --usecli fails with:

AssertionError: Expected substring not found in error message:
substring: 'JSON value of type bool is not of expected type number'
error message: 'Wrong type passed:'.

(cherry picked from commit fae4370)
@l0rinc
l0rinc force-pushed the l0rinc/getorphantxs-verbosity-help branch from e913ca2 to 5a9061c Compare December 1, 2026 14:32
l0rinc and others added 4 commits December 1, 2026 15:37
The headings still refer to the removed `verbose` alias, so following the help and passing `verbose=1` returns `Unknown named parameter verbose`.

Check all three result headings in the existing RPC help test.
Check that the default verbosity returns the remaining orphan's txid and that verbosity 1 omits its hex.
The verbosity 1 details check previously inspected the result of a verbosity 2 call.
The schema already declares `verbosity` as numeric with a default of 0, so use it to check the argument type and supply the default.
Type errors keep code `-3` and now use the standard message with the argument name and position, which replaces the custom boolean message.

Co-authored-by: maflcko <[email protected]>
`estimatesmartfee` is the only caller that asks `ParseVerbosity` to reject booleans, and its options type check already rejects them before the call.
`getblock` and `getrawtransaction` accept booleans for compatibility, so the flag can be removed from all three calls.

Point new RPC methods to `getorphantxs` as an example of integer verbosity checked by the schema.
@l0rinc
l0rinc force-pushed the l0rinc/getorphantxs-verbosity-help branch from 5a9061c to 8944504 Compare December 1, 2026 14:39
@l0rinc

l0rinc commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Rebased and cherry-picked @maflcko’s commit from #36976 to fix CI and applied Ralph's coverage suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants