bitcoin-tx: validate range of parsed output amount #22193

pull theStack wants to merge 1 commits into bitcoin:master from theStack:202106-bitcoin-tx-validate_money_range changing 1 files +2 −0
  1. theStack commented at 11:31 PM on June 8, 2021: contributor

    This tiny PR adds a sanity check to the bitcoin-tx tool w.r.t. to tx output values specified by the user: the parsing function ExtractAndValidateValue is extended to throw if the amount is not in range [0, MAX_MONEY].

    master:

    $ bitcoin-tx -create outdata=21000001:affe
    0200000000010021fd5ff0750700046a02affe00000000
    

    PR branch:

    $ bitcoin-tx -create outdata=21000001:affe
    error: TX output value out of range
    
  2. bitcoin-tx: validate range of parsed output amount b6448c70dc
  3. meshcollider added the label Utils/log/libs on Jun 9, 2021
  4. practicalswift commented at 12:30 PM on June 9, 2021: contributor

    Concept ACK

    Non-blocking thought: I guess it could be argued that bool ParseMoney(const std::string& str, CAmount& nRet) should return false if !MoneyRange(nRet).

    Can we see a use case for ParseMoney where it shouldn't be immediately followed by a MoneyRange check?

  5. MarcoFalke commented at 8:13 AM on June 10, 2021: member

    Agree with @practicalswift that neither fees nor fee rates larger than MAX_MONEY make any sense.

    See also:

    Finally, ParseMoney could be changed to return std::optional<CAmount>.

  6. fanquake cross-referenced this on Jun 11, 2021 from issue util: make ParseMoney return a std::optional<CAmount> by fanquake
  7. DrahtBot commented at 3:48 PM on June 11, 2021: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    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.

  8. theStack commented at 12:15 PM on August 3, 2021: contributor

    PR #22220 includes putting the MoneyRange check into ParseMoney, so this PR can be closed.

  9. theStack closed this on Aug 3, 2021

  10. fanquake referenced this in commit 61a843e43b on Aug 24, 2021
  11. sidhujag referenced this in commit ba83c0e35f on Aug 24, 2021
  12. bitcoin locked this on Aug 18, 2022

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-05-20 06:54 UTC