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

bitcoin-core/gui-qml: PR #1140

3 suggestions

Optional improvements

Link

[suggestion] · Comma tests omit Send's production configuration and numeric paste

The new QML tests use individual keys and override decimalPoint, leaving Send's manual-validation configuration, comma-containing clipboard replacements and the default locale binding uncovered.

Location: test/qml/tst_bitcoinamountinputfield.qml:30 (head).

Details and suggested fix

The amount fixture leaves interceptPaste false, so it uses the native validator. Production SendRecipientEditor sets it true, disabling that validator and using restoreLastAcceptedText() for invalid edits. SendCreate also routes non-URI clipboard text through amountField.paste(). Parameterize the amount tests over both configurations and add clipboard-driven comma values, such as 0,12345678, into an empty field and over a selected draft. Check canonical text, satoshis and undo, since these edits exercise the new remove()/insert() normalization differently from individual keystrokes. Add numeric paste cases for the Receive and fee consumers, and a locale-configured case that leaves the default Qt.locale().decimalPoint binding intact. The existing functional URI-paste test takes a different branch. This is a coverage gap, not an established paste failure.


Link

[suggestion] · The QML wallet mock still rejects .5

Production accepts .5 at the fixture's minimum fee rate, but the QML mock rejects it, and the new test does not check the resulting validity or error state.

Location: test/qml/tst_sendfeeselection.qml:99 (head).

Details and suggested fix

The mock's customFeeRateValid() pattern still requires at least one whole-part digit, unlike the updated production CUSTOM_FEE_RATE_PATTERN. At the test's 0.1 sat/vB minimum, .5 therefore remains invalid in the fixture. SendFeeSelection uses that property for its error text, and SendCreate uses it to disable Review when custom fees are enabled. The new test checks only the entered text, stored string and canUndo, hiding this divergence. Update the mock to accept the same leading-period syntax and extend this test to assert customFeeRateValid is true and the fee row's errorText is empty.


Link

[suggestion] · The .5 parser test does not check its numeric fee rate

The parser currently computes .5 correctly, but interpreting it as 5 sat/vB would still satisfy the new validity assertion and the QML stored-string assertions.

Location: test/test_walletqmlmodel.cpp:1232 (head).

Details and suggested fix

customFeeRateValid() only checks whether ParseCustomFeeRatePerKvB() returns a value, so both 500 and 5000 sat/kvB would pass the new .5 row. The existing scheduleFeeEstimates_usesCustomFeeRateWhenEnabled dataset already verifies the numeric CFeeRate passed through coin control, but its rows are only 2, 0.1 and 0.123. Add .5 with per_kvb equal to 500 and the corresponding formatted fee. That directly protects the new syntax's numeric meaning rather than only its acceptance.


Coverage details

Background

Ralph's summary of historical context for the behaviour affected by this change. The historical record reviewed here is incomplete.

Documented decisions

Bitcoin-Qt historically separated its canonical period-based amount convention from users' locale-specific typing habits. Comma-to-period translation was presented as a way to make amount entry usable while retaining consistency across fields.

The pinned Bitcoin-Qt dependency still uses fixed-point parsing with a period and translates comma key events into periods. The QML change similarly accepts another input spelling while retaining period-based text for BitcoinAmount, payment-request parsing and custom-fee parsing. This is historical GUI precedent, not evidence of a consensus requirement.

Source 1 · Source 2 · Source 3 · Source 4

Choosing a locale is not sufficient to resolve numeric-entry ambiguity: a comma can be interpreted as grouping rather than as a decimal separator. Earlier reviewers explicitly objected that accepting and ignoring a comma could confuse users.

The affected base validators and sanitizer recognize period-based numbers. The head introduces locale-gated comma normalization rather than general locale-number parsing. The historical discussion explains why grouping semantics and silently ignored punctuation matter independently of whether the final text passes validation.

Source 1 · Source 2 · Source 3

Earlier GUI-QML design discussion distinguished validation during editing from presentation formatting after editing finishes. It also requested restricted numeric input, including periods and commas, rather than unrestricted text.

BitcoinAmountInputField retains editable draft text, commits accepted edits to BitcoinAmount and formats on editing completion. This history explains the separate editing and canonical-display stages affected by comma replacement. The earlier PR was closed, so its discussion documents design intent rather than proving how every current implementation choice originated.

Source 1 · Source 2 · Source 3 · Source 4

The preceding reports framed preservation of the entered number as the safety constraint: rejecting punctuation while accepting subsequent digits can create a different valid amount or fee rate, even when later screens faithfully display the resulting value.

Issue #1081 reported that the altered amount reached a saved Receive request and QR code, and Send review. Issue #1130 reported that the altered fee rate reached transaction construction and payment while review remained internally accurate. These reports explain why the affected boundary is input interpretation before persistence or transaction preparation, rather than merely final formatting.

Source 1 · Source 2

Ralph's inferences

Accepting additional human input spellings while keeping one internal spelling reconciles familiar number entry with existing fixed-point wallet interfaces; it need not imply a change to backend monetary semantics.

At the pinned head, QML normalizes accepted commas to periods, PaymentRequestCard converts period-based text directly to integer satoshis, and the fee parser converts period-based sat/vB text to integer sat/kvB before setting coin control. The dependency pin is unchanged. The historical consistency and usability arguments support this interpretation, but do not establish that the present implementation satisfies every Qt editing contract.

Source 1 · Source 2 · Source 3

Unresolved disagreements

The inspected record contains different approaches to internationalized entry: use locale machinery consistently, or retain a locale-independent Bitcoin amount convention with explicit punctuation translation. It does not settle a universal policy for locale-gated versus unconditional comma acceptance.

PR #13278 questioned special-case translation and proposed consistency with other amount fields; it was later closed for inactivity. PR #14177 pursued a narrower C-locale fix and discussed comma grouping. These sources illuminate the tradeoff behind the current locale gate without establishing historical consensus for that exact policy.

Source 1 · Source 2 · Source 3 · Source 4 · Source 5