Non-English Decimal Interpreted Incorrectly in util.cpp:ParseMoney #330

issue pickerin opened this issue on June 19, 2011
  1. pickerin commented at 12:21 AM on June 19, 2011: none

    I did not find this bug, but I'm reporting it:

    See: http://forum.bitcoin.org/index.php?topic=19168.msg240196#msg240196

    "If you enter 0,005 as amount to be sent, the client sends 5.00

    For the US-only localized guys I must add: 0,005 is, for example, in Germany the natural way to type what in the US would be typed as 0.005 - and this is consistent with all kinds of localizations in the operating system.

    So a German user is likely to send a much higher amount than she intended to.

    We have the bug confirmed on the 0.3.23-beta client on Windows 7 by Dennis1234 and on the 0.3.23-beta client on Linux self compilation by mself. Since my client is running in testnet currently I did some testing:

    0,0005 is parsed as "error in amount" 0,005 is reparsed as 5.00 0,05 produces an "error in amount" 0,5 produces an "error in amount"

    Reparsed as 5.00 means the following:

    I enter 0,005 and upon "Send" the displayed amount changes into 5.00 and I get an error on insufficient funds (I do not have 5 BTC in my current testnet account). From the normal behaviour of the client I assume that, if I had more than 5.00 i would just lose these 5.00.

    DEVELOPER INFORMATION:

    The bug is in src/util.cpp:ParseMoney. In particular, on line 375 the function explicitly checks for ',' and interprets it as the American/English (or other?) digit grouping symbol. It checks if there is a digit before the comma, and three digits after it (e.g. One Million Dollars can be written as $1,000,000).

    Because of this 0,005 is considered valid, even though it makes no sense even from an a digit grouping perspective. I'd say several patches are in order:

    1. 0,005 should not be considered valid when interpreted as digit grouping
    2. ParseMoney should be locale sensitive
    3. OnButtonSend should display the valid it interpreted (after line 1925, nValue) and ask for confirmation.

    3 is necessary because bugs like this are likely to crop up for a long time, and it's just all around a good idea to give the user a second chance to verify their input.

  2. gavinandresen commented at 8:58 PM on April 4, 2012: contributor

    Keeping this open, although the immediate issue was fixed long ago it still might be nice to eventually make number parsing locale-aware.

  3. laanwj commented at 10:00 AM on October 21, 2013: member

    I think it's time to revive this issue (or kill it forever). Do we really want number parsing and formatting in the GUI (this is oblivious to bitcoind) locale aware? Implementation wise it's a trivial change as Qt contains everything for locale-specific number processing.

    But it may cause communication confusion between people or result in wrong amounts being sent if, for some reason, the locale is picked wrongly. This was the original reason for Satoshi to settle on one kind of number formatting. But maybe it's a misplaced concern now that we always ask for confirmation.

  4. laanwj commented at 7:40 AM on March 17, 2014: member

    Closing in favor of #3887 which is more clearly formulated

  5. laanwj closed this on Mar 17, 2014

  6. classesjack referenced this in commit 0ba40e6935 on Jan 2, 2018
  7. attilaaf referenced this in commit adbea71519 on Jan 13, 2020
  8. Losangelosgenetics referenced this in commit 3954011965 on Mar 12, 2020
  9. rajarshimaitra referenced this in commit 32477bc8ba on Aug 5, 2021
  10. DrahtBot locked this on Sep 8, 2021

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

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