Skip to content

Commit 075665f

Browse files
committed
Merge 60cf64e into merged_master (Elements PR ElementsProject#1374)
Some refactoring around the pegged asset name during this merge, please check in the GUI.
2 parents 70c8195 + 60cf64e commit 075665f

File tree

1 file changed

+38
-22
lines changed

1 file changed

+38
-22
lines changed

src/qt/bitcoinunits.cpp

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,48 +29,64 @@ QList<BitcoinUnit> BitcoinUnits::availableUnits()
2929
return unitlist;
3030
}
3131

32+
// ELEMENTS
33+
std::string peggedAssetWithUnit(BitcoinUnits::Unit unit)
34+
{
35+
const std::string default_asset_name = gArgs.GetArg("-defaultpeggedassetname", "");
36+
if (default_asset_name != "") {
37+
std::string rv;
38+
switch(unit)
39+
{
40+
case BitcoinUnits::Unit::BTC: return default_asset_name;
41+
case BitcoinUnits::Unit::mBTC: return std::string("m-") + default_asset_name;
42+
case BitcoinUnits::Unit::uBTC: return std::string("μ-") + default_asset_name;
43+
case BitcoinUnits::Unit::SAT: return std::string("sat-") + default_asset_name;
44+
} // no default case, so the compiler can warn about missing cases
45+
assert(false);
46+
}
47+
return default_asset_name;
48+
}
49+
3250
QString BitcoinUnits::longName(Unit unit)
3351
{
52+
const std::string pegged_asset_with_unit = peggedAssetWithUnit(unit);
53+
if (pegged_asset_with_unit != "") {
54+
return QString::fromUtf8(pegged_asset_with_unit.c_str());
55+
}
3456
switch (unit) {
35-
case Unit::BTC: return QString("L-BTC");
36-
case Unit::mBTC: return QString("mL-BTC");
37-
case Unit::uBTC: return QString::fromUtf8("µL-BTC (L-bits)");
38-
case Unit::SAT: return QString("Satoshi (L-sat)");
57+
case Unit::BTC: return QString("LBTC");
58+
case Unit::mBTC: return QString("mLBTC");
59+
case Unit::uBTC: return QString::fromUtf8("µLBTC (Lbits)");
60+
case Unit::SAT: return QString("Satoshi (Lsat)");
3961
} // no default case, so the compiler can warn about missing cases
4062
assert(false);
4163
}
4264

4365
QString BitcoinUnits::shortName(Unit unit)
4466
{
45-
const std::string default_asset_name = gArgs.GetArg("-defaultpeggedassetname", "");
46-
if (default_asset_name != "") {
47-
std::string rv;
48-
switch(unit)
49-
{
50-
case Unit::BTC: rv=default_asset_name;break;
51-
case Unit::mBTC: rv=std::string("m-")+default_asset_name;break;
52-
case Unit::uBTC: rv=std::string("μ-")+default_asset_name;break;
53-
case Unit::SAT: rv=std::string("sat-")+default_asset_name;break;
54-
default: rv="???";break;
55-
}
56-
return QString::fromUtf8(rv.c_str());
67+
const std::string pegged_asset_with_unit = peggedAssetWithUnit(unit);
68+
if (pegged_asset_with_unit != "") {
69+
return QString::fromUtf8(pegged_asset_with_unit.c_str());
5770
}
5871
switch (unit) {
5972
case Unit::BTC: return longName(unit);
6073
case Unit::mBTC: return longName(unit);
61-
case Unit::uBTC: return QString("L-bits");
62-
case Unit::SAT: return QString("L-sat");
74+
case Unit::uBTC: return QString("Lbits");
75+
case Unit::SAT: return QString("Lsat");
6376
} // no default case, so the compiler can warn about missing cases
6477
assert(false);
6578
}
6679

6780
QString BitcoinUnits::description(Unit unit)
6881
{
82+
if (gArgs.GetArg("-defaultpeggedassetname", "") != "") {
83+
return longName(unit);
84+
}
6985
switch (unit) {
70-
case Unit::BTC: return QString("Bitcoins");
71-
case Unit::mBTC: return QString("Milli-Bitcoins (1 / 1" THIN_SP_UTF8 "000)");
72-
case Unit::uBTC: return QString("Micro-Bitcoins (bits) (1 / 1" THIN_SP_UTF8 "000" THIN_SP_UTF8 "000)");
73-
case Unit::SAT: return QString("Satoshi (sat) (1 / 100" THIN_SP_UTF8 "000" THIN_SP_UTF8 "000)");
86+
case Unit::BTC: return QString("Liquid Bitcoins");
87+
case Unit::mBTC: return QString("Liquid Milli-Bitcoins (1 / 1" THIN_SP_UTF8 "000)");
88+
case Unit::uBTC: return QString("Liquid Micro-Bitcoins (bits) (1 / 1" THIN_SP_UTF8 "000" THIN_SP_UTF8 "000)");
89+
case Unit::SAT: return QString("Liquid Satoshi (sat) (1 / 100" THIN_SP_UTF8 "000" THIN_SP_UTF8 "000)");
7490
} // no default case, so the compiler can warn about missing cases
7591
assert(false);
7692
}

0 commit comments

Comments
 (0)