wallet, rpc: Change OutputType items from string into compile-time constants string_view #32432

pull w0xlt wants to merge 1 commits into bitcoin:master from w0xlt:outputtype_const changing 5 files +123 −48
  1. w0xlt commented at 2:27 am on May 7, 2025: contributor

    Follow-up to #32429, built on top of it.

    This PR addresses the #32429 (review) that the RPC documentation does not use OUTPUT_TYPES, but rather hardcodes them, as is already the case for the getnewaddress command. So here the output types are changed from std::string to std::string_view so that the values are known at compile time or during the early stages of program startup, before main() execution.

    It also updates wallet/rpc/addresses.cpp to write the RPC docs according to OUTPUT_TYPES instead of using hardcoded version.

    It also updates the documentation in outputtypes.h, adding Doxygen comments,

  2. DrahtBot commented at 2:28 am on May 7, 2025: contributor

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

    Code Coverage & Benchmarks

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

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK musaHaruna

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #32511 (refactor: bdb removals by maflcko)

    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.

  3. w0xlt force-pushed on May 7, 2025
  4. DrahtBot added the label CI failed on May 7, 2025
  5. DrahtBot commented at 2:41 am on May 7, 2025: contributor

    🚧 At least one of the CI tasks failed. Task ARM, unit tests, no functional tests: https://github.com/bitcoin/bitcoin/runs/41767168365 LLM reason (✨ experimental): The CI failure is due to a “/*” within a comment, which is treated as an error.

    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.

  6. w0xlt force-pushed on May 7, 2025
  7. DrahtBot removed the label CI failed on May 7, 2025
  8. laanwj added the label Wallet on May 7, 2025
  9. laanwj added the label RPC/REST/ZMQ on May 7, 2025
  10. DrahtBot added the label Needs rebase on May 7, 2025
  11. wallet: Map `OutputType` to string into compile-time constants 2fee8f4886
  12. w0xlt force-pushed on May 8, 2025
  13. DrahtBot removed the label Needs rebase on May 8, 2025
  14. musaHaruna commented at 6:53 pm on May 8, 2025: none

    Concept ACK 2fee8f4

    After reading the comment #32429

    The PR is addresses the comment very well.

    Overall code looks good to me. The additional documentation added to the outputtype.h file help makes the code clearer. A little suggestion which you can feel free to ignore. Since PR is also making updates to the documentation in outputtypes.h you can also add that to the PR’s description.

  15. w0xlt commented at 9:44 pm on May 8, 2025: contributor
    Thanks for the review and suggestion @musaHaruna . Added that text to the PR’s description.
  16. musaHaruna commented at 8:40 pm on May 13, 2025: none

    tACK 2fee8f4z

    Compiled Successfully without errors Test the code functionality using: build/bin/bitcoin-cli -regtest help getnewaddress Result: Arguments: ` …..

    2. address_type (string, optional, default=set by -addresstype) The address type to use. Options are "legacy", "p2sh-segwit", "bech32", "bech32m".

  17. maflcko commented at 10:00 am on May 14, 2025: member

    So here the output types are changed from std::string to std::string_view so that the values are known at compile time or during the early stages of program startup, before main() execution.

    Can you explain why this is needed? Seems a lot of shuffling and code changes for a trivial change that will later cast everything to std::string anyway?

  18. w0xlt commented at 8:12 pm on May 15, 2025: contributor

    std::string_view is known (and usable) at compile time as a view over some static data (it can be constexpr), so it can be concatenated to RPC docs. [1] std::string no, it’s always a runtime, owning, heap‐allocated string, so it won´t work to produce the RPC docs.

    [1] https://stackoverflow.com/a/77358740 [2] https://en.cppreference.com/w/cpp/string/basic_string_view

  19. maflcko commented at 6:58 am on May 16, 2025: member

    std::string no, it’s always a runtime, owning, heap‐allocated string, so it won´t work to produce the RPC docs.

    Not sure what you mean by “won’t work”. What is the exact diff to reproduce the compile failure or error?

  20. maflcko commented at 7:07 am on May 16, 2025: member

    std::string_view is known (and usable) at compile time as a view over some static data (it can be constexpr), so it can be concatenated to RPC docs. [1]

    Also, I don’t think this is true. I don’t think it is possible in C++20 to concatenate two string_view into a single string_view at compile time.

  21. DrahtBot commented at 8:49 pm on May 16, 2025: contributor

    🐙 This pull request conflicts with the target branch and needs rebase.

  22. DrahtBot added the label Needs rebase on May 16, 2025

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: 2025-05-30 00:13 UTC

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