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

    External sites

    <!--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:

    • #36566 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36566.svg"></sub> (private broadcast: wait synchronously for mempool acceptance by andrewtoth)
    • #36264 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36264.svg"></sub> (wallet rpc: fix stale argument metadata and help text by MrHodlX)
    • #36167 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36167.svg"></sub> ([RFC] Enable -Wunused by fanquake)
    • #35511 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35511.svg"></sub> (RFC: consensus: Make CAmount a class by hodlinator)
    • #35370 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35370.svg"></sub> (rpc: add key-origin modes to PSBT processing RPCs by junbyjun1238)
    • #35302 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35302.svg"></sub> (Silent Payments: Sending (take 2) by Eunovo)
    • #33112 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/33112.svg"></sub> (wallet: relax external_signer flag constraints by Sjors)
    • #32857 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/32857.svg"></sub> (wallet: allow skipping script paths by Sjors)
    • #32468 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/32468.svg"></sub> (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. maflcko force-pushed on Sep 29, 2026
  8. maflcko force-pushed on Sep 30, 2026
  9. maflcko force-pushed on Sep 30, 2026
  10. DrahtBot removed the label CI failed on Sep 30, 2026
  11. fanquake commented at 9:23 AM on October 1, 2026: member

    Concept ACK

  12. 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).
     
    
  13. 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.
    faf3065478
  14. rpc: doc: Use proper RPCArg::Default in verifychain fad499442c
  15. 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.
    fa7770e374
  16. doc: Fix typo in walletcreatefundedpsbt dev comment
    Use same wording as in walletprocesspsbt
    faf493feb4
  17. maflcko force-pushed on Oct 19, 2026

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-21 18:51 UTC

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