rpc: fix getorphantxs verbosity help and type checking #36979

Open
l0rinc wants to merge 5 commits from l0rinc/getorphantxs-verbosity-help into master AGit
l0rinc commented 2026-11-25 13:01:50 +00:00 (Migrated from github.com)

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.

**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 commented 2026-11-25 13:02:01 +00:00 (Migrated from github.com)

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.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36979 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36979.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36979#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. A summary of reviews will appear here. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#36990](https://github.com/bitcoin/bitcoin/pull/36990) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36990.svg"></sub> (test: replace hard-coded RPC error codes by l0rinc) * [#36976](https://github.com/bitcoin/bitcoin/pull/36976) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36976.svg"></sub> (rpc: Use OBJ_NAMED_PARAMS in estimatesmartfee by maflcko) * [#33741](https://github.com/bitcoin/bitcoin/pull/33741) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/33741.svg"></sub> (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. <!--5faf32d7da4f0f540f40219e4f7537a3-->
maflcko (Migrated from github.com) reviewed 2026-11-25 13:33:15 +00:00
maflcko (Migrated from github.com) commented 2026-11-25 13:33:15 +00:00

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()
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 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 commented 2026-11-25 17:03:30 +00:00 (Migrated from github.com)

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.

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`.
First-time contributor

🔵 Suggestion · Boolean options.verbosity rejection lacks test coverage

Although estimatesmartfee still rejects boolean options.verbosity, the tests do not cover the check that now solely enforces that behavior.

Location: src/rpc/fees.cpp:122 (head).


Reviewed: 89445045a736 · Review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:312ddb2095238aa2ca395a9cc39b05ab5a38a7177afbdb0d69098df9c3e0bef9:9a7f127b15c6116c267953d38288a9f17ec7c7bcd3a975fb71a2db8bfd974dbf --> <!-- ralph-base:2e5d7540a1da07a7e448f339d54cfb40a78dddbc --> <!-- ralph-head:89445045a73649da9989df41380cadf2864986ad --> <!-- ralph-case:05eb6105538541621a30fc3c94e9ce795e464d52f4030003c5f2d843f552ef11 --> **🔵 Suggestion · Boolean `options.verbosity` rejection lacks test coverage** Although `estimatesmartfee` still rejects boolean `options.verbosity`, the tests do not cover the check that now solely enforces that behavior. Location: [`src/rpc/fees.cpp:122`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/89445045a73649da9989df41380cadf2864986ad/src/rpc/fees.cpp#L122>) (head). <!-- Review tier: sensitive --> --- Reviewed: [`89445045a736`](<https://git.fish.foo/bitcoin/bitcoin/commit/89445045a73649da9989df41380cadf2864986ad>) · [Review report](<https://review.fish.foo/report/36979-89445045a73649da9989df41380cadf2864986ad-3396-4.html>) · [Previous reports](<https://review.fish.foo/traces/36979/>) [permalink](<https://review.fish.foo/report/36979-89445045a73649da9989df41380cadf2864986ad-3396-4.html>)
maflcko commented 2026-11-26 10:44:06 +00:00 (Migrated from github.com)
The ci/cli failure is fixed in https://github.com/bitcoin/bitcoin/pull/36976/commits (ffff10c970346451a04491b5964b0a75b6351f86)
DrahtBot commented 2026-11-27 17:28:33 +00:00 (Migrated from github.com)

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

<!--85328a0da195eb286784d51f73fa0af9--> 🚧 At least one of the CI tasks failed. <sub>Task `Alpine (musl)`: https://github.com/bitcoin/bitcoin/actions/runs/45660194112/job/140644356512</sub> <sub>LLM reason (✨ experimental): functional_test_fail: The functional test `rpc_orphans.py` failed.</sub> <details><summary>Hints</summary> 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. </details>
l0rinc commented 2026-12-01 14:39:33 +00:00 (Migrated from github.com)

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

Rebased and cherry-picked @maflcko’s commit from #36976 to fix CI and applied Ralph's coverage suggestion.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36979
No description provided.