rpc: Use self.Arg<_>(name) helper over manual and duplicate parsing #36384

pull maflcko wants to merge 4 commits into bitcoin:master from maflcko:2609-rpc-arg-defaults-duplicate changing 14 files +75 −133
  1. maflcko commented at 8:05 PM on September 29, 2026: member

    The Arg() helper has many benefits:

    • It does not require manual isNull checks
    • It does not require hard-coding the fallback/default value a second time
    • It does not require manually specifying the getter for the type. Specifying the type is enough.

    So use it more broadly.

  2. DrahtBot added the label RPC/REST/ZMQ on Sep 29, 2026
  3. DrahtBot commented at 8:05 PM on September 29, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/36384.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    Concept ACK fanquake

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #36264 (wallet rpc: fix stale argument metadata and help text by MrHodlX)
    • #35370 (rpc: add key-origin modes to PSBT processing RPCs by junbyjun1238)
    • #33112 (wallet: relax external_signer flag constraints by Sjors)
    • #32857 (wallet: allow skipping script paths by Sjors)
    • #32468 (rpc: generateblock to allow multiple outputs 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-->

  4. maflcko force-pushed on Sep 29, 2026
  5. DrahtBot added the label CI failed on Sep 29, 2026
  6. DrahtBot commented at 8:28 PM on September 29, 2026: contributor

    <!--85328a0da195eb286784d51f73fa0af9-->

    🚧 At least one of the CI tasks failed. <sub>Task iwyu: https://github.com/bitcoin/bitcoin/actions/runs/36623882963/job/109595800670</sub> <sub>LLM reason (✨ experimental): CI failed because IWYU detected incorrect/missing includes and triggered a “Failure generated from IWYU” (returned exit code 1).</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.

    • An intermittent issue.

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

    </details>

  7. rpc: Use the first arg name in GetParamIndex
    GetName does not support aliases at all. However, it should be fine for
    GetParamIndex (used in Arg and MaybeArg) to support lookup by the first
    name.
    
    The test is modified to show the second legacy alias is ignored.
    fae108b0a2
  8. maflcko force-pushed on Sep 29, 2026
  9. rpc: doc: Use proper RPCArg::Default in verifychain faf064078b
  10. maflcko force-pushed on Sep 30, 2026
  11. refactor: rpc: Use self.Arg<_>(name) helper over manual isNull() ? fallback : getter()
    The Arg() helper has many benefits:
    
    * It does not require manual isNull checks
    * It does not require hard-coding the fallback/default value a second time
    * It does not require manually specifying the getter for the type. Specifying the type is enough.
    
    So use it in this refactor, which does not change any behavior.
    fae633e268
  12. doc: Fix typo in walletcreatefundedpsbt dev comment
    Use same wording as in walletprocesspsbt
    fa77e12603
  13. maflcko force-pushed on Sep 30, 2026
  14. DrahtBot removed the label CI failed on Sep 30, 2026
  15. fanquake commented at 9:23 AM on October 1, 2026: member

    Concept ACK

  16. maflcko commented at 9:39 AM on October 1, 2026: member

    Forgot to say that everything here is a refactor, except for the cleanup commit that changes the schema of one RPC:

    diff --git a/getopenrpcinfo.full.json b/getopenrpcinfo.full.json
    index e0cebef..cbbf785 100644
    --- a/getopenrpcinfo.full.json
    +++ b/getopenrpcinfo.full.json
    @@ -15035,5 +15035,5 @@
                             "type": "number",
    -                        "x-bitcoin-default-hint": "3, range=0-4"
    +                        "default": 3
                         },
    -                    "description": "How thorough the block verification is:\n- level 0 reads the blocks from disk\n- level 1 verifies block validity\n- level 2 verifies undo data\n- level 3 checks disconnection of tip blocks\n- level 4 tries to reconnect the blocks\n- each level includes the checks of the previous levels"
    +                    "description": "How thorough the block verification is (range 0-4):\n- level 0 reads the blocks from disk\n- level 1 verifies block validity\n- level 2 verifies undo data\n- level 3 checks disconnection of tip blocks\n- level 4 tries to reconnect the blocks\n- each level includes the checks of the previous levels"
                     },
    @@ -15044,5 +15044,5 @@
                             "type": "number",
    -                        "x-bitcoin-default-hint": "6, 0=all"
    +                        "default": 6
                         },
    -                    "description": "The number of blocks to check."
    +                    "description": "The number of blocks to check (0=all)."
                     }
    diff --git a/verifychain b/verifychain
    index b742f17..1863a80 100644
    --- a/verifychain
    +++ b/verifychain
    @@ -5,3 +5,3 @@ Verifies blockchain database.
     Arguments:
    -1. checklevel    (numeric, optional, default=3, range=0-4) How thorough the block verification is:
    +1. checklevel    (numeric, optional, default=3) How thorough the block verification is (range 0-4):
                      - level 0 reads the blocks from disk
    @@ -12,3 +12,3 @@ Arguments:
                      - each level includes the checks of the previous levels
    -2. nblocks       (numeric, optional, default=6, 0=all) The number of blocks to check.
    +2. nblocks       (numeric, optional, default=6) The number of blocks to check (0=all).
     
    

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-10-01 17:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me