rpc: Use ‘byte’/‘bytes’ for bech32(m) validation error message #27747

pull russeree wants to merge 1 commits into bitcoin:master from russeree:27727-ext changing 3 files +11 −8
  1. russeree commented at 1:43 am on May 25, 2023: contributor

    This PR rectifies a linguistic inconsistency found in merged PR 27727. It addresses the improper usage of the term ‘byte’ in error reports. As it stands, PR 27727 exclusively utilizes ‘byte’ in error messages, regardless of the context, as demonstrated below:

    Currently: Invalid Bech32 v0 address program size (16 byte), per BIP141

    This modification enhances the accuracy of error reporting in most scenarios users are likely to encounter by checking for a plural or singular number of bytes.

    This PR

    16 Bytes program size error :

    0(
    1    "BC1QR508D6QEJXTDG4Y5R3ZARVARYV98GJ9P",
    2    "Invalid Bech32 v0 address program size (16 bytes), per BIP141",
    3    [],
    4)
    

    1 Byte program size error

    0(
    1    "bc1pw5dgrnzv", 
    2    "Invalid Bech32 address program size (1 byte)",
    3    []
    4),
    

    Thank you

  2. in src/key_io.cpp:150 in 7d52c6f5a3 outdated
    145@@ -146,6 +146,9 @@ CTxDestination DecodeDestination(const std::string& str, const CChainParams& par
    146         // The rest of the symbols are converted witness program bytes.
    147         data.reserve(((dec.data.size() - 1) * 5) / 8);
    148         if (ConvertBits<5, 8, false>([&](unsigned char c) { data.push_back(c); }, dec.data.begin() + 1, dec.data.end())) {
    149+
    150+            const std::string byteStr = data.size() == 1 ? "byte" : "bytes";
    


    maflcko commented at 6:01 am on May 25, 2023:
    0            std::string_view byte_str{data.size() == 1 ? "byte" : "bytes"};
    

    nit: snake_case per dev notes and string_view to avoid a copy?


    russeree commented at 6:23 am on May 25, 2023:

    Applied, committed, squashed, and pushed.

    • Is there any need for const keyword with std::string_view since it is read only?

    • Snake case has been remedied.

  3. maflcko approved
  4. maflcko commented at 6:02 am on May 25, 2023: member
    lgtm
  5. DrahtBot renamed this:
    Use 'byte'/'bytes' for bech32(m) validation error message - 27727 follow up.
    rpc: Use 'byte'/'bytes' for bech32(m) validation error message
    on May 25, 2023
  6. DrahtBot commented at 6:06 am on May 25, 2023: contributor

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

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK MarcoFalke

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

  7. DrahtBot added the label RPC/REST/ZMQ on May 25, 2023
  8. russeree force-pushed on May 25, 2023
  9. russeree force-pushed on May 25, 2023
  10. use 'byte'/'bytes' for bech32(m) validation error
    changed from std::string -> std::string_view
    
    applied snake case to byteStr -> byte_str
    3d0a5c37e9
  11. in src/key_io.cpp:150 in 6fbdc72052 outdated
    145@@ -146,6 +146,9 @@ CTxDestination DecodeDestination(const std::string& str, const CChainParams& par
    146         // The rest of the symbols are converted witness program bytes.
    147         data.reserve(((dec.data.size() - 1) * 5) / 8);
    148         if (ConvertBits<5, 8, false>([&](unsigned char c) { data.push_back(c); }, dec.data.begin() + 1, dec.data.end())) {
    149+
    150+            std::string_view byteStr {data.size() == 1 ? "byte" : "bytes"};
    


    maflcko commented at 6:25 am on May 25, 2023:
    0            std::string_view byte_str{data.size() == 1 ? "byte" : "bytes"};
    

    russeree commented at 6:32 am on May 25, 2023:
    My apologies for not being attentive to detail. This has now been remedied.
  12. russeree force-pushed on May 25, 2023
  13. maflcko commented at 10:04 am on May 25, 2023: member
    lgtm ACK 3d0a5c37e9ccedfa4ecfaa48eeeca1ada5b4eec1
  14. fanquake merged this on May 25, 2023
  15. fanquake closed this on May 25, 2023

  16. russeree deleted the branch on May 25, 2023
  17. russeree restored the branch on May 25, 2023
  18. russeree deleted the branch on May 25, 2023
  19. russeree restored the branch on May 25, 2023
  20. luke-jr referenced this in commit 9c7e57e614 on Aug 16, 2023
  21. bitcoin locked this on May 24, 2024

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: 2024-09-28 22:12 UTC

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