qml: Accept the locale's decimal comma in amount and fee fields #1140

Open
AndreaDiazCorreia wants to merge 2 commits from fix/decimal-comma-amount-input into qt6 AGit
AndreaDiazCorreia commented 2026-11-17 00:07:21 +00:00 (Migrated from github.com)

The amount and custom fee rate fields refused a comma or a leading period, but kept the digits typed after it. The result was a different valid value with no error: 0,02 became 2 BTC in Send and Receive (saved into the payment request and its QR code), and .5 was paid as 5 sat/vB.

Where the locale uses a decimal comma, a comma is now accepted as the decimal point and stored as a period. Elsewhere a comma groups thousands and is still refused, so 1,000 keeps meaning one thousand. Only the comma is replaced, so the undo history is kept. BitcoinAmount::sanitize() follows the same rule instead of dropping the comma. The custom fee rate also accepts an empty whole part, so .5 is 0.5 sat/vB, as in Bitcoin-Qt.

Unit and QML tests cover typed and pasted commas in both locale kinds, undo after the comma, sanitize(), and .5 and . in the fee rate parser.

Fixes #1081
Fixes #1130

The amount and custom fee rate fields refused a comma or a leading period, but kept the digits typed after it. The result was a different valid value with no error: `0,02` became 2 BTC in Send and Receive (saved into the payment request and its QR code), and `.5` was paid as 5 sat/vB. Where the locale uses a decimal comma, a comma is now accepted as the decimal point and stored as a period. Elsewhere a comma groups thousands and is still refused, so `1,000` keeps meaning one thousand. Only the comma is replaced, so the undo history is kept. `BitcoinAmount::sanitize()` follows the same rule instead of dropping the comma. The custom fee rate also accepts an empty whole part, so `.5` is 0.5 sat/vB, as in Bitcoin-Qt. Unit and QML tests cover typed and pasted commas in both locale kinds, undo after the comma, `sanitize()`, and `.5` and `.` in the fee rate parser. Fixes #1081 Fixes #1130
rreview commented 2026-11-17 00:37:33 +00:00 (Migrated from github.com)

🔵 Suggestion · Decimal-comma functional coverage stops before Review and broadcast

The real-wallet test checks the 1,5 fee estimate but never the paid fee; preparation coverage for 1,5 and .5 uses a mock wallet, leaving these repaired input forms without end-to-end payment coverage.

Location: test/functional/qml_test_decimal_comma.py:60 (head).

Review coverage was incomplete.


Reviewed: 8622eddfac9d · Review report

<!-- ralph-major:bitcoin-core/gui-qml --> **🔵 Suggestion · Decimal-comma functional coverage stops before Review and broadcast** The real-wallet test checks the `1,5` fee estimate but never the paid fee; preparation coverage for `1,5` and `.5` uses a mock wallet, leaving these repaired input forms without end-to-end payment coverage. Location: [test/functional/qml_test_decimal_comma.py:60](<https://github.com/bitcoin-core/gui-qml/blob/8622eddfac9d26c95e881b8975c7ab263637e4d9/test/functional/qml_test_decimal_comma.py#L60>) (head). Review coverage was incomplete. <!-- Review tier: sensitive --> --- Reviewed: [`8622eddfac9d`](<https://github.com/bitcoin-core/gui-qml/commit/8622eddfac9d26c95e881b8975c7ab263637e4d9>) · [Review report](<https://review.fish.foo/report/gui/1140-8622eddfac9d26c95e881b8975c7ab263637e4d9-2901-2.html>)
ValeraFinebits (Migrated from github.com) reviewed 2026-11-17 16:51:30 +00:00
ValeraFinebits (Migrated from github.com) left a comment

I ran into a paste issue on the Send page with de_DE and BTC selected:

  1. Copy 1,23456789 to the clipboard
  2. Clear the amount field and type 987
  3. Without leaving the field, press Ctrl+A, then Ctrl+V

I get 9.87 BTC here, while I’d expect 1.23456789 BTC. Looks like the decimal point ends up being inserted into the old 987 value.

Beyond this specific issue, modifying the text inside the edit handler feels fragile to me, since validation can run halfway through the change. Perhaps we should rethink how normalization and validation work together here.

I ran into a paste issue on the Send page with `de_DE` and BTC selected: 1. Copy `1,23456789` to the clipboard 2. Clear the amount field and type `987` 3. Without leaving the field, press Ctrl+A, then Ctrl+V I get `9.87 BTC` here, while I’d expect `1.23456789 BTC`. Looks like the decimal point ends up being inserted into the old `987` value. Beyond this specific issue, modifying the text inside the edit handler feels fragile to me, since validation can run halfway through the change. Perhaps we should rethink how normalization and validation work together here.
ValeraFinebits (Migrated from github.com) reviewed 2026-11-21 14:33:18 +00:00
ValeraFinebits (Migrated from github.com) left a comment

I retested with de_DE and BTC selected. Pasting 1,23456789 over 987 now gives the right amount, and Ctrl+Z brings back 987.

One thing I like about #1142 is that Send and Receive share a C++ parser, so the rules for inputs like 0,02 live in one place.

I retested with `de_DE` and BTC selected. Pasting `1,23456789` over `987` now gives the right amount, and Ctrl+Z brings back `987`. One thing I like about #1142 is that Send and Receive share a C++ parser, so the rules for inputs like `0,02` live in one place.
Sign in to join this conversation.
No description provided.