Skip to content

Commit 047799c

Browse files
luke-jrinstagibbs
authored andcommitted
CAsset: GetIdentifier to get label or hex id
1 parent d81c9f7 commit 047799c

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/assetsdir.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ std::string CAssetsDir::GetLabel(const CAsset& asset) const
7272
return GetMetadata(asset).GetLabel();
7373
}
7474

75+
std::string CAssetsDir::GetIdentifier(const CAsset& asset) const
76+
{
77+
const std::string label = GetMetadata(asset).GetLabel();
78+
if (!label.empty()) return label;
79+
return asset.GetHex();
80+
}
81+
7582
std::vector<CAsset> CAssetsDir::GetKnownAssets() const
7683
{
7784
std::vector<CAsset> knownAssets;

src/assetsdir.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ class CAssetsDir
4040
/** @return the label associated to the asset id */
4141
std::string GetLabel(const CAsset& asset) const;
4242

43+
/** @return the label associated to the asset id, or some other identifier */
44+
std::string GetIdentifier(const CAsset& asset) const;
45+
4346
std::vector<CAsset> GetKnownAssets() const;
4447
};
4548

src/qt/guiutil.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -790,12 +790,8 @@ QString formatAssetAmount(const CAsset& asset, const CAmount& amount, const int
790790
if (fraction) {
791791
str += QString(".%1").arg(fraction, 8, 10, QLatin1Char('0'));
792792
}
793-
std::string asset_label = gAssetsDir.GetLabel(asset);
794-
if (asset_label.empty()) {
795-
asset_label = asset.GetHex();
796-
}
797793
if (include_asset_name) {
798-
str += QString(" ") + QString::fromStdString(asset_label);
794+
str += QString(" ") + QString::fromStdString(gAssetsDir.GetIdentifier(asset));
799795
}
800796
return str;
801797
}

0 commit comments

Comments
 (0)