@@ -30,60 +30,57 @@ QList<BitcoinUnit> BitcoinUnits::availableUnits()
30
30
31
31
QString BitcoinUnits::longName (Unit unit)
32
32
{
33
- switch (unit)
34
- {
33
+ switch (unit) {
35
34
case Unit::BTC: return QString (" BTC" );
36
35
case Unit::mBTC : return QString (" mBTC" );
37
36
case Unit::uBTC: return QString::fromUtf8 (" µBTC (bits)" );
38
37
case Unit::SAT: return QString (" Satoshi (sat)" );
39
- default : return QString ( " ??? " );
40
- }
38
+ } // no default case, so the compiler can warn about missing cases
39
+ assert ( false );
41
40
}
42
41
43
42
QString BitcoinUnits::shortName (Unit unit)
44
43
{
45
- switch (unit)
46
- {
47
- case Unit::uBTC: return QString::fromUtf8 (" bits" );
44
+ switch (unit) {
45
+ case Unit::BTC: return longName (unit);
46
+ case Unit::mBTC : return longName (unit);
47
+ case Unit::uBTC: return QString (" bits" );
48
48
case Unit::SAT: return QString (" sat" );
49
- default : return longName (unit);
50
- }
49
+ } // no default case, so the compiler can warn about missing cases
50
+ assert ( false );
51
51
}
52
52
53
53
QString BitcoinUnits::description (Unit unit)
54
54
{
55
- switch (unit)
56
- {
55
+ switch (unit) {
57
56
case Unit::BTC: return QString (" Bitcoins" );
58
57
case Unit::mBTC : return QString (" Milli-Bitcoins (1 / 1" THIN_SP_UTF8 " 000)" );
59
58
case Unit::uBTC: return QString (" Micro-Bitcoins (bits) (1 / 1" THIN_SP_UTF8 " 000" THIN_SP_UTF8 " 000)" );
60
59
case Unit::SAT: return QString (" Satoshi (sat) (1 / 100" THIN_SP_UTF8 " 000" THIN_SP_UTF8 " 000)" );
61
- default : return QString ( " ??? " );
62
- }
60
+ } // no default case, so the compiler can warn about missing cases
61
+ assert ( false );
63
62
}
64
63
65
64
qint64 BitcoinUnits::factor (Unit unit)
66
65
{
67
- switch (unit)
68
- {
66
+ switch (unit) {
69
67
case Unit::BTC: return 100'000'000 ;
70
68
case Unit::mBTC : return 100'000 ;
71
69
case Unit::uBTC: return 100 ;
72
70
case Unit::SAT: return 1 ;
73
- default : return 100'000'000 ;
74
- }
71
+ } // no default case, so the compiler can warn about missing cases
72
+ assert ( false );
75
73
}
76
74
77
75
int BitcoinUnits::decimals (Unit unit)
78
76
{
79
- switch (unit)
80
- {
77
+ switch (unit) {
81
78
case Unit::BTC: return 8 ;
82
79
case Unit::mBTC : return 5 ;
83
80
case Unit::uBTC: return 2 ;
84
81
case Unit::SAT: return 0 ;
85
- default : return 0 ;
86
- }
82
+ } // no default case, so the compiler can warn about missing cases
83
+ assert ( false );
87
84
}
88
85
89
86
QString BitcoinUnits::format (Unit unit, const CAmount& nIn, bool fPlus , SeparatorStyle separators, bool justify)
0 commit comments