Skip to content

Commit d0e76b5

Browse files
author
MarcoFalke
committed
Merge bitcoin-core#153: Define MAX_DIGITS_BTC for magic number in BitcoinUnits::format
198fff8 GUI: Define MAX_DIGITS_BTC for magic number in BitcoinUnits::format (Luke Dashjr) Pull request description: A magic number snuck in with bitcoin/bitcoin#16432 ACKs for top commit: hebasto: ACK 198fff8, I have reviewed the code and it looks OK, I agree it can be merged. kristapsk: utACK 198fff8 Tree-SHA512: 78dc23c2ae61bac41e5e34eebf57274599cb2ebb0b18d46e8a3228d42b256a1bc9bb17091c748f0f692ef1c4c241cfbd3e30a12bcd12222a234c1a9547ebe786
2 parents 83abd6b + 198fff8 commit d0e76b5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/qt/bitcoinunits.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#include <cassert>
1010

11+
static constexpr auto MAX_DIGITS_BTC = 16;
12+
1113
BitcoinUnits::BitcoinUnits(QObject *parent):
1214
QAbstractListModel(parent),
1315
unitlist(availableUnits())
@@ -108,7 +110,9 @@ QString BitcoinUnits::format(int unit, const CAmount& nIn, bool fPlus, Separator
108110
qint64 n_abs = (n > 0 ? n : -n);
109111
qint64 quotient = n_abs / coin;
110112
QString quotient_str = QString::number(quotient);
111-
if (justify) quotient_str = quotient_str.rightJustified(16 - num_decimals, ' ');
113+
if (justify) {
114+
quotient_str = quotient_str.rightJustified(MAX_DIGITS_BTC - num_decimals, ' ');
115+
}
112116

113117
// Use SI-style thin space separators as these are locale independent and can't be
114118
// confused with the decimal marker.

0 commit comments

Comments
 (0)