Skip to content

Commit 64f0c3d

Browse files
MarcoFalkePastaPastaPasta
authored andcommitted
Merge bitcoin-core/gui#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#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
1 parent 51fa0ed commit 64f0c3d

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
@@ -11,6 +11,8 @@
1111

1212
#include <cassert>
1313

14+
static constexpr auto MAX_DIGITS_BTC = 16;
15+
1416
BitcoinUnits::BitcoinUnits(QObject *parent):
1517
QAbstractListModel(parent),
1618
unitlist(availableUnits())
@@ -129,7 +131,9 @@ QString BitcoinUnits::format(int unit, const CAmount& nIn, bool fPlus, Separator
129131
qint64 n_abs = (n > 0 ? n : -n);
130132
qint64 quotient = n_abs / coin;
131133
QString quotient_str = QString::number(quotient);
132-
if (justify) quotient_str = quotient_str.rightJustified(16 - num_decimals, ' ');
134+
if (justify) {
135+
quotient_str = quotient_str.rightJustified(MAX_DIGITS_BTC - num_decimals, ' ');
136+
}
133137

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

0 commit comments

Comments
 (0)