[wallet] Add GetAssetIDFromString method to get an asset id from either an id or a label string.

This commit is contained in:
Karl-Johan Alm 2017-02-23 13:55:36 -08:00 committed by Gregory Sanders
parent 3832bd46e0
commit da36309317
2 changed files with 13 additions and 0 deletions

View file

@ -4327,6 +4327,13 @@ uint256 CWallet::GetAssetIDFromLabel(const std::string& label) const
return uint256();
}
CAssetID CWallet::GetAssetIDFromString(const std::string& asset) const
{
// TODO: may be worth LOCK(cs_wallet) here and do GetAsset* inline instead
CAssetID id(uint256S(asset));
return GetAssetLabelFromID(id) == "" ? GetAssetIDFromLabel(asset) : id;
}
CKey CWallet::GetBlindingKey(const CScript* script) const
{
CKey key;

View file

@ -1012,6 +1012,12 @@ public:
std::string GetAssetLabelFromID(const uint256& id) const;
/* Returns asset id corresponding to asset label */
uint256 GetAssetIDFromLabel(const std::string& label) const;
/**
* Returns asset id coresponding to the given asset expression, which is either an asset label or a hex value.
* @param asset A label string or a hex value corresponding to an asset
* @return The asset ID for the given expression
*/
CAssetID GetAssetIDFromString(const std::string& asset) const;
//! script == NULL gives the backward compatible blinding key
CKey GetBlindingKey(const CScript* script) const;