Page MenuHomePhabricator

qt: Improve BitcoinAmountField class
ClosedPublic

Authored by PiRK on Oct 29 2020, 12:59.

Details

Reviewers
Fabien
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Restricted Project
Commits
rABC3e543f79b679: qt: Improve BitcoinAmountField class
Summary

This adds functions for specifing a min/max value for a BitcoinAmountField. These options only affect user input, so it's still possible to use setValue to set values outside of the min/max range. The existing value will not be changed when calling these functions even if it's out of range. The min/max range will be reinforced when the field loses focus.
This also adds SetAllowEmpty function which specifies if the field is allowed to be left empty by the user. If set to false the field will be set to the minimum allowed value if it's empty when focus is lost.

This is a backport of Core PR14608 [1/2]
Commit: https://github.com/bitcoin/bitcoin/pull/14608/commits/8711cc0c78fb15e49c6ab477a5d922fc51627873

Depends on D8177.

Test Plan

ninja && src/qt/bitcoin-qt

Verify that in the spend tab you cannot set amount or fees larger than 21 MBCH or lower than 0.

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Owners added a reviewer: Restricted Owners Package.Oct 29 2020, 12:59
PiRK requested review of this revision.Oct 29 2020, 12:59
Fabien added a subscriber: Fabien.
Fabien added inline comments.
src/qt/bitcoinamountfield.cpp
147 ↗(On Diff #25225)

Out of scope, but does this step value makes sense ? 1000 sat/kB seems more appropriated.
Edit: after a quick check the value is overridden to 1000 sat/kB in sendcoinsdialog.cpp:200

src/qt/bitcoinamountfield.h
34 ↗(On Diff #25225)

Nit: close **/ on its own line:

This revision is now accepted and ready to land.Oct 29 2020, 15:40

closing comment on new line