aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-12-17 10:53:31 +0100
committerMarcoFalke <falke.marco@gmail.com>2020-12-17 10:53:34 +0100
commitd0e76b5050a2f4af94022b7a1dc137a54ab801ce (patch)
tree313cd2f14f71fcacf6df6cd307a737bff4fedd4a /src
parent83abd6b126c22ee53d623b5ada674dc921c97ebe (diff)
parent198fff88f385e090b57a0ee902719bcc22a6b86b (diff)
Merge bitcoin-core/gui#153: Define MAX_DIGITS_BTC for magic number in BitcoinUnits::format
198fff88f385e090b57a0ee902719bcc22a6b86b GUI: Define MAX_DIGITS_BTC for magic number in BitcoinUnits::format (Luke Dashjr) Pull request description: A magic number snuck in with https://github.com/bitcoin/bitcoin/pull/16432 ACKs for top commit: hebasto: ACK 198fff88f385e090b57a0ee902719bcc22a6b86b, I have reviewed the code and it looks OK, I agree it can be merged. kristapsk: utACK 198fff88f385e090b57a0ee902719bcc22a6b86b Tree-SHA512: 78dc23c2ae61bac41e5e34eebf57274599cb2ebb0b18d46e8a3228d42b256a1bc9bb17091c748f0f692ef1c4c241cfbd3e30a12bcd12222a234c1a9547ebe786
Diffstat (limited to 'src')
-rw-r--r--src/qt/bitcoinunits.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/qt/bitcoinunits.cpp b/src/qt/bitcoinunits.cpp
index fd55c547fc..5402ed371d 100644
--- a/src/qt/bitcoinunits.cpp
+++ b/src/qt/bitcoinunits.cpp
@@ -8,6 +8,8 @@
#include <cassert>
+static constexpr auto MAX_DIGITS_BTC = 16;
+
BitcoinUnits::BitcoinUnits(QObject *parent):
QAbstractListModel(parent),
unitlist(availableUnits())
@@ -108,7 +110,9 @@ QString BitcoinUnits::format(int unit, const CAmount& nIn, bool fPlus, Separator
qint64 n_abs = (n > 0 ? n : -n);
qint64 quotient = n_abs / coin;
QString quotient_str = QString::number(quotient);
- if (justify) quotient_str = quotient_str.rightJustified(16 - num_decimals, ' ');
+ if (justify) {
+ quotient_str = quotient_str.rightJustified(MAX_DIGITS_BTC - num_decimals, ' ');
+ }
// Use SI-style thin space separators as these are locale independent and can't be
// confused with the decimal marker.