mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-13 12:33:42 +02:00
CAsset: GetIdentifier to get label or hex id
This commit is contained in:
parent
d81c9f7b3e
commit
047799cb12
3 changed files with 11 additions and 5 deletions
|
|
@ -72,6 +72,13 @@ std::string CAssetsDir::GetLabel(const CAsset& asset) const
|
|||
return GetMetadata(asset).GetLabel();
|
||||
}
|
||||
|
||||
std::string CAssetsDir::GetIdentifier(const CAsset& asset) const
|
||||
{
|
||||
const std::string label = GetMetadata(asset).GetLabel();
|
||||
if (!label.empty()) return label;
|
||||
return asset.GetHex();
|
||||
}
|
||||
|
||||
std::vector<CAsset> CAssetsDir::GetKnownAssets() const
|
||||
{
|
||||
std::vector<CAsset> knownAssets;
|
||||
|
|
|
|||
|
|
@ -40,6 +40,9 @@ public:
|
|||
/** @return the label associated to the asset id */
|
||||
std::string GetLabel(const CAsset& asset) const;
|
||||
|
||||
/** @return the label associated to the asset id, or some other identifier */
|
||||
std::string GetIdentifier(const CAsset& asset) const;
|
||||
|
||||
std::vector<CAsset> GetKnownAssets() const;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -790,12 +790,8 @@ QString formatAssetAmount(const CAsset& asset, const CAmount& amount, const int
|
|||
if (fraction) {
|
||||
str += QString(".%1").arg(fraction, 8, 10, QLatin1Char('0'));
|
||||
}
|
||||
std::string asset_label = gAssetsDir.GetLabel(asset);
|
||||
if (asset_label.empty()) {
|
||||
asset_label = asset.GetHex();
|
||||
}
|
||||
if (include_asset_name) {
|
||||
str += QString(" ") + QString::fromStdString(asset_label);
|
||||
str += QString(" ") + QString::fromStdString(gAssetsDir.GetIdentifier(asset));
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue